@proton-app/main 0.0.8 → 0.1.0
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 +39 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/setup.d.ts +6 -0
- package/dist/setup.js +43 -0
- package/package.json +1 -1
package/dist/communication.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type IpcRenderer } from "electron";
|
|
1
2
|
import Storage from "electron-store";
|
|
2
3
|
export declare function setupAppIpc<T extends Record<string, any>>(storage: Storage<T>): void;
|
|
3
4
|
export type IpcSchema = Record<string, Record<string, {
|
|
@@ -22,4 +23,27 @@ export declare class IpcManager<S extends IpcSchema> {
|
|
|
22
23
|
constructor(delimiter?: string);
|
|
23
24
|
private makeNamespace;
|
|
24
25
|
}
|
|
26
|
+
export declare const APP_CHANNELS: {
|
|
27
|
+
readonly minimize: "app:minimize";
|
|
28
|
+
readonly close: "app:close";
|
|
29
|
+
readonly choosePath: "app:choose-path";
|
|
30
|
+
readonly openLink: "app:open-link";
|
|
31
|
+
readonly getValue: "app:get-value";
|
|
32
|
+
readonly setValue: "app:set-value";
|
|
33
|
+
readonly syncAuth: "app:sync-auth";
|
|
34
|
+
};
|
|
35
|
+
export interface AppBridge {
|
|
36
|
+
minimize: () => void;
|
|
37
|
+
close: () => void;
|
|
38
|
+
choosePath: () => Promise<string | null>;
|
|
39
|
+
openLink: (url: string) => void;
|
|
40
|
+
getValue: <T>(key: string) => T;
|
|
41
|
+
setValue: <T>(key: string, value: T) => T;
|
|
42
|
+
syncAuth: (accessToken: string) => void;
|
|
43
|
+
}
|
|
44
|
+
type IpcClient = Pick<IpcRenderer, "send" | "invoke">;
|
|
45
|
+
/**
|
|
46
|
+
* Creates the standard application controls exposed by an Electron preload.
|
|
47
|
+
*/
|
|
48
|
+
export declare function createAppBridge(ipc: IpcClient): AppBridge;
|
|
25
49
|
export {};
|
package/dist/communication.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IpcManager = void 0;
|
|
3
|
+
exports.APP_CHANNELS = exports.IpcManager = void 0;
|
|
4
4
|
exports.setupAppIpc = setupAppIpc;
|
|
5
|
+
exports.createAppBridge = createAppBridge;
|
|
5
6
|
const electron_1 = require("electron");
|
|
6
7
|
const files_1 = require("./files");
|
|
7
8
|
function setupAppIpc(storage) {
|
|
@@ -57,3 +58,40 @@ class IpcManager {
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
exports.IpcManager = IpcManager;
|
|
61
|
+
exports.APP_CHANNELS = {
|
|
62
|
+
minimize: "app:minimize",
|
|
63
|
+
close: "app:close",
|
|
64
|
+
choosePath: "app:choose-path",
|
|
65
|
+
openLink: "app:open-link",
|
|
66
|
+
getValue: "app:get-value",
|
|
67
|
+
setValue: "app:set-value",
|
|
68
|
+
syncAuth: "app:sync-auth"
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Creates the standard application controls exposed by an Electron preload.
|
|
72
|
+
*/
|
|
73
|
+
function createAppBridge(ipc) {
|
|
74
|
+
return {
|
|
75
|
+
minimize: () => {
|
|
76
|
+
ipc.send(exports.APP_CHANNELS.minimize);
|
|
77
|
+
},
|
|
78
|
+
close: () => {
|
|
79
|
+
ipc.send(exports.APP_CHANNELS.close);
|
|
80
|
+
},
|
|
81
|
+
choosePath: () => {
|
|
82
|
+
return ipc.invoke(exports.APP_CHANNELS.choosePath);
|
|
83
|
+
},
|
|
84
|
+
openLink: (url) => {
|
|
85
|
+
ipc.send(exports.APP_CHANNELS.openLink, url);
|
|
86
|
+
},
|
|
87
|
+
getValue: (key) => {
|
|
88
|
+
return ipc.invoke(exports.APP_CHANNELS.getValue, key);
|
|
89
|
+
},
|
|
90
|
+
setValue: (key, value) => {
|
|
91
|
+
return ipc.invoke(exports.APP_CHANNELS.setValue, key, value);
|
|
92
|
+
},
|
|
93
|
+
syncAuth: (accessToken) => {
|
|
94
|
+
return ipc.send(exports.APP_CHANNELS.syncAuth, accessToken);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/setup.d.ts
ADDED
package/dist/setup.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupApp = setupApp;
|
|
4
|
+
const electron_1 = require("electron");
|
|
5
|
+
const communication_1 = require("./communication");
|
|
6
|
+
const csp_1 = require("./csp");
|
|
7
|
+
let mainWindow = null;
|
|
8
|
+
function setupApp(app, storage, opts) {
|
|
9
|
+
function createWindow() {
|
|
10
|
+
if (mainWindow && !mainWindow.isDestroyed())
|
|
11
|
+
return mainWindow;
|
|
12
|
+
mainWindow = new electron_1.BrowserWindow({
|
|
13
|
+
width: opts.width,
|
|
14
|
+
height: opts.height,
|
|
15
|
+
icon: "../../../public/icon.ico",
|
|
16
|
+
show: false,
|
|
17
|
+
frame: false,
|
|
18
|
+
resizable: false,
|
|
19
|
+
webPreferences: {
|
|
20
|
+
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
|
|
21
|
+
contextIsolation: true,
|
|
22
|
+
nodeIntegration: false
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
mainWindow.once("ready-to-show", () => mainWindow?.show());
|
|
26
|
+
mainWindow.on("closed", () => (mainWindow = null));
|
|
27
|
+
void mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
|
|
28
|
+
return mainWindow;
|
|
29
|
+
}
|
|
30
|
+
app.on("ready", () => {
|
|
31
|
+
createWindow();
|
|
32
|
+
(0, csp_1.setupCspPolicy)();
|
|
33
|
+
});
|
|
34
|
+
app.on("activate", () => {
|
|
35
|
+
if (electron_1.BrowserWindow.getAllWindows().length === 0)
|
|
36
|
+
createWindow();
|
|
37
|
+
});
|
|
38
|
+
app.on("window-all-closed", () => {
|
|
39
|
+
if (process.platform !== "darwin")
|
|
40
|
+
app.quit();
|
|
41
|
+
});
|
|
42
|
+
(0, communication_1.setupAppIpc)(storage);
|
|
43
|
+
}
|