Skip to content

Commit

Permalink
feat: app separation (#69)
Browse files Browse the repository at this point in the history
## Motivation

<!-- List motivation and changes here -->

- adds SDK integration
- offers multiple apps to be open at once
- introduces spotlight like search
- allows 3rd party and core apps
- introduces tabbed windows (concept)

## Issues closed

<!-- List closed issues here -->
  • Loading branch information
pixelass committed Mar 8, 2024
1 parent 972c88f commit 1339741
Show file tree
Hide file tree
Showing 86 changed files with 3,077 additions and 3,984 deletions.
2 changes: 1 addition & 1 deletion .ncurc.json
@@ -1,4 +1,4 @@
{
"upgrade": true,
"reject": ["@types/node", "codemirror", "next", "sharp"]
"reject": ["@types/node", "codemirror", "next", "sharp", "semantic-release"]
}
Binary file added assests/blibla-logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion jest.config.electron.e2e.ts
Expand Up @@ -3,7 +3,7 @@ import { defaults } from "jest-config";
const jestConfig = {
...defaults,
roots: ["<rootDir>/src/electron"],
testMatch: ["**/e2e/**/*.test.ts"],
testMatch: ["**/*.test.e2e.ts"],
transform: {
"^.+\\.(ts|js)$": ["@swc/jest"],
},
Expand Down
1 change: 1 addition & 0 deletions nextron.config.js
Expand Up @@ -15,6 +15,7 @@ module.exports = {
config.entry = {
background: "./src/electron/background.ts",
preload: "./src/electron/preload.ts",
"app-preload": "./src/electron/app-preload.ts",
};
return config;
},
Expand Down
3,291 changes: 1,272 additions & 2,019 deletions package-lock.json

Large diffs are not rendered by default.

111 changes: 63 additions & 48 deletions package.json
Expand Up @@ -31,119 +31,134 @@
},
"dependencies": {
"electron-context-menu": "3.6.1",
"electron-dl": "3.5.1",
"electron-dl": "3.5.2",
"electron-serve": "1.3.0",
"electron-store": "^8.1.0",
"electron-store": "^8.2.0",
"sharp": "0.33.2"
},
"devDependencies": {
"@commitlint/cli": "^18.6.0",
"@commitlint/config-conventional": "^18.6.0",
"@emotion/react": "11.11.3",
"@captn/joy": "^0.3.0",
"@captn/react": "^0.3.1",
"@captn/theme": "^0.3.0",
"@captn/utils": "^0.3.0",
"@commitlint/cli": "^19.0.3",
"@commitlint/config-conventional": "^19.0.3",
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.0",
"@jest/globals": "^29.7.0",
"@langchain/community": "^0.0.34",
"@langchain/openai": "^0.0.15",
"@langchain/community": "^0.0.35",
"@langchain/openai": "^0.0.18",
"@lottiefiles/react-lottie-player": "^3.5.3",
"@mdx-js/react": "3.0.0",
"@mui/base": "5.0.0-beta.33",
"@mui/icons-material": "5.15.6",
"@mui/joy": "5.0.0-beta.24",
"@mui/material": "5.15.6",
"@next/mdx": "14.1.0",
"@playwright/test": "^1.41.2",
"@mdx-js/react": "3.0.1",
"@mui/base": "5.0.0-beta.38",
"@mui/icons-material": "5.15.12",
"@mui/joy": "5.0.0-beta.30",
"@mui/material": "5.15.12",
"@next/mdx": "14.1.3",
"@playwright/test": "^1.42.1",
"@qdrant/js-client-rest": "^1.8.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^9.2.6",
"@swc/cli": "^0.3.5",
"@swc/core": "^1.3.107",
"@swc/jest": "^0.2.31",
"@testing-library/jest-dom": "^6.4.0",
"@testing-library/react": "^14.2.0",
"@swc/cli": "^0.3.10",
"@swc/core": "^1.4.6",
"@swc/jest": "^0.2.36",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
"@types/codemirror": "^5.60.15",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.14.202",
"@types/node": "^18.19.10",
"@types/node-7z": "^2.1.8",
"@types/react": "^18.2.48",
"@types/react": "^18.2.64",
"@types/react-custom-scrollbars": "^4.0.13",
"@types/react-dom": "^18.2.18",
"@types/react-dom": "^18.2.21",
"@types/react-window": "^1.8.8",
"@types/sort-json": "^2.0.3",
"@types/supertest": "^6.0.2",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"axios": "^1.6.7",
"codemirror": "^5.65.16",
"conventional-changelog-cli": "^4.1.0",
"cross-env": "^7.0.3",
"dayjs": "1.11.10",
"dotenv": "^16.4.5",
"dotenv-cli": "^7.3.0",
"electron": "29.0.0-beta.4",
"electron-builder": "^24.9.1",
"eslint": "^8.56.0",
"eslint-config-next": "^14.1.0",
"dotenv-cli": "^7.4.0",
"electron": "30.0.0-alpha.4",
"electron-builder": "^24.13.3",
"eslint": "^8.57.0",
"eslint-config-next": "^14.1.3",
"eslint-config-prettier": "^9.1.0",
"eslint-config-typescript": "^3.0.0",
"eslint-config-xo": "^0.43.1",
"eslint-config-xo": "^0.44.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unicorn": "^50.0.1",
"eslint-plugin-unused-imports": "^3.0.0",
"eslint-plugin-unicorn": "^51.0.1",
"eslint-plugin-unused-imports": "^3.1.0",
"execa": "^8.0.1",
"exifr": "^7.1.3",
"file-type": "^19.0.0",
"framer-motion": "^11.0.5",
"framer-motion": "^11.0.8",
"fs-extra": "^11.2.0",
"globby": "14.0.0",
"husky": "^9.0.7",
"i18next": "23.8.1",
"globby": "14.0.1",
"husky": "^9.0.11",
"i18next": "23.10.1",
"jest": "^29.7.0",
"jest-config": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-mock-extended": "^3.0.5",
"jest-ts-webcompat-resolver": "^1.0.0",
"jotai": "2.6.3",
"jotai": "2.7.0",
"json5": "^2.2.3",
"langchain": "^0.1.25",
"lodash": "^4.17.21",
"next": "^13.5.6",
"next-i18next": "15.2.0",
"next-transpile-modules": "10.0.1",
"nextron": "^8.12.0",
"nextron": "^8.13.0",
"node-7z": "^3.0.0",
"node-loader": "^2.0.0",
"openai": "^4.28.0",
"prettier": "^3.2.4",
"openai": "^4.28.4",
"prettier": "^3.2.5",
"react": "^18.2.0",
"react-codemirror2": "^7.3.0",
"react-custom-scrollbars": "^4.2.1",
"react-dom": "^18.2.0",
"react-hook-form": "^7.49.3",
"react-i18next": "14.0.1",
"react-hook-form": "^7.51.0",
"react-i18next": "14.1.0",
"react-markdown": "^9.0.1",
"react-virtualized-auto-sizer": "^1.0.21",
"react-textarea-autosize": "^8.5.3",
"react-virtualized-auto-sizer": "^1.0.24",
"react-window": "^1.8.10",
"react-zoom-pan-pinch": "^3.3.0",
"react-zoom-pan-pinch": "^3.4.3",
"remark-gfm": "4.0.0",
"semantic-release": "^22.0.12",
"semver": "^7.5.4",
"semver": "^7.6.0",
"sort-json": "^2.0.1",
"swr": "^2.2.4",
"swr": "^2.2.5",
"ts-jest": "^29.1.2",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"tslib": "2.6.2",
"type-fest": "4.10.2",
"typescript": "^5.3.3",
"type-fest": "4.12.0",
"typescript": "^5.4.2",
"uuid": "^9.0.1",
"webpack": "^5.90.3"
},
"optionalDependencies": {
"@swc/core-darwin-arm64": "^1.4.6",
"@swc/core-darwin-x64": "^1.4.6",
"@swc/core-linux-arm-gnueabihf": "^1.4.6",
"@swc/core-linux-arm64-gnu": "^1.4.6",
"@swc/core-linux-arm64-musl": "^1.4.6",
"@swc/core-linux-x64-gnu": "^1.4.6",
"@swc/core-linux-x64-musl": "^1.4.6",
"@swc/core-win32-x64-msvc": "^1.4.6"
}
}
6 changes: 3 additions & 3 deletions playwright/main-window.test.ts
Expand Up @@ -24,19 +24,19 @@ test.afterAll(async () => {
await electronApp.close();
});

test("Renders the dashboard page", async () => {
test.skip("Renders the dashboard page", async () => {
page = await electronApp.firstWindow();
await expect(page.url()).toContain("dashboard");
});

test("Open Live Painting", async () => {
test.skip("Open Live Painting", async () => {
page = await electronApp.firstWindow();

await page.getByTestId("sidebar-live-painting").click();
await expect(page.url()).toContain("live-painting");
});

test("Open Settings", async () => {
test.skip("Open Settings", async () => {
page = await electronApp.firstWindow();

await page.getByTestId("sidebar-settings").click();
Expand Down
@@ -1,4 +1,4 @@
import { atom } from "jotai/index";
import { atom } from "jotai";

import type { ImageItem } from "#/types";

Expand Down
1 change: 1 addition & 0 deletions src/client/apps/live-painting/constants.ts
@@ -0,0 +1 @@
export const APP_ID = "live-painting";
@@ -1,10 +1,11 @@
import { useSDK } from "@captn/react/use-sdk";
import Box from "@mui/joy/Box";
import { useAtom } from "jotai/index";
import { useAtom } from "jotai";
import { type PointerEvent as ReactPointerEvent, useEffect, useRef } from "react";

import { buildKey } from "#/build-key";
import { ID } from "#/enums";
import { clearCounterAtom, livePaintingOptionsAtom } from "@/ions/atoms/live-painting";
import { clearCounterAtom, livePaintingOptionsAtom } from "./atoms";

import { APP_ID } from "@/apps/live-painting/constants";

export function DrawingArea({ isOverlay }: { isOverlay?: boolean }) {
const canvas = useRef<HTMLCanvasElement>(null);
Expand All @@ -14,6 +15,21 @@ export function DrawingArea({ isOverlay }: { isOverlay?: boolean }) {
const [clearCounter] = useAtom(clearCounterAtom);
const canvasContainerReference = useRef<HTMLDivElement>(null);

const { send } = useSDK<unknown, string>(APP_ID, {
onMessage(message) {
console.log(message);
switch (message.action) {
case "livePainting:generated": {
break;
}

default: {
break;
}
}
},
});

function startDrawing(event: ReactPointerEvent) {
if (!canvas.current) {
return;
Expand Down Expand Up @@ -61,10 +77,12 @@ export function DrawingArea({ isOverlay }: { isOverlay?: boolean }) {
return;
}

context.current?.lineTo(event.clientX - rect.left, event.clientY - rect.top);
context.current?.stroke();
const dataUrl = canvas.current.toDataURL();
window.ipc.send(buildKey([ID.LIVE_PAINT], { suffix: ":dataUrl" }), dataUrl);
if (context.current) {
context.current.lineTo(event.clientX - rect.left, event.clientY - rect.top);
context.current.stroke();
}

send({ action: "livePainting:dataUrl", payload: canvas.current.toDataURL() });
}

function handleMouseUp() {
Expand Down Expand Up @@ -126,8 +144,7 @@ export function DrawingArea({ isOverlay }: { isOverlay?: boolean }) {
context.current.fillStyle = "#ffffff";
context.current.clearRect(0, 0, canvas.current.width, canvas.current.height);
context.current.fillRect(0, 0, canvas.current.width, canvas.current.height);
const dataUrl = canvas.current.toDataURL();
window.ipc.send(buildKey([ID.LIVE_PAINT], { suffix: ":dataUrl" }), dataUrl);
send({ action: "livePainting:dataUrl", payload: canvas.current.toDataURL() });
}
}, [clearCounter]);

Check warning on line 149 in src/client/apps/live-painting/drawing-area.tsx

View workflow job for this annotation

GitHub Actions / release

React Hook useEffect has a missing dependency: 'send'. Either include it or remove the dependency array

Expand All @@ -137,7 +154,7 @@ export function DrawingArea({ isOverlay }: { isOverlay?: boolean }) {
sx={{
width: 512,
height: 512,
boxShadow: "sm",
boxShadow: isOverlay ? undefined : "sm",
position: "relative",
overflow: "hidden",
cursor: "none",
Expand Down

0 comments on commit 1339741

Please sign in to comment.