@proton-app/renderer 0.0.3 → 0.0.4
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/app.d.ts +13 -0
- package/dist/app.js +13 -0
- package/dist/assets/dash.svg +6 -0
- package/dist/assets/x.svg +6 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -4
- package/dist/layouts/_.d.ts +1 -0
- package/dist/layouts/_.js +8 -0
- package/dist/layouts/normal.d.ts +51 -0
- package/dist/layouts/normal.js +73 -0
- package/dist/router.d.ts +1 -2
- package/package.json +7 -5
- package/dist/mount.d.ts +0 -1
- package/dist/mount.js +0 -9
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type AppDefinition = {
|
|
3
|
+
layout?: ReactNode;
|
|
4
|
+
routes: Record<string, ReactNode>;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Declares an app: one layout wrapping a flat map of
|
|
8
|
+
* path → page. Paths use React Router syntax ("/editor/:songId").
|
|
9
|
+
**/
|
|
10
|
+
export declare const defineApp: (app: AppDefinition) => AppDefinition;
|
|
11
|
+
export declare const AppRoutes: ({ app }: {
|
|
12
|
+
app: AppDefinition;
|
|
13
|
+
}) => import("react").JSX.Element;
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppRoutes = exports.defineApp = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
+
/**
|
|
7
|
+
* Declares an app: one layout wrapping a flat map of
|
|
8
|
+
* path → page. Paths use React Router syntax ("/editor/:songId").
|
|
9
|
+
**/
|
|
10
|
+
const defineApp = (app) => app;
|
|
11
|
+
exports.defineApp = defineApp;
|
|
12
|
+
const AppRoutes = ({ app }) => ((0, jsx_runtime_1.jsx)(react_router_dom_1.Routes, { children: (0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { element: app.layout ?? (0, jsx_runtime_1.jsx)(react_router_dom_1.Outlet, {}), children: Object.entries(app.routes).map(([path, element]) => ((0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: path, element: element }, path))) }) }));
|
|
13
|
+
exports.AppRoutes = AppRoutes;
|
|
@@ -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>
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,9 +18,10 @@ exports.mountApp = mountApp;
|
|
|
18
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
const client_1 = require("react-dom/client");
|
|
20
20
|
const react_router_dom_1 = require("react-router-dom");
|
|
21
|
+
const app_1 = require("./app");
|
|
21
22
|
function mountApp(app) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
root.render((0, jsx_runtime_1.jsx)(react_router_dom_1.HashRouter, { children: app }));
|
|
23
|
+
const root = (0, client_1.createRoot)(document.getElementById("root"));
|
|
24
|
+
root.render((0, jsx_runtime_1.jsx)(react_router_dom_1.HashRouter, { children: (0, jsx_runtime_1.jsx)(app_1.AppRoutes, { app: app }) }));
|
|
25
25
|
}
|
|
26
|
-
__exportStar(require("./
|
|
26
|
+
__exportStar(require("./app"), exports);
|
|
27
|
+
__exportStar(require("./layouts/_"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as NormalLayout } from "./normal";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NormalLayout = void 0;
|
|
7
|
+
var normal_1 = require("./normal");
|
|
8
|
+
Object.defineProperty(exports, "NormalLayout", { enumerable: true, get: function () { return __importDefault(normal_1).default; } });
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type NavItem } from "@bouku/core";
|
|
2
|
+
export type NavItemT = {
|
|
3
|
+
label: string;
|
|
4
|
+
icon?: React.ReactNode;
|
|
5
|
+
isActive: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const TabItemBase: ({ label, icon, isActive }: Omit<NavItemT, "id">) => import("react").JSX.Element;
|
|
8
|
+
/**
|
|
9
|
+
* Title Bar component.
|
|
10
|
+
*
|
|
11
|
+
* Application-level title bar used in the root layout.
|
|
12
|
+
* Renders a horizontal bar with logo and window controls.
|
|
13
|
+
* Uses `draggable` class to replace frame of Electron
|
|
14
|
+
* window and make the app move on the user's screen.
|
|
15
|
+
**/
|
|
16
|
+
export declare const TitleBar: ({ banner }: {
|
|
17
|
+
banner: string;
|
|
18
|
+
}) => import("react").JSX.Element;
|
|
19
|
+
type Props = {
|
|
20
|
+
style?: string;
|
|
21
|
+
banner: string;
|
|
22
|
+
tabs?: NavItem[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Root Layout.
|
|
26
|
+
*
|
|
27
|
+
* Application-level layout wrapper used by all routes.
|
|
28
|
+
* Provides a full-screen column layout with a persistent title
|
|
29
|
+
* bar and a centered content area for routed pages.
|
|
30
|
+
*
|
|
31
|
+
* @param children - Page content.
|
|
32
|
+
**/
|
|
33
|
+
declare const NormalLayout: ({ style, banner, tabs }: Props) => import("react").JSX.Element;
|
|
34
|
+
/**
|
|
35
|
+
* Tab Navigation Component.
|
|
36
|
+
*
|
|
37
|
+
* A `TabItem` wrapper that integrates with React Router.
|
|
38
|
+
* Derives active state from the current URL and renders a
|
|
39
|
+
* navigable tab using a router `<Link>`.
|
|
40
|
+
*
|
|
41
|
+
* Behavior:
|
|
42
|
+
* - Builds a route from the provided `id` (/[id]).
|
|
43
|
+
* - Marks tab as active when the pathname includes that route.
|
|
44
|
+
* - Delegates all visual rendering to `TabItem`.
|
|
45
|
+
* - Nested routes keep the parent tab active.
|
|
46
|
+
*
|
|
47
|
+
* @param id - Route identifier used to construct the URL.
|
|
48
|
+
* @param props - Remaining `NavItem` props forwarded to `TabItem`.
|
|
49
|
+
**/
|
|
50
|
+
export declare const TabItem: ({ href, ...props }: NavItem) => import("react").JSX.Element;
|
|
51
|
+
export default NormalLayout;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TabItem = exports.TitleBar = exports.TabItemBase = void 0;
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
10
|
+
const core_1 = require("@bouku/core");
|
|
11
|
+
const dash_svg_1 = __importDefault(require("../assets/dash.svg"));
|
|
12
|
+
const x_svg_1 = __importDefault(require("../assets/x.svg"));
|
|
13
|
+
const app = () => window.api.app;
|
|
14
|
+
const TabItemBase = ({ label, icon, isActive }) => ((0, jsx_runtime_1.jsxs)("div", { className: (0, core_1.cn)(stylesT, isActive && "!bg-surface-light text-primary hover:cursor-default"), children: [icon && (0, jsx_runtime_1.jsx)("div", { className: (0, core_1.cn)("duration-200", isActive && "text-accent"), children: icon }), label] }));
|
|
15
|
+
exports.TabItemBase = TabItemBase;
|
|
16
|
+
const stylesT = (0, core_1.css)({
|
|
17
|
+
base: "flex items-center gap-2 px-2 py-1 rounded-xs duration-200 cursor-pointer",
|
|
18
|
+
color: "bg-surface-dark hover:bg-surface border border-border-dark",
|
|
19
|
+
text: "font-medium text-sm text-primary-dark"
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Title Bar component.
|
|
23
|
+
*
|
|
24
|
+
* Application-level title bar used in the root layout.
|
|
25
|
+
* Renders a horizontal bar with logo and window controls.
|
|
26
|
+
* Uses `draggable` class to replace frame of Electron
|
|
27
|
+
* window and make the app move on the user's screen.
|
|
28
|
+
**/
|
|
29
|
+
const TitleBar = ({ banner }) => ((0, jsx_runtime_1.jsxs)("div", { className: s.container, style: { WebkitAppRegion: "drag" }, children: [(0, jsx_runtime_1.jsx)("div", { className: s.subcontainer, children: (0, jsx_runtime_1.jsx)("img", { className: "w-auto h-6", src: banner, alt: "Logo" }) }), (0, jsx_runtime_1.jsxs)(core_1.RowBox, { style: s.actions, children: [(0, jsx_runtime_1.jsx)(core_1.Button, { size: "xs", variant: "ghost", style: s.minimize, icon: (0, jsx_runtime_1.jsx)(dash_svg_1.default, {}), action: () => app().minimize() }), (0, jsx_runtime_1.jsx)(core_1.Button, { variant: "ghost", style: s.close, icon: (0, jsx_runtime_1.jsx)(x_svg_1.default, {}), action: () => app().close() })] })] }));
|
|
30
|
+
exports.TitleBar = TitleBar;
|
|
31
|
+
const s = {
|
|
32
|
+
container: "bg-background-light border-b border-border-dark",
|
|
33
|
+
subcontainer: "grow p-4 draggable",
|
|
34
|
+
actions: "gap-2 items-center px-4",
|
|
35
|
+
minimize: "hover:!text-primary-darker",
|
|
36
|
+
close: "hover:!text-error"
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Root Layout.
|
|
40
|
+
*
|
|
41
|
+
* Application-level layout wrapper used by all routes.
|
|
42
|
+
* Provides a full-screen column layout with a persistent title
|
|
43
|
+
* bar and a centered content area for routed pages.
|
|
44
|
+
*
|
|
45
|
+
* @param children - Page content.
|
|
46
|
+
**/
|
|
47
|
+
const NormalLayout = ({ style, banner, tabs }) => ((0, jsx_runtime_1.jsxs)(core_1.ColumnBox, { style: styles.page, children: [(0, jsx_runtime_1.jsx)(exports.TitleBar, { banner: banner }), (0, jsx_runtime_1.jsxs)(core_1.ColumnBox, { style: styles.content, center: true, children: [tabs && ((0, jsx_runtime_1.jsx)(core_1.RowBox, { style: "items-center gap-3 w-full p-5 pb-0", children: tabs.map((t, i) => (0, react_1.createElement)(exports.TabItem, { ...t, key: i })) })), (0, jsx_runtime_1.jsx)("div", { className: (0, core_1.cn)("flex flex-col grow gap-4 w-full overflow-hidden", style), children: (0, jsx_runtime_1.jsx)(react_router_dom_1.Outlet, {}) })] })] }));
|
|
48
|
+
/**
|
|
49
|
+
* Tab Navigation Component.
|
|
50
|
+
*
|
|
51
|
+
* A `TabItem` wrapper that integrates with React Router.
|
|
52
|
+
* Derives active state from the current URL and renders a
|
|
53
|
+
* navigable tab using a router `<Link>`.
|
|
54
|
+
*
|
|
55
|
+
* Behavior:
|
|
56
|
+
* - Builds a route from the provided `id` (/[id]).
|
|
57
|
+
* - Marks tab as active when the pathname includes that route.
|
|
58
|
+
* - Delegates all visual rendering to `TabItem`.
|
|
59
|
+
* - Nested routes keep the parent tab active.
|
|
60
|
+
*
|
|
61
|
+
* @param id - Route identifier used to construct the URL.
|
|
62
|
+
* @param props - Remaining `NavItem` props forwarded to `TabItem`.
|
|
63
|
+
**/
|
|
64
|
+
const TabItem = ({ href, ...props }) => {
|
|
65
|
+
const isActive = !!(0, react_router_dom_1.useMatch)(href + "/*");
|
|
66
|
+
return ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, { to: href, children: (0, jsx_runtime_1.jsx)(exports.TabItemBase, { isActive: isActive, ...props }) }));
|
|
67
|
+
};
|
|
68
|
+
exports.TabItem = TabItem;
|
|
69
|
+
const styles = {
|
|
70
|
+
page: "w-screen h-screen bg-background overflow-hidden",
|
|
71
|
+
content: "grow gap-4 w-full overflow-hidden"
|
|
72
|
+
};
|
|
73
|
+
exports.default = NormalLayout;
|
package/dist/router.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
type RouterConfig = Record<string, {
|
|
2
|
+
export type RouterConfig = Record<string, {
|
|
3
3
|
layout: ReactNode;
|
|
4
4
|
routes: Record<string, {
|
|
5
5
|
param?: string;
|
|
@@ -9,4 +9,3 @@ type RouterConfig = Record<string, {
|
|
|
9
9
|
export declare const AppRouter: ({ config }: {
|
|
10
10
|
config: RouterConfig;
|
|
11
11
|
}) => import("react").JSX.Element;
|
|
12
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proton-app/renderer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,19 +17,21 @@
|
|
|
17
17
|
"react-router-dom": "^7.12.0"
|
|
18
18
|
},
|
|
19
19
|
"exports": {
|
|
20
|
-
".": "./dist/index.js"
|
|
21
|
-
"./styles.css": "./dist/styles.css"
|
|
20
|
+
".": "./dist/index.js"
|
|
22
21
|
},
|
|
23
22
|
"engines": {},
|
|
24
23
|
"scripts": {
|
|
25
|
-
"build": "tsc"
|
|
24
|
+
"build": "tsc && node -e \"require('fs').cpSync('src/assets','dist/assets',{recursive:true})\""
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
27
|
"@types/node": "^24.3.1",
|
|
29
|
-
"@types/react": "^19.
|
|
28
|
+
"@types/react": "^19.3.0",
|
|
30
29
|
"@types/react-dom": "^19.2.3",
|
|
31
30
|
"react": "^19.1.1",
|
|
32
31
|
"react-router-dom": "^7.12.0",
|
|
33
32
|
"typescript": "^5.9.2"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@bouku/core": "^0.5.5"
|
|
34
36
|
}
|
|
35
37
|
}
|
package/dist/mount.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function mountApp(app: React.ReactNode): void;
|
package/dist/mount.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mountApp = mountApp;
|
|
4
|
-
const client_1 = require("react-dom/client");
|
|
5
|
-
function mountApp(app) {
|
|
6
|
-
const element = document.getElementById("root");
|
|
7
|
-
const root = (0, client_1.createRoot)(element);
|
|
8
|
-
root.render(app);
|
|
9
|
-
}
|