@proton-app/main 0.1.2 → 0.1.4
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 +8 -13
- package/dist/communication.js +9 -12
- package/dist/storage.d.ts +12 -8
- package/dist/storage.js +19 -0
- 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,
|
|
4
|
+
export type IpcSchema = Record<string, {
|
|
5
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";
|
package/dist/communication.js
CHANGED
|
@@ -40,22 +40,19 @@ function setupAppIpc(storage) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
class IpcManager {
|
|
43
|
+
namespace;
|
|
43
44
|
delimiter;
|
|
44
|
-
|
|
45
|
-
constructor(delimiter = ":") {
|
|
45
|
+
on;
|
|
46
|
+
constructor(namespace, delimiter = ":") {
|
|
47
|
+
this.namespace = namespace;
|
|
46
48
|
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
|
-
},
|
|
49
|
+
this.on = (key, handler) => {
|
|
50
|
+
electron_1.ipcMain.handle(this.channel(key), (_event, input) => handler(input));
|
|
57
51
|
};
|
|
58
52
|
}
|
|
53
|
+
channel(key) {
|
|
54
|
+
return `${this.namespace}${this.delimiter}${key}`;
|
|
55
|
+
}
|
|
59
56
|
}
|
|
60
57
|
exports.IpcManager = IpcManager;
|
|
61
58
|
exports.APP_CHANNELS = {
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import ElectronStore from "electron-store";
|
|
2
|
+
type StorageSchema = Record<string, {
|
|
3
|
+
type: string;
|
|
4
|
+
default: unknown;
|
|
5
|
+
}>;
|
|
6
|
+
type BaseStorage = {
|
|
7
|
+
access_token: string | null;
|
|
5
8
|
};
|
|
6
|
-
|
|
7
|
-
[K in keyof T]: T[K]
|
|
8
|
-
type: infer U extends keyof StorageTypeMap;
|
|
9
|
-
} ? StorageTypeMap[U] : never;
|
|
9
|
+
type InferSchema<T extends StorageSchema> = BaseStorage & {
|
|
10
|
+
[K in Exclude<keyof T, keyof BaseStorage>]: T[K]["default"];
|
|
10
11
|
};
|
|
12
|
+
export declare class Storage<const T extends StorageSchema> extends ElectronStore<InferSchema<T>> {
|
|
13
|
+
constructor(schema: T);
|
|
14
|
+
}
|
|
11
15
|
export {};
|
package/dist/storage.js
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Storage = void 0;
|
|
7
|
+
const electron_store_1 = __importDefault(require("electron-store"));
|
|
8
|
+
class Storage extends electron_store_1.default {
|
|
9
|
+
constructor(schema) {
|
|
10
|
+
super({
|
|
11
|
+
schema: {
|
|
12
|
+
access_token: {
|
|
13
|
+
type: ["string", "null"],
|
|
14
|
+
default: null
|
|
15
|
+
},
|
|
16
|
+
...schema
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.Storage = Storage;
|