@zubridge/electron
Version:
A streamlined state management library for Electron applications using Zustand.
52 lines (47 loc) • 1.84 kB
text/typescript
import { AnyState, Handlers } from '@zubridge/types';
interface ThunkProcessorOptions {
/**
* Maximum number of pending actions allowed in the queue (default: 100)
* When this limit is exceeded, new actions will throw a QueueOverflowError
*/
maxQueueSize?: number;
/**
* Timeout for action completion in milliseconds
* Platform-specific defaults: Linux=60000ms, others=30000ms
*/
actionCompletionTimeoutMs?: number;
}
/**
* Configuration options for preload bridge
*
* @example
* ```typescript
* // Configure with custom queue size and timeout
* const options: PreloadOptions = {
* maxQueueSize: 50, // Allow up to 50 pending actions
* actionCompletionTimeoutMs: 15000 // 15 second timeout
* };
*
* // Use in preload
* const bridge = preloadBridge<MyState>(options);
* ```
*/
type PreloadOptions = ThunkProcessorOptions;
interface PreloadZustandBridgeReturn<S extends AnyState> {
handlers: Handlers<S>;
initialized: boolean;
}
/**
* Creates and returns handlers that the window.zubridge object will expose
* This uses the Electron IPC bridge to communicate with the main process
*/
declare const preloadBridge: <S extends AnyState>(options?: PreloadOptions) => PreloadZustandBridgeReturn<S>;
/**
* Legacy preload bridge for backward compatibility
* @deprecated This is now an alias for preloadBridge and uses the new IPC channels.
* Please update your code to use preloadBridge directly in the future.
*/
declare const preloadZustandBridge: <S extends AnyState>(options?: PreloadOptions) => PreloadZustandBridgeReturn<S>;
type PreloadZustandBridge = typeof preloadZustandBridge;
type PreloadBridge = typeof preloadBridge;
export { type PreloadBridge, type PreloadZustandBridge, type PreloadZustandBridgeReturn, preloadBridge, preloadZustandBridge };