@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.
Files changed (111) hide show
  1. package/dist/cjs/controller/index.d.ts +12 -0
  2. package/dist/cjs/controller/index.d.ts.map +1 -0
  3. package/dist/cjs/controller/index.js +1 -0
  4. package/dist/cjs/ipc/IpcMain.d.ts +20 -0
  5. package/dist/cjs/ipc/IpcMain.d.ts.map +1 -0
  6. package/dist/cjs/ipc/IpcTypes.d.ts +24 -0
  7. package/dist/cjs/ipc/IpcTypes.d.ts.map +1 -0
  8. package/dist/cjs/ipc/index.d.ts +66 -0
  9. package/dist/cjs/ipc/index.d.ts.map +1 -0
  10. package/dist/cjs/ipc/index.js +1 -0
  11. package/dist/cjs/logger/String16.d.ts +11 -0
  12. package/dist/cjs/logger/String16.d.ts.map +1 -0
  13. package/dist/cjs/logger/index.d.ts +104 -0
  14. package/dist/cjs/logger/index.d.ts.map +1 -0
  15. package/dist/cjs/logger/index.js +1 -0
  16. package/dist/cjs/orm/common/logger.d.ts +4 -0
  17. package/dist/cjs/orm/common/logger.d.ts.map +1 -0
  18. package/dist/cjs/orm/index.d.ts +4 -0
  19. package/dist/cjs/orm/index.d.ts.map +1 -0
  20. package/dist/cjs/orm/index.js +1 -0
  21. package/dist/cjs/orm/orm/CheckHealth.d.ts +4 -0
  22. package/dist/cjs/orm/orm/CheckHealth.d.ts.map +1 -0
  23. package/dist/cjs/orm/orm/ExecuteInTransaction.d.ts +5 -0
  24. package/dist/cjs/orm/orm/ExecuteInTransaction.d.ts.map +1 -0
  25. package/dist/cjs/orm/orm/SafeAlterTable.d.ts +8 -0
  26. package/dist/cjs/orm/orm/SafeAlterTable.d.ts.map +1 -0
  27. package/dist/cjs/orm/orm/SqLiteConnection.d.ts +5 -0
  28. package/dist/cjs/orm/orm/SqLiteConnection.d.ts.map +1 -0
  29. package/dist/cjs/orm/sqlite/index.d.ts +10 -0
  30. package/dist/cjs/orm/sqlite/index.d.ts.map +1 -0
  31. package/dist/cjs/platform/index.d.ts +2 -0
  32. package/dist/cjs/platform/index.d.ts.map +1 -0
  33. package/dist/cjs/platform/index.js +1 -0
  34. package/dist/cjs/platform/platform/detector.d.ts +47 -0
  35. package/dist/cjs/platform/platform/detector.d.ts.map +1 -0
  36. package/dist/cjs/platform/platform/registry/index.d.ts +47 -0
  37. package/dist/cjs/platform/platform/registry/index.d.ts.map +1 -0
  38. package/dist/cjs/platform/platform/registry/kylin-registry.d.ts +31 -0
  39. package/dist/cjs/platform/platform/registry/kylin-registry.d.ts.map +1 -0
  40. package/dist/cjs/platform/platform/registry/registry.d.ts +89 -0
  41. package/dist/cjs/platform/platform/registry/registry.d.ts.map +1 -0
  42. package/dist/cjs/platform/platform/registry/windows-registry.d.ts +32 -0
  43. package/dist/cjs/platform/platform/registry/windows-registry.d.ts.map +1 -0
  44. package/dist/cjs/response-factory/factory/AppError.d.ts +8 -0
  45. package/dist/cjs/response-factory/factory/AppError.d.ts.map +1 -0
  46. package/dist/cjs/response-factory/factory/BusinessError.d.ts +70 -0
  47. package/dist/cjs/response-factory/factory/BusinessError.d.ts.map +1 -0
  48. package/dist/cjs/response-factory/index.d.ts +3 -0
  49. package/dist/cjs/response-factory/index.d.ts.map +1 -0
  50. package/dist/cjs/response-factory/index.js +1 -0
  51. package/dist/cjs/response-factory/response/Response.d.ts +15 -0
  52. package/dist/cjs/response-factory/response/Response.d.ts.map +1 -0
  53. package/dist/esm/_commonjsHelpers-Dm6U3U_N.js +35 -0
  54. package/dist/esm/controller/index.d.ts +12 -0
  55. package/dist/esm/controller/index.d.ts.map +1 -0
  56. package/dist/esm/controller/index.js +1128 -0
  57. package/dist/esm/events-CqhjgOaW.js +213 -0
  58. package/dist/esm/index-Dys2BW-7.js +256 -0
  59. package/dist/esm/index-xOyNRTcn.js +21640 -0
  60. package/dist/esm/ipc/IpcMain.d.ts +20 -0
  61. package/dist/esm/ipc/IpcMain.d.ts.map +1 -0
  62. package/dist/esm/ipc/IpcTypes.d.ts +24 -0
  63. package/dist/esm/ipc/IpcTypes.d.ts.map +1 -0
  64. package/dist/esm/ipc/index.d.ts +66 -0
  65. package/dist/esm/ipc/index.d.ts.map +1 -0
  66. package/dist/esm/ipc/index.js +137 -0
  67. package/dist/esm/kylin-registry-3nmgzi3s.js +249 -0
  68. package/dist/esm/logger/String16.d.ts +11 -0
  69. package/dist/esm/logger/String16.d.ts.map +1 -0
  70. package/dist/esm/logger/index.d.ts +104 -0
  71. package/dist/esm/logger/index.d.ts.map +1 -0
  72. package/dist/esm/logger/index.js +7 -0
  73. package/dist/esm/orm/common/logger.d.ts +4 -0
  74. package/dist/esm/orm/common/logger.d.ts.map +1 -0
  75. package/dist/esm/orm/index.d.ts +4 -0
  76. package/dist/esm/orm/index.d.ts.map +1 -0
  77. package/dist/esm/orm/index.js +50024 -0
  78. package/dist/esm/orm/orm/CheckHealth.d.ts +4 -0
  79. package/dist/esm/orm/orm/CheckHealth.d.ts.map +1 -0
  80. package/dist/esm/orm/orm/ExecuteInTransaction.d.ts +5 -0
  81. package/dist/esm/orm/orm/ExecuteInTransaction.d.ts.map +1 -0
  82. package/dist/esm/orm/orm/SafeAlterTable.d.ts +8 -0
  83. package/dist/esm/orm/orm/SafeAlterTable.d.ts.map +1 -0
  84. package/dist/esm/orm/orm/SqLiteConnection.d.ts +5 -0
  85. package/dist/esm/orm/orm/SqLiteConnection.d.ts.map +1 -0
  86. package/dist/esm/orm/sqlite/index.d.ts +10 -0
  87. package/dist/esm/orm/sqlite/index.d.ts.map +1 -0
  88. package/dist/esm/platform/index.d.ts +2 -0
  89. package/dist/esm/platform/index.d.ts.map +1 -0
  90. package/dist/esm/platform/index.js +8 -0
  91. package/dist/esm/platform/platform/detector.d.ts +47 -0
  92. package/dist/esm/platform/platform/detector.d.ts.map +1 -0
  93. package/dist/esm/platform/platform/registry/index.d.ts +47 -0
  94. package/dist/esm/platform/platform/registry/index.d.ts.map +1 -0
  95. package/dist/esm/platform/platform/registry/kylin-registry.d.ts +31 -0
  96. package/dist/esm/platform/platform/registry/kylin-registry.d.ts.map +1 -0
  97. package/dist/esm/platform/platform/registry/registry.d.ts +89 -0
  98. package/dist/esm/platform/platform/registry/registry.d.ts.map +1 -0
  99. package/dist/esm/platform/platform/registry/windows-registry.d.ts +32 -0
  100. package/dist/esm/platform/platform/registry/windows-registry.d.ts.map +1 -0
  101. package/dist/esm/response-factory/factory/AppError.d.ts +8 -0
  102. package/dist/esm/response-factory/factory/AppError.d.ts.map +1 -0
  103. package/dist/esm/response-factory/factory/BusinessError.d.ts +70 -0
  104. package/dist/esm/response-factory/factory/BusinessError.d.ts.map +1 -0
  105. package/dist/esm/response-factory/index.d.ts +3 -0
  106. package/dist/esm/response-factory/index.d.ts.map +1 -0
  107. package/dist/esm/response-factory/index.js +121 -0
  108. package/dist/esm/response-factory/response/Response.d.ts +15 -0
  109. package/dist/esm/response-factory/response/Response.d.ts.map +1 -0
  110. package/dist/esm/windows-registry-B92IgP1f.js +354 -0
  111. package/package.json +73 -0
@@ -0,0 +1,20 @@
1
+ import type { BrowserWindow } from 'electron';
2
+ import type { IPCRendererChannels } from './IpcTypes';
3
+ /**
4
+ * 主进程 IPC 封装
5
+ */
6
+ declare class IPCMainHandler {
7
+ private readonly windows;
8
+ registerWindow(win: BrowserWindow): void;
9
+ /**
10
+ * 发送消息到所有窗口
11
+ */
12
+ sendToAllWindows<K extends keyof IPCRendererChannels>(channel: K, args: IPCRendererChannels[K]): void;
13
+ /**
14
+ * 发送消息到特定窗口
15
+ */
16
+ sendToWindow<K extends keyof IPCRendererChannels>(win: BrowserWindow, channel: K, args: IPCRendererChannels[K]): void;
17
+ }
18
+ export declare const IpcMainHandler: IPCMainHandler;
19
+ export {};
20
+ //# sourceMappingURL=IpcMain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IpcMain.d.ts","sourceRoot":"","sources":["../../../src/ipc/IpcMain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD;;GAEG;AACH,cAAM,cAAc;IAClB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IAE7C,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAK/C;;OAEG;IACI,gBAAgB,CAAC,CAAC,SAAS,MAAM,mBAAmB,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,IAAI;IAQ5G;;OAEG;IACI,YAAY,CAAC,CAAC,SAAS,MAAM,mBAAmB,EACrD,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,CAAC,EACV,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAC3B,IAAI;CAKR;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { IpcRendererEvent } from 'electron';
2
+ /**
3
+ * IPC 通道类型定义
4
+ */
5
+ export interface IPCChannels {
6
+ [key: string]: string;
7
+ }
8
+ /**
9
+ * 主进程发送到渲染进程的通道
10
+ */
11
+ export interface IPCRendererChannels {
12
+ [key: string]: string;
13
+ }
14
+ /**
15
+ * 类型安全的 IPC 调用接口
16
+ */
17
+ export interface TypedIPCRenderer {
18
+ invoke<K extends keyof IPCChannels>(channel: K, ...args: IPCChannels[K] extends never ? [] : [IPCChannels[K]]): Promise<IPCChannels[K]>;
19
+ send<K extends keyof IPCChannels>(channel: K, ...args: IPCChannels[K] extends never ? [] : [IPCChannels[K]]): void;
20
+ on<K extends keyof IPCRendererChannels>(channel: K, listener: (event: IpcRendererEvent, args: IPCRendererChannels[K]) => void): () => void;
21
+ once<K extends keyof IPCRendererChannels>(channel: K, listener: (event: IpcRendererEvent, args: IPCRendererChannels[K]) => void): void;
22
+ }
23
+ export declare const typedIpc: TypedIPCRenderer;
24
+ //# sourceMappingURL=IpcTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IpcTypes.d.ts","sourceRoot":"","sources":["../../../src/ipc/IpcTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,CAAC,SAAS,MAAM,WAAW,EAChC,OAAO,EAAE,CAAC,EACV,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC5D,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3B,IAAI,CAAC,CAAC,SAAS,MAAM,WAAW,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAEnH,EAAE,CAAC,CAAC,SAAS,MAAM,mBAAmB,EACpC,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,GACxE,MAAM,IAAI,CAAC;IAEd,IAAI,CAAC,CAAC,SAAS,MAAM,mBAAmB,EACtC,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,GACxE,IAAI,CAAC;CACT;AAGD,eAAO,MAAM,QAAQ,EAAE,gBAA0C,CAAC"}
@@ -0,0 +1,66 @@
1
+ import type { IpcRendererEvent } from 'electron';
2
+ import { IpcMainHandler } from './IpcMain';
3
+ /**
4
+ * Electron IPC 通信封装
5
+ */
6
+ declare class IPCRenderer {
7
+ private static instance;
8
+ private readonly emitter;
9
+ private constructor();
10
+ static getInstance(): IPCRenderer;
11
+ /**
12
+ * 调用主进程方法 (请求-响应模式)
13
+ * @param channel 通信通道
14
+ * @param args 参数
15
+ * @returns Promise<T>
16
+ */
17
+ invoke<T>(channel: string, ...args: T[]): Promise<T>;
18
+ /**
19
+ * 发送消息到主进程 (无响应)
20
+ * @param channel 通信通道
21
+ * @param args 参数
22
+ */
23
+ send<T>(channel: string, ...args: T[]): void;
24
+ /**
25
+ * 监听主进程消息
26
+ * @param channel 通信通道
27
+ * @param listener 监听函数
28
+ * @returns 取消监听函数
29
+ */
30
+ on<T>(channel: string, listener: (event: IpcRendererEvent, ...args: T[]) => void): () => void;
31
+ /**
32
+ * 一次性监听主进程消息
33
+ * @param channel 通信通道
34
+ * @param listener 监听函数
35
+ */
36
+ once<T>(channel: string, listener: (event: IpcRendererEvent, ...args: T[]) => void): void;
37
+ /**
38
+ * 移除监听器
39
+ * @param channel 通信通道
40
+ * @param listener 监听函数
41
+ */
42
+ off<T>(channel: string, listener: (event: IpcRendererEvent, ...args: T[]) => void): void;
43
+ /**
44
+ * 发送事件到主进程并等待回复 (带超时)
45
+ * @param channel 通信通道
46
+ * @param timeout 超时时间(ms)
47
+ * @param args 参数
48
+ * @returns Promise<T>
49
+ */
50
+ invokeOperation<T, R>(channel: string, data: T, type?: string): Promise<R>;
51
+ /**
52
+ * 注册本地事件 (渲染进程内部通信)
53
+ * @param event 事件名
54
+ * @param listener 监听函数
55
+ */
56
+ registerLocalEvent<T>(event: string, listener: (...args: T[]) => void): () => void;
57
+ /**
58
+ * 触发本地事件
59
+ * @param event 事件名
60
+ * @param args 参数
61
+ */
62
+ emitLocalEvent<T>(event: string, ...args: T[]): void;
63
+ }
64
+ export declare const Ipc: IPCRenderer;
65
+ export { IpcMainHandler };
66
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ipc/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C;;GAEG;AACH,cAAM,WAAW;IAEf,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA4B;IACnD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAE9C,OAAO;WAKO,WAAW,IAAI,WAAW;IAOxC;;;;;OAKG;IACI,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;IAI3D;;;;OAIG;IACI,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI;IAInD;;;;;OAKG;IACI,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI;IAKpG;;;;OAIG;IACI,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,KAAK,IAAI,GAAG,IAAI;IAIhG;;;;OAIG;IACI,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,KAAK,IAAI,GAAG,IAAI;IAI/F;;;;;;OAMG;IACI,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAkBjF;;;;OAIG;IACI,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI;IAKzF;;;;OAIG;IACI,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI;CAG5D;AAED,eAAO,MAAM,GAAG,aAA4B,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,137 @@
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 { ipcRenderer } from "electron";
8
+ import { e as events } from "../events-CqhjgOaW.js";
9
+ class IPCMainHandler {
10
+ constructor() {
11
+ __publicField(this, "windows", /* @__PURE__ */ new Set());
12
+ }
13
+ registerWindow(win) {
14
+ this.windows.add(win);
15
+ win.on("closed", () => this.windows.delete(win));
16
+ }
17
+ /**
18
+ * 发送消息到所有窗口
19
+ */
20
+ sendToAllWindows(channel, args) {
21
+ for (const win of this.windows) {
22
+ if (!win.isDestroyed()) {
23
+ win.webContents.send(channel, args);
24
+ }
25
+ }
26
+ }
27
+ /**
28
+ * 发送消息到特定窗口
29
+ */
30
+ sendToWindow(win, channel, args) {
31
+ if (!win.isDestroyed()) {
32
+ win.webContents.send(channel, args);
33
+ }
34
+ }
35
+ }
36
+ const IpcMainHandler = new IPCMainHandler();
37
+ const _IPCRenderer = class _IPCRenderer {
38
+ constructor() {
39
+ __publicField(this, "emitter", new events.EventEmitter());
40
+ }
41
+ // 在整个应用中应该使用同一个实例(单例)
42
+ static getInstance() {
43
+ if (!_IPCRenderer.instance) {
44
+ _IPCRenderer.instance = new _IPCRenderer();
45
+ }
46
+ return _IPCRenderer.instance;
47
+ }
48
+ /**
49
+ * 调用主进程方法 (请求-响应模式)
50
+ * @param channel 通信通道
51
+ * @param args 参数
52
+ * @returns Promise<T>
53
+ */
54
+ invoke(channel, ...args) {
55
+ return ipcRenderer.invoke(channel, ...args);
56
+ }
57
+ /**
58
+ * 发送消息到主进程 (无响应)
59
+ * @param channel 通信通道
60
+ * @param args 参数
61
+ */
62
+ send(channel, ...args) {
63
+ ipcRenderer.send(channel, ...args);
64
+ }
65
+ /**
66
+ * 监听主进程消息
67
+ * @param channel 通信通道
68
+ * @param listener 监听函数
69
+ * @returns 取消监听函数
70
+ */
71
+ on(channel, listener) {
72
+ ipcRenderer.on(channel, listener);
73
+ return () => this.off(channel, listener);
74
+ }
75
+ /**
76
+ * 一次性监听主进程消息
77
+ * @param channel 通信通道
78
+ * @param listener 监听函数
79
+ */
80
+ once(channel, listener) {
81
+ ipcRenderer.once(channel, listener);
82
+ }
83
+ /**
84
+ * 移除监听器
85
+ * @param channel 通信通道
86
+ * @param listener 监听函数
87
+ */
88
+ off(channel, listener) {
89
+ ipcRenderer.off(channel, listener);
90
+ }
91
+ /**
92
+ * 发送事件到主进程并等待回复 (带超时)
93
+ * @param channel 通信通道
94
+ * @param timeout 超时时间(ms)
95
+ * @param args 参数
96
+ * @returns Promise<T>
97
+ */
98
+ invokeOperation(channel, data, type) {
99
+ return new Promise((resolve, reject) => {
100
+ const timer = setTimeout(() => {
101
+ reject(new Error(`IPC调用超时 (${6e3}ms): ${channel}`));
102
+ }, 6e3);
103
+ ipcRenderer.invoke(channel, data, type).then((response) => {
104
+ clearTimeout(timer);
105
+ resolve(response);
106
+ }).catch((error) => {
107
+ clearTimeout(timer);
108
+ reject(error);
109
+ });
110
+ });
111
+ }
112
+ /**
113
+ * 注册本地事件 (渲染进程内部通信)
114
+ * @param event 事件名
115
+ * @param listener 监听函数
116
+ */
117
+ registerLocalEvent(event, listener) {
118
+ this.emitter.on(event, listener);
119
+ return () => this.emitter.off(event, listener);
120
+ }
121
+ /**
122
+ * 触发本地事件
123
+ * @param event 事件名
124
+ * @param args 参数
125
+ */
126
+ emitLocalEvent(event, ...args) {
127
+ this.emitter.emit(event, ...args);
128
+ }
129
+ };
130
+ // eslint-disable-next-line no-use-before-define
131
+ __publicField(_IPCRenderer, "instance", null);
132
+ let IPCRenderer = _IPCRenderer;
133
+ const Ipc = IPCRenderer.getInstance();
134
+ export {
135
+ Ipc,
136
+ IpcMainHandler
137
+ };
@@ -0,0 +1,249 @@
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 "./index-Dys2BW-7.js";
8
+ import { promises } from "fs";
9
+ import { join, dirname } from "path";
10
+ import { homedir } from "os";
11
+ class KylinRegistryError extends Error {
12
+ constructor(message, hive, key, valueName) {
13
+ super(message);
14
+ __publicField(this, "hive");
15
+ __publicField(this, "key");
16
+ __publicField(this, "valueName");
17
+ this.hive = hive;
18
+ this.key = key;
19
+ this.valueName = valueName;
20
+ this.name = "KylinRegistryError";
21
+ }
22
+ }
23
+ let configBaseDir;
24
+ const _KylinRegistry = class _KylinRegistry {
25
+ constructor() {
26
+ configBaseDir = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
27
+ }
28
+ static getInstance() {
29
+ if (!_KylinRegistry.instance) {
30
+ _KylinRegistry.instance = new _KylinRegistry();
31
+ }
32
+ return _KylinRegistry.instance;
33
+ }
34
+ // 核心方法
35
+ static mapRegistryToConfigPath(hive, key) {
36
+ const cleanKey = `${hive}//${key}`;
37
+ return join(cleanKey, "config.json");
38
+ }
39
+ static async ensureConfigDir(configPath) {
40
+ await promises.mkdir(dirname(configPath), { recursive: true, mode: 493 });
41
+ }
42
+ static async safeOperation(operation, options = {}, operationName = "操作") {
43
+ const { retryCount = 3, retryDelay = 100 } = options;
44
+ for (let attempt = 1; attempt <= retryCount; attempt++) {
45
+ try {
46
+ return await operation();
47
+ } catch (error) {
48
+ if (attempt < retryCount) {
49
+ console.warn(`${operationName} 失败,第 ${attempt} 次重试:`, error);
50
+ await this.delay(retryDelay * attempt);
51
+ } else if (error instanceof Error) {
52
+ throw new KylinRegistryError(`${operationName} 失败: ${error.message}`, void 0, void 0, void 0);
53
+ }
54
+ }
55
+ }
56
+ throw new KylinRegistryError(`${operationName} 失败,未知错误`);
57
+ }
58
+ static delay(ms) {
59
+ return new Promise((resolve) => setTimeout(resolve, ms));
60
+ }
61
+ // 基本操作
62
+ static async getValue(hive, key, valueName, options = {}) {
63
+ return this.safeOperation(async () => {
64
+ const configPath = this.mapRegistryToConfigPath(hive, key);
65
+ try {
66
+ const configData = await promises.readFile(configPath, "utf8");
67
+ const config = JSON.parse(configData);
68
+ if (config[valueName] !== void 0) {
69
+ return { value: config[valueName], exists: true };
70
+ }
71
+ } catch (error) {
72
+ const err = error;
73
+ if (err.code === "ENOENT") {
74
+ return { value: null, exists: false };
75
+ }
76
+ throw error;
77
+ }
78
+ return { value: null, exists: false };
79
+ }, options, "读取配置值");
80
+ }
81
+ static async setValue(hive, key, valueName, value, options = {}) {
82
+ return this.safeOperation(async () => {
83
+ const configPath = this.mapRegistryToConfigPath(hive, key);
84
+ if (options.backupBeforeModify) {
85
+ const backup = await this.getValue(hive, key, valueName);
86
+ if (backup.exists) {
87
+ this.valueBackupCache.set(`${hive}:${key}:${valueName}`, backup);
88
+ }
89
+ }
90
+ await this.ensureConfigDir(configPath);
91
+ let config = {};
92
+ try {
93
+ const configData = await promises.readFile(configPath, "utf8");
94
+ config = JSON.parse(configData);
95
+ } catch (error) {
96
+ const err = error;
97
+ if (err.code === "ENOENT")
98
+ throw error;
99
+ }
100
+ config[valueName] = value;
101
+ await promises.writeFile(configPath, JSON.stringify(config, null, 2), "utf8");
102
+ }, options, "设置配置值");
103
+ }
104
+ static async deleteValue(hive, key, valueName, options = {}) {
105
+ return this.safeOperation(async () => {
106
+ const configPath = this.mapRegistryToConfigPath(hive, key);
107
+ if (options.backupBeforeModify) {
108
+ const backup = await this.getValue(hive, key, valueName);
109
+ if (backup.exists) {
110
+ this.valueBackupCache.set(`${hive}:${key}:${valueName}`, backup);
111
+ }
112
+ }
113
+ try {
114
+ const configData = await promises.readFile(configPath, "utf8");
115
+ const config = JSON.parse(configData);
116
+ if (config[valueName] !== void 0) {
117
+ delete config[valueName];
118
+ if (Object.keys(config).length === 0) {
119
+ await promises.unlink(configPath);
120
+ } else {
121
+ await promises.writeFile(configPath, JSON.stringify(config, null, 2), "utf8");
122
+ }
123
+ }
124
+ } catch (error) {
125
+ const err = error;
126
+ if (err.code === "ENOENT")
127
+ throw error;
128
+ }
129
+ }, options, "删除配置值");
130
+ }
131
+ static async createKey(hive, key, options = {}) {
132
+ return this.safeOperation(async () => {
133
+ const configPath = this.mapRegistryToConfigPath(hive, key);
134
+ await this.ensureConfigDir(configPath);
135
+ await promises.writeFile(configPath, "{}", "utf8");
136
+ }, options, "创建配置键");
137
+ }
138
+ static async deleteKey(hive, key, options = {}) {
139
+ return this.safeOperation(async () => {
140
+ const configPath = this.mapRegistryToConfigPath(hive, key);
141
+ try {
142
+ await promises.unlink(configPath);
143
+ } catch (error) {
144
+ const err = error;
145
+ if (err.code === "ENOENT")
146
+ throw error;
147
+ }
148
+ }, options, "删除配置键");
149
+ }
150
+ // 高级操作
151
+ static async listKeys(hive, key, options = {}) {
152
+ return this.safeOperation(async () => {
153
+ const configPath = this.mapRegistryToConfigPath(hive, key);
154
+ const dirPath = dirname(configPath);
155
+ try {
156
+ const items = await promises.readdir(dirPath, { withFileTypes: true });
157
+ return items.filter((item) => item.isDirectory()).map((item) => item.name);
158
+ } catch (error) {
159
+ const err = error;
160
+ if (err.code === "ENOENT")
161
+ return [];
162
+ throw err;
163
+ }
164
+ }, options, "枚举子键");
165
+ }
166
+ static async listValues(hive, key, options = {}) {
167
+ return this.safeOperation(async () => {
168
+ const configPath = this.mapRegistryToConfigPath(hive, key);
169
+ try {
170
+ const configData = await promises.readFile(configPath, "utf8");
171
+ const config = JSON.parse(configData);
172
+ return Object.entries(config).map(([name, value]) => ({ name, value }));
173
+ } catch (error) {
174
+ const err = error;
175
+ if (err.code === "ENOENT")
176
+ return [];
177
+ throw err;
178
+ }
179
+ }, options, "枚举配置值");
180
+ }
181
+ static async getKeyInfo(hive, key, options = {}) {
182
+ return this.safeOperation(async () => {
183
+ const [subKeys, values] = await Promise.all([
184
+ this.listKeys(hive, key, options),
185
+ this.listValues(hive, key, options)
186
+ ]);
187
+ return {
188
+ name: key,
189
+ subKeys,
190
+ values
191
+ // configPath: this.mapRegistryToConfigPath(hive, key),
192
+ };
193
+ }, options, "获取配置键信息");
194
+ }
195
+ // 批量操作
196
+ static async batchSetValues(hive, key, values, options = {}) {
197
+ return this.safeOperation(async () => {
198
+ const configPath = this.mapRegistryToConfigPath(hive, key);
199
+ await this.ensureConfigDir(configPath);
200
+ let config = {};
201
+ try {
202
+ const configData = await promises.readFile(configPath, "utf8");
203
+ config = JSON.parse(configData);
204
+ } catch (error) {
205
+ const err = error;
206
+ if (err.code === "ENOENT")
207
+ throw error;
208
+ }
209
+ for (const [valueName, { value }] of Object.entries(values)) {
210
+ config[valueName] = value;
211
+ }
212
+ await promises.writeFile(configPath, JSON.stringify(config, null, 2), "utf8");
213
+ }, options, "批量设置配置值");
214
+ }
215
+ // 工具方法
216
+ static async keyExists(hive, key) {
217
+ try {
218
+ const configPath = this.mapRegistryToConfigPath(hive, key);
219
+ await promises.access(configPath);
220
+ return true;
221
+ } catch (error) {
222
+ const err = error;
223
+ if (err.code === "ENOENT")
224
+ return false;
225
+ throw err;
226
+ }
227
+ }
228
+ static async valueExists(hive, key, valueName, options = {}) {
229
+ try {
230
+ const result = await this.getValue(hive, key, valueName, options);
231
+ return result.exists;
232
+ } catch (error) {
233
+ return false;
234
+ }
235
+ }
236
+ setConfigBaseDir(baseDir) {
237
+ configBaseDir = baseDir;
238
+ }
239
+ getConfigBaseDir() {
240
+ return configBaseDir;
241
+ }
242
+ };
243
+ __publicField(_KylinRegistry, "instance", null);
244
+ // private configBaseDir: string;
245
+ __publicField(_KylinRegistry, "valueBackupCache", /* @__PURE__ */ new Map());
246
+ let KylinRegistry = _KylinRegistry;
247
+ export {
248
+ KylinRegistry
249
+ };
@@ -0,0 +1,11 @@
1
+ export declare class String16 {
2
+ private readonly value;
3
+ constructor(str: string);
4
+ toString(): string;
5
+ valueOf(): string;
6
+ getValue(): string;
7
+ static from(str: string): String16;
8
+ static isValid(str: string): boolean;
9
+ static generate(): String16;
10
+ }
11
+ //# sourceMappingURL=String16.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"String16.d.ts","sourceRoot":"","sources":["../../../src/logger/String16.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,GAAG,EAAE,MAAM;IAOvB,QAAQ,IAAI,MAAM;IAIlB,OAAO,IAAI,MAAM;IAIjB,QAAQ,IAAI,MAAM;IAKlB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ;IAKlC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAKpC,MAAM,CAAC,QAAQ,IAAI,QAAQ;CAQ5B"}
@@ -0,0 +1,104 @@
1
+ import type { LoggerConfig, Logger } from '@ahana-awesome-platform/shared-types';
2
+ import winston from 'winston';
3
+ /**
4
+ * 日志服务类
5
+ * 提供加密、轮转、多级别日志功能
6
+ */
7
+ export declare class LoggerService implements Logger {
8
+ private readonly levels;
9
+ private readonly colors;
10
+ private readonly params;
11
+ private logDir;
12
+ private readonly logger;
13
+ private readonly sqlLogger;
14
+ /**
15
+ * 构造函数
16
+ * @param params 日志配置参数
17
+ */
18
+ constructor(params?: Partial<LoggerConfig>);
19
+ /**
20
+ * 获取默认日志目录
21
+ */
22
+ private getDefaultLogDir;
23
+ /**
24
+ * 检查加密密钥
25
+ */
26
+ private checkEncryptionKey;
27
+ /**
28
+ * 设置日志参数
29
+ * @param params 日志参数
30
+ */
31
+ setParams(params: Partial<LoggerConfig>): this;
32
+ /**
33
+ * 生成加密密钥
34
+ */
35
+ generateEncryptionKey(): string;
36
+ /**
37
+ * 加密文本
38
+ * @param text 要加密的文本
39
+ */
40
+ encrypt(text: string): string;
41
+ /**
42
+ * 解密文本
43
+ * @param encryptedText 加密文本
44
+ */
45
+ decrypt(encryptedText: string): string;
46
+ /**
47
+ * 格式化消息
48
+ * @param message 消息
49
+ */
50
+ private formatMessage;
51
+ /**
52
+ * 创建日志格式化器
53
+ * @param isConsole 是否为控制台格式
54
+ * @param shouldEncrypt 是否加密
55
+ */
56
+ private createFormat;
57
+ /**
58
+ * 创建日志传输器
59
+ */
60
+ private createTransports;
61
+ /**
62
+ * 创建日志记录器
63
+ */
64
+ private createLogger;
65
+ /**
66
+ * 创建SQL日志记录器
67
+ */
68
+ private createSqlLogger;
69
+ /**
70
+ * 获取流接口(供morgan等中间件使用)
71
+ */
72
+ getLogStream(): {
73
+ write: (message: string) => void;
74
+ };
75
+ /**
76
+ * 生成新的加密密钥
77
+ */
78
+ generateNewEncryptionKey(): string;
79
+ /**
80
+ * 获取日志记录器
81
+ */
82
+ getLogger(): winston.Logger;
83
+ /**
84
+ * 获取SQL日志记录器
85
+ */
86
+ getSqlLogger(): {
87
+ log: (query: string, duration: number, options?: Record<string, unknown> | undefined) => void;
88
+ };
89
+ /**
90
+ * 获取日志参数
91
+ */
92
+ getParams(): LoggerConfig;
93
+ /**
94
+ * 获取日志目录
95
+ */
96
+ getLogDir(): string;
97
+ error(message: string): void;
98
+ warn(message: string): void;
99
+ info(message: string): void;
100
+ http(message: string): void;
101
+ debug(message: string): void;
102
+ sql(query: string, duration: number): void;
103
+ }
104
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/logger/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAClG,OAAO,OAAO,MAAM,SAAS,CAAC;AAU9B;;;GAGG;AACH,qBAAa,aAAc,YAAW,MAAM;IAE1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAOrB;IAEF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAOrB;IAEF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAQrB;IAEF,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAExB;IAEF;;;OAGG;gBACS,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM;IAoB9C;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAqB9C;;OAEG;IACH,qBAAqB,IAAI,MAAM;IAI/B;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAkB7B;;;OAGG;IACH,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IA8BtC;;;OAGG;IACH,OAAO,CAAC,aAAa;IAMrB;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAoEpB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA4DxB;;OAEG;IACH,OAAO,CAAC,YAAY;IAUpB;;OAEG;IACH,OAAO,CAAC,eAAe;IAQvB;;OAEG;IACH,YAAY;yBAES,MAAM;;IAM3B;;OAEG;IACH,wBAAwB,IAAI,MAAM;IAMlC;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC,MAAM;IAI3B;;OAEG;IACH,YAAY;;;IAIZ;;OAEG;IACH,SAAS,IAAI,YAAY;IAIzB;;OAEG;IACH,SAAS,IAAI,MAAM;IAKnB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;CAG3C"}
@@ -0,0 +1,7 @@
1
+ import { L } from "../index-xOyNRTcn.js";
2
+ import "crypto";
3
+ import "path";
4
+ import "os";
5
+ export {
6
+ L as LoggerService
7
+ };
@@ -0,0 +1,4 @@
1
+ import type { Logger, LoggerConfig } from '@ahana-awesome-platform/shared-types';
2
+ export declare let logger: Logger | null;
3
+ export declare const setLogger: (sqliteDatabaseConfig: LoggerConfig) => Promise<unknown>;
4
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/orm/common/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAGjF,eAAO,IAAI,MAAM,EAAE,MAAM,GAAG,IAAW,CAAC;AAExC,eAAO,MAAM,SAAS,yBAA0B,YAAY,qBASxD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { getSqliteDatabase } from './sqlite';
2
+ export * from 'sequelize';
3
+ export { getSqliteDatabase };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/orm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,CAAC"}