@proton-app/main 0.1.3 → 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 +17 -21
- package/dist/communication.js +13 -12
- package/dist/storage.d.ts +5 -2
- package/dist/storage.js +7 -1
- package/package.json +1 -1
package/dist/communication.d.ts
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
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
|
-
export type IpcSchema = Record<string,
|
|
5
|
-
input
|
|
4
|
+
export type IpcSchema = Record<string, {
|
|
5
|
+
input: unknown;
|
|
6
6
|
result: unknown;
|
|
7
|
-
}
|
|
8
|
-
type Input<S extends IpcSchema,
|
|
7
|
+
}>;
|
|
8
|
+
type Input<S extends IpcSchema, K extends keyof S> = S[K] extends {
|
|
9
9
|
input: infer I;
|
|
10
10
|
} ? I : undefined;
|
|
11
|
-
type Result<S extends IpcSchema,
|
|
11
|
+
type Result<S extends IpcSchema, K extends keyof S> = S[K] extends {
|
|
12
12
|
result: infer R;
|
|
13
13
|
} ? R : never;
|
|
14
|
-
type Namespace<S extends IpcSchema, N extends keyof S> = {
|
|
15
|
-
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;
|
|
16
|
-
};
|
|
17
|
-
type Client<S extends IpcSchema> = {
|
|
18
|
-
[N in keyof S]: Namespace<S, N>;
|
|
19
|
-
};
|
|
20
14
|
export declare class IpcManager<S extends IpcSchema> {
|
|
15
|
+
private namespace;
|
|
21
16
|
private delimiter;
|
|
22
|
-
readonly
|
|
23
|
-
constructor(delimiter?: string);
|
|
24
|
-
private
|
|
17
|
+
readonly on: <K extends keyof S & string>(key: K, handler: (input: Input<S, K>) => Result<S, K> | Promise<Result<S, K>>) => void;
|
|
18
|
+
constructor(namespace: string, delimiter?: string);
|
|
19
|
+
private channel;
|
|
25
20
|
}
|
|
26
21
|
export declare const APP_CHANNELS: {
|
|
27
22
|
readonly minimize: "app:minimize";
|
|
@@ -46,12 +41,13 @@ type IpcClient = Pick<IpcRenderer, "send" | "invoke">;
|
|
|
46
41
|
* Creates the standard application controls exposed by an Electron preload.
|
|
47
42
|
*/
|
|
48
43
|
export declare function createAppBridge(ipc: IpcClient): AppBridge;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
input: infer Input;
|
|
53
|
-
result: infer Result;
|
|
54
|
-
} ? (input: Input) => Promise<Result> : never;
|
|
55
|
-
};
|
|
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"]>;
|
|
56
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]>;
|
|
57
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) {
|
|
@@ -40,22 +41,19 @@ function setupAppIpc(storage) {
|
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
class IpcManager {
|
|
44
|
+
namespace;
|
|
43
45
|
delimiter;
|
|
44
|
-
|
|
45
|
-
constructor(delimiter = ":") {
|
|
46
|
+
on;
|
|
47
|
+
constructor(namespace, delimiter = ":") {
|
|
48
|
+
this.namespace = namespace;
|
|
46
49
|
this.delimiter = delimiter;
|
|
47
|
-
this.
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
makeNamespace(ns) {
|
|
52
|
-
const ch = (key) => `${ns}${this.delimiter}${key}`;
|
|
53
|
-
return {
|
|
54
|
-
on: (key, handler) => {
|
|
55
|
-
electron_1.ipcMain.handle(ch(key), (_event, input) => handler(input));
|
|
56
|
-
},
|
|
50
|
+
this.on = (key, handler) => {
|
|
51
|
+
electron_1.ipcMain.handle(this.channel(key), (_event, input) => handler(input));
|
|
57
52
|
};
|
|
58
53
|
}
|
|
54
|
+
channel(key) {
|
|
55
|
+
return `${this.namespace}${this.delimiter}${key}`;
|
|
56
|
+
}
|
|
59
57
|
}
|
|
60
58
|
exports.IpcManager = IpcManager;
|
|
61
59
|
exports.APP_CHANNELS = {
|
|
@@ -95,3 +93,6 @@ function createAppBridge(ipc) {
|
|
|
95
93
|
}
|
|
96
94
|
};
|
|
97
95
|
}
|
|
96
|
+
function createIpcManager() {
|
|
97
|
+
return (namespace) => new IpcManager(namespace);
|
|
98
|
+
}
|
package/dist/storage.d.ts
CHANGED
|
@@ -3,8 +3,11 @@ type StorageSchema = Record<string, {
|
|
|
3
3
|
type: string;
|
|
4
4
|
default: unknown;
|
|
5
5
|
}>;
|
|
6
|
-
type
|
|
7
|
-
|
|
6
|
+
type BaseStorage = {
|
|
7
|
+
access_token: string | null;
|
|
8
|
+
};
|
|
9
|
+
type InferSchema<T extends StorageSchema> = BaseStorage & {
|
|
10
|
+
[K in Exclude<keyof T, keyof BaseStorage>]: T[K]["default"];
|
|
8
11
|
};
|
|
9
12
|
export declare class Storage<const T extends StorageSchema> extends ElectronStore<InferSchema<T>> {
|
|
10
13
|
constructor(schema: T);
|
package/dist/storage.js
CHANGED
|
@@ -8,7 +8,13 @@ const electron_store_1 = __importDefault(require("electron-store"));
|
|
|
8
8
|
class Storage extends electron_store_1.default {
|
|
9
9
|
constructor(schema) {
|
|
10
10
|
super({
|
|
11
|
-
schema
|
|
11
|
+
schema: {
|
|
12
|
+
access_token: {
|
|
13
|
+
type: ["string", "null"],
|
|
14
|
+
default: null
|
|
15
|
+
},
|
|
16
|
+
...schema
|
|
17
|
+
}
|
|
12
18
|
});
|
|
13
19
|
}
|
|
14
20
|
}
|