electron-infra-kit 0.0.2

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 (254) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +302 -0
  3. package/README.zh-CN.md +308 -0
  4. package/dist/core/error/WindowError.d.ts +56 -0
  5. package/dist/core/error/WindowError.js +71 -0
  6. package/dist/core/error/WindowError.js.map +1 -0
  7. package/dist/core/error/WindowError.mjs +71 -0
  8. package/dist/core/error/WindowError.mjs.map +1 -0
  9. package/dist/core/ipc/IpcHandler.d.ts +48 -0
  10. package/dist/core/ipc/IpcHandler.js +59 -0
  11. package/dist/core/ipc/IpcHandler.js.map +1 -0
  12. package/dist/core/ipc/IpcHandler.mjs +59 -0
  13. package/dist/core/ipc/IpcHandler.mjs.map +1 -0
  14. package/dist/core/ipc/IpcRouter.d.ts +70 -0
  15. package/dist/core/ipc/IpcRouter.js +143 -0
  16. package/dist/core/ipc/IpcRouter.js.map +1 -0
  17. package/dist/core/ipc/IpcRouter.mjs +143 -0
  18. package/dist/core/ipc/IpcRouter.mjs.map +1 -0
  19. package/dist/core/ipc/index.d.ts +3 -0
  20. package/dist/core/ipc/index.js +1 -0
  21. package/dist/core/ipc/index.js.map +1 -0
  22. package/dist/core/ipc/index.mjs +1 -0
  23. package/dist/core/ipc/index.mjs.map +1 -0
  24. package/dist/core/ipc/ipc-router.type.d.ts +73 -0
  25. package/dist/core/ipc/transport/index.d.ts +65 -0
  26. package/dist/core/ipc/transport/index.js +229 -0
  27. package/dist/core/ipc/transport/index.js.map +1 -0
  28. package/dist/core/ipc/transport/index.mjs +229 -0
  29. package/dist/core/ipc/transport/index.mjs.map +1 -0
  30. package/dist/core/ipc/transport/ipc.type.d.ts +36 -0
  31. package/dist/core/lifecycle/LifecycleManager.d.ts +66 -0
  32. package/dist/core/lifecycle/LifecycleManager.js +140 -0
  33. package/dist/core/lifecycle/LifecycleManager.js.map +1 -0
  34. package/dist/core/lifecycle/LifecycleManager.mjs +140 -0
  35. package/dist/core/lifecycle/LifecycleManager.mjs.map +1 -0
  36. package/dist/core/message-bus/MessageBus.d.ts +282 -0
  37. package/dist/core/message-bus/MessageBus.js +677 -0
  38. package/dist/core/message-bus/MessageBus.js.map +1 -0
  39. package/dist/core/message-bus/MessageBus.mjs +677 -0
  40. package/dist/core/message-bus/MessageBus.mjs.map +1 -0
  41. package/dist/core/message-bus/MessageBusClient.d.ts +100 -0
  42. package/dist/core/message-bus/MessageBusClient.js +280 -0
  43. package/dist/core/message-bus/MessageBusClient.js.map +1 -0
  44. package/dist/core/message-bus/MessageBusClient.mjs +280 -0
  45. package/dist/core/message-bus/MessageBusClient.mjs.map +1 -0
  46. package/dist/core/message-bus/core/DataStoreManager.d.ts +51 -0
  47. package/dist/core/message-bus/core/DataStoreManager.js +94 -0
  48. package/dist/core/message-bus/core/DataStoreManager.js.map +1 -0
  49. package/dist/core/message-bus/core/DataStoreManager.mjs +94 -0
  50. package/dist/core/message-bus/core/DataStoreManager.mjs.map +1 -0
  51. package/dist/core/message-bus/core/ManagedPort.d.ts +26 -0
  52. package/dist/core/message-bus/core/ManagedPort.js +55 -0
  53. package/dist/core/message-bus/core/ManagedPort.js.map +1 -0
  54. package/dist/core/message-bus/core/ManagedPort.mjs +55 -0
  55. package/dist/core/message-bus/core/ManagedPort.mjs.map +1 -0
  56. package/dist/core/message-bus/core/PortManager.d.ts +47 -0
  57. package/dist/core/message-bus/core/PortManager.js +114 -0
  58. package/dist/core/message-bus/core/PortManager.js.map +1 -0
  59. package/dist/core/message-bus/core/PortManager.mjs +114 -0
  60. package/dist/core/message-bus/core/PortManager.mjs.map +1 -0
  61. package/dist/core/message-bus/core/SubscriptionManager.d.ts +36 -0
  62. package/dist/core/message-bus/core/SubscriptionManager.js +78 -0
  63. package/dist/core/message-bus/core/SubscriptionManager.js.map +1 -0
  64. package/dist/core/message-bus/core/SubscriptionManager.mjs +78 -0
  65. package/dist/core/message-bus/core/SubscriptionManager.mjs.map +1 -0
  66. package/dist/core/message-bus/core/TransactionManager.d.ts +54 -0
  67. package/dist/core/message-bus/core/TransactionManager.js +95 -0
  68. package/dist/core/message-bus/core/TransactionManager.js.map +1 -0
  69. package/dist/core/message-bus/core/TransactionManager.mjs +95 -0
  70. package/dist/core/message-bus/core/TransactionManager.mjs.map +1 -0
  71. package/dist/core/message-bus/core/index.d.ts +5 -0
  72. package/dist/core/message-bus/index.d.ts +4 -0
  73. package/dist/core/message-bus/index.js +1 -0
  74. package/dist/core/message-bus/index.js.map +1 -0
  75. package/dist/core/message-bus/index.mjs +1 -0
  76. package/dist/core/message-bus/index.mjs.map +1 -0
  77. package/dist/core/message-bus/message-bus.type.d.ts +143 -0
  78. package/dist/core/message-bus/message-bus.type.js +26 -0
  79. package/dist/core/message-bus/message-bus.type.js.map +1 -0
  80. package/dist/core/message-bus/message-bus.type.mjs +26 -0
  81. package/dist/core/message-bus/message-bus.type.mjs.map +1 -0
  82. package/dist/core/message-bus/preload.d.ts +16 -0
  83. package/dist/core/message-bus/preload.js +27 -0
  84. package/dist/core/message-bus/preload.js.map +1 -0
  85. package/dist/core/message-bus/preload.mjs +27 -0
  86. package/dist/core/message-bus/preload.mjs.map +1 -0
  87. package/dist/core/message-bus/transport/ITransport.d.ts +40 -0
  88. package/dist/core/message-bus/transport/IpcTransport.d.ts +18 -0
  89. package/dist/core/message-bus/transport/IpcTransport.js +60 -0
  90. package/dist/core/message-bus/transport/IpcTransport.js.map +1 -0
  91. package/dist/core/message-bus/transport/IpcTransport.mjs +60 -0
  92. package/dist/core/message-bus/transport/IpcTransport.mjs.map +1 -0
  93. package/dist/core/message-bus/transport/MessagePortTransport.d.ts +15 -0
  94. package/dist/core/message-bus/transport/MessagePortTransport.js +35 -0
  95. package/dist/core/message-bus/transport/MessagePortTransport.js.map +1 -0
  96. package/dist/core/message-bus/transport/MessagePortTransport.mjs +35 -0
  97. package/dist/core/message-bus/transport/MessagePortTransport.mjs.map +1 -0
  98. package/dist/core/message-bus/transport/index.d.ts +3 -0
  99. package/dist/core/window/IpcSetup.d.ts +50 -0
  100. package/dist/core/window/IpcSetup.js +96 -0
  101. package/dist/core/window/IpcSetup.js.map +1 -0
  102. package/dist/core/window/IpcSetup.mjs +96 -0
  103. package/dist/core/window/IpcSetup.mjs.map +1 -0
  104. package/dist/core/window/WindowCreator.d.ts +66 -0
  105. package/dist/core/window/WindowCreator.js +168 -0
  106. package/dist/core/window/WindowCreator.js.map +1 -0
  107. package/dist/core/window/WindowCreator.mjs +168 -0
  108. package/dist/core/window/WindowCreator.mjs.map +1 -0
  109. package/dist/core/window/WindowManager.d.ts +214 -0
  110. package/dist/core/window/WindowManager.js +583 -0
  111. package/dist/core/window/WindowManager.js.map +1 -0
  112. package/dist/core/window/WindowManager.mjs +583 -0
  113. package/dist/core/window/WindowManager.mjs.map +1 -0
  114. package/dist/core/window/WindowStore.d.ts +136 -0
  115. package/dist/core/window/WindowStore.js +436 -0
  116. package/dist/core/window/WindowStore.js.map +1 -0
  117. package/dist/core/window/WindowStore.mjs +436 -0
  118. package/dist/core/window/WindowStore.mjs.map +1 -0
  119. package/dist/core/window/constants.d.ts +17 -0
  120. package/dist/core/window/constants.js +15 -0
  121. package/dist/core/window/constants.js.map +1 -0
  122. package/dist/core/window/constants.mjs +15 -0
  123. package/dist/core/window/constants.mjs.map +1 -0
  124. package/dist/core/window/core/MetricsManager.d.ts +14 -0
  125. package/dist/core/window/core/MetricsManager.js +27 -0
  126. package/dist/core/window/core/MetricsManager.js.map +1 -0
  127. package/dist/core/window/core/MetricsManager.mjs +27 -0
  128. package/dist/core/window/core/MetricsManager.mjs.map +1 -0
  129. package/dist/core/window/core/PluginExecutor.d.ts +22 -0
  130. package/dist/core/window/core/PluginExecutor.js +110 -0
  131. package/dist/core/window/core/PluginExecutor.js.map +1 -0
  132. package/dist/core/window/core/PluginExecutor.mjs +110 -0
  133. package/dist/core/window/core/PluginExecutor.mjs.map +1 -0
  134. package/dist/core/window/core/WindowContextManager.d.ts +26 -0
  135. package/dist/core/window/core/WindowContextManager.js +59 -0
  136. package/dist/core/window/core/WindowContextManager.js.map +1 -0
  137. package/dist/core/window/core/WindowContextManager.mjs +59 -0
  138. package/dist/core/window/core/WindowContextManager.mjs.map +1 -0
  139. package/dist/core/window/core/WindowLifecycle.d.ts +15 -0
  140. package/dist/core/window/core/WindowLifecycle.js +150 -0
  141. package/dist/core/window/core/WindowLifecycle.js.map +1 -0
  142. package/dist/core/window/core/WindowLifecycle.mjs +150 -0
  143. package/dist/core/window/core/WindowLifecycle.mjs.map +1 -0
  144. package/dist/core/window/core/WindowOperator.d.ts +90 -0
  145. package/dist/core/window/core/WindowOperator.js +154 -0
  146. package/dist/core/window/core/WindowOperator.js.map +1 -0
  147. package/dist/core/window/core/WindowOperator.mjs +154 -0
  148. package/dist/core/window/core/WindowOperator.mjs.map +1 -0
  149. package/dist/core/window/core/WindowRegistry.d.ts +168 -0
  150. package/dist/core/window/core/WindowRegistry.js +331 -0
  151. package/dist/core/window/core/WindowRegistry.js.map +1 -0
  152. package/dist/core/window/core/WindowRegistry.mjs +331 -0
  153. package/dist/core/window/core/WindowRegistry.mjs.map +1 -0
  154. package/dist/core/window/core/WindowStateManager.d.ts +40 -0
  155. package/dist/core/window/core/WindowStateManager.js +110 -0
  156. package/dist/core/window/core/WindowStateManager.js.map +1 -0
  157. package/dist/core/window/core/WindowStateManager.mjs +110 -0
  158. package/dist/core/window/core/WindowStateManager.mjs.map +1 -0
  159. package/dist/core/window/index.d.ts +7 -0
  160. package/dist/core/window/index.js +1 -0
  161. package/dist/core/window/index.js.map +1 -0
  162. package/dist/core/window/index.mjs +1 -0
  163. package/dist/core/window/index.mjs.map +1 -0
  164. package/dist/core/window/window-manager.schema.d.ts +50 -0
  165. package/dist/core/window/window-manager.schema.js +87 -0
  166. package/dist/core/window/window-manager.schema.js.map +1 -0
  167. package/dist/core/window/window-manager.schema.mjs +87 -0
  168. package/dist/core/window/window-manager.schema.mjs.map +1 -0
  169. package/dist/core/window/window-manager.type.d.ts +365 -0
  170. package/dist/index.d.ts +25 -0
  171. package/dist/index.js +33 -0
  172. package/dist/index.js.map +1 -0
  173. package/dist/index.mjs +33 -0
  174. package/dist/index.mjs.map +1 -0
  175. package/dist/index.umd.js +1 -0
  176. package/dist/infrastructure/config/ConfigManager.d.ts +133 -0
  177. package/dist/infrastructure/config/ConfigManager.js +218 -0
  178. package/dist/infrastructure/config/ConfigManager.js.map +1 -0
  179. package/dist/infrastructure/config/ConfigManager.mjs +218 -0
  180. package/dist/infrastructure/config/ConfigManager.mjs.map +1 -0
  181. package/dist/infrastructure/config/index.d.ts +1 -0
  182. package/dist/infrastructure/debug/EnhancedDebugHelper.d.ts +106 -0
  183. package/dist/infrastructure/debug/EnhancedDebugHelper.js +218 -0
  184. package/dist/infrastructure/debug/EnhancedDebugHelper.js.map +1 -0
  185. package/dist/infrastructure/debug/EnhancedDebugHelper.mjs +218 -0
  186. package/dist/infrastructure/debug/EnhancedDebugHelper.mjs.map +1 -0
  187. package/dist/infrastructure/debug/PerformanceMonitor.d.ts +45 -0
  188. package/dist/infrastructure/debug/PerformanceMonitor.js +67 -0
  189. package/dist/infrastructure/debug/PerformanceMonitor.js.map +1 -0
  190. package/dist/infrastructure/debug/PerformanceMonitor.mjs +67 -0
  191. package/dist/infrastructure/debug/PerformanceMonitor.mjs.map +1 -0
  192. package/dist/infrastructure/debug/index.d.ts +22 -0
  193. package/dist/infrastructure/debug/index.js +47 -0
  194. package/dist/infrastructure/debug/index.js.map +1 -0
  195. package/dist/infrastructure/debug/index.mjs +47 -0
  196. package/dist/infrastructure/debug/index.mjs.map +1 -0
  197. package/dist/infrastructure/errors/ErrorCodes.d.ts +74 -0
  198. package/dist/infrastructure/errors/ErrorCodes.js +78 -0
  199. package/dist/infrastructure/errors/ErrorCodes.js.map +1 -0
  200. package/dist/infrastructure/errors/ErrorCodes.mjs +78 -0
  201. package/dist/infrastructure/errors/ErrorCodes.mjs.map +1 -0
  202. package/dist/infrastructure/errors/StandardError.d.ts +61 -0
  203. package/dist/infrastructure/errors/StandardError.js +84 -0
  204. package/dist/infrastructure/errors/StandardError.js.map +1 -0
  205. package/dist/infrastructure/errors/StandardError.mjs +84 -0
  206. package/dist/infrastructure/errors/StandardError.mjs.map +1 -0
  207. package/dist/infrastructure/errors/index.d.ts +13 -0
  208. package/dist/infrastructure/errors/index.js +24 -0
  209. package/dist/infrastructure/errors/index.js.map +1 -0
  210. package/dist/infrastructure/errors/index.mjs +24 -0
  211. package/dist/infrastructure/errors/index.mjs.map +1 -0
  212. package/dist/infrastructure/logger/ElectronLogger.d.ts +39 -0
  213. package/dist/infrastructure/logger/ElectronLogger.js +65 -0
  214. package/dist/infrastructure/logger/ElectronLogger.js.map +1 -0
  215. package/dist/infrastructure/logger/ElectronLogger.mjs +65 -0
  216. package/dist/infrastructure/logger/ElectronLogger.mjs.map +1 -0
  217. package/dist/infrastructure/logger/index.d.ts +2 -0
  218. package/dist/infrastructure/logger/logger.type.d.ts +8 -0
  219. package/dist/internal/types/BrandedTypes.d.ts +64 -0
  220. package/dist/internal/types/BrandedTypes.js +54 -0
  221. package/dist/internal/types/BrandedTypes.js.map +1 -0
  222. package/dist/internal/types/BrandedTypes.mjs +54 -0
  223. package/dist/internal/types/BrandedTypes.mjs.map +1 -0
  224. package/dist/internal/types/PerformanceOptions.d.ts +87 -0
  225. package/dist/internal/types/branded.d.ts +42 -0
  226. package/dist/internal/utils/MessageDispatcher.d.ts +67 -0
  227. package/dist/internal/utils/MessageDispatcher.js +96 -0
  228. package/dist/internal/utils/MessageDispatcher.js.map +1 -0
  229. package/dist/internal/utils/MessageDispatcher.mjs +96 -0
  230. package/dist/internal/utils/MessageDispatcher.mjs.map +1 -0
  231. package/dist/internal/utils/RateLimiter.d.ts +41 -0
  232. package/dist/internal/utils/RateLimiter.js +83 -0
  233. package/dist/internal/utils/RateLimiter.js.map +1 -0
  234. package/dist/internal/utils/RateLimiter.mjs +83 -0
  235. package/dist/internal/utils/RateLimiter.mjs.map +1 -0
  236. package/dist/internal/utils/StateKeeper.d.ts +125 -0
  237. package/dist/internal/utils/StateKeeper.js +334 -0
  238. package/dist/internal/utils/StateKeeper.js.map +1 -0
  239. package/dist/internal/utils/StateKeeper.mjs +334 -0
  240. package/dist/internal/utils/StateKeeper.mjs.map +1 -0
  241. package/dist/internal/utils/branded-helpers.d.ts +33 -0
  242. package/dist/internal/utils/index.d.ts +5 -0
  243. package/dist/preload/index.d.ts +45 -0
  244. package/dist/preload/index.js +91 -0
  245. package/dist/preload/index.js.map +1 -0
  246. package/dist/preload/index.mjs +91 -0
  247. package/dist/preload/index.mjs.map +1 -0
  248. package/dist/preload/preload.type.d.ts +15 -0
  249. package/dist/types.d.ts +7 -0
  250. package/dist/types.js +1 -0
  251. package/dist/types.js.map +1 -0
  252. package/dist/types.mjs +1 -0
  253. package/dist/types.mjs.map +1 -0
  254. package/package.json +143 -0
@@ -0,0 +1,110 @@
1
+ 'use strict';class PluginExecutor {
2
+ plugins = [];
3
+ hooks = {};
4
+ logger;
5
+ constructor(logger, plugins = [], hooks = {}) {
6
+ this.logger = logger;
7
+ this.plugins = plugins;
8
+ this.hooks = hooks;
9
+ }
10
+ addPlugin(plugin) {
11
+ this.plugins.push(plugin);
12
+ }
13
+ getPlugins() {
14
+ return this.plugins;
15
+ }
16
+ async initPlugins(wm) {
17
+ for (const plugin of this.plugins) {
18
+ try {
19
+ await plugin.onInit?.(wm);
20
+ }
21
+ catch (error) {
22
+ this.logger.error(`Plugin "${plugin.name}" initialization failed: ${error}`);
23
+ }
24
+ }
25
+ }
26
+ async initPlugin(plugin, wm) {
27
+ try {
28
+ await plugin.onInit?.(wm);
29
+ }
30
+ catch (error) {
31
+ this.logger.error(`Plugin "${plugin.name}" initialization failed: ${error}`);
32
+ }
33
+ }
34
+ onWillCreate(config) {
35
+ let hookConfig = { ...config };
36
+ // 1. Plugins
37
+ for (const plugin of this.plugins) {
38
+ if (plugin.onWillCreate) {
39
+ const result = plugin.onWillCreate(hookConfig);
40
+ if (result === false)
41
+ return false;
42
+ if (result && typeof result === 'object')
43
+ hookConfig = result;
44
+ }
45
+ }
46
+ // 2. Lifecycle Hooks
47
+ if (this.hooks.onWillCreate) {
48
+ const result = this.hooks.onWillCreate(hookConfig);
49
+ if (result === false)
50
+ return false;
51
+ if (result && typeof result === 'object')
52
+ hookConfig = result;
53
+ }
54
+ return hookConfig;
55
+ }
56
+ async onDidCreate(details) {
57
+ for (const p of this.plugins) {
58
+ try {
59
+ await p.onDidCreate?.(details);
60
+ }
61
+ catch (e) {
62
+ this.logger.error(`Plugin ${p.name} onDidCreate failed: ${e}`);
63
+ }
64
+ }
65
+ if (this.hooks.onDidCreate) {
66
+ try {
67
+ await this.hooks.onDidCreate(details);
68
+ }
69
+ catch (e) {
70
+ this.logger.error(`Hook onDidCreate failed: ${e}`);
71
+ }
72
+ }
73
+ }
74
+ async onWillDestroy(windowId) {
75
+ for (const p of this.plugins) {
76
+ try {
77
+ await p.onWillDestroy?.(windowId);
78
+ }
79
+ catch (e) {
80
+ this.logger.error(`Plugin ${p.name} onWillDestroy failed: ${e}`);
81
+ }
82
+ }
83
+ if (this.hooks.onWillDestroy) {
84
+ try {
85
+ await this.hooks.onWillDestroy(windowId);
86
+ }
87
+ catch (e) {
88
+ this.logger.error(`Hook onWillDestroy failed: ${e}`);
89
+ }
90
+ }
91
+ }
92
+ async onDidDestroy(windowId) {
93
+ for (const p of this.plugins) {
94
+ try {
95
+ await p.onDidDestroy?.(windowId);
96
+ }
97
+ catch (e) {
98
+ this.logger.error(`Plugin ${p.name} onDidDestroy failed: ${e}`);
99
+ }
100
+ }
101
+ if (this.hooks.onDidDestroy) {
102
+ try {
103
+ await this.hooks.onDidDestroy(windowId);
104
+ }
105
+ catch (e) {
106
+ this.logger.error(`Hook onDidDestroy failed: ${e}`);
107
+ }
108
+ }
109
+ }
110
+ }exports.PluginExecutor=PluginExecutor;//# sourceMappingURL=PluginExecutor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginExecutor.js","sources":["../../../../src/core/window/core/PluginExecutor.ts"],"sourcesContent":["import { BrowserWindow } from 'electron';\nimport { WindowManagerPlugin, LifecycleHooks, WindowCreationOptions } from '../window-manager.type';\nimport { ILogger } from '@/infrastructure/logger';\nimport type WindowManager from '../WindowManager';\n\nexport class PluginExecutor {\n private plugins: WindowManagerPlugin[] = [];\n private hooks: LifecycleHooks = {};\n private logger: ILogger;\n\n constructor(logger: ILogger, plugins: WindowManagerPlugin[] = [], hooks: LifecycleHooks = {}) {\n this.logger = logger;\n this.plugins = plugins;\n this.hooks = hooks;\n }\n\n public addPlugin(plugin: WindowManagerPlugin): void {\n this.plugins.push(plugin);\n }\n\n public getPlugins(): WindowManagerPlugin[] {\n return this.plugins;\n }\n\n public async initPlugins(wm: WindowManager): Promise<void> {\n for (const plugin of this.plugins) {\n try {\n await plugin.onInit?.(wm);\n } catch (error) {\n this.logger.error(`Plugin \"${plugin.name}\" initialization failed: ${error}`);\n }\n }\n }\n\n public async initPlugin(plugin: WindowManagerPlugin, wm: WindowManager): Promise<void> {\n try {\n await plugin.onInit?.(wm);\n } catch (error) {\n this.logger.error(`Plugin \"${plugin.name}\" initialization failed: ${error}`);\n }\n }\n\n public onWillCreate(config: WindowCreationOptions): WindowCreationOptions | false {\n let hookConfig = { ...config };\n\n // 1. Plugins\n for (const plugin of this.plugins) {\n if (plugin.onWillCreate) {\n const result = plugin.onWillCreate(hookConfig);\n if (result === false) return false;\n if (result && typeof result === 'object') hookConfig = result;\n }\n }\n\n // 2. Lifecycle Hooks\n if (this.hooks.onWillCreate) {\n const result = this.hooks.onWillCreate(hookConfig);\n if (result === false) return false;\n if (result && typeof result === 'object') hookConfig = result;\n }\n\n return hookConfig;\n }\n\n public async onDidCreate(details: {\n window: BrowserWindow;\n id: string;\n name?: string;\n }): Promise<void> {\n for (const p of this.plugins) {\n try {\n await p.onDidCreate?.(details);\n } catch (e) {\n this.logger.error(`Plugin ${p.name} onDidCreate failed: ${e}`);\n }\n }\n\n if (this.hooks.onDidCreate) {\n try {\n await this.hooks.onDidCreate(details);\n } catch (e) {\n this.logger.error(`Hook onDidCreate failed: ${e}`);\n }\n }\n }\n\n public async onWillDestroy(windowId: string): Promise<void> {\n for (const p of this.plugins) {\n try {\n await p.onWillDestroy?.(windowId);\n } catch (e) {\n this.logger.error(`Plugin ${p.name} onWillDestroy failed: ${e}`);\n }\n }\n\n if (this.hooks.onWillDestroy) {\n try {\n await this.hooks.onWillDestroy(windowId);\n } catch (e) {\n this.logger.error(`Hook onWillDestroy failed: ${e}`);\n }\n }\n }\n\n public async onDidDestroy(windowId: string): Promise<void> {\n for (const p of this.plugins) {\n try {\n await p.onDidDestroy?.(windowId);\n } catch (e) {\n this.logger.error(`Plugin ${p.name} onDidDestroy failed: ${e}`);\n }\n }\n\n if (this.hooks.onDidDestroy) {\n try {\n await this.hooks.onDidDestroy(windowId);\n } catch (e) {\n this.logger.error(`Hook onDidDestroy failed: ${e}`);\n }\n }\n }\n}\n"],"names":[],"mappings":"mBAKa,cAAc,CAAA;IACjB,OAAO,GAA0B,EAAE;IACnC,KAAK,GAAmB,EAAE;AAC1B,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,MAAe,EAAE,OAAA,GAAiC,EAAE,EAAE,QAAwB,EAAE,EAAA;AAC1F,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;AACtB,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK;IACpB;AAEO,IAAA,SAAS,CAAC,MAA2B,EAAA;AAC1C,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;IAC3B;IAEO,UAAU,GAAA;QACf,OAAO,IAAI,CAAC,OAAO;IACrB;IAEO,MAAM,WAAW,CAAC,EAAiB,EAAA;AACxC,QAAA,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;AACjC,YAAA,IAAI;AACF,gBAAA,M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AC,QAAgB,EAAA;AACxC,QAAA,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE;AAC5B,YAAA,IAAI;AACF,gBAAA,MAAM,CAAC,CAAC,YAAY,GAAG,QAAQ,CAAC;YAClC;YAAE,OAAO,CAAC,EAAE;AACV,gBAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,OAAA,EAAU,CAAC,CAAC,IAAI,CAAA,sBAAA,EAAyB,CAAC,CAAA,CAAE,CAAC;YACjE;QACF;AAEA,QAAA,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;AAC3B,YAAA,IAAI;gBACF,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC;YACzC;YAAE,OAAO,CAAC,EAAE;gBACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,0BAAA,EAA6B,CAAC,CAAA,CAAE,CAAC;YACrD;QACF;IACF;AACD"}
@@ -0,0 +1,110 @@
1
+ class PluginExecutor {
2
+ plugins = [];
3
+ hooks = {};
4
+ logger;
5
+ constructor(logger, plugins = [], hooks = {}) {
6
+ this.logger = logger;
7
+ this.plugins = plugins;
8
+ this.hooks = hooks;
9
+ }
10
+ addPlugin(plugin) {
11
+ this.plugins.push(plugin);
12
+ }
13
+ getPlugins() {
14
+ return this.plugins;
15
+ }
16
+ async initPlugins(wm) {
17
+ for (const plugin of this.plugins) {
18
+ try {
19
+ await plugin.onInit?.(wm);
20
+ }
21
+ catch (error) {
22
+ this.logger.error(`Plugin "${plugin.name}" initialization failed: ${error}`);
23
+ }
24
+ }
25
+ }
26
+ async initPlugin(plugin, wm) {
27
+ try {
28
+ await plugin.onInit?.(wm);
29
+ }
30
+ catch (error) {
31
+ this.logger.error(`Plugin "${plugin.name}" initialization failed: ${error}`);
32
+ }
33
+ }
34
+ onWillCreate(config) {
35
+ let hookConfig = { ...config };
36
+ // 1. Plugins
37
+ for (const plugin of this.plugins) {
38
+ if (plugin.onWillCreate) {
39
+ const result = plugin.onWillCreate(hookConfig);
40
+ if (result === false)
41
+ return false;
42
+ if (result && typeof result === 'object')
43
+ hookConfig = result;
44
+ }
45
+ }
46
+ // 2. Lifecycle Hooks
47
+ if (this.hooks.onWillCreate) {
48
+ const result = this.hooks.onWillCreate(hookConfig);
49
+ if (result === false)
50
+ return false;
51
+ if (result && typeof result === 'object')
52
+ hookConfig = result;
53
+ }
54
+ return hookConfig;
55
+ }
56
+ async onDidCreate(details) {
57
+ for (const p of this.plugins) {
58
+ try {
59
+ await p.onDidCreate?.(details);
60
+ }
61
+ catch (e) {
62
+ this.logger.error(`Plugin ${p.name} onDidCreate failed: ${e}`);
63
+ }
64
+ }
65
+ if (this.hooks.onDidCreate) {
66
+ try {
67
+ await this.hooks.onDidCreate(details);
68
+ }
69
+ catch (e) {
70
+ this.logger.error(`Hook onDidCreate failed: ${e}`);
71
+ }
72
+ }
73
+ }
74
+ async onWillDestroy(windowId) {
75
+ for (const p of this.plugins) {
76
+ try {
77
+ await p.onWillDestroy?.(windowId);
78
+ }
79
+ catch (e) {
80
+ this.logger.error(`Plugin ${p.name} onWillDestroy failed: ${e}`);
81
+ }
82
+ }
83
+ if (this.hooks.onWillDestroy) {
84
+ try {
85
+ await this.hooks.onWillDestroy(windowId);
86
+ }
87
+ catch (e) {
88
+ this.logger.error(`Hook onWillDestroy failed: ${e}`);
89
+ }
90
+ }
91
+ }
92
+ async onDidDestroy(windowId) {
93
+ for (const p of this.plugins) {
94
+ try {
95
+ await p.onDidDestroy?.(windowId);
96
+ }
97
+ catch (e) {
98
+ this.logger.error(`Plugin ${p.name} onDidDestroy failed: ${e}`);
99
+ }
100
+ }
101
+ if (this.hooks.onDidDestroy) {
102
+ try {
103
+ await this.hooks.onDidDestroy(windowId);
104
+ }
105
+ catch (e) {
106
+ this.logger.error(`Hook onDidDestroy failed: ${e}`);
107
+ }
108
+ }
109
+ }
110
+ }export{PluginExecutor};//# sourceMappingURL=PluginExecutor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginExecutor.mjs","sources":["../../../../src/core/window/core/PluginExecutor.ts"],"sourcesContent":["import { BrowserWindow } from 'electron';\nimport { WindowManagerPlugin, LifecycleHooks, WindowCreationOptions } from '../window-manager.type';\nimport { ILogger } from '@/infrastructure/logger';\nimport type WindowManager from '../WindowManager';\n\nexport class PluginExecutor {\n private plugins: WindowManagerPlugin[] = [];\n private hooks: LifecycleHooks = {};\n private logger: ILogger;\n\n constructor(logger: ILogger, plugins: WindowManagerPlugin[] = [], hooks: LifecycleHooks = {}) {\n this.logger = logger;\n this.plugins = plugins;\n this.hooks = hooks;\n }\n\n public addPlugin(plugin: WindowManagerPlugin): void {\n this.plugins.push(plugin);\n }\n\n public getPlugins(): WindowManagerPlugin[] {\n return this.plugins;\n }\n\n public async initPlugins(wm: WindowManager): Promise<void> {\n for (const plugin of this.plugins) {\n try {\n await plugin.onInit?.(wm);\n } catch (error) {\n this.logger.error(`Plugin \"${plugin.name}\" initialization failed: ${error}`);\n }\n }\n }\n\n public async initPlugin(plugin: WindowManagerPlugin, wm: WindowManager): Promise<void> {\n try {\n await plugin.onInit?.(wm);\n } catch (error) {\n this.logger.error(`Plugin \"${plugin.name}\" initialization failed: ${error}`);\n }\n }\n\n public onWillCreate(config: WindowCreationOptions): WindowCreationOptions | false {\n let hookConfig = { ...config };\n\n // 1. Plugins\n for (const plugin of this.plugins) {\n if (plugin.onWillCreate) {\n const result = plugin.onWillCreate(hookConfig);\n if (result === false) return false;\n if (result && typeof result === 'object') hookConfig = result;\n }\n }\n\n // 2. Lifecycle Hooks\n if (this.hooks.onWillCreate) {\n const result = this.hooks.onWillCreate(hookConfig);\n if (result === false) return false;\n if (result && typeof result === 'object') hookConfig = result;\n }\n\n return hookConfig;\n }\n\n public async onDidCreate(details: {\n window: BrowserWindow;\n id: string;\n name?: string;\n }): Promise<void> {\n for (const p of this.plugins) {\n try {\n await p.onDidCreate?.(details);\n } catch (e) {\n this.logger.error(`Plugin ${p.name} onDidCreate failed: ${e}`);\n }\n }\n\n if (this.hooks.onDidCreate) {\n try {\n await this.hooks.onDidCreate(details);\n } catch (e) {\n this.logger.error(`Hook onDidCreate failed: ${e}`);\n }\n }\n }\n\n public async onWillDestroy(windowId: string): Promise<void> {\n for (const p of this.plugins) {\n try {\n await p.onWillDestroy?.(windowId);\n } catch (e) {\n this.logger.error(`Plugin ${p.name} onWillDestroy failed: ${e}`);\n }\n }\n\n if (this.hooks.onWillDestroy) {\n try {\n await this.hooks.onWillDestroy(windowId);\n } catch (e) {\n this.logger.error(`Hook onWillDestroy failed: ${e}`);\n }\n }\n }\n\n public async onDidDestroy(windowId: string): Promise<void> {\n for (const p of this.plugins) {\n try {\n await p.onDidDestroy?.(windowId);\n } catch (e) {\n this.logger.error(`Plugin ${p.name} onDidDestroy failed: ${e}`);\n }\n }\n\n if (this.hooks.onDidDestroy) {\n try {\n await this.hooks.onDidDestroy(windowId);\n } catch (e) {\n this.logger.error(`Hook onDidDestroy failed: ${e}`);\n }\n }\n }\n}\n"],"names":[],"mappings":"MAKa,cAAc,CAAA;IACjB,OAAO,GAA0B,EAAE;IACnC,KAAK,GAAmB,EAAE;AAC1B,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,MAAe,EAAE,OAAA,GAAiC,EAAE,EAAE,QAAwB,EAAE,EAAA;AAC1F,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;AACtB,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK;IACpB;AAEO,IAAA,SAAS,CAAC,MAA2B,EAAA;AAC1C,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;IAC3B;IAEO,UAAU,GAAA;QACf,OAAO,IAAI,CAAC,OAAO;IACrB;IAEO,MAAM,WAAW,CAAC,EAAiB,EAAA;AACxC,QAAA,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;AACjC,YAAA,IA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O,MAAM,YAAY,CAAC,QAAgB,EAAA;AACxC,QAAA,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE;AAC5B,YAAA,IAAI;AACF,gBAAA,MAAM,CAAC,CAAC,YAAY,GAAG,QAAQ,CAAC;YAClC;YAAE,OAAO,CAAC,EAAE;AACV,gBAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,OAAA,EAAU,CAAC,CAAC,IAAI,CAAA,sBAAA,EAAyB,CAAC,CAAA,CAAE,CAAC;YACjE;QACF;AAEA,QAAA,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;AAC3B,YAAA,IAAI;gBACF,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC;YACzC;YAAE,OAAO,CAAC,EAAE;gBACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,0BAAA,EAA6B,CAAC,CAAA,CAAE,CAAC;YACrD;QACF;IACF;AACD"}
@@ -0,0 +1,26 @@
1
+ import { IContextPersistence } from '../window-manager.type';
2
+ import { ILogger } from '@/infrastructure/logger';
3
+ /**
4
+ * WindowContextManager - Manages window context persistence
5
+ * 窗口上下文管理器 - 管理窗口上下文持久化
6
+ */
7
+ export declare class WindowContextManager {
8
+ private persistence;
9
+ private logger;
10
+ constructor(persistence: IContextPersistence | undefined, logger: ILogger);
11
+ /**
12
+ * Save window context
13
+ * 保存窗口上下文
14
+ */
15
+ save(windowId: string, context: any): Promise<void>;
16
+ /**
17
+ * Load window context
18
+ * 加载窗口上下文
19
+ */
20
+ load(windowId: string): Promise<any>;
21
+ /**
22
+ * Clear window context
23
+ * 清除窗口上下文
24
+ */
25
+ clear(windowId: string): Promise<void>;
26
+ }
@@ -0,0 +1,59 @@
1
+ 'use strict';/**
2
+ * WindowContextManager - Manages window context persistence
3
+ * 窗口上下文管理器 - 管理窗口上下文持久化
4
+ */
5
+ class WindowContextManager {
6
+ persistence;
7
+ logger;
8
+ constructor(persistence, logger) {
9
+ this.persistence = persistence;
10
+ this.logger = logger;
11
+ }
12
+ /**
13
+ * Save window context
14
+ * 保存窗口上下文
15
+ */
16
+ async save(windowId, context) {
17
+ if (!this.persistence) {
18
+ this.logger.warn('Context persistence is not enabled');
19
+ return;
20
+ }
21
+ try {
22
+ await this.persistence.save(windowId, context);
23
+ }
24
+ catch (error) {
25
+ this.logger.error(`Failed to save context for window ${windowId}: ${error}`);
26
+ }
27
+ }
28
+ /**
29
+ * Load window context
30
+ * 加载窗口上下文
31
+ */
32
+ async load(windowId) {
33
+ if (!this.persistence) {
34
+ return null;
35
+ }
36
+ try {
37
+ return await this.persistence.load(windowId);
38
+ }
39
+ catch (error) {
40
+ this.logger.error(`Failed to load context for window ${windowId}: ${error}`);
41
+ return null;
42
+ }
43
+ }
44
+ /**
45
+ * Clear window context
46
+ * 清除窗口上下文
47
+ */
48
+ async clear(windowId) {
49
+ if (!this.persistence) {
50
+ return;
51
+ }
52
+ try {
53
+ await this.persistence.clear(windowId);
54
+ }
55
+ catch (error) {
56
+ this.logger.error(`Failed to clear context for window ${windowId}: ${error}`);
57
+ }
58
+ }
59
+ }exports.WindowContextManager=WindowContextManager;//# sourceMappingURL=WindowContextManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowContextManager.js","sources":["../../../../src/core/window/core/WindowContextManager.ts"],"sourcesContent":["import { IContextPersistence } from '../window-manager.type';\nimport { ILogger } from '@/infrastructure/logger';\n\n/**\n * WindowContextManager - Manages window context persistence\n * 窗口上下文管理器 - 管理窗口上下文持久化\n */\nexport class WindowContextManager {\n constructor(\n private persistence: IContextPersistence | undefined,\n private logger: ILogger\n ) {}\n\n /**\n * Save window context\n * 保存窗口上下文\n */\n async save(windowId: string, context: any): Promise<void> {\n if (!this.persistence) {\n this.logger.warn('Context persistence is not enabled');\n return;\n }\n try {\n await this.persistence.save(windowId, context);\n } catch (error) {\n this.logger.error(`Failed to save context for window ${windowId}: ${error}`);\n }\n }\n\n /**\n * Load window context\n * 加载窗口上下文\n */\n async load(windowId: string): Promise<any> {\n if (!this.persistence) {\n return null;\n }\n try {\n return await this.persistence.load(windowId);\n } catch (error) {\n this.logger.error(`Failed to load context for window ${windowId}: ${error}`);\n return null;\n }\n }\n\n /**\n * Clear window context\n * 清除窗口上下文\n */\n async clear(windowId: string): Promise<void> {\n if (!this.persistence) {\n return;\n }\n try {\n await this.persistence.clear(windowId);\n } catch (error) {\n this.logger.error(`Failed to clear context for window ${windowId}: ${error}`);\n }\n }\n}\n"],"names":[],"mappings":"aAGA;;;AAGG;MACU,oBAAoB,CAAA;AAErB,IAAA,WAAA;AACA,IAAA,MAAA;IAFV,WAAA,CACU,WAA4C,EAC5C,MAAe,EAAA;QADf,IAAA,CAAA,WAAW,GAAX,WAAW;QACX,IAAA,CAAA,MAAM,GAAN,MAAM;IACb;AAEH;;;AAGG;AACH,IAAA,MAAM,IAAI,CAAC,QAAgB,EAAE,OAAY,EAAA;AACvC,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;AACrB,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC;YACtD;QACF;AACA,QAAA,IAAI;YACF,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC;QAChD;QAAE,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,kCAAA,EAAqC,QAAQ,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAC;QAC9E;IACF;AAEA;;;AAGG;IACH,MAAM,IAAI,CAAC,QAAgB,EAAA;AACzB,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;AACrB,YAAA,OAAO,IAAI;QACb;AACA,QAAA,IAAI;YACF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC9C;QAAE,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,kCAAA,EAAqC,QAAQ,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAC;AAC5E,YAAA,OAAO,IAAI;QACb;IACF;AAEA;;;AAGG;IACH,MAAM,KAAK,CAAC,QAAgB,EAAA;AAC1B,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB;QACF;AACA,QAAA,IAAI;YACF,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC;QACxC;QAAE,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,mCAAA,EAAsC,QAAQ,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAC;QAC/E;IACF;AACD"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * WindowContextManager - Manages window context persistence
3
+ * 窗口上下文管理器 - 管理窗口上下文持久化
4
+ */
5
+ class WindowContextManager {
6
+ persistence;
7
+ logger;
8
+ constructor(persistence, logger) {
9
+ this.persistence = persistence;
10
+ this.logger = logger;
11
+ }
12
+ /**
13
+ * Save window context
14
+ * 保存窗口上下文
15
+ */
16
+ async save(windowId, context) {
17
+ if (!this.persistence) {
18
+ this.logger.warn('Context persistence is not enabled');
19
+ return;
20
+ }
21
+ try {
22
+ await this.persistence.save(windowId, context);
23
+ }
24
+ catch (error) {
25
+ this.logger.error(`Failed to save context for window ${windowId}: ${error}`);
26
+ }
27
+ }
28
+ /**
29
+ * Load window context
30
+ * 加载窗口上下文
31
+ */
32
+ async load(windowId) {
33
+ if (!this.persistence) {
34
+ return null;
35
+ }
36
+ try {
37
+ return await this.persistence.load(windowId);
38
+ }
39
+ catch (error) {
40
+ this.logger.error(`Failed to load context for window ${windowId}: ${error}`);
41
+ return null;
42
+ }
43
+ }
44
+ /**
45
+ * Clear window context
46
+ * 清除窗口上下文
47
+ */
48
+ async clear(windowId) {
49
+ if (!this.persistence) {
50
+ return;
51
+ }
52
+ try {
53
+ await this.persistence.clear(windowId);
54
+ }
55
+ catch (error) {
56
+ this.logger.error(`Failed to clear context for window ${windowId}: ${error}`);
57
+ }
58
+ }
59
+ }export{WindowContextManager};//# sourceMappingURL=WindowContextManager.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowContextManager.mjs","sources":["../../../../src/core/window/core/WindowContextManager.ts"],"sourcesContent":["import { IContextPersistence } from '../window-manager.type';\nimport { ILogger } from '@/infrastructure/logger';\n\n/**\n * WindowContextManager - Manages window context persistence\n * 窗口上下文管理器 - 管理窗口上下文持久化\n */\nexport class WindowContextManager {\n constructor(\n private persistence: IContextPersistence | undefined,\n private logger: ILogger\n ) {}\n\n /**\n * Save window context\n * 保存窗口上下文\n */\n async save(windowId: string, context: any): Promise<void> {\n if (!this.persistence) {\n this.logger.warn('Context persistence is not enabled');\n return;\n }\n try {\n await this.persistence.save(windowId, context);\n } catch (error) {\n this.logger.error(`Failed to save context for window ${windowId}: ${error}`);\n }\n }\n\n /**\n * Load window context\n * 加载窗口上下文\n */\n async load(windowId: string): Promise<any> {\n if (!this.persistence) {\n return null;\n }\n try {\n return await this.persistence.load(windowId);\n } catch (error) {\n this.logger.error(`Failed to load context for window ${windowId}: ${error}`);\n return null;\n }\n }\n\n /**\n * Clear window context\n * 清除窗口上下文\n */\n async clear(windowId: string): Promise<void> {\n if (!this.persistence) {\n return;\n }\n try {\n await this.persistence.clear(windowId);\n } catch (error) {\n this.logger.error(`Failed to clear context for window ${windowId}: ${error}`);\n }\n }\n}\n"],"names":[],"mappings":"AAGA;;;AAGG;MACU,oBAAoB,CAAA;AAErB,IAAA,WAAA;AACA,IAAA,MAAA;IAFV,WAAA,CACU,WAA4C,EAC5C,MAAe,EAAA;QADf,IAAA,CAAA,WAAW,GAAX,WAAW;QACX,IAAA,CAAA,MAAM,GAAN,MAAM;IACb;AAEH;;;AAGG;AACH,IAAA,MAAM,IAAI,CAAC,QAAgB,EAAE,OAAY,EAAA;AACvC,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;AACrB,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC;YACtD;QACF;AACA,QAAA,IAAI;YACF,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC;QAChD;QAAE,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,kCAAA,EAAqC,QAAQ,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAC;QAC9E;IACF;AAEA;;;AAGG;IACH,MAAM,IAAI,CAAC,QAAgB,EAAA;AACzB,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;AACrB,YAAA,OAAO,IAAI;QACb;AACA,QAAA,IAAI;YACF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC9C;QAAE,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,kCAAA,EAAqC,QAAQ,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAC;AAC5E,YAAA,OAAO,IAAI;QACb;IACF;AAEA;;;AAGG;IACH,MAAM,KAAK,CAAC,QAAgB,EAAA;AAC1B,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB;QACF;AACA,QAAA,IAAI;YACF,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC;QACxC;QAAE,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,mCAAA,EAAsC,QAAQ,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAC;QAC/E;IACF;AACD"}
@@ -0,0 +1,15 @@
1
+ import type WindowManager from '../WindowManager';
2
+ import { WindowCreationOptions } from '../window-manager.type';
3
+ import { PluginExecutor } from './PluginExecutor';
4
+ import { MetricsManager } from './MetricsManager';
5
+ import { ILogger } from '@/infrastructure/logger';
6
+ export declare class WindowLifecycle {
7
+ private wm;
8
+ private pluginExecutor;
9
+ private metrics;
10
+ private logger;
11
+ constructor(wm: WindowManager, pluginExecutor: PluginExecutor, metrics: MetricsManager, logger: ILogger);
12
+ create(config?: WindowCreationOptions): Promise<string>;
13
+ removeWindow(windowId: string): Promise<void>;
14
+ private registerStateManagement;
15
+ }
@@ -0,0 +1,150 @@
1
+ 'use strict';var electron=require('electron'),WindowCreator=require('../WindowCreator.js'),PerformanceMonitor=require('../../../infrastructure/debug/PerformanceMonitor.js');const IS_DEV = !electron.app.isPackaged;
2
+ class WindowLifecycle {
3
+ wm;
4
+ pluginExecutor;
5
+ metrics;
6
+ logger;
7
+ constructor(wm, pluginExecutor, metrics, logger) {
8
+ this.wm = wm;
9
+ this.pluginExecutor = pluginExecutor;
10
+ this.metrics = metrics;
11
+ this.logger = logger;
12
+ }
13
+ async create(config = {}) {
14
+ const startTime = Date.now();
15
+ const perf = PerformanceMonitor.PerformanceMonitor.getInstance();
16
+ const measureId = `create-window-${Date.now()}`;
17
+ perf.startMeasure(measureId, 'Window Creation', { name: config.name });
18
+ // Run onWillCreate hooks via PluginExecutor
19
+ const hookResult = this.pluginExecutor.onWillCreate(config);
20
+ if (hookResult === false)
21
+ return '';
22
+ config = hookResult;
23
+ // Initialize config from creation parameters
24
+ if (config.defaultConfig) {
25
+ this.wm.config.defaultConfig = config.defaultConfig;
26
+ }
27
+ // Use module-level constant IS_DEV to lock environment state
28
+ this.wm.config.isDevelopment = config.isDevelopment ?? IS_DEV;
29
+ this.logger.info(`Current Environment / 当前环境: ${JSON.stringify({
30
+ appIsPackaged: electron.app.isPackaged,
31
+ cachedIsDev: IS_DEV,
32
+ finalConfigIsDev: this.wm.config.isDevelopment,
33
+ }, null, 2)}`);
34
+ // Prepare API for WindowCreator
35
+ const api = {
36
+ window: {
37
+ hasById: (id) => this.wm.windowStore.hasById(id),
38
+ isDestroyed: (id) => this.wm.windowStore.isDestroyed(id),
39
+ deleteByName: (name) => {
40
+ const id = this.wm.windowStore.getWindowByNameId(name);
41
+ if (id) {
42
+ this.removeWindow(id); // Call this.removeWindow to trigger hooks
43
+ return true;
44
+ }
45
+ return false;
46
+ },
47
+ deleteById: (id) => {
48
+ if (this.wm.windowStore.hasById(id)) {
49
+ this.removeWindow(id); // Call this.removeWindow to trigger hooks
50
+ return true;
51
+ }
52
+ return false;
53
+ },
54
+ getTargetWindow: (id) => this.wm.windowStore.getTargetWindow(id),
55
+ removeWindow: (id) => this.removeWindow(id), // Call this.removeWindow to trigger hooks
56
+ show: (window, id) => this.wm.windowStore.show(window, id),
57
+ },
58
+ };
59
+ // Resolve window ID if name is provided
60
+ const resolvedWindowId = config.windowId ||
61
+ (config.name ? this.wm.windowStore.getWindowByNameId(config.name) : undefined);
62
+ if (config.windowId) {
63
+ this.wm.validateWindowId(config.windowId, 'create');
64
+ }
65
+ // Handle state persistence restoration
66
+ let finalConfig = { ...config };
67
+ const shouldPersist = config.enablePersistence ?? this.wm.windowStore.persistenceEnabled;
68
+ if (shouldPersist && config.name) {
69
+ const savedState = this.wm.windowStore.getWindowState(config.name, config.width, config.height);
70
+ if (savedState) {
71
+ finalConfig = {
72
+ ...finalConfig,
73
+ x: savedState.x,
74
+ y: savedState.y,
75
+ width: savedState.width,
76
+ height: savedState.height,
77
+ fullscreen: savedState.isFullScreen || config.fullscreen,
78
+ };
79
+ }
80
+ }
81
+ const operator = new WindowCreator(api, {
82
+ data: { ...finalConfig, winId: resolvedWindowId },
83
+ contentLoader: this.wm.config.contentLoader,
84
+ }, async (options) => {
85
+ // Call public/accessible method on wm
86
+ const newWindow = this.wm.createBrowserWindow(options);
87
+ // Restore maximized state
88
+ if (shouldPersist && config.name) {
89
+ const savedState = this.wm.windowStore.getWindowState(config.name);
90
+ if (savedState?.isMaximized && !newWindow.isFullScreen()) {
91
+ newWindow.maximize();
92
+ }
93
+ }
94
+ const windowId = this.wm.windowStore.createWindow(newWindow, options);
95
+ this.wm.configureWindowBehavior(newWindow, windowId);
96
+ // Restore groups if any
97
+ if (options.name) {
98
+ const savedState = this.wm.windowStore.getWindowState(options.name);
99
+ if (savedState && savedState.groups && Array.isArray(savedState.groups)) {
100
+ savedState.groups.forEach((group) => {
101
+ this.wm.windowStore.joinGroup(windowId, group);
102
+ });
103
+ }
104
+ // Register state management (auto-save)
105
+ // Access private method? No, registerStateManagement is private.
106
+ // I should move registerStateManagement to WindowLifecycle or make it public.
107
+ // I'll make it public or move it.
108
+ // Moving it here is better.
109
+ this.registerStateManagement(options.name, newWindow);
110
+ }
111
+ // Run onDidCreate hooks
112
+ const details = { window: newWindow, id: windowId, name: options.data.name || '' };
113
+ await this.pluginExecutor.onDidCreate(details);
114
+ this.wm.emit('window-created', details);
115
+ return windowId;
116
+ }, undefined, this.logger);
117
+ const windowId = await operator.createAndShow();
118
+ // Record metrics
119
+ const duration = Date.now() - startTime;
120
+ this.metrics.recordCreation(duration);
121
+ if (duration > 2000) {
122
+ this.logger.warn(`Slow window creation detected: ${windowId} took ${duration}ms`);
123
+ }
124
+ perf.endMeasure(measureId, { windowId });
125
+ return windowId;
126
+ }
127
+ async removeWindow(windowId) {
128
+ const perf = PerformanceMonitor.PerformanceMonitor.getInstance();
129
+ const measureId = `destroy-window-${windowId}`;
130
+ perf.startMeasure(measureId, 'Window Destruction', { windowId });
131
+ this.wm.validateWindowId(windowId, 'removeWindow');
132
+ // 1. onWillDestroy Hooks
133
+ await this.pluginExecutor.onWillDestroy(windowId);
134
+ // 2. Notify MessageBus cleanup
135
+ this.wm.emit('window-will-be-destroyed', windowId);
136
+ // 3. Actual removal
137
+ this.wm.windowStore.removeWindow(windowId);
138
+ // Track destroyed count
139
+ this.metrics.recordDestruction();
140
+ // 4. onDidDestroy Hooks
141
+ await this.pluginExecutor.onDidDestroy(windowId);
142
+ this.wm.emit('window-destroyed', windowId);
143
+ perf.endMeasure(measureId, { windowId });
144
+ }
145
+ registerStateManagement(name, window) {
146
+ if (this.wm.windowStore.persistenceEnabled) {
147
+ this.wm.windowStore.manageState(name, window, () => this.wm.windowStore.getWindowGroups(window.id.toString()));
148
+ }
149
+ }
150
+ }exports.WindowLifecycle=WindowLifecycle;//# sourceMappingURL=WindowLifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowLifecycle.js","sources":["../../../../src/core/window/core/WindowLifecycle.ts"],"sourcesContent":["import { BrowserWindow, app } from 'electron';\nimport { PerformanceMonitor } from '@/infrastructure/debug';\nimport WindowCreator from '../WindowCreator';\nimport type WindowManager from '../WindowManager';\nimport { WindowManagerApi, WindowCreationOptions } from '../window-manager.type';\nimport { PluginExecutor } from './PluginExecutor';\nimport { MetricsManager } from './MetricsManager';\nimport { ILogger } from '@/infrastructure/logger';\n\nconst IS_DEV = !app.isPackaged;\n\nexport class WindowLifecycle {\n constructor(\n private wm: WindowManager,\n private pluginExecutor: PluginExecutor,\n private metrics: MetricsManager,\n private logger: ILogger\n ) {}\n\n public async create(config: WindowCreationOptions = {}): Promise<string> {\n const startTime = Date.now();\n const perf = PerformanceMonitor.getInstance();\n const measureId = `create-window-${Date.now()}`;\n perf.startMeasure(measureId, 'Window Creation', { name: config.name });\n\n // Run onWillCreate hooks via PluginExecutor\n const hookResult = this.pluginExecutor.onWillCreate(config);\n if (hookResult === false) return '';\n config = hookResult;\n\n // Initialize config from creation parameters\n if (config.defaultConfig) {\n this.wm.config.defaultConfig = config.defaultConfig;\n }\n\n // Use module-level constant IS_DEV to lock environment state\n this.wm.config.isDevelopment = config.isDevelopment ?? IS_DEV;\n\n this.logger.info(\n `Current Environment / 当前环境: ${JSON.stringify(\n {\n appIsPackaged: app.isPackaged,\n cachedIsDev: IS_DEV,\n finalConfigIsDev: this.wm.config.isDevelopment,\n },\n null,\n 2\n )}`\n );\n\n // Prepare API for WindowCreator\n const api: WindowManagerApi = {\n window: {\n hasById: (id: string) => this.wm.windowStore.hasById(id),\n isDestroyed: (id: string) => this.wm.windowStore.isDestroyed(id),\n deleteByName: (name: string) => {\n const id = this.wm.windowStore.getWindowByNameId(name);\n if (id) {\n this.removeWindow(id); // Call this.removeWindow to trigger hooks\n return true;\n }\n return false;\n },\n deleteById: (id: string) => {\n if (this.wm.windowStore.hasById(id)) {\n this.removeWindow(id); // Call this.removeWindow to trigger hooks\n return true;\n }\n return false;\n },\n getTargetWindow: (id: string) => this.wm.windowStore.getTargetWindow(id),\n removeWindow: (id: string) => this.removeWindow(id), // Call this.removeWindow to trigger hooks\n show: (window: BrowserWindow, id: string) => this.wm.windowStore.show(window, id),\n },\n };\n\n // Resolve window ID if name is provided\n const resolvedWindowId =\n config.windowId ||\n (config.name ? this.wm.windowStore.getWindowByNameId(config.name) : undefined);\n\n if (config.windowId) {\n this.wm.validateWindowId(config.windowId, 'create');\n }\n\n // Handle state persistence restoration\n let finalConfig = { ...config };\n const shouldPersist = config.enablePersistence ?? this.wm.windowStore.persistenceEnabled;\n\n if (shouldPersist && config.name) {\n const savedState = this.wm.windowStore.getWindowState(\n config.name,\n config.width,\n config.height\n );\n if (savedState) {\n finalConfig = {\n ...finalConfig,\n x: savedState.x,\n y: savedState.y,\n width: savedState.width,\n height: savedState.height,\n fullscreen: savedState.isFullScreen || config.fullscreen,\n };\n }\n }\n\n const operator = new WindowCreator(\n api,\n {\n data: { ...finalConfig, winId: resolvedWindowId },\n contentLoader: this.wm.config.contentLoader,\n },\n async (options) => {\n // Call public/accessible method on wm\n const newWindow = this.wm.createBrowserWindow(options);\n\n // Restore maximized state\n if (shouldPersist && config.name) {\n const savedState = this.wm.windowStore.getWindowState(config.name);\n if (savedState?.isMaximized && !newWindow.isFullScreen()) {\n newWindow.maximize();\n }\n }\n\n const windowId = this.wm.windowStore.createWindow(newWindow, options);\n this.wm.configureWindowBehavior(newWindow, windowId);\n\n // Restore groups if any\n if (options.name) {\n const savedState = this.wm.windowStore.getWindowState(options.name);\n if (savedState && savedState.groups && Array.isArray(savedState.groups)) {\n savedState.groups.forEach((group: string) => {\n this.wm.windowStore.joinGroup(windowId, group);\n });\n }\n\n // Register state management (auto-save)\n // Access private method? No, registerStateManagement is private.\n // I should move registerStateManagement to WindowLifecycle or make it public.\n // I'll make it public or move it.\n // Moving it here is better.\n this.registerStateManagement(options.name, newWindow);\n }\n\n // Run onDidCreate hooks\n const details = { window: newWindow, id: windowId, name: options.data.name || '' };\n await this.pluginExecutor.onDidCreate(details);\n\n this.wm.emit('window-created', details);\n\n return windowId;\n },\n undefined,\n this.logger\n );\n\n const windowId = await operator.createAndShow();\n\n // Record metrics\n const duration = Date.now() - startTime;\n this.metrics.recordCreation(duration);\n\n if (duration > 2000) {\n this.logger.warn(`Slow window creation detected: ${windowId} took ${duration}ms`);\n }\n\n perf.endMeasure(measureId, { windowId });\n\n return windowId;\n }\n\n public async removeWindow(windowId: string): Promise<void> {\n const perf = PerformanceMonitor.getInstance();\n const measureId = `destroy-window-${windowId}`;\n perf.startMeasure(measureId, 'Window Destruction', { windowId });\n\n this.wm.validateWindowId(windowId, 'removeWindow');\n\n // 1. onWillDestroy Hooks\n await this.pluginExecutor.onWillDestroy(windowId);\n\n // 2. Notify MessageBus cleanup\n this.wm.emit('window-will-be-destroyed', windowId);\n\n // 3. Actual removal\n this.wm.windowStore.removeWindow(windowId);\n\n // Track destroyed count\n this.metrics.recordDestruction();\n\n // 4. onDidDestroy Hooks\n await this.pluginExecutor.onDidDestroy(windowId);\n\n this.wm.emit('window-destroyed', windowId);\n\n perf.endMeasure(measureId, { windowId });\n }\n\n private registerStateManagement(name: string, window: BrowserWindow): void {\n if (this.wm.windowStore.persistenceEnabled) {\n this.wm.windowStore.manageState(name, window, () =>\n this.wm.windowStore.getWindowGroups(window.id.toString())\n );\n }\n }\n}\n"],"names":["app","PerformanceMonitor"],"mappings":"6KASA,MAAM,MAAM,GAAG,CAACA,YAAG,CAAC,UAAU;MAEjB,eAAe,CAAA;AAEhB,IAAA,EAAA;AACA,IAAA,cAAA;AACA,IAAA,OAAA;AACA,IAAA,MAAA;AAJV,IAAA,WAAA,CACU,EAAiB,EACjB,cAA8B,EAC9B,O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