@bouko/electron 1.1.1 → 1.1.2

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.
@@ -0,0 +1,6 @@
1
+ export declare class IpcManager {
2
+ id: string;
3
+ constructor(id: string);
4
+ on<T, K>(channel: string, cb: (params?: T) => Promise<K>): void;
5
+ }
6
+ export declare function setupAppIpc(): void;
@@ -0,0 +1,35 @@
1
+ import { ipcMain, BrowserWindow, shell } from "electron";
2
+ import { choosePath } from "../files/dialog";
3
+ export class IpcManager {
4
+ id;
5
+ constructor(id) {
6
+ this.id = id;
7
+ }
8
+ on(channel, cb) {
9
+ ipcMain.handle(`${this.id}:${channel}`, (_, params) => cb(params));
10
+ }
11
+ }
12
+ export function setupAppIpc() {
13
+ ipcMain.on("app:minimize", (event) => {
14
+ const window = BrowserWindow.fromWebContents(event.sender);
15
+ window?.minimize();
16
+ });
17
+ ipcMain.on("app:close", (event) => {
18
+ const window = BrowserWindow.fromWebContents(event.sender);
19
+ window?.close();
20
+ });
21
+ ipcMain.on("app:open-link", (_, url) => {
22
+ if (url)
23
+ shell.openExternal(url);
24
+ });
25
+ ipcMain.handle("app:choose-path", async (event) => {
26
+ const window = BrowserWindow.fromWebContents(event.sender);
27
+ if (!window)
28
+ return;
29
+ return await choosePath({
30
+ window: window,
31
+ title: "Choose Vault Folder",
32
+ defaultPath: "music"
33
+ });
34
+ });
35
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./ipc";
1
+ export * from "./communication";
2
2
  export * from "./csp";
3
3
  export * from "./files/_";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /// <reference path="./ipc.d.ts" />
2
- export * from "./ipc";
2
+ export * from "./communication";
3
3
  export * from "./csp";
4
4
  export * from "./files/_";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/electron",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "description": "",
6
6
  "keywords": [],
7
7
  "author": "",