@proton-app/main 0.1.4 → 0.1.5
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/dist/communication.d.ts +9 -8
- package/dist/communication.js +4 -0
- package/package.json +1 -1
package/dist/communication.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type IpcRenderer } from "electron";
|
|
|
2
2
|
import Storage from "electron-store";
|
|
3
3
|
export declare function setupAppIpc<T extends Record<string, any>>(storage: Storage<T>): void;
|
|
4
4
|
export type IpcSchema = Record<string, {
|
|
5
|
-
input
|
|
5
|
+
input: unknown;
|
|
6
6
|
result: unknown;
|
|
7
7
|
}>;
|
|
8
8
|
type Input<S extends IpcSchema, K extends keyof S> = S[K] extends {
|
|
@@ -41,12 +41,13 @@ type IpcClient = Pick<IpcRenderer, "send" | "invoke">;
|
|
|
41
41
|
* Creates the standard application controls exposed by an Electron preload.
|
|
42
42
|
*/
|
|
43
43
|
export declare function createAppBridge(ipc: IpcClient): AppBridge;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
input: infer Input;
|
|
48
|
-
result: infer Result;
|
|
49
|
-
} ? (input: Input) => Promise<Result> : never;
|
|
50
|
-
};
|
|
44
|
+
type KebabToCamel<S extends string> = S extends `${infer A}-${infer B}` ? `${A}${Capitalize<KebabToCamel<B>>}` : S;
|
|
45
|
+
type NamespaceApi<S extends IpcSchema> = {
|
|
46
|
+
[K in keyof S & string as KebabToCamel<K>]: (input: S[K]["input"]) => Promise<S[K]["result"]>;
|
|
51
47
|
};
|
|
48
|
+
type UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
|
|
49
|
+
export type IpcApi<S extends Record<string, IpcSchema>> = UnionToIntersection<{
|
|
50
|
+
[N in keyof S]: NamespaceApi<S[N]>;
|
|
51
|
+
}[keyof S]>;
|
|
52
|
+
export declare function createIpcManager<S extends Record<string, IpcSchema>>(): <N extends keyof S & string>(namespace: N) => IpcManager<S[N]>;
|
|
52
53
|
export {};
|
package/dist/communication.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.APP_CHANNELS = exports.IpcManager = void 0;
|
|
4
4
|
exports.setupAppIpc = setupAppIpc;
|
|
5
5
|
exports.createAppBridge = createAppBridge;
|
|
6
|
+
exports.createIpcManager = createIpcManager;
|
|
6
7
|
const electron_1 = require("electron");
|
|
7
8
|
const files_1 = require("./files");
|
|
8
9
|
function setupAppIpc(storage) {
|
|
@@ -92,3 +93,6 @@ function createAppBridge(ipc) {
|
|
|
92
93
|
}
|
|
93
94
|
};
|
|
94
95
|
}
|
|
96
|
+
function createIpcManager() {
|
|
97
|
+
return (namespace) => new IpcManager(namespace);
|
|
98
|
+
}
|