@ahana-awesome-platform/ahana-electron-sdk 1.0.0
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/dist/cjs/controller/index.d.ts +12 -0
- package/dist/cjs/controller/index.d.ts.map +1 -0
- package/dist/cjs/controller/index.js +1 -0
- package/dist/cjs/ipc/IpcMain.d.ts +20 -0
- package/dist/cjs/ipc/IpcMain.d.ts.map +1 -0
- package/dist/cjs/ipc/IpcTypes.d.ts +24 -0
- package/dist/cjs/ipc/IpcTypes.d.ts.map +1 -0
- package/dist/cjs/ipc/index.d.ts +66 -0
- package/dist/cjs/ipc/index.d.ts.map +1 -0
- package/dist/cjs/ipc/index.js +1 -0
- package/dist/cjs/logger/String16.d.ts +11 -0
- package/dist/cjs/logger/String16.d.ts.map +1 -0
- package/dist/cjs/logger/index.d.ts +104 -0
- package/dist/cjs/logger/index.d.ts.map +1 -0
- package/dist/cjs/logger/index.js +1 -0
- package/dist/cjs/orm/common/logger.d.ts +4 -0
- package/dist/cjs/orm/common/logger.d.ts.map +1 -0
- package/dist/cjs/orm/index.d.ts +4 -0
- package/dist/cjs/orm/index.d.ts.map +1 -0
- package/dist/cjs/orm/index.js +1 -0
- package/dist/cjs/orm/orm/CheckHealth.d.ts +4 -0
- package/dist/cjs/orm/orm/CheckHealth.d.ts.map +1 -0
- package/dist/cjs/orm/orm/ExecuteInTransaction.d.ts +5 -0
- package/dist/cjs/orm/orm/ExecuteInTransaction.d.ts.map +1 -0
- package/dist/cjs/orm/orm/SafeAlterTable.d.ts +8 -0
- package/dist/cjs/orm/orm/SafeAlterTable.d.ts.map +1 -0
- package/dist/cjs/orm/orm/SqLiteConnection.d.ts +5 -0
- package/dist/cjs/orm/orm/SqLiteConnection.d.ts.map +1 -0
- package/dist/cjs/orm/sqlite/index.d.ts +10 -0
- package/dist/cjs/orm/sqlite/index.d.ts.map +1 -0
- package/dist/cjs/platform/index.d.ts +2 -0
- package/dist/cjs/platform/index.d.ts.map +1 -0
- package/dist/cjs/platform/index.js +1 -0
- package/dist/cjs/platform/platform/detector.d.ts +47 -0
- package/dist/cjs/platform/platform/detector.d.ts.map +1 -0
- package/dist/cjs/platform/platform/registry/index.d.ts +47 -0
- package/dist/cjs/platform/platform/registry/index.d.ts.map +1 -0
- package/dist/cjs/platform/platform/registry/kylin-registry.d.ts +31 -0
- package/dist/cjs/platform/platform/registry/kylin-registry.d.ts.map +1 -0
- package/dist/cjs/platform/platform/registry/registry.d.ts +89 -0
- package/dist/cjs/platform/platform/registry/registry.d.ts.map +1 -0
- package/dist/cjs/platform/platform/registry/windows-registry.d.ts +32 -0
- package/dist/cjs/platform/platform/registry/windows-registry.d.ts.map +1 -0
- package/dist/cjs/response-factory/factory/AppError.d.ts +8 -0
- package/dist/cjs/response-factory/factory/AppError.d.ts.map +1 -0
- package/dist/cjs/response-factory/factory/BusinessError.d.ts +70 -0
- package/dist/cjs/response-factory/factory/BusinessError.d.ts.map +1 -0
- package/dist/cjs/response-factory/index.d.ts +3 -0
- package/dist/cjs/response-factory/index.d.ts.map +1 -0
- package/dist/cjs/response-factory/index.js +1 -0
- package/dist/cjs/response-factory/response/Response.d.ts +15 -0
- package/dist/cjs/response-factory/response/Response.d.ts.map +1 -0
- package/dist/esm/_commonjsHelpers-Dm6U3U_N.js +35 -0
- package/dist/esm/controller/index.d.ts +12 -0
- package/dist/esm/controller/index.d.ts.map +1 -0
- package/dist/esm/controller/index.js +1128 -0
- package/dist/esm/events-CqhjgOaW.js +213 -0
- package/dist/esm/index-Dys2BW-7.js +256 -0
- package/dist/esm/index-xOyNRTcn.js +21640 -0
- package/dist/esm/ipc/IpcMain.d.ts +20 -0
- package/dist/esm/ipc/IpcMain.d.ts.map +1 -0
- package/dist/esm/ipc/IpcTypes.d.ts +24 -0
- package/dist/esm/ipc/IpcTypes.d.ts.map +1 -0
- package/dist/esm/ipc/index.d.ts +66 -0
- package/dist/esm/ipc/index.d.ts.map +1 -0
- package/dist/esm/ipc/index.js +137 -0
- package/dist/esm/kylin-registry-3nmgzi3s.js +249 -0
- package/dist/esm/logger/String16.d.ts +11 -0
- package/dist/esm/logger/String16.d.ts.map +1 -0
- package/dist/esm/logger/index.d.ts +104 -0
- package/dist/esm/logger/index.d.ts.map +1 -0
- package/dist/esm/logger/index.js +7 -0
- package/dist/esm/orm/common/logger.d.ts +4 -0
- package/dist/esm/orm/common/logger.d.ts.map +1 -0
- package/dist/esm/orm/index.d.ts +4 -0
- package/dist/esm/orm/index.d.ts.map +1 -0
- package/dist/esm/orm/index.js +50024 -0
- package/dist/esm/orm/orm/CheckHealth.d.ts +4 -0
- package/dist/esm/orm/orm/CheckHealth.d.ts.map +1 -0
- package/dist/esm/orm/orm/ExecuteInTransaction.d.ts +5 -0
- package/dist/esm/orm/orm/ExecuteInTransaction.d.ts.map +1 -0
- package/dist/esm/orm/orm/SafeAlterTable.d.ts +8 -0
- package/dist/esm/orm/orm/SafeAlterTable.d.ts.map +1 -0
- package/dist/esm/orm/orm/SqLiteConnection.d.ts +5 -0
- package/dist/esm/orm/orm/SqLiteConnection.d.ts.map +1 -0
- package/dist/esm/orm/sqlite/index.d.ts +10 -0
- package/dist/esm/orm/sqlite/index.d.ts.map +1 -0
- package/dist/esm/platform/index.d.ts +2 -0
- package/dist/esm/platform/index.d.ts.map +1 -0
- package/dist/esm/platform/index.js +8 -0
- package/dist/esm/platform/platform/detector.d.ts +47 -0
- package/dist/esm/platform/platform/detector.d.ts.map +1 -0
- package/dist/esm/platform/platform/registry/index.d.ts +47 -0
- package/dist/esm/platform/platform/registry/index.d.ts.map +1 -0
- package/dist/esm/platform/platform/registry/kylin-registry.d.ts +31 -0
- package/dist/esm/platform/platform/registry/kylin-registry.d.ts.map +1 -0
- package/dist/esm/platform/platform/registry/registry.d.ts +89 -0
- package/dist/esm/platform/platform/registry/registry.d.ts.map +1 -0
- package/dist/esm/platform/platform/registry/windows-registry.d.ts +32 -0
- package/dist/esm/platform/platform/registry/windows-registry.d.ts.map +1 -0
- package/dist/esm/response-factory/factory/AppError.d.ts +8 -0
- package/dist/esm/response-factory/factory/AppError.d.ts.map +1 -0
- package/dist/esm/response-factory/factory/BusinessError.d.ts +70 -0
- package/dist/esm/response-factory/factory/BusinessError.d.ts.map +1 -0
- package/dist/esm/response-factory/index.d.ts +3 -0
- package/dist/esm/response-factory/index.d.ts.map +1 -0
- package/dist/esm/response-factory/index.js +121 -0
- package/dist/esm/response-factory/response/Response.d.ts +15 -0
- package/dist/esm/response-factory/response/Response.d.ts.map +1 -0
- package/dist/esm/windows-registry-B92IgP1f.js +354 -0
- package/package.json +73 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { n as normalizeRegistryPathAdvanced } from "./index-Dys2BW-7.js";
|
|
8
|
+
import { exec } from "child_process";
|
|
9
|
+
const execAsync = (command, options = { encoding: "utf8", windowsHide: true }) => new Promise((resolve, reject) => {
|
|
10
|
+
exec(command, options, (error, stdout, stderr) => {
|
|
11
|
+
if (error) {
|
|
12
|
+
reject({
|
|
13
|
+
message: error.message,
|
|
14
|
+
stdout,
|
|
15
|
+
stderr
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
resolve({ stdout, stderr });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
class WindowsRegistryError extends Error {
|
|
23
|
+
constructor(message, hive, key, valueName) {
|
|
24
|
+
super(message);
|
|
25
|
+
__publicField(this, "hive");
|
|
26
|
+
__publicField(this, "key");
|
|
27
|
+
__publicField(this, "valueName");
|
|
28
|
+
this.hive = hive;
|
|
29
|
+
this.key = key;
|
|
30
|
+
this.valueName = valueName;
|
|
31
|
+
this.name = "WindowsRegistryError";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const _WindowsRegistry = class _WindowsRegistry {
|
|
35
|
+
constructor() {
|
|
36
|
+
}
|
|
37
|
+
static getInstance() {
|
|
38
|
+
if (!_WindowsRegistry.instance) {
|
|
39
|
+
_WindowsRegistry.instance = new _WindowsRegistry();
|
|
40
|
+
}
|
|
41
|
+
return _WindowsRegistry.instance;
|
|
42
|
+
}
|
|
43
|
+
// 核心方法
|
|
44
|
+
static buildRegPath(hive, key) {
|
|
45
|
+
let regPath = `${hive}:${key}`;
|
|
46
|
+
regPath = normalizeRegistryPathAdvanced(regPath);
|
|
47
|
+
return regPath;
|
|
48
|
+
}
|
|
49
|
+
static convertToRegType(value) {
|
|
50
|
+
if (typeof value === "string") {
|
|
51
|
+
return { type: "REG_SZ", data: value };
|
|
52
|
+
} else if (typeof value === "number") {
|
|
53
|
+
if (Number.isInteger(value)) {
|
|
54
|
+
return { type: "REG_DWORD", data: `0x${value.toString(16)}` };
|
|
55
|
+
} else {
|
|
56
|
+
return { type: "REG_BINARY", data: Buffer.from(value.toString()).toString("hex") };
|
|
57
|
+
}
|
|
58
|
+
} else if (typeof value === "boolean") {
|
|
59
|
+
return { type: "REG_DWORD", data: value ? "0x1" : "0x0" };
|
|
60
|
+
} else if (value === null) {
|
|
61
|
+
return { type: "REG_SZ", data: "" };
|
|
62
|
+
} else if (Array.isArray(value)) {
|
|
63
|
+
const data = value.join("\0") + "\0";
|
|
64
|
+
return { type: "REG_MULTI_SZ", data };
|
|
65
|
+
} else if (Buffer.isBuffer(value)) {
|
|
66
|
+
return { type: "REG_BINARY", data: value.toString("hex") };
|
|
67
|
+
} else {
|
|
68
|
+
return { type: "REG_SZ", data: JSON.stringify(value) };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
static parseRegValue(output) {
|
|
72
|
+
var _a;
|
|
73
|
+
const lines = output.trim().split("\n");
|
|
74
|
+
for (const line of lines) {
|
|
75
|
+
if (line.includes("REG_SZ") || line.includes("REG_EXPAND_SZ")) {
|
|
76
|
+
const match = line.match(/(REG_SZ|REG_EXPAND_SZ)\s+(.+)/);
|
|
77
|
+
if (match)
|
|
78
|
+
return match[2].trim();
|
|
79
|
+
} else if (line.includes("REG_DWORD")) {
|
|
80
|
+
const match = line.match(/REG_DWORD\s+(0x[0-9a-fA-F]+)/);
|
|
81
|
+
if (match)
|
|
82
|
+
return parseInt(match[1], 16);
|
|
83
|
+
} else if (line.includes("REG_QWORD")) {
|
|
84
|
+
const match = line.match(/REG_QWORD\s+(0x[0-9a-fA-F]+)/);
|
|
85
|
+
if (match)
|
|
86
|
+
return parseInt(match[1], 16);
|
|
87
|
+
} else if (line.includes("REG_MULTI_SZ")) {
|
|
88
|
+
const match = line.match(/REG_MULTI_SZ\s+(.+)/);
|
|
89
|
+
if (match) {
|
|
90
|
+
const data = match[1].trim();
|
|
91
|
+
return data.split("\0").filter((str) => str !== "");
|
|
92
|
+
}
|
|
93
|
+
} else if (line.includes("REG_BINARY")) {
|
|
94
|
+
const match = line.match(/REG_BINARY\s+([0-9a-fA-F\s]+)/);
|
|
95
|
+
if (match) {
|
|
96
|
+
const hexString = match[1].replace(/\s+/g, "");
|
|
97
|
+
return Buffer.from(hexString, "hex");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const lastLine = (_a = lines[lines.length - 1]) == null ? void 0 : _a.trim();
|
|
102
|
+
return lastLine || null;
|
|
103
|
+
}
|
|
104
|
+
static async safeOperation(operation, options = {}, operationName = "操作") {
|
|
105
|
+
const { retryCount = 3, retryDelay = 100 } = options;
|
|
106
|
+
for (let attempt = 1; attempt <= retryCount; attempt++) {
|
|
107
|
+
try {
|
|
108
|
+
return await operation();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (attempt < retryCount) {
|
|
111
|
+
console.warn(`${operationName} 失败,第 ${attempt} 次重试:`, error);
|
|
112
|
+
await this.delay(retryDelay * attempt);
|
|
113
|
+
} else if (error instanceof Error) {
|
|
114
|
+
throw new WindowsRegistryError(`${operationName} 失败: ${error.message}`, void 0, void 0, void 0);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
throw new WindowsRegistryError(`${operationName} 失败,未知错误`);
|
|
119
|
+
}
|
|
120
|
+
static delay(ms) {
|
|
121
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
122
|
+
}
|
|
123
|
+
// 基本操作
|
|
124
|
+
static async getValue(hive, key, valueName, options = {}) {
|
|
125
|
+
return this.safeOperation(async () => {
|
|
126
|
+
const regPath = this.buildRegPath(hive, key);
|
|
127
|
+
try {
|
|
128
|
+
const { stdout, stderr } = await execAsync(`reg query "${regPath}" /v "${valueName}"`, {
|
|
129
|
+
encoding: "utf8",
|
|
130
|
+
windowsHide: true
|
|
131
|
+
});
|
|
132
|
+
if (stderr) {
|
|
133
|
+
throw new Error(stderr);
|
|
134
|
+
}
|
|
135
|
+
const value = this.parseRegValue(stdout);
|
|
136
|
+
return { value, exists: true };
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (error instanceof Error && (error.message.includes("错误: 系统找不到指定的注册表项或值。") || error.message.includes("ERROR: The system was unable to find the specified registry key or value."))) {
|
|
139
|
+
return { value: null, exists: false };
|
|
140
|
+
}
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}, options, "读取注册表值");
|
|
144
|
+
}
|
|
145
|
+
static async setValue(hive, key, valueName, value, options = {}) {
|
|
146
|
+
return this.safeOperation(async () => {
|
|
147
|
+
const regPath = this.buildRegPath(hive, key);
|
|
148
|
+
const { type, data } = this.convertToRegType(value);
|
|
149
|
+
if (options.backupBeforeModify) {
|
|
150
|
+
const backup = await this.getValue(hive, key, valueName);
|
|
151
|
+
if (backup.exists) {
|
|
152
|
+
this.valueBackupCache.set(`${hive}:${key}:${valueName}`, backup);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const command = `reg add "${regPath}" /v "${valueName}" /t ${type} /d "${data}" /f`;
|
|
156
|
+
const { stderr } = await execAsync(command, {
|
|
157
|
+
encoding: "utf8",
|
|
158
|
+
windowsHide: true
|
|
159
|
+
});
|
|
160
|
+
if (stderr && !stderr.includes("操作成功完成")) {
|
|
161
|
+
throw new Error(stderr);
|
|
162
|
+
}
|
|
163
|
+
}, options, "设置注册表值");
|
|
164
|
+
}
|
|
165
|
+
static async deleteValue(hive, key, valueName, options = {}) {
|
|
166
|
+
return this.safeOperation(async () => {
|
|
167
|
+
const regPath = this.buildRegPath(hive, key);
|
|
168
|
+
if (options.backupBeforeModify) {
|
|
169
|
+
const backup = await this.getValue(hive, key, valueName);
|
|
170
|
+
if (backup.exists) {
|
|
171
|
+
this.valueBackupCache.set(`${hive}:${key}:${valueName}`, backup);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const command = `reg delete "${regPath}" /v "${valueName}" /f`;
|
|
175
|
+
const { stderr } = await execAsync(command, {
|
|
176
|
+
encoding: "utf8",
|
|
177
|
+
windowsHide: true
|
|
178
|
+
});
|
|
179
|
+
if (stderr && !stderr.includes("操作成功完成")) {
|
|
180
|
+
if (stderr.includes("错误: 系统找不到指定的注册表项或值。") || stderr.includes("ERROR: The system was unable to find the specified registry key or value.")) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
throw new Error(stderr);
|
|
184
|
+
}
|
|
185
|
+
}, options, "删除注册表值");
|
|
186
|
+
}
|
|
187
|
+
static async createKey(hive, key, options = {}) {
|
|
188
|
+
return this.safeOperation(async () => {
|
|
189
|
+
const regPath = this.buildRegPath(hive, key);
|
|
190
|
+
const command = `reg add "${regPath}" /f`;
|
|
191
|
+
const { stderr } = await execAsync(command, {
|
|
192
|
+
encoding: "utf8",
|
|
193
|
+
windowsHide: true
|
|
194
|
+
});
|
|
195
|
+
if (stderr && !stderr.includes("操作成功完成")) {
|
|
196
|
+
throw new Error(stderr);
|
|
197
|
+
}
|
|
198
|
+
}, options, "创建注册表键");
|
|
199
|
+
}
|
|
200
|
+
static async deleteKey(hive, key, options = {}) {
|
|
201
|
+
return this.safeOperation(async () => {
|
|
202
|
+
const regPath = this.buildRegPath(hive, key);
|
|
203
|
+
const command = `reg delete "${regPath}" /f`;
|
|
204
|
+
const { stderr } = await execAsync(command, {
|
|
205
|
+
encoding: "utf8",
|
|
206
|
+
windowsHide: true
|
|
207
|
+
});
|
|
208
|
+
if (stderr && !stderr.includes("操作成功完成")) {
|
|
209
|
+
if (stderr.includes("错误: 系统找不到指定的注册表项或值。") || stderr.includes("ERROR: The system was unable to find the specified registry key or value.")) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
throw new Error(stderr);
|
|
213
|
+
}
|
|
214
|
+
}, options, "删除注册表键");
|
|
215
|
+
}
|
|
216
|
+
// 高级操作
|
|
217
|
+
static async listKeys(hive, key, options = {}) {
|
|
218
|
+
return this.safeOperation(async () => {
|
|
219
|
+
const regPath = this.buildRegPath(hive, key);
|
|
220
|
+
try {
|
|
221
|
+
const { stdout, stderr } = await execAsync(`reg query "${regPath}"`, {
|
|
222
|
+
encoding: "utf8",
|
|
223
|
+
windowsHide: true
|
|
224
|
+
});
|
|
225
|
+
if (stderr)
|
|
226
|
+
throw new Error(stderr);
|
|
227
|
+
return this.parseRegistryKeysSimple(stdout, hive, key);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
230
|
+
if (errorMessage.includes("错误: 系统找不到指定的注册表项或值。") || errorMessage.includes("ERROR: The system was unable to find the specified registry key or value.")) {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
}, options, "枚举子键");
|
|
236
|
+
}
|
|
237
|
+
static parseRegistryKeysSimple(stdout, hive, key) {
|
|
238
|
+
const subKeys = /* @__PURE__ */ new Set();
|
|
239
|
+
for (const line of stdout.trim().split("\n")) {
|
|
240
|
+
const match = line.match(/HKEY_[A-Z_]+\\(.+)/);
|
|
241
|
+
if (!match)
|
|
242
|
+
continue;
|
|
243
|
+
const fullPath = match[1];
|
|
244
|
+
if (!fullPath.startsWith(key) || fullPath === key)
|
|
245
|
+
continue;
|
|
246
|
+
const relativePath = fullPath.substring(key.length + 1);
|
|
247
|
+
const subKey = relativePath.split("\\")[0];
|
|
248
|
+
if (subKey)
|
|
249
|
+
subKeys.add(subKey);
|
|
250
|
+
}
|
|
251
|
+
return Array.from(subKeys);
|
|
252
|
+
}
|
|
253
|
+
static async listValues(hive, key, options = {}) {
|
|
254
|
+
return this.safeOperation(async () => {
|
|
255
|
+
const regPath = this.buildRegPath(hive, key);
|
|
256
|
+
const values = [];
|
|
257
|
+
try {
|
|
258
|
+
const { stdout, stderr } = await execAsync(`reg query "${regPath}"`, {
|
|
259
|
+
encoding: "utf8",
|
|
260
|
+
windowsHide: true
|
|
261
|
+
});
|
|
262
|
+
if (stderr || !stdout) {
|
|
263
|
+
throw new Error(stderr);
|
|
264
|
+
}
|
|
265
|
+
const lines = stdout.trim().split("\n");
|
|
266
|
+
let isValuesSection = false;
|
|
267
|
+
for (const line of lines) {
|
|
268
|
+
if (line.includes("(默认)") || line.includes("(Default)")) {
|
|
269
|
+
isValuesSection = true;
|
|
270
|
+
}
|
|
271
|
+
if (isValuesSection && line.trim() && !line.includes("REG_")) {
|
|
272
|
+
const match = line.match(/^\s*(.+?)\s+(REG_[A-Z_]+)\s+(.+)$/);
|
|
273
|
+
if (match) {
|
|
274
|
+
const [, name, , valueStr] = match;
|
|
275
|
+
values.push({
|
|
276
|
+
name: name.trim(),
|
|
277
|
+
value: valueStr.trim()
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} catch (error) {
|
|
283
|
+
if ((error instanceof Error ? error.message : String(error)).includes("错误: 系统找不到指定的注册表项或值。") || (error instanceof Error ? error.message : String(error)).includes("ERROR: The system was unable to find the specified registry key or value.")) {
|
|
284
|
+
return [];
|
|
285
|
+
}
|
|
286
|
+
throw error;
|
|
287
|
+
}
|
|
288
|
+
return values;
|
|
289
|
+
}, options, "枚举注册表值");
|
|
290
|
+
}
|
|
291
|
+
static async getKeyInfo(hive, key, options = {}) {
|
|
292
|
+
return this.safeOperation(async () => {
|
|
293
|
+
const [subKeys, values] = await Promise.all([
|
|
294
|
+
this.listKeys(hive, key, options),
|
|
295
|
+
this.listValues(hive, key, options)
|
|
296
|
+
]);
|
|
297
|
+
return {
|
|
298
|
+
name: key,
|
|
299
|
+
subKeys,
|
|
300
|
+
values
|
|
301
|
+
};
|
|
302
|
+
}, options, "获取注册表键信息");
|
|
303
|
+
}
|
|
304
|
+
// 批量操作
|
|
305
|
+
static async batchSetValues(hive, key, values, options = {}) {
|
|
306
|
+
return this.safeOperation(async () => {
|
|
307
|
+
for (const [valueName, { value }] of Object.entries(values)) {
|
|
308
|
+
await this.setValue(hive, key, valueName, value, options);
|
|
309
|
+
}
|
|
310
|
+
}, options, "批量设置注册表值");
|
|
311
|
+
}
|
|
312
|
+
// 工具方法
|
|
313
|
+
static async keyExists(hive, key) {
|
|
314
|
+
try {
|
|
315
|
+
const regPath = this.buildRegPath(hive, key);
|
|
316
|
+
const { stderr } = await execAsync(`reg query "${regPath}"`, {
|
|
317
|
+
encoding: "utf8",
|
|
318
|
+
windowsHide: true
|
|
319
|
+
});
|
|
320
|
+
return !stderr || stderr.includes("操作成功完成");
|
|
321
|
+
} catch (error) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
static async valueExists(hive, key, valueName, options = {}) {
|
|
326
|
+
try {
|
|
327
|
+
const result = await this.getValue(hive, key, valueName, options);
|
|
328
|
+
return result.exists;
|
|
329
|
+
} catch (error) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
// 恢复备份
|
|
334
|
+
static async restoreBackup(hive, key, valueName) {
|
|
335
|
+
const cacheKey = `${hive}:${key}:${valueName}`;
|
|
336
|
+
const backup = this.valueBackupCache.get(cacheKey);
|
|
337
|
+
if (backup) {
|
|
338
|
+
if (backup.exists) {
|
|
339
|
+
await this.setValue(hive, key, valueName, backup.value);
|
|
340
|
+
} else {
|
|
341
|
+
await this.deleteValue(hive, key, valueName);
|
|
342
|
+
}
|
|
343
|
+
this.valueBackupCache.delete(cacheKey);
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
__publicField(_WindowsRegistry, "instance", null);
|
|
350
|
+
__publicField(_WindowsRegistry, "valueBackupCache", /* @__PURE__ */ new Map());
|
|
351
|
+
let WindowsRegistry = _WindowsRegistry;
|
|
352
|
+
export {
|
|
353
|
+
WindowsRegistry
|
|
354
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ahana-awesome-platform/ahana-electron-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "",
|
|
6
|
+
"main": "/dist/esm/index.js",
|
|
7
|
+
"module": "/dist/cjs/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/esm/index.d.ts",
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"require": "./dist/cjs/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./controller": {
|
|
15
|
+
"types": "./dist/esm/controller/index.d.ts",
|
|
16
|
+
"import": "./dist/esm/controller/index.js",
|
|
17
|
+
"require": "./dist/cjs/controller/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./ipc": {
|
|
20
|
+
"types": "./dist/esm/ipc/index.d.ts",
|
|
21
|
+
"import": "./dist/esm/ipc/index.js",
|
|
22
|
+
"require": "./dist/cjs/ipc/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./logger": {
|
|
25
|
+
"types": "./dist/esm/logger/index.d.ts",
|
|
26
|
+
"import": "./dist/esm/logger/index.js",
|
|
27
|
+
"require": "./dist/cjs/logger/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./orm": {
|
|
30
|
+
"types": "./dist/esm/orm/index.d.ts",
|
|
31
|
+
"import": "./dist/esm/orm/index.js",
|
|
32
|
+
"require": "./dist/cjs/orm/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./platform": {
|
|
35
|
+
"types": "./dist/esm/platform/index.d.ts",
|
|
36
|
+
"import": "./dist/esm/platform/index.js",
|
|
37
|
+
"require": "./dist/cjs/platform/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./response-factory": {
|
|
40
|
+
"types": "./dist/esm/response-factory/index.d.ts",
|
|
41
|
+
"import": "./dist/esm/response-factory/index.js",
|
|
42
|
+
"require": "./dist/cjs/response-factory/index.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist",
|
|
47
|
+
"package.json"
|
|
48
|
+
],
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public",
|
|
51
|
+
"registry": "https://registry.npmjs.org/"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"vite:build:cjs": "cross-env BUILD_FORMAT=cjs vite build",
|
|
55
|
+
"vite:build:esm": "cross-env BUILD_FORMAT=esm vite build",
|
|
56
|
+
"vite:build": "pnpm run vite:build:cjs && pnpm run vite:build:esm"
|
|
57
|
+
},
|
|
58
|
+
"keywords": [],
|
|
59
|
+
"author": "",
|
|
60
|
+
"license": "ISC",
|
|
61
|
+
"packageManager": "pnpm@10.8.1",
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"reflect-metadata": "^0.2.2",
|
|
64
|
+
"sequelize": "^6.37.7",
|
|
65
|
+
"winston": "^3.19.0",
|
|
66
|
+
"winston-daily-rotate-file": "^5.0.0"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@rollup/plugin-terser": "0.4.4",
|
|
70
|
+
"@types/node": "^22.19.3",
|
|
71
|
+
"@ahana-awesome-platform/shared-types": "workspace:*"
|
|
72
|
+
}
|
|
73
|
+
}
|