UNPKG

@zubridge/electron

Version:

A streamlined state management library for Electron applications using Zustand.

54 lines (53 loc) 2.21 kB
import type { Store } from 'redux'; import type { StoreApi } from 'zustand/vanilla'; import type { BackendBridge, AnyState, Dispatch, WrapperOrWebContents } from '@zubridge/types'; import { createCoreBridge } from './bridge.js'; import { ZustandOptions } from './adapters/zustand.js'; import { ReduxOptions } from './adapters/redux.js'; /** * Export the core bridge creation function for custom implementations */ export { createCoreBridge }; /** * Re-export adapter options types */ export type { ZustandOptions, ReduxOptions }; /** * Interface for a bridge that connects a Zustand store to the main process */ export interface ZustandBridge<S extends AnyState = AnyState> extends BackendBridge<number> { subscribe: (windows: WrapperOrWebContents[]) => { unsubscribe: () => void; }; unsubscribe: (windows?: WrapperOrWebContents[]) => void; getSubscribedWindows: () => number[]; dispatch: Dispatch<S>; destroy: () => void; } /** * Creates a bridge between a Zustand store and the renderer process */ export declare function createZustandBridge<S extends AnyState>(store: StoreApi<S>, windows?: WrapperOrWebContents[], options?: ZustandOptions<S>): ZustandBridge<S>; /** * Interface for a bridge that connects a Redux store to the main process */ export interface ReduxBridge<S extends AnyState = AnyState> extends BackendBridge<number> { subscribe: (windows: WrapperOrWebContents[]) => { unsubscribe: () => void; }; unsubscribe: (windows?: WrapperOrWebContents[]) => void; getSubscribedWindows: () => number[]; dispatch: Dispatch<S>; destroy: () => void; } /** * Creates a bridge between a Redux store and the renderer process */ export declare function createReduxBridge<S extends AnyState>(store: Store<S>, windows?: WrapperOrWebContents[], options?: ReduxOptions<S>): ReduxBridge<S>; /** * Legacy bridge alias for backward compatibility * @deprecated This is now an alias for createZustandBridge and uses the new IPC channels. * Please update your code to use createZustandBridge directly in the future. */ export declare const mainZustandBridge: typeof createZustandBridge; export { createDispatch } from './utils/dispatch';