import type { Observable } from 'rxjs'; import type { Asyncify, ConditionalKeys } from 'type-fest'; export type ProxyAsyncProperties = ConditionalKeys any>; export type ProxyObservableProperties = ConditionalKeys> | ConditionalKeys Observable>; export type ProxyWithOnlyObservable = Pick>; export type ProxyWithOutObservable = Omit>; /** * To call services that is located in main process, from the renderer process, we use IPC.invoke, so all method should now promisify * Note this type only promisify methods that return things, not methods that returns observable. */ export type AsyncifyProxy, ObservableKey extends ProxyObservableProperties = ProxyObservableProperties, AsyncKey extends Exclude, ObservableKey> = Exclude, ObservableKey>> = { [P in AsyncKey]: Asyncify; } & { [Q in ObservableKey]: OriginalProxy[Q]; }; /** Extract observable keys from services */ export type IServicesWithOnlyObservables = { [P in keyof Services]: ProxyWithOnlyObservable; }; export type IServicesWithoutObservables = { [P in keyof Services]: ProxyWithOutObservable; }; export declare enum ProxyPropertyType { Function = "function", Function$ = "function$", Value = "value", Value$ = "value$" } export interface ProxyDescriptor { channel: string; properties: Record; } export declare enum RequestType { Apply = "apply", ApplySubscribe = "applySubscribe", Get = "get", Subscribe = "subscribe", Unsubscribe = "unsubscribe" } export interface UnknownRequest { type: 'unknown'; } export interface GetRequest { propKey: PropertyKey; type: RequestType.Get; } export interface ApplyRequest { args: unknown[]; propKey: string; type: RequestType.Apply; } export interface SubscribeRequest { propKey: string; subscriptionId?: string; type: RequestType.Subscribe; } export interface ApplySubscribeRequest { args: unknown[]; propKey: string; subscriptionId?: string; type: RequestType.ApplySubscribe; } export interface UnsubscribeRequest { subscriptionId: string; type: RequestType.Unsubscribe; } export type Request = UnknownRequest | GetRequest | ApplyRequest | SubscribeRequest | ApplySubscribeRequest | UnsubscribeRequest; export interface IWebViewPoseMessageCatData { channel: string; correlationId: string; request: Request; } export interface IWebViewOnMessageCatData { channel: string; correlationId: string; response: Response; } export type WebViewCatOnDataEvent = CustomEvent; export declare enum ResponseType { Complete = "complete", Error = "error", Next = "next", Result = "result" } export interface ResultResponse { result: unknown; type: ResponseType.Result; } export interface ErrorResponse { error: string; type: ResponseType.Error; } export interface NextResponse { type: ResponseType.Next; value: unknown; } export interface CompleteResponse { type: ResponseType.Complete; } export type Response = ResultResponse | ErrorResponse | NextResponse | CompleteResponse;