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.
- package/LICENSE +21 -0
- package/README.md +302 -0
- package/README.zh-CN.md +308 -0
- package/dist/core/error/WindowError.d.ts +56 -0
- package/dist/core/error/WindowError.js +71 -0
- package/dist/core/error/WindowError.js.map +1 -0
- package/dist/core/error/WindowError.mjs +71 -0
- package/dist/core/error/WindowError.mjs.map +1 -0
- package/dist/core/ipc/IpcHandler.d.ts +48 -0
- package/dist/core/ipc/IpcHandler.js +59 -0
- package/dist/core/ipc/IpcHandler.js.map +1 -0
- package/dist/core/ipc/IpcHandler.mjs +59 -0
- package/dist/core/ipc/IpcHandler.mjs.map +1 -0
- package/dist/core/ipc/IpcRouter.d.ts +70 -0
- package/dist/core/ipc/IpcRouter.js +143 -0
- package/dist/core/ipc/IpcRouter.js.map +1 -0
- package/dist/core/ipc/IpcRouter.mjs +143 -0
- package/dist/core/ipc/IpcRouter.mjs.map +1 -0
- package/dist/core/ipc/index.d.ts +3 -0
- package/dist/core/ipc/index.js +1 -0
- package/dist/core/ipc/index.js.map +1 -0
- package/dist/core/ipc/index.mjs +1 -0
- package/dist/core/ipc/index.mjs.map +1 -0
- package/dist/core/ipc/ipc-router.type.d.ts +73 -0
- package/dist/core/ipc/transport/index.d.ts +65 -0
- package/dist/core/ipc/transport/index.js +229 -0
- package/dist/core/ipc/transport/index.js.map +1 -0
- package/dist/core/ipc/transport/index.mjs +229 -0
- package/dist/core/ipc/transport/index.mjs.map +1 -0
- package/dist/core/ipc/transport/ipc.type.d.ts +36 -0
- package/dist/core/lifecycle/LifecycleManager.d.ts +66 -0
- package/dist/core/lifecycle/LifecycleManager.js +140 -0
- package/dist/core/lifecycle/LifecycleManager.js.map +1 -0
- package/dist/core/lifecycle/LifecycleManager.mjs +140 -0
- package/dist/core/lifecycle/LifecycleManager.mjs.map +1 -0
- package/dist/core/message-bus/MessageBus.d.ts +282 -0
- package/dist/core/message-bus/MessageBus.js +677 -0
- package/dist/core/message-bus/MessageBus.js.map +1 -0
- package/dist/core/message-bus/MessageBus.mjs +677 -0
- package/dist/core/message-bus/MessageBus.mjs.map +1 -0
- package/dist/core/message-bus/MessageBusClient.d.ts +100 -0
- package/dist/core/message-bus/MessageBusClient.js +280 -0
- package/dist/core/message-bus/MessageBusClient.js.map +1 -0
- package/dist/core/message-bus/MessageBusClient.mjs +280 -0
- package/dist/core/message-bus/MessageBusClient.mjs.map +1 -0
- package/dist/core/message-bus/core/DataStoreManager.d.ts +51 -0
- package/dist/core/message-bus/core/DataStoreManager.js +94 -0
- package/dist/core/message-bus/core/DataStoreManager.js.map +1 -0
- package/dist/core/message-bus/core/DataStoreManager.mjs +94 -0
- package/dist/core/message-bus/core/DataStoreManager.mjs.map +1 -0
- package/dist/core/message-bus/core/ManagedPort.d.ts +26 -0
- package/dist/core/message-bus/core/ManagedPort.js +55 -0
- package/dist/core/message-bus/core/ManagedPort.js.map +1 -0
- package/dist/core/message-bus/core/ManagedPort.mjs +55 -0
- package/dist/core/message-bus/core/ManagedPort.mjs.map +1 -0
- package/dist/core/message-bus/core/PortManager.d.ts +47 -0
- package/dist/core/message-bus/core/PortManager.js +114 -0
- package/dist/core/message-bus/core/PortManager.js.map +1 -0
- package/dist/core/message-bus/core/PortManager.mjs +114 -0
- package/dist/core/message-bus/core/PortManager.mjs.map +1 -0
- package/dist/core/message-bus/core/SubscriptionManager.d.ts +36 -0
- package/dist/core/message-bus/core/SubscriptionManager.js +78 -0
- package/dist/core/message-bus/core/SubscriptionManager.js.map +1 -0
- package/dist/core/message-bus/core/SubscriptionManager.mjs +78 -0
- package/dist/core/message-bus/core/SubscriptionManager.mjs.map +1 -0
- package/dist/core/message-bus/core/TransactionManager.d.ts +54 -0
- package/dist/core/message-bus/core/TransactionManager.js +95 -0
- package/dist/core/message-bus/core/TransactionManager.js.map +1 -0
- package/dist/core/message-bus/core/TransactionManager.mjs +95 -0
- package/dist/core/message-bus/core/TransactionManager.mjs.map +1 -0
- package/dist/core/message-bus/core/index.d.ts +5 -0
- package/dist/core/message-bus/index.d.ts +4 -0
- package/dist/core/message-bus/index.js +1 -0
- package/dist/core/message-bus/index.js.map +1 -0
- package/dist/core/message-bus/index.mjs +1 -0
- package/dist/core/message-bus/index.mjs.map +1 -0
- package/dist/core/message-bus/message-bus.type.d.ts +143 -0
- package/dist/core/message-bus/message-bus.type.js +26 -0
- package/dist/core/message-bus/message-bus.type.js.map +1 -0
- package/dist/core/message-bus/message-bus.type.mjs +26 -0
- package/dist/core/message-bus/message-bus.type.mjs.map +1 -0
- package/dist/core/message-bus/preload.d.ts +16 -0
- package/dist/core/message-bus/preload.js +27 -0
- package/dist/core/message-bus/preload.js.map +1 -0
- package/dist/core/message-bus/preload.mjs +27 -0
- package/dist/core/message-bus/preload.mjs.map +1 -0
- package/dist/core/message-bus/transport/ITransport.d.ts +40 -0
- package/dist/core/message-bus/transport/IpcTransport.d.ts +18 -0
- package/dist/core/message-bus/transport/IpcTransport.js +60 -0
- package/dist/core/message-bus/transport/IpcTransport.js.map +1 -0
- package/dist/core/message-bus/transport/IpcTransport.mjs +60 -0
- package/dist/core/message-bus/transport/IpcTransport.mjs.map +1 -0
- package/dist/core/message-bus/transport/MessagePortTransport.d.ts +15 -0
- package/dist/core/message-bus/transport/MessagePortTransport.js +35 -0
- package/dist/core/message-bus/transport/MessagePortTransport.js.map +1 -0
- package/dist/core/message-bus/transport/MessagePortTransport.mjs +35 -0
- package/dist/core/message-bus/transport/MessagePortTransport.mjs.map +1 -0
- package/dist/core/message-bus/transport/index.d.ts +3 -0
- package/dist/core/window/IpcSetup.d.ts +50 -0
- package/dist/core/window/IpcSetup.js +96 -0
- package/dist/core/window/IpcSetup.js.map +1 -0
- package/dist/core/window/IpcSetup.mjs +96 -0
- package/dist/core/window/IpcSetup.mjs.map +1 -0
- package/dist/core/window/WindowCreator.d.ts +66 -0
- package/dist/core/window/WindowCreator.js +168 -0
- package/dist/core/window/WindowCreator.js.map +1 -0
- package/dist/core/window/WindowCreator.mjs +168 -0
- package/dist/core/window/WindowCreator.mjs.map +1 -0
- package/dist/core/window/WindowManager.d.ts +214 -0
- package/dist/core/window/WindowManager.js +583 -0
- package/dist/core/window/WindowManager.js.map +1 -0
- package/dist/core/window/WindowManager.mjs +583 -0
- package/dist/core/window/WindowManager.mjs.map +1 -0
- package/dist/core/window/WindowStore.d.ts +136 -0
- package/dist/core/window/WindowStore.js +436 -0
- package/dist/core/window/WindowStore.js.map +1 -0
- package/dist/core/window/WindowStore.mjs +436 -0
- package/dist/core/window/WindowStore.mjs.map +1 -0
- package/dist/core/window/constants.d.ts +17 -0
- package/dist/core/window/constants.js +15 -0
- package/dist/core/window/constants.js.map +1 -0
- package/dist/core/window/constants.mjs +15 -0
- package/dist/core/window/constants.mjs.map +1 -0
- package/dist/core/window/core/MetricsManager.d.ts +14 -0
- package/dist/core/window/core/MetricsManager.js +27 -0
- package/dist/core/window/core/MetricsManager.js.map +1 -0
- package/dist/core/window/core/MetricsManager.mjs +27 -0
- package/dist/core/window/core/MetricsManager.mjs.map +1 -0
- package/dist/core/window/core/PluginExecutor.d.ts +22 -0
- package/dist/core/window/core/PluginExecutor.js +110 -0
- package/dist/core/window/core/PluginExecutor.js.map +1 -0
- package/dist/core/window/core/PluginExecutor.mjs +110 -0
- package/dist/core/window/core/PluginExecutor.mjs.map +1 -0
- package/dist/core/window/core/WindowContextManager.d.ts +26 -0
- package/dist/core/window/core/WindowContextManager.js +59 -0
- package/dist/core/window/core/WindowContextManager.js.map +1 -0
- package/dist/core/window/core/WindowContextManager.mjs +59 -0
- package/dist/core/window/core/WindowContextManager.mjs.map +1 -0
- package/dist/core/window/core/WindowLifecycle.d.ts +15 -0
- package/dist/core/window/core/WindowLifecycle.js +150 -0
- package/dist/core/window/core/WindowLifecycle.js.map +1 -0
- package/dist/core/window/core/WindowLifecycle.mjs +150 -0
- package/dist/core/window/core/WindowLifecycle.mjs.map +1 -0
- package/dist/core/window/core/WindowOperator.d.ts +90 -0
- package/dist/core/window/core/WindowOperator.js +154 -0
- package/dist/core/window/core/WindowOperator.js.map +1 -0
- package/dist/core/window/core/WindowOperator.mjs +154 -0
- package/dist/core/window/core/WindowOperator.mjs.map +1 -0
- package/dist/core/window/core/WindowRegistry.d.ts +168 -0
- package/dist/core/window/core/WindowRegistry.js +331 -0
- package/dist/core/window/core/WindowRegistry.js.map +1 -0
- package/dist/core/window/core/WindowRegistry.mjs +331 -0
- package/dist/core/window/core/WindowRegistry.mjs.map +1 -0
- package/dist/core/window/core/WindowStateManager.d.ts +40 -0
- package/dist/core/window/core/WindowStateManager.js +110 -0
- package/dist/core/window/core/WindowStateManager.js.map +1 -0
- package/dist/core/window/core/WindowStateManager.mjs +110 -0
- package/dist/core/window/core/WindowStateManager.mjs.map +1 -0
- package/dist/core/window/index.d.ts +7 -0
- package/dist/core/window/index.js +1 -0
- package/dist/core/window/index.js.map +1 -0
- package/dist/core/window/index.mjs +1 -0
- package/dist/core/window/index.mjs.map +1 -0
- package/dist/core/window/window-manager.schema.d.ts +50 -0
- package/dist/core/window/window-manager.schema.js +87 -0
- package/dist/core/window/window-manager.schema.js.map +1 -0
- package/dist/core/window/window-manager.schema.mjs +87 -0
- package/dist/core/window/window-manager.schema.mjs.map +1 -0
- package/dist/core/window/window-manager.type.d.ts +365 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +33 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.umd.js +1 -0
- package/dist/infrastructure/config/ConfigManager.d.ts +133 -0
- package/dist/infrastructure/config/ConfigManager.js +218 -0
- package/dist/infrastructure/config/ConfigManager.js.map +1 -0
- package/dist/infrastructure/config/ConfigManager.mjs +218 -0
- package/dist/infrastructure/config/ConfigManager.mjs.map +1 -0
- package/dist/infrastructure/config/index.d.ts +1 -0
- package/dist/infrastructure/debug/EnhancedDebugHelper.d.ts +106 -0
- package/dist/infrastructure/debug/EnhancedDebugHelper.js +218 -0
- package/dist/infrastructure/debug/EnhancedDebugHelper.js.map +1 -0
- package/dist/infrastructure/debug/EnhancedDebugHelper.mjs +218 -0
- package/dist/infrastructure/debug/EnhancedDebugHelper.mjs.map +1 -0
- package/dist/infrastructure/debug/PerformanceMonitor.d.ts +45 -0
- package/dist/infrastructure/debug/PerformanceMonitor.js +67 -0
- package/dist/infrastructure/debug/PerformanceMonitor.js.map +1 -0
- package/dist/infrastructure/debug/PerformanceMonitor.mjs +67 -0
- package/dist/infrastructure/debug/PerformanceMonitor.mjs.map +1 -0
- package/dist/infrastructure/debug/index.d.ts +22 -0
- package/dist/infrastructure/debug/index.js +47 -0
- package/dist/infrastructure/debug/index.js.map +1 -0
- package/dist/infrastructure/debug/index.mjs +47 -0
- package/dist/infrastructure/debug/index.mjs.map +1 -0
- package/dist/infrastructure/errors/ErrorCodes.d.ts +74 -0
- package/dist/infrastructure/errors/ErrorCodes.js +78 -0
- package/dist/infrastructure/errors/ErrorCodes.js.map +1 -0
- package/dist/infrastructure/errors/ErrorCodes.mjs +78 -0
- package/dist/infrastructure/errors/ErrorCodes.mjs.map +1 -0
- package/dist/infrastructure/errors/StandardError.d.ts +61 -0
- package/dist/infrastructure/errors/StandardError.js +84 -0
- package/dist/infrastructure/errors/StandardError.js.map +1 -0
- package/dist/infrastructure/errors/StandardError.mjs +84 -0
- package/dist/infrastructure/errors/StandardError.mjs.map +1 -0
- package/dist/infrastructure/errors/index.d.ts +13 -0
- package/dist/infrastructure/errors/index.js +24 -0
- package/dist/infrastructure/errors/index.js.map +1 -0
- package/dist/infrastructure/errors/index.mjs +24 -0
- package/dist/infrastructure/errors/index.mjs.map +1 -0
- package/dist/infrastructure/logger/ElectronLogger.d.ts +39 -0
- package/dist/infrastructure/logger/ElectronLogger.js +65 -0
- package/dist/infrastructure/logger/ElectronLogger.js.map +1 -0
- package/dist/infrastructure/logger/ElectronLogger.mjs +65 -0
- package/dist/infrastructure/logger/ElectronLogger.mjs.map +1 -0
- package/dist/infrastructure/logger/index.d.ts +2 -0
- package/dist/infrastructure/logger/logger.type.d.ts +8 -0
- package/dist/internal/types/BrandedTypes.d.ts +64 -0
- package/dist/internal/types/BrandedTypes.js +54 -0
- package/dist/internal/types/BrandedTypes.js.map +1 -0
- package/dist/internal/types/BrandedTypes.mjs +54 -0
- package/dist/internal/types/BrandedTypes.mjs.map +1 -0
- package/dist/internal/types/PerformanceOptions.d.ts +87 -0
- package/dist/internal/types/branded.d.ts +42 -0
- package/dist/internal/utils/MessageDispatcher.d.ts +67 -0
- package/dist/internal/utils/MessageDispatcher.js +96 -0
- package/dist/internal/utils/MessageDispatcher.js.map +1 -0
- package/dist/internal/utils/MessageDispatcher.mjs +96 -0
- package/dist/internal/utils/MessageDispatcher.mjs.map +1 -0
- package/dist/internal/utils/RateLimiter.d.ts +41 -0
- package/dist/internal/utils/RateLimiter.js +83 -0
- package/dist/internal/utils/RateLimiter.js.map +1 -0
- package/dist/internal/utils/RateLimiter.mjs +83 -0
- package/dist/internal/utils/RateLimiter.mjs.map +1 -0
- package/dist/internal/utils/StateKeeper.d.ts +125 -0
- package/dist/internal/utils/StateKeeper.js +334 -0
- package/dist/internal/utils/StateKeeper.js.map +1 -0
- package/dist/internal/utils/StateKeeper.mjs +334 -0
- package/dist/internal/utils/StateKeeper.mjs.map +1 -0
- package/dist/internal/utils/branded-helpers.d.ts +33 -0
- package/dist/internal/utils/index.d.ts +5 -0
- package/dist/preload/index.d.ts +45 -0
- package/dist/preload/index.js +91 -0
- package/dist/preload/index.js.map +1 -0
- package/dist/preload/index.mjs +91 -0
- package/dist/preload/index.mjs.map +1 -0
- package/dist/preload/preload.type.d.ts +15 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +1 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +143 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as WindowStore}from'./WindowStore.mjs';export{default as WindowManager}from'./WindowManager.mjs';export{default as WindowCreator}from'./WindowCreator.mjs';export{IpcSetup}from'./IpcSetup.mjs';export{WindowError,WindowErrorCode}from'../error/WindowError.mjs';export{validateWindowManagerConfig}from'./window-manager.schema.mjs';//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ILogger } from '@/infrastructure/logger';
|
|
3
|
+
import IpcRouter from '@/core/ipc/IpcRouter';
|
|
4
|
+
import { MessageBus } from '@/core/message-bus/MessageBus';
|
|
5
|
+
/**
|
|
6
|
+
* Logger interface schema for runtime validation
|
|
7
|
+
* Logger 接口的运行时验证 schema
|
|
8
|
+
*/
|
|
9
|
+
export declare const LoggerSchema: z.ZodCustom<ILogger, ILogger>;
|
|
10
|
+
/**
|
|
11
|
+
* IpcRouter interface schema for runtime validation
|
|
12
|
+
* IpcRouter 接口的运行时验证 schema
|
|
13
|
+
*/
|
|
14
|
+
export declare const IpcRouterSchema: z.ZodCustom<IpcRouter<Record<string, any>, Record<string, import("../ipc").IpcDefinition<any, any>>>, IpcRouter<Record<string, any>, Record<string, import("../ipc").IpcDefinition<any, any>>>>;
|
|
15
|
+
/**
|
|
16
|
+
* MessageBus interface schema for runtime validation
|
|
17
|
+
* MessageBus 接口的运行时验证 schema
|
|
18
|
+
*/
|
|
19
|
+
export declare const MessageBusSchema: z.ZodCustom<MessageBus, MessageBus>;
|
|
20
|
+
/**
|
|
21
|
+
* WindowManagerConfig schema
|
|
22
|
+
* WindowManager 配置验证 schema
|
|
23
|
+
*/
|
|
24
|
+
export declare const WindowManagerConfigSchema: z.ZodObject<{
|
|
25
|
+
logger: z.ZodOptional<z.ZodCustom<ILogger, ILogger>>;
|
|
26
|
+
ipcRouter: z.ZodOptional<z.ZodCustom<IpcRouter<Record<string, any>, Record<string, import("../ipc").IpcDefinition<any, any>>>, IpcRouter<Record<string, any>, Record<string, import("../ipc").IpcDefinition<any, any>>>>>;
|
|
27
|
+
messageBus: z.ZodOptional<z.ZodCustom<MessageBus, MessageBus>>;
|
|
28
|
+
isDevelopment: z.ZodDefault<z.ZodBoolean>;
|
|
29
|
+
preventExternalLinks: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
+
defaultConfig: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
31
|
+
plugins: z.ZodDefault<z.ZodArray<z.ZodAny>>;
|
|
32
|
+
hooks: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
33
|
+
ipc: z.ZodDefault<z.ZodObject<{
|
|
34
|
+
autoInit: z.ZodDefault<z.ZodBoolean>;
|
|
35
|
+
}, z.core.$strip>>;
|
|
36
|
+
store: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
37
|
+
ipcSetup: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
38
|
+
ipcTransport: z.ZodOptional<z.ZodAny>;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
/**
|
|
41
|
+
* Validate WindowManagerConfig
|
|
42
|
+
* 验证 WindowManagerConfig
|
|
43
|
+
* @param config - Configuration to validate
|
|
44
|
+
* @returns Validation result
|
|
45
|
+
*/
|
|
46
|
+
export declare function validateWindowManagerConfig(config: any): {
|
|
47
|
+
success: boolean;
|
|
48
|
+
error?: string;
|
|
49
|
+
data?: z.infer<typeof WindowManagerConfigSchema>;
|
|
50
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';var zod=require('zod');/**
|
|
2
|
+
* Logger interface schema for runtime validation
|
|
3
|
+
* Logger 接口的运行时验证 schema
|
|
4
|
+
*/
|
|
5
|
+
const LoggerSchema = zod.z.custom((val) => {
|
|
6
|
+
return (typeof val === 'object' &&
|
|
7
|
+
val !== null &&
|
|
8
|
+
'info' in val &&
|
|
9
|
+
'warn' in val &&
|
|
10
|
+
'error' in val &&
|
|
11
|
+
'debug' in val &&
|
|
12
|
+
typeof val.info === 'function' &&
|
|
13
|
+
typeof val.warn === 'function' &&
|
|
14
|
+
typeof val.error === 'function' &&
|
|
15
|
+
typeof val.debug === 'function');
|
|
16
|
+
}, 'Logger must implement ILogger interface with info/warn/error/debug methods');
|
|
17
|
+
/**
|
|
18
|
+
* IpcRouter interface schema for runtime validation
|
|
19
|
+
* IpcRouter 接口的运行时验证 schema
|
|
20
|
+
*/
|
|
21
|
+
const IpcRouterSchema = zod.z.custom((val) => {
|
|
22
|
+
return (typeof val === 'object' &&
|
|
23
|
+
val !== null &&
|
|
24
|
+
'handle' in val &&
|
|
25
|
+
'addHandler' in val &&
|
|
26
|
+
typeof val.handle === 'function' &&
|
|
27
|
+
typeof val.addHandler === 'function');
|
|
28
|
+
}, 'IpcRouter must implement handle/addHandler methods');
|
|
29
|
+
/**
|
|
30
|
+
* MessageBus interface schema for runtime validation
|
|
31
|
+
* MessageBus 接口的运行时验证 schema
|
|
32
|
+
*/
|
|
33
|
+
const MessageBusSchema = zod.z.custom((val) => {
|
|
34
|
+
return (typeof val === 'object' &&
|
|
35
|
+
val !== null &&
|
|
36
|
+
'registerWindow' in val &&
|
|
37
|
+
'unregisterWindow' in val &&
|
|
38
|
+
typeof val.registerWindow === 'function' &&
|
|
39
|
+
typeof val.unregisterWindow === 'function');
|
|
40
|
+
}, 'MessageBus must implement registerWindow/unregisterWindow methods');
|
|
41
|
+
/**
|
|
42
|
+
* WindowManagerConfig schema
|
|
43
|
+
* WindowManager 配置验证 schema
|
|
44
|
+
*/
|
|
45
|
+
const WindowManagerConfigSchema = zod.z
|
|
46
|
+
.object({
|
|
47
|
+
logger: LoggerSchema.optional(),
|
|
48
|
+
ipcRouter: IpcRouterSchema.optional(),
|
|
49
|
+
messageBus: MessageBusSchema.optional(),
|
|
50
|
+
isDevelopment: zod.z.boolean().default(false),
|
|
51
|
+
preventExternalLinks: zod.z.boolean().default(true),
|
|
52
|
+
defaultConfig: zod.z.record(zod.z.string(), zod.z.any()).default({}),
|
|
53
|
+
plugins: zod.z.array(zod.z.any()).default([]),
|
|
54
|
+
hooks: zod.z.record(zod.z.string(), zod.z.any()).default({}),
|
|
55
|
+
ipc: zod.z
|
|
56
|
+
.object({
|
|
57
|
+
autoInit: zod.z.boolean().default(true),
|
|
58
|
+
})
|
|
59
|
+
.default({ autoInit: true }),
|
|
60
|
+
store: zod.z.record(zod.z.string(), zod.z.any()).default({}),
|
|
61
|
+
ipcSetup: zod.z.function().optional(),
|
|
62
|
+
ipcTransport: zod.z.any().optional(),
|
|
63
|
+
})
|
|
64
|
+
.strict(); // Enforce no unknown keys for stricter validation
|
|
65
|
+
/**
|
|
66
|
+
* Validate WindowManagerConfig
|
|
67
|
+
* 验证 WindowManagerConfig
|
|
68
|
+
* @param config - Configuration to validate
|
|
69
|
+
* @returns Validation result
|
|
70
|
+
*/
|
|
71
|
+
function validateWindowManagerConfig(config) {
|
|
72
|
+
const result = WindowManagerConfigSchema.safeParse(config);
|
|
73
|
+
if (!result.success) {
|
|
74
|
+
// Format Zod errors into a readable string
|
|
75
|
+
const errorMessage = result.error.issues
|
|
76
|
+
.map((err) => `${err.path.join('.')}: ${err.message}`)
|
|
77
|
+
.join('; ');
|
|
78
|
+
return {
|
|
79
|
+
success: false,
|
|
80
|
+
error: errorMessage,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
success: true,
|
|
85
|
+
data: result.data,
|
|
86
|
+
};
|
|
87
|
+
}exports.IpcRouterSchema=IpcRouterSchema;exports.LoggerSchema=LoggerSchema;exports.MessageBusSchema=MessageBusSchema;exports.WindowManagerConfigSchema=WindowManagerConfigSchema;exports.validateWindowManagerConfig=validateWindowManagerConfig;//# sourceMappingURL=window-manager.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window-manager.schema.js","sources":["../../../src/core/window/window-manager.schema.ts"],"sourcesContent":["import { z } from 'zod';\nimport { ILogger } from '@/infrastructure/logger';\nimport IpcRouter from '@/core/ipc/IpcRouter';\nimport { MessageBus } from '@/core/message-bus/MessageBus';\n\n/**\n * Logger interface schema for runtime validation\n * Logger 接口的运行时验证 schema\n */\nexport const LoggerSchema = z.custom<ILogger>((val) => {\n return (\n typeof val === 'object' &&\n val !== null &&\n 'info' in val &&\n 'warn' in val &&\n 'error' in val &&\n 'debug' in val &&\n typeof (val as any).info === 'function' &&\n typeof (val as any).warn === 'function' &&\n typeof (val as any).error === 'function' &&\n typeof (val as any).debug === 'function'\n );\n}, 'Logger must implement ILogger interface with info/warn/error/debug methods');\n\n/**\n * IpcRouter interface schema for runtime validation\n * IpcRouter 接口的运行时验证 schema\n */\nexport const IpcRouterSchema = z.custom<IpcRouter>((val) => {\n return (\n typeof val === 'object' &&\n val !== null &&\n 'handle' in val &&\n 'addHandler' in val &&\n typeof (val as any).handle === 'function' &&\n typeof (val as any).addHandler === 'function'\n );\n}, 'IpcRouter must implement handle/addHandler methods');\n\n/**\n * MessageBus interface schema for runtime validation\n * MessageBus 接口的运行时验证 schema\n */\nexport const MessageBusSchema = z.custom<MessageBus>((val) => {\n return (\n typeof val === 'object' &&\n val !== null &&\n 'registerWindow' in val &&\n 'unregisterWindow' in val &&\n typeof (val as any).registerWindow === 'function' &&\n typeof (val as any).unregisterWindow === 'function'\n );\n}, 'MessageBus must implement registerWindow/unregisterWindow methods');\n\n/**\n * WindowManagerConfig schema\n * WindowManager 配置验证 schema\n */\nexport const WindowManagerConfigSchema = z\n .object({\n logger: LoggerSchema.optional(),\n ipcRouter: IpcRouterSchema.optional(),\n messageBus: MessageBusSchema.optional(),\n\n isDevelopment: z.boolean().default(false),\n preventExternalLinks: z.boolean().default(true),\n\n defaultConfig: z.record(z.string(), z.any()).default({}),\n\n plugins: z.array(z.any()).default([]),\n hooks: z.record(z.string(), z.any()).default({}),\n\n ipc: z\n .object({\n autoInit: z.boolean().default(true),\n })\n .default({ autoInit: true }),\n\n store: z.record(z.string(), z.any()).default({}),\n\n ipcSetup: z.function().optional(),\n ipcTransport: z.any().optional(),\n })\n .strict(); // Enforce no unknown keys for stricter validation\n\n/**\n * Validate WindowManagerConfig\n * 验证 WindowManagerConfig\n * @param config - Configuration to validate\n * @returns Validation result\n */\nexport function validateWindowManagerConfig(config: any): {\n success: boolean;\n error?: string;\n data?: z.infer<typeof WindowManagerConfigSchema>;\n} {\n const result = WindowManagerConfigSchema.safeParse(config);\n if (!result.success) {\n // Format Zod errors into a readable string\n const errorMessage = result.error.issues\n .map((err) => `${err.path.join('.')}: ${err.message}`)\n .join('; ');\n\n return {\n success: false,\n error: errorMessage,\n };\n }\n return {\n success: true,\n data: result.data,\n };\n}\n"],"names":["z"],"mappings":"oCAKA;;;AAGG;AACI,MAAM,YAAY,GAAGA,KAAC,CAAC,MAAM,CAAU,CAAC,GAAG,KAAI;AACpD,IAAA,QACE,OAAO,GAAG,KAAK,QAAQ;AACvB,QAAA,GAAG,KAAK,IAAI;AACZ,QAAA,MAAM,IAAI,GAAG;AACb,QAAA,MAAM,IAAI,GAAG;AACb,QAAA,OAAO,IAAI,GAAG;AACd,QAAA,OAAO,IAAI,GAAG;AACd,QAAA,OAAQ,GAAW,CAAC,IAAI,KAAK,UAAU;AACvC,QAAA,OAAQ,GAAW,CAAC,IAAI,KAAK,UAAU;AACvC,QAAA,OAAQ,GAAW,CAAC,KAAK,KAAK,UAAU;AACxC,QAAA,OAAQ,GAAW,CAAC,KAAK,KAAK,UAAU;AAE5C,CAAC,EAAE,4EAA4E;AAE/E;;;AAGG;AACI,MAAM,eAAe,GAAGA,KAAC,CAAC,MAAM,CAAY,CAAC,GAAG,KAAI;AACzD,IAAA,QACE,OAAO,GAAG,KAAK,QAAQ;AACvB,QAAA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|
+
* Logger 接口的运行时验证 schema
|
|
4
|
+
*/
|
|
5
|
+
const LoggerSchema = z.custom((val) => {
|
|
6
|
+
return (typeof val === 'object' &&
|
|
7
|
+
val !== null &&
|
|
8
|
+
'info' in val &&
|
|
9
|
+
'warn' in val &&
|
|
10
|
+
'error' in val &&
|
|
11
|
+
'debug' in val &&
|
|
12
|
+
typeof val.info === 'function' &&
|
|
13
|
+
typeof val.warn === 'function' &&
|
|
14
|
+
typeof val.error === 'function' &&
|
|
15
|
+
typeof val.debug === 'function');
|
|
16
|
+
}, 'Logger must implement ILogger interface with info/warn/error/debug methods');
|
|
17
|
+
/**
|
|
18
|
+
* IpcRouter interface schema for runtime validation
|
|
19
|
+
* IpcRouter 接口的运行时验证 schema
|
|
20
|
+
*/
|
|
21
|
+
const IpcRouterSchema = z.custom((val) => {
|
|
22
|
+
return (typeof val === 'object' &&
|
|
23
|
+
val !== null &&
|
|
24
|
+
'handle' in val &&
|
|
25
|
+
'addHandler' in val &&
|
|
26
|
+
typeof val.handle === 'function' &&
|
|
27
|
+
typeof val.addHandler === 'function');
|
|
28
|
+
}, 'IpcRouter must implement handle/addHandler methods');
|
|
29
|
+
/**
|
|
30
|
+
* MessageBus interface schema for runtime validation
|
|
31
|
+
* MessageBus 接口的运行时验证 schema
|
|
32
|
+
*/
|
|
33
|
+
const MessageBusSchema = z.custom((val) => {
|
|
34
|
+
return (typeof val === 'object' &&
|
|
35
|
+
val !== null &&
|
|
36
|
+
'registerWindow' in val &&
|
|
37
|
+
'unregisterWindow' in val &&
|
|
38
|
+
typeof val.registerWindow === 'function' &&
|
|
39
|
+
typeof val.unregisterWindow === 'function');
|
|
40
|
+
}, 'MessageBus must implement registerWindow/unregisterWindow methods');
|
|
41
|
+
/**
|
|
42
|
+
* WindowManagerConfig schema
|
|
43
|
+
* WindowManager 配置验证 schema
|
|
44
|
+
*/
|
|
45
|
+
const WindowManagerConfigSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
logger: LoggerSchema.optional(),
|
|
48
|
+
ipcRouter: IpcRouterSchema.optional(),
|
|
49
|
+
messageBus: MessageBusSchema.optional(),
|
|
50
|
+
isDevelopment: z.boolean().default(false),
|
|
51
|
+
preventExternalLinks: z.boolean().default(true),
|
|
52
|
+
defaultConfig: z.record(z.string(), z.any()).default({}),
|
|
53
|
+
plugins: z.array(z.any()).default([]),
|
|
54
|
+
hooks: z.record(z.string(), z.any()).default({}),
|
|
55
|
+
ipc: z
|
|
56
|
+
.object({
|
|
57
|
+
autoInit: z.boolean().default(true),
|
|
58
|
+
})
|
|
59
|
+
.default({ autoInit: true }),
|
|
60
|
+
store: z.record(z.string(), z.any()).default({}),
|
|
61
|
+
ipcSetup: z.function().optional(),
|
|
62
|
+
ipcTransport: z.any().optional(),
|
|
63
|
+
})
|
|
64
|
+
.strict(); // Enforce no unknown keys for stricter validation
|
|
65
|
+
/**
|
|
66
|
+
* Validate WindowManagerConfig
|
|
67
|
+
* 验证 WindowManagerConfig
|
|
68
|
+
* @param config - Configuration to validate
|
|
69
|
+
* @returns Validation result
|
|
70
|
+
*/
|
|
71
|
+
function validateWindowManagerConfig(config) {
|
|
72
|
+
const result = WindowManagerConfigSchema.safeParse(config);
|
|
73
|
+
if (!result.success) {
|
|
74
|
+
// Format Zod errors into a readable string
|
|
75
|
+
const errorMessage = result.error.issues
|
|
76
|
+
.map((err) => `${err.path.join('.')}: ${err.message}`)
|
|
77
|
+
.join('; ');
|
|
78
|
+
return {
|
|
79
|
+
success: false,
|
|
80
|
+
error: errorMessage,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
success: true,
|
|
85
|
+
data: result.data,
|
|
86
|
+
};
|
|
87
|
+
}export{IpcRouterSchema,LoggerSchema,MessageBusSchema,WindowManagerConfigSchema,validateWindowManagerConfig};//# sourceMappingURL=window-manager.schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window-manager.schema.mjs","sources":["../../../src/core/window/window-manager.schema.ts"],"sourcesContent":["import { z } from 'zod';\nimport { ILogger } from '@/infrastructure/logger';\nimport IpcRouter from '@/core/ipc/IpcRouter';\nimport { MessageBus } from '@/core/message-bus/MessageBus';\n\n/**\n * Logger interface schema for runtime validation\n * Logger 接口的运行时验证 schema\n */\nexport const LoggerSchema = z.custom<ILogger>((val) => {\n return (\n typeof val === 'object' &&\n val !== null &&\n 'info' in val &&\n 'warn' in val &&\n 'error' in val &&\n 'debug' in val &&\n typeof (val as any).info === 'function' &&\n typeof (val as any).warn === 'function' &&\n typeof (val as any).error === 'function' &&\n typeof (val as any).debug === 'function'\n );\n}, 'Logger must implement ILogger interface with info/warn/error/debug methods');\n\n/**\n * IpcRouter interface schema for runtime validation\n * IpcRouter 接口的运行时验证 schema\n */\nexport const IpcRouterSchema = z.custom<IpcRouter>((val) => {\n return (\n typeof val === 'object' &&\n val !== null &&\n 'handle' in val &&\n 'addHandler' in val &&\n typeof (val as any).handle === 'function' &&\n typeof (val as any).addHandler === 'function'\n );\n}, 'IpcRouter must implement handle/addHandler methods');\n\n/**\n * MessageBus interface schema for runtime validation\n * MessageBus 接口的运行时验证 schema\n */\nexport const MessageBusSchema = z.custom<MessageBus>((val) => {\n return (\n typeof val === 'object' &&\n val !== null &&\n 'registerWindow' in val &&\n 'unregisterWindow' in val &&\n typeof (val as any).registerWindow === 'function' &&\n typeof (val as any).unregisterWindow === 'function'\n );\n}, 'MessageBus must implement registerWindow/unregisterWindow methods');\n\n/**\n * WindowManagerConfig schema\n * WindowManager 配置验证 schema\n */\nexport const WindowManagerConfigSchema = z\n .object({\n logger: LoggerSchema.optional(),\n ipcRouter: IpcRouterSchema.optional(),\n messageBus: MessageBusSchema.optional(),\n\n isDevelopment: z.boolean().default(false),\n preventExternalLinks: z.boolean().default(true),\n\n defaultConfig: z.record(z.string(), z.any()).default({}),\n\n plugins: z.array(z.any()).default([]),\n hooks: z.record(z.string(), z.any()).default({}),\n\n ipc: z\n .object({\n autoInit: z.boolean().default(true),\n })\n .default({ autoInit: true }),\n\n store: z.record(z.string(), z.any()).default({}),\n\n ipcSetup: z.function().optional(),\n ipcTransport: z.any().optional(),\n })\n .strict(); // Enforce no unknown keys for stricter validation\n\n/**\n * Validate WindowManagerConfig\n * 验证 WindowManagerConfig\n * @param config - Configuration to validate\n * @returns Validation result\n */\nexport function validateWindowManagerConfig(config: any): {\n success: boolean;\n error?: string;\n data?: z.infer<typeof WindowManagerConfigSchema>;\n} {\n const result = WindowManagerConfigSchema.safeParse(config);\n if (!result.success) {\n // Format Zod errors into a readable string\n const errorMessage = result.error.issues\n .map((err) => `${err.path.join('.')}: ${err.message}`)\n .join('; ');\n\n return {\n success: false,\n error: errorMessage,\n };\n }\n return {\n success: true,\n data: result.data,\n };\n}\n"],"names":[],"mappings":"oBAKA;;;AAGG;AACI,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAU,CAAC,GAAG,KAAI;AACpD,IAAA,QACE,OAAO,GAAG,KAAK,QAAQ;AACvB,QAAA,GAAG,KAAK,IAAI;AACZ,QAAA,MAAM,IAAI,GAAG;AACb,QAAA,MAAM,IAAI,GAAG;AACb,QAAA,OAAO,IAAI,GAAG;AACd,QAAA,OAAO,IAAI,GAAG;AACd,QAAA,OAAQ,GAAW,CAAC,IAAI,KAAK,UAAU;AACvC,QAAA,OAAQ,GAAW,CAAC,IAAI,KAAK,UAAU;AACvC,QAAA,OAAQ,GAAW,CAAC,KAAK,KAAK,UAAU;AACxC,QAAA,OAAQ,GAAW,CAAC,KAAK,KAAK,UAAU;AAE5C,CAAC,EAAE,4EAA4E;AAE/E;;;AAGG;AACI,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAY,CAAC,GAAG,KAAI;AACzD,IAAA,QACE,OAAO,GAAG,KAAK,QAAQ;AACvB,QAAA,GAAG,KAAK,IAAI;AACZ,QAAA,QAAQ,IAAI,GAAG;AACf,QAAA,YAAY,IAAI,GAAG;AACnB,QAAA,OAAQ,GAAW,CAAC,MAAM,K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AC;QACN,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;KACpC;AACA,SAAA,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAE9B,IAAA,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;AAEhD,IAAA,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;AACjC,IAAA,YAAY,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;CACjC;KACA,MAAM,GAAG;AAEZ;;;;;AAKG;AACG,SAAU,2BAA2B,CAAC,MAAW,EAAA;IAKrD,MAAM,MAAM,GAAG,yBAAyB,CAAC,SAAS,CAAC,MAAM,CAAC;AAC1D,IAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;;AAEnB,QAAA,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;aAC/B,GAAG,CAAC,CAAC,GAAG,KAAK,CAAA,EAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA,EAAA,EAAK,GAAG,CAAC,OAAO,EAAE;aACpD,IAAI,CAAC,IAAI,CAAC;QAEb,OAAO;AACL,YAAA,OAAO,EAAE,KAAK;AACd,YAAA,KAAK,EAAE,YAAY;SACpB;IACH;IACA,OAAO;AACL,QAAA,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,MAAM,CAAC,IAAI;KAClB;AACH"}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { BrowserWindow, BrowserWindowConstructorOptions } from 'electron';
|
|
2
|
+
import type WindowManager from './WindowManager';
|
|
3
|
+
import type { ILogger } from '@/infrastructure/logger';
|
|
4
|
+
import type StateKeeper from '@/internal/utils/StateKeeper';
|
|
5
|
+
import type { IIpcTransport } from '@/core/ipc/transport/ipc.type';
|
|
6
|
+
import type IpcRouter from '@/core/ipc/IpcRouter';
|
|
7
|
+
import type { MessageBus } from '@/core/message-bus/MessageBus';
|
|
8
|
+
/**
|
|
9
|
+
* WindowManager Plugin Interface
|
|
10
|
+
* WindowManager 插件接口
|
|
11
|
+
*/
|
|
12
|
+
export interface WindowManagerPlugin {
|
|
13
|
+
/**
|
|
14
|
+
* Plugin name
|
|
15
|
+
* 插件名称
|
|
16
|
+
*/
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* Called when plugin is initialized
|
|
20
|
+
* 插件初始化时调用
|
|
21
|
+
*/
|
|
22
|
+
onInit?(windowManager: WindowManager): void | Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Called before window creation. Return false to cancel creation.
|
|
25
|
+
* 窗口创建前调用。返回 false 取消创建。
|
|
26
|
+
* Note: Must be synchronous to keep create() synchronous.
|
|
27
|
+
* 注意:必须是同步的,以保持 create() 同步。
|
|
28
|
+
*/
|
|
29
|
+
onWillCreate?(config: WindowCreationOptions): WindowCreationOptions | void | false;
|
|
30
|
+
/**
|
|
31
|
+
* Called after window creation
|
|
32
|
+
* 窗口创建后调用
|
|
33
|
+
*/
|
|
34
|
+
onDidCreate?(details: {
|
|
35
|
+
window: BrowserWindow;
|
|
36
|
+
id: string;
|
|
37
|
+
name?: string;
|
|
38
|
+
}): void | Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Called before window destruction
|
|
41
|
+
* 窗口销毁前调用
|
|
42
|
+
*/
|
|
43
|
+
onWillDestroy?(windowId: string): void | Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Called after window destruction
|
|
46
|
+
* 窗口销毁后调用
|
|
47
|
+
*/
|
|
48
|
+
onDidDestroy?(windowId: string): void | Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Lifecycle Hooks Interface
|
|
52
|
+
* 生命周期钩子接口
|
|
53
|
+
*/
|
|
54
|
+
export interface LifecycleHooks {
|
|
55
|
+
onWillCreate?: (config: WindowCreationOptions) => WindowCreationOptions | void | false;
|
|
56
|
+
onDidCreate?: (details: {
|
|
57
|
+
window: BrowserWindow;
|
|
58
|
+
id: string;
|
|
59
|
+
name?: string;
|
|
60
|
+
}) => void | Promise<void>;
|
|
61
|
+
onWillDestroy?: (windowId: string) => void | Promise<void>;
|
|
62
|
+
onDidDestroy?: (windowId: string) => void | Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Context Persistence Interface
|
|
66
|
+
* 上下文持久化接口
|
|
67
|
+
*/
|
|
68
|
+
export interface IContextPersistence {
|
|
69
|
+
save(windowId: string, context: any): Promise<void>;
|
|
70
|
+
load(windowId: string): Promise<any>;
|
|
71
|
+
clear(windowId: string): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Window Store Options Interface
|
|
75
|
+
* 窗口存储配置接口
|
|
76
|
+
*/
|
|
77
|
+
export interface WindowStoreOptions {
|
|
78
|
+
/**
|
|
79
|
+
* Logger instance
|
|
80
|
+
* 日志实例
|
|
81
|
+
*/
|
|
82
|
+
logger?: ILogger;
|
|
83
|
+
/**
|
|
84
|
+
* State Keeper instance
|
|
85
|
+
* 状态保持器实例
|
|
86
|
+
*/
|
|
87
|
+
stateKeeper?: StateKeeper;
|
|
88
|
+
/**
|
|
89
|
+
* Context Persistence Strategy
|
|
90
|
+
* 上下文持久化策略
|
|
91
|
+
*/
|
|
92
|
+
contextPersistence?: IContextPersistence;
|
|
93
|
+
/**
|
|
94
|
+
* Maximum number of windows allowed
|
|
95
|
+
* 允许的最大窗口数量
|
|
96
|
+
*/
|
|
97
|
+
maxWindows?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Interval for cleaning up destroyed windows (in ms)
|
|
100
|
+
* 清理已销毁窗口的间隔(毫秒)
|
|
101
|
+
*/
|
|
102
|
+
cleanupInterval?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Whether to enable window state persistence
|
|
105
|
+
* 是否启用窗口状态持久化
|
|
106
|
+
*/
|
|
107
|
+
enablePersistence?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Whether to automatically start cleanup protection (default: true)
|
|
110
|
+
* 是否自动启动清理保护(默认:true)
|
|
111
|
+
*/
|
|
112
|
+
autoStartCleanup?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Custom Window Creation Options
|
|
116
|
+
* 自定义窗口创建选项
|
|
117
|
+
*/
|
|
118
|
+
export interface WindowCreationOptions extends BrowserWindowConstructorOptions {
|
|
119
|
+
/**
|
|
120
|
+
* Unique window identifier
|
|
121
|
+
* 唯一窗口标识符
|
|
122
|
+
*/
|
|
123
|
+
windowId?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Window semantic name
|
|
126
|
+
* 窗口语义化名称
|
|
127
|
+
*/
|
|
128
|
+
name?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Whether to open DevTools in development
|
|
131
|
+
* 是否在开发模式下打开开发者工具
|
|
132
|
+
*/
|
|
133
|
+
isDevelopment?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Default configuration to inherit from
|
|
136
|
+
* 要继承的默认配置
|
|
137
|
+
*/
|
|
138
|
+
defaultConfig?: BrowserWindowConstructorOptions;
|
|
139
|
+
/**
|
|
140
|
+
* URL to load immediately after window creation
|
|
141
|
+
* 窗口创建后立即加载的 URL
|
|
142
|
+
*/
|
|
143
|
+
loadUrl?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Local file path to load immediately after window creation
|
|
146
|
+
* 窗口创建后立即加载的本地文件路径
|
|
147
|
+
*/
|
|
148
|
+
loadFile?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Custom content loading handler
|
|
151
|
+
* 自定义内容加载处理程序
|
|
152
|
+
* If provided, loadUrl and loadFile will be ignored by default handler.
|
|
153
|
+
* 如果提供,loadUrl 和 loadFile 将被默认处理程序忽略。
|
|
154
|
+
*/
|
|
155
|
+
loadWindowContent?: (window: BrowserWindow) => Promise<void> | void;
|
|
156
|
+
/**
|
|
157
|
+
* Additional custom properties
|
|
158
|
+
* 其他自定义属性
|
|
159
|
+
*/
|
|
160
|
+
[key: string]: any;
|
|
161
|
+
/**
|
|
162
|
+
* Whether to enable state persistence for this window
|
|
163
|
+
* 是否为此窗口启用状态持久化
|
|
164
|
+
*/
|
|
165
|
+
enablePersistence?: boolean;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* WindowManager Events Interface
|
|
169
|
+
* WindowManager 事件接口
|
|
170
|
+
*/
|
|
171
|
+
export interface WindowManagerEvents {
|
|
172
|
+
/**
|
|
173
|
+
* Emitted when an error occurs
|
|
174
|
+
* 当发生错误时触发
|
|
175
|
+
*/
|
|
176
|
+
error: (error: Error) => void;
|
|
177
|
+
/**
|
|
178
|
+
* Emitted after a window is created
|
|
179
|
+
* 窗口创建后触发
|
|
180
|
+
*/
|
|
181
|
+
'window-created': (details: {
|
|
182
|
+
window: BrowserWindow;
|
|
183
|
+
id: string;
|
|
184
|
+
name: string;
|
|
185
|
+
}) => void;
|
|
186
|
+
/**
|
|
187
|
+
* Emitted after a window is destroyed
|
|
188
|
+
* 窗口销毁后触发
|
|
189
|
+
*/
|
|
190
|
+
'window-destroyed': (id: string) => void;
|
|
191
|
+
/**
|
|
192
|
+
* Emitted before a window is destroyed
|
|
193
|
+
* 窗口销毁前触发
|
|
194
|
+
*/
|
|
195
|
+
'window-will-be-destroyed': (id: string) => void;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Window Manager API Interface (for internal use)
|
|
199
|
+
* 窗口管理器 API 接口(内部使用)
|
|
200
|
+
*/
|
|
201
|
+
export interface WindowManagerApi {
|
|
202
|
+
/**
|
|
203
|
+
* Window operations namespace
|
|
204
|
+
* 窗口操作命名空间
|
|
205
|
+
*/
|
|
206
|
+
window: {
|
|
207
|
+
/**
|
|
208
|
+
* Check if window exists by ID
|
|
209
|
+
* 检查指定 ID 的窗口是否存在
|
|
210
|
+
*/
|
|
211
|
+
hasById(id: string): boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Check if window is destroyed
|
|
214
|
+
* 检查窗口是否已销毁
|
|
215
|
+
*/
|
|
216
|
+
isDestroyed(id: string): boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Delete window by name
|
|
219
|
+
* 根据名称删除窗口
|
|
220
|
+
*/
|
|
221
|
+
deleteByName(name: string): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Delete window by ID
|
|
224
|
+
* 根据 ID 删除窗口
|
|
225
|
+
*/
|
|
226
|
+
deleteById(id: string): boolean;
|
|
227
|
+
/**
|
|
228
|
+
* Get target window by ID
|
|
229
|
+
* 获取目标窗口
|
|
230
|
+
*/
|
|
231
|
+
getTargetWindow(id: string): BrowserWindow | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* Remove window
|
|
234
|
+
* 移除窗口
|
|
235
|
+
*/
|
|
236
|
+
removeWindow(id: string): void | Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Show window
|
|
239
|
+
* 显示窗口
|
|
240
|
+
*/
|
|
241
|
+
show(window: BrowserWindow, id: string): void;
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Window Manager Configuration Interface
|
|
246
|
+
* 窗口管理器配置接口
|
|
247
|
+
*
|
|
248
|
+
* Note: Uses 'any' for external dependencies to keep the module independent
|
|
249
|
+
* 注意:对外部依赖使用 'any' 类型以保持模块独立性
|
|
250
|
+
*/
|
|
251
|
+
export interface WindowManagerConfig {
|
|
252
|
+
/**
|
|
253
|
+
* Default browser window options
|
|
254
|
+
* 默认浏览器窗口选项
|
|
255
|
+
*/
|
|
256
|
+
defaultConfig?: BrowserWindowConstructorOptions;
|
|
257
|
+
/**
|
|
258
|
+
* Development mode flag
|
|
259
|
+
* 开发模式标志
|
|
260
|
+
*/
|
|
261
|
+
isDevelopment?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Linux platform flag
|
|
264
|
+
* Linux 平台标志
|
|
265
|
+
*/
|
|
266
|
+
isLinux?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Logger instance
|
|
269
|
+
* 日志实例
|
|
270
|
+
*/
|
|
271
|
+
logger?: ILogger;
|
|
272
|
+
/**
|
|
273
|
+
* IpcRouter instance for dependency injection
|
|
274
|
+
* 用于依赖注入的 IpcRouter 实例
|
|
275
|
+
*/
|
|
276
|
+
ipcRouter?: IpcRouter;
|
|
277
|
+
/**
|
|
278
|
+
* IpcTransport instance
|
|
279
|
+
* IpcTransport 实例
|
|
280
|
+
*/
|
|
281
|
+
ipcTransport?: IIpcTransport;
|
|
282
|
+
/**
|
|
283
|
+
* MessageBus instance for dependency injection
|
|
284
|
+
* 用于依赖注入的 MessageBus 实例
|
|
285
|
+
*/
|
|
286
|
+
messageBus?: MessageBus;
|
|
287
|
+
/**
|
|
288
|
+
* IPC configuration
|
|
289
|
+
* IPC 配置
|
|
290
|
+
*/
|
|
291
|
+
ipc?: {
|
|
292
|
+
/**
|
|
293
|
+
* Whether to automatically initialize IPC on instantiation, default is true
|
|
294
|
+
* 是否在实例化时自动初始化 IPC,默认为 true
|
|
295
|
+
*/
|
|
296
|
+
autoInit?: boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Async communication channel name, default is 'renderer-to-main'
|
|
299
|
+
* 异步通信频道名称,默认为 'renderer-to-main'
|
|
300
|
+
*/
|
|
301
|
+
channel?: string;
|
|
302
|
+
/**
|
|
303
|
+
* Sync communication channel name, default is 'renderer-to-main-sync'
|
|
304
|
+
* 同步通信频道名称,默认为 'renderer-to-main-sync'
|
|
305
|
+
*/
|
|
306
|
+
syncChannel?: string;
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Optional custom IPC setup function
|
|
310
|
+
* 可选的自定义 IPC 设置函数
|
|
311
|
+
*/
|
|
312
|
+
ipcSetup?: (windowManager: WindowManager, options?: {
|
|
313
|
+
channel?: string;
|
|
314
|
+
syncChannel?: string;
|
|
315
|
+
}) => {
|
|
316
|
+
channel: string;
|
|
317
|
+
syncChannel: string;
|
|
318
|
+
ipcTransport?: IIpcTransport;
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Whether to prevent external links from opening in the window (default: true)
|
|
322
|
+
* 是否阻止在窗口中打开外部链接(默认:true)
|
|
323
|
+
*/
|
|
324
|
+
preventExternalLinks?: boolean;
|
|
325
|
+
/**
|
|
326
|
+
* Plugins list
|
|
327
|
+
* 插件列表
|
|
328
|
+
*/
|
|
329
|
+
plugins?: WindowManagerPlugin[];
|
|
330
|
+
/**
|
|
331
|
+
* Lifecycle hooks
|
|
332
|
+
* 生命周期钩子
|
|
333
|
+
*/
|
|
334
|
+
hooks?: LifecycleHooks;
|
|
335
|
+
/**
|
|
336
|
+
* WindowStore configuration (nested)
|
|
337
|
+
* WindowStore 配置(嵌套)
|
|
338
|
+
*/
|
|
339
|
+
store?: WindowStoreOptions;
|
|
340
|
+
/**
|
|
341
|
+
* Global custom content loader
|
|
342
|
+
* 全局自定义内容加载器
|
|
343
|
+
* Fallback for when no specific loadWindowContent is provided in window options
|
|
344
|
+
* 当窗口选项中未提供特定 loadWindowContent 时的后备
|
|
345
|
+
*/
|
|
346
|
+
contentLoader?: (window: BrowserWindow, options: WindowCreationOptions) => Promise<void> | void;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Frame Interface
|
|
350
|
+
* 窗口框架接口
|
|
351
|
+
*/
|
|
352
|
+
export interface Frame {
|
|
353
|
+
/**
|
|
354
|
+
* Create window
|
|
355
|
+
* 创建窗口
|
|
356
|
+
*/
|
|
357
|
+
create(config?: WindowCreationOptions): string;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Frame Constructor Interface
|
|
361
|
+
* 窗口框架构造函数接口
|
|
362
|
+
*/
|
|
363
|
+
export interface FrameConstructor {
|
|
364
|
+
new (): Frame;
|
|
365
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import WindowManager from './core/window/WindowManager';
|
|
2
|
+
import IpcRouter from './core/ipc/IpcRouter';
|
|
3
|
+
import { MessageBus } from './core/message-bus/MessageBus';
|
|
4
|
+
import { WindowManagerConfig } from './core/window/window-manager.type';
|
|
5
|
+
/**
|
|
6
|
+
* Quick Start Helper
|
|
7
|
+
* 快速开始助手
|
|
8
|
+
* @param config - WindowManager configuration
|
|
9
|
+
* @returns Object containing initialized instances
|
|
10
|
+
*/
|
|
11
|
+
export declare function createElectronToolkit(config?: WindowManagerConfig): {
|
|
12
|
+
windowManager: WindowManager;
|
|
13
|
+
ipcRouter: IpcRouter<Record<string, any>, Record<string, import("./types").IpcDefinition<any, any>>>;
|
|
14
|
+
messageBus: MessageBus;
|
|
15
|
+
};
|
|
16
|
+
export * from './core/window';
|
|
17
|
+
export * from './core/ipc';
|
|
18
|
+
export * from './core/message-bus';
|
|
19
|
+
export * from './core/lifecycle/LifecycleManager';
|
|
20
|
+
export { Logger, type LoggerOptions } from './infrastructure/logger';
|
|
21
|
+
export * from './preload';
|
|
22
|
+
export * from './infrastructure/config';
|
|
23
|
+
export * as Types from './types';
|
|
24
|
+
export { DebugHelper, debugHelper, EnhancedDebugHelper } from './infrastructure/debug';
|
|
25
|
+
export * from './infrastructure/errors';
|