@bouko/electron 1.0.4 → 1.0.6
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/assets/icons/dash.svg +6 -0
- package/dist/assets/icons/x.svg +6 -0
- package/dist/assets/styles/index.css +3 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/title-bar/actions.d.ts +9 -0
- package/dist/components/title-bar/actions.js +18 -0
- package/dist/components/title-bar/branding.d.ts +8 -0
- package/dist/components/title-bar/branding.js +9 -0
- package/dist/components/title-bar/index.d.ts +11 -0
- package/dist/components/title-bar/index.js +19 -0
- package/dist/csp/index.js +1 -3
- package/dist/files/dialog.d.ts +1 -1
- package/dist/files/index.d.ts +0 -1
- package/dist/files/index.js +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/ipc/index.d.ts +6 -2
- package/dist/ipc/index.js +31 -2
- package/dist/styles.css +3 -0
- package/package.json +9 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" width="1em" height="1em">
|
|
2
|
+
<path
|
|
3
|
+
d="M55.1 73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L147.2 256 9.9 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192.5 301.3 329.9 438.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.8 256 375.1 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192.5 210.7 55.1 73.4z"
|
|
4
|
+
fill="currentColor"
|
|
5
|
+
/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TitleBar } from "./title-bar";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TitleBar } from "./title-bar";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Title Bar Actions Component.
|
|
3
|
+
*
|
|
4
|
+
* Displays two buttons in the top right:
|
|
5
|
+
* > Minimize - Minimizes the app.
|
|
6
|
+
* > Close - Closes the app.
|
|
7
|
+
**/
|
|
8
|
+
declare const TitleBarActions: () => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default TitleBarActions;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { RowBox, IconButton } from "@bouko/react";
|
|
3
|
+
import Minimize from "../../assets/icons/dash.svg";
|
|
4
|
+
import Close from "../../assets/icons/x.svg";
|
|
5
|
+
/**
|
|
6
|
+
* Title Bar Actions Component.
|
|
7
|
+
*
|
|
8
|
+
* Displays two buttons in the top right:
|
|
9
|
+
* > Minimize - Minimizes the app.
|
|
10
|
+
* > Close - Closes the app.
|
|
11
|
+
**/
|
|
12
|
+
const TitleBarActions = () => (_jsxs(RowBox, { style: styles.container, children: [_jsx(IconButton, { variant: "ghost", style: styles.minimize, icon: _jsx(Minimize, {}), action: () => window.api.app.minimize() }), _jsx(IconButton, { variant: "ghost", style: styles.close, icon: _jsx(Close, {}), action: () => window.api.app.close() })] }));
|
|
13
|
+
const styles = {
|
|
14
|
+
container: "gap-2 items-center px-4",
|
|
15
|
+
minimize: "hover:!text-primary-darker",
|
|
16
|
+
close: "hover:!text-error"
|
|
17
|
+
};
|
|
18
|
+
export default TitleBarActions;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Title Bar Branding Component.
|
|
4
|
+
*
|
|
5
|
+
* Displays company banner in the top left of title bar.
|
|
6
|
+
**/
|
|
7
|
+
export default function TitleBarBranding({ banner }) {
|
|
8
|
+
return (_jsx("img", { className: "w-auto h-6", src: banner, alt: "Logo" }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Title Bar component.
|
|
3
|
+
*
|
|
4
|
+
* Application-level title bar used in the root layout.
|
|
5
|
+
* Renders a horizontal bar with logo and window controls.
|
|
6
|
+
* Uses `draggable` class to replace frame of Electron
|
|
7
|
+
* window and make the app move on the user's screen.
|
|
8
|
+
**/
|
|
9
|
+
export default function TitleBar({ banner }: {
|
|
10
|
+
banner: string;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { RowBox } from "@bouko/react";
|
|
3
|
+
import Branding from "./branding";
|
|
4
|
+
import Actions from "./actions";
|
|
5
|
+
/**
|
|
6
|
+
* Title Bar component.
|
|
7
|
+
*
|
|
8
|
+
* Application-level title bar used in the root layout.
|
|
9
|
+
* Renders a horizontal bar with logo and window controls.
|
|
10
|
+
* Uses `draggable` class to replace frame of Electron
|
|
11
|
+
* window and make the app move on the user's screen.
|
|
12
|
+
**/
|
|
13
|
+
export default function TitleBar({ banner }) {
|
|
14
|
+
return (_jsxs(RowBox, { style: s.container, children: [_jsx("div", { className: s.subcontainer, children: _jsx(Branding, { banner: banner }) }), _jsx(Actions, {})] }));
|
|
15
|
+
}
|
|
16
|
+
const s = {
|
|
17
|
+
container: "bg-background-light border-b border-border-dark",
|
|
18
|
+
subcontainer: "grow p-4 draggable"
|
|
19
|
+
};
|
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
|
});
|
package/dist/files/dialog.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BrowserWindow } from "electron";
|
|
|
2
2
|
type Props = {
|
|
3
3
|
window: BrowserWindow;
|
|
4
4
|
title: string;
|
|
5
|
-
defaultPath
|
|
5
|
+
defaultPath: "music";
|
|
6
6
|
};
|
|
7
7
|
export declare function choosePath({ window, title, defaultPath }: Props): Promise<string | null>;
|
|
8
8
|
export {};
|
package/dist/files/index.d.ts
CHANGED
package/dist/files/index.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/ipc/index.d.ts
CHANGED
package/dist/ipc/index.js
CHANGED
|
@@ -1,2 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ipcMain, BrowserWindow } 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:choose-path", async (event) => {
|
|
22
|
+
const window = BrowserWindow.fromWebContents(event.sender);
|
|
23
|
+
if (!window)
|
|
24
|
+
return;
|
|
25
|
+
return await choosePath({
|
|
26
|
+
window: window,
|
|
27
|
+
title: "Choose Vault Folder",
|
|
28
|
+
defaultPath: "music"
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
package/dist/styles.css
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
|
|
3
3
|
"name": "@bouko/electron",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"author": "",
|
|
@@ -14,18 +14,25 @@
|
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./dist/index.js",
|
|
19
|
+
"./styles.css": "./dist/styles.css"
|
|
20
|
+
},
|
|
17
21
|
"engines": {},
|
|
18
22
|
|
|
19
23
|
"scripts": {
|
|
20
|
-
"build": "tsc"
|
|
24
|
+
"build": "tsc",
|
|
25
|
+
"postbuild": "node ./scripts/copy-styles.mjs"
|
|
21
26
|
},
|
|
22
27
|
|
|
23
28
|
"dependencies": {
|
|
29
|
+
"@bouko/react": "^3.1.3",
|
|
24
30
|
"@bouko/ts": "^0.3.8",
|
|
25
31
|
"path": "^0.12.7"
|
|
26
32
|
},
|
|
27
33
|
|
|
28
34
|
"devDependencies": {
|
|
35
|
+
"@types/react": "^19.2.13",
|
|
29
36
|
"electron": "^39.2.7",
|
|
30
37
|
"react-router-dom": "^7.12.0",
|
|
31
38
|
"typescript": "^5.9.3"
|