@bouko/electron 1.1.4 → 1.1.6
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.
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type IpcSchema = Record<string, Record<string, {
|
|
2
|
+
input?: string | object;
|
|
3
|
+
result: any;
|
|
4
|
+
}>>;
|
|
5
|
+
type Input<S extends IpcSchema, N extends keyof S, K extends keyof S[N]> = S[N][K] extends {
|
|
6
|
+
input: infer I;
|
|
7
|
+
} ? I : undefined;
|
|
8
|
+
type Result<S extends IpcSchema, N extends keyof S, K extends keyof S[N]> = S[N][K] extends {
|
|
9
|
+
result: infer R;
|
|
10
|
+
} ? R : never;
|
|
11
|
+
export type MainAdapter = {
|
|
12
|
+
handle: (channel: string, handler: (input: any) => any) => void;
|
|
13
|
+
};
|
|
14
|
+
export type RendererAdapter = {
|
|
15
|
+
invoke: (channel: string, input?: any) => Promise<any>;
|
|
16
|
+
};
|
|
17
|
+
type NamespaceMain<S extends IpcSchema, N extends keyof S> = {
|
|
18
|
+
on<K extends keyof S[N] & string>(key: K, handler: (input: Input<S, N, K>) => Result<S, N, K> | Promise<Result<S, N, K>>): void;
|
|
19
|
+
};
|
|
20
|
+
type NamespaceRenderer<S extends IpcSchema, N extends keyof S> = {
|
|
21
|
+
call<K extends keyof S[N] & string>(key: K, input: Input<S, N, K>): Promise<Result<S, N, K>>;
|
|
22
|
+
call0<K extends keyof S[N] & string>(key: K): Input<S, N, K> extends undefined ? Promise<Result<S, N, K>> : never;
|
|
23
|
+
};
|
|
24
|
+
type MainClient<S extends IpcSchema> = {
|
|
25
|
+
[N in keyof S]: NamespaceMain<S, N>;
|
|
26
|
+
};
|
|
27
|
+
type RendererClient<S extends IpcSchema> = {
|
|
28
|
+
[N in keyof S]: NamespaceRenderer<S, N>;
|
|
29
|
+
};
|
|
30
|
+
export declare class IpcMainManager<S extends IpcSchema> {
|
|
31
|
+
private adapter;
|
|
32
|
+
private delimiter;
|
|
33
|
+
readonly ipc: MainClient<S>;
|
|
34
|
+
constructor(adapter: MainAdapter, delimiter?: string);
|
|
35
|
+
private makeNamespace;
|
|
36
|
+
}
|
|
37
|
+
export declare class IpcRendererManager<S extends IpcSchema> {
|
|
38
|
+
private adapter;
|
|
39
|
+
private delimiter;
|
|
40
|
+
readonly ipc: RendererClient<S>;
|
|
41
|
+
constructor(adapter: RendererAdapter, delimiter?: string);
|
|
42
|
+
private makeNamespace;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
package/dist/files/paths.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const getUserDataPath: (
|
|
2
|
-
export declare const getAppDataPath: (
|
|
1
|
+
export declare const getUserDataPath: (...segments: string[]) => string;
|
|
2
|
+
export declare const getAppDataPath: (...segments: string[]) => string;
|