@proton-app/main 0.0.3 → 0.0.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 +24 -0
- package/dist/communication.js +49 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/ipc.d.ts +16 -22
- package/dist/ipc.js +0 -47
- package/package.json +1 -1
- package/dist/types/ipc.d.ts +0 -25
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare function setupAppIpc(): void;
|
|
2
|
+
export type IpcSchema = Record<string, Record<string, {
|
|
3
|
+
input?: unknown;
|
|
4
|
+
result: unknown;
|
|
5
|
+
}>>;
|
|
6
|
+
type Input<S extends IpcSchema, N extends keyof S, K extends keyof S[N]> = S[N][K] extends {
|
|
7
|
+
input: infer I;
|
|
8
|
+
} ? I : undefined;
|
|
9
|
+
type Result<S extends IpcSchema, N extends keyof S, K extends keyof S[N]> = S[N][K] extends {
|
|
10
|
+
result: infer R;
|
|
11
|
+
} ? R : never;
|
|
12
|
+
type Namespace<S extends IpcSchema, N extends keyof S> = {
|
|
13
|
+
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;
|
|
14
|
+
};
|
|
15
|
+
type Client<S extends IpcSchema> = {
|
|
16
|
+
[N in keyof S]: Namespace<S, N>;
|
|
17
|
+
};
|
|
18
|
+
export declare class IpcManager<S extends IpcSchema> {
|
|
19
|
+
private delimiter;
|
|
20
|
+
readonly ipc: Client<S>;
|
|
21
|
+
constructor(delimiter?: string);
|
|
22
|
+
private makeNamespace;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IpcManager = void 0;
|
|
4
|
+
exports.setupAppIpc = setupAppIpc;
|
|
5
|
+
const electron_1 = require("electron");
|
|
6
|
+
const files_1 = require("./files");
|
|
7
|
+
function setupAppIpc() {
|
|
8
|
+
electron_1.ipcMain.on("app:minimize", (event) => {
|
|
9
|
+
const window = electron_1.BrowserWindow.fromWebContents(event.sender);
|
|
10
|
+
window?.minimize();
|
|
11
|
+
});
|
|
12
|
+
electron_1.ipcMain.on("app:close", (event) => {
|
|
13
|
+
const window = electron_1.BrowserWindow.fromWebContents(event.sender);
|
|
14
|
+
window?.close();
|
|
15
|
+
});
|
|
16
|
+
electron_1.ipcMain.on("app:open-link", (_, url) => {
|
|
17
|
+
if (url)
|
|
18
|
+
electron_1.shell.openExternal(url);
|
|
19
|
+
});
|
|
20
|
+
electron_1.ipcMain.handle("app:choose-path", async (event) => {
|
|
21
|
+
const window = electron_1.BrowserWindow.fromWebContents(event.sender);
|
|
22
|
+
if (!window)
|
|
23
|
+
return;
|
|
24
|
+
return await (0, files_1.choosePath)({
|
|
25
|
+
window: window,
|
|
26
|
+
title: "Choose Vault Folder",
|
|
27
|
+
defaultPath: "music"
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
class IpcManager {
|
|
32
|
+
delimiter;
|
|
33
|
+
ipc;
|
|
34
|
+
constructor(delimiter = ":") {
|
|
35
|
+
this.delimiter = delimiter;
|
|
36
|
+
this.ipc = new Proxy({}, {
|
|
37
|
+
get: (_target, ns) => this.makeNamespace(ns),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
makeNamespace(ns) {
|
|
41
|
+
const ch = (key) => `${ns}${this.delimiter}${key}`;
|
|
42
|
+
return {
|
|
43
|
+
on: (key, handler) => {
|
|
44
|
+
electron_1.ipcMain.handle(ch(key), (_event, input) => handler(input));
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.IpcManager = IpcManager;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/// <reference path="./types/ipc.d.ts" />
|
|
3
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
3
|
if (k2 === undefined) k2 = k;
|
|
5
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -15,8 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
15
|
};
|
|
17
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
|
|
17
|
+
/// <reference path="./ipc.ts" />
|
|
18
|
+
require("./ipc");
|
|
19
19
|
__exportStar(require("./csp"), exports);
|
|
20
20
|
__exportStar(require("./files"), exports);
|
|
21
|
-
__exportStar(require("./
|
|
21
|
+
__exportStar(require("./communication"), exports);
|
|
22
22
|
__exportStar(require("./window"), exports);
|
package/dist/ipc.d.ts
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}>>;
|
|
6
|
-
type Input<S extends IpcSchema, N extends keyof S, K extends keyof S[N]> = S[N][K] extends {
|
|
7
|
-
input: infer I;
|
|
8
|
-
} ? I : undefined;
|
|
9
|
-
type Result<S extends IpcSchema, N extends keyof S, K extends keyof S[N]> = S[N][K] extends {
|
|
10
|
-
result: infer R;
|
|
11
|
-
} ? R : never;
|
|
12
|
-
type Namespace<S extends IpcSchema, N extends keyof S> = {
|
|
13
|
-
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;
|
|
14
|
-
};
|
|
15
|
-
type Client<S extends IpcSchema> = {
|
|
16
|
-
[N in keyof S]: Namespace<S, N>;
|
|
1
|
+
export {};
|
|
2
|
+
type ChoosePathProps = {
|
|
3
|
+
title: string;
|
|
4
|
+
default?: "music";
|
|
17
5
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
declare global {
|
|
7
|
+
interface IpcApi {
|
|
8
|
+
app: {
|
|
9
|
+
minimize: () => void;
|
|
10
|
+
close: () => void;
|
|
11
|
+
choosePath: (opts: ChoosePathProps) => Promise<string | null>;
|
|
12
|
+
openLink: (url: string) => void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
interface Window {
|
|
16
|
+
api: IpcApi;
|
|
17
|
+
}
|
|
23
18
|
}
|
|
24
|
-
export {};
|
package/dist/ipc.js
CHANGED
|
@@ -1,49 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IpcManager = void 0;
|
|
4
|
-
exports.setupAppIpc = setupAppIpc;
|
|
5
|
-
const electron_1 = require("electron");
|
|
6
|
-
const files_1 = require("./files");
|
|
7
|
-
function setupAppIpc() {
|
|
8
|
-
electron_1.ipcMain.on("app:minimize", (event) => {
|
|
9
|
-
const window = electron_1.BrowserWindow.fromWebContents(event.sender);
|
|
10
|
-
window?.minimize();
|
|
11
|
-
});
|
|
12
|
-
electron_1.ipcMain.on("app:close", (event) => {
|
|
13
|
-
const window = electron_1.BrowserWindow.fromWebContents(event.sender);
|
|
14
|
-
window?.close();
|
|
15
|
-
});
|
|
16
|
-
electron_1.ipcMain.on("app:open-link", (_, url) => {
|
|
17
|
-
if (url)
|
|
18
|
-
electron_1.shell.openExternal(url);
|
|
19
|
-
});
|
|
20
|
-
electron_1.ipcMain.handle("app:choose-path", async (event) => {
|
|
21
|
-
const window = electron_1.BrowserWindow.fromWebContents(event.sender);
|
|
22
|
-
if (!window)
|
|
23
|
-
return;
|
|
24
|
-
return await (0, files_1.choosePath)({
|
|
25
|
-
window: window,
|
|
26
|
-
title: "Choose Vault Folder",
|
|
27
|
-
defaultPath: "music"
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
class IpcManager {
|
|
32
|
-
delimiter;
|
|
33
|
-
ipc;
|
|
34
|
-
constructor(delimiter = ":") {
|
|
35
|
-
this.delimiter = delimiter;
|
|
36
|
-
this.ipc = new Proxy({}, {
|
|
37
|
-
get: (_target, ns) => this.makeNamespace(ns),
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
makeNamespace(ns) {
|
|
41
|
-
const ch = (key) => `${ns}${this.delimiter}${key}`;
|
|
42
|
-
return {
|
|
43
|
-
on: (key, handler) => {
|
|
44
|
-
electron_1.ipcMain.handle(ch(key), (_event, input) => handler(input));
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.IpcManager = IpcManager;
|
package/package.json
CHANGED
package/dist/types/ipc.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
|
|
3
|
-
type ChoosePathProps = {
|
|
4
|
-
title: string;
|
|
5
|
-
default?: "music";
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
declare global {
|
|
9
|
-
|
|
10
|
-
interface IpcApi {
|
|
11
|
-
|
|
12
|
-
app: {
|
|
13
|
-
minimize: () => void;
|
|
14
|
-
close: () => void;
|
|
15
|
-
choosePath: (opts: ChoosePathProps) => Promise<string | null>;
|
|
16
|
-
openLink: (url: string) => void;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface Window {
|
|
22
|
-
api: IpcApi;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}
|