@bouko/electron 1.0.5 → 1.0.7

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/csp/index.js CHANGED
@@ -33,8 +33,7 @@ export const devCsp = "default-src 'self' http://localhost:* blob: data:; " +
33
33
  "worker-src 'self' blob: http://localhost:*; " +
34
34
  `connect-src 'self' blob: http://localhost:* ws://localhost:* ${getEnv("DB_URL")};`;
35
35
  export const setupCspPolicy = () => session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
36
- if (details.url.startsWith("file://") ||
37
- details.url.startsWith("http://localhost")) {
36
+ if (details.url.startsWith("file://") || details.url.startsWith("http://localhost")) {
38
37
  callback({
39
38
  responseHeaders: {
40
39
  ...details.responseHeaders,
@@ -43,6 +42,5 @@ export const setupCspPolicy = () => session.defaultSession.webRequest.onHeadersR
43
42
  });
44
43
  return;
45
44
  }
46
- // Do NOT touch third-party pages (SoundCloud, etc.)
47
45
  callback({ responseHeaders: details.responseHeaders });
48
46
  });
@@ -0,0 +1,2 @@
1
+ export * from "./dialog";
2
+ export * from "./paths";
@@ -0,0 +1,2 @@
1
+ export * from "./dialog";
2
+ export * from "./paths";
@@ -2,7 +2,7 @@ import { BrowserWindow } from "electron";
2
2
  type Props = {
3
3
  window: BrowserWindow;
4
4
  title: string;
5
- defaultPath?: "music";
5
+ defaultPath: "music";
6
6
  };
7
7
  export declare function choosePath({ window, title, defaultPath }: Props): Promise<string | null>;
8
8
  export {};
@@ -1,2 +1 @@
1
- export * from "./paths";
2
1
  export * from "./dialog";
@@ -1,2 +1 @@
1
- export * from "./paths";
2
1
  export * from "./dialog";
@@ -1 +1,2 @@
1
1
  export declare const getUserDataPath: (x: string) => string;
2
+ export declare const getAppDataPath: (x: string) => string;
@@ -1,3 +1,4 @@
1
1
  import { app } from "electron";
2
2
  import { join } from "path";
3
3
  export const getUserDataPath = (x) => join(app.getPath("userData"), x);
4
+ export const getAppDataPath = (x) => join(app.getPath("appData"), x);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from "./ipc";
2
- export * from "./files";
3
2
  export * from "./csp";
4
- export * from "./components";
3
+ export * from "./files/_";
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from "./ipc";
2
- export * from "./files";
3
2
  export * from "./csp";
4
- export * from "./components";
3
+ export * from "./files/_";
@@ -1,2 +1,6 @@
1
- export * from "./manager";
2
- export * from "./app";
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;
package/dist/ipc/index.js CHANGED
@@ -1,2 +1,35 @@
1
- export * from "./manager";
2
- export * from "./app";
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", (_, 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/package.json CHANGED
@@ -1,72 +1,41 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/electron",
4
-
5
- "version": "1.0.5",
6
-
4
+ "version": "1.0.7",
7
5
  "description": "",
8
-
9
6
  "keywords": [],
10
-
11
7
  "author": "",
12
-
13
8
  "license": "ISC",
14
-
15
9
  "main": "./dist/index.js",
16
-
17
10
  "types": "./dist/index.d.ts",
18
-
19
11
  "files": [
20
-
21
12
  "dist"
22
-
23
13
  ],
24
-
25
14
  "publishConfig": {
26
-
27
15
  "access": "public"
28
-
29
16
  },
30
-
31
17
  "exports": {
32
-
33
18
  ".": "./dist/index.js",
34
-
35
19
  "./styles.css": "./dist/styles.css"
36
-
37
20
  },
38
-
39
21
  "engines": {},
40
22
 
41
23
  "scripts": {
42
-
43
24
  "build": "tsc",
44
-
45
25
  "postbuild": "node ./scripts/copy-styles.mjs"
46
-
47
26
  },
48
27
 
49
28
  "dependencies": {
50
-
51
29
  "@bouko/react": "^3.1.3",
52
-
53
30
  "@bouko/ts": "^0.3.8",
54
-
55
31
  "path": "^0.12.7"
56
-
57
32
  },
58
33
 
59
34
  "devDependencies": {
60
-
61
35
  "@types/react": "^19.2.13",
62
-
63
36
  "electron": "^39.2.7",
64
-
65
37
  "react-router-dom": "^7.12.0",
66
-
67
38
  "typescript": "^5.9.3"
68
-
69
39
  }
70
40
 
71
- }
72
-
41
+ }