Skip to content

Commit 0ecb777

Browse files
authored
Merge pull request #4 from yossTheDev/dev
v2 Beta 1
2 parents 89fc3b6 + 2e30024 commit 0ecb777

179 files changed

Lines changed: 18607 additions & 6478 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
2-
"plugins": ["prettier-plugin-tailwindcss"],
3-
"tailwindConfig": "./tailwind.config.cjs",
42
"useTabs": true,
53
"singleQuote": true,
64
"jsxSingleQuote": true

AGENTS.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# AGENTS.md
2+
3+
## Purpose
4+
5+
This file summarizes how `karbonized` is organized so an agent or contributor can work on it quickly and safely.
6+
7+
## What This Project Is
8+
9+
Karbonized is a visual image/mockup editor built with React + Vite + TypeScript. The core app allows users to:
10+
11+
- create and edit visual workspaces
12+
- add blocks such as text, code, images, shapes, QR codes, and custom components
13+
- move, resize, rotate, crop, and warp blocks
14+
- export the result as `png`, `jpeg`, or `svg`
15+
- load packaged extensions as `.kext`
16+
17+
There is no in-app agent system in this project. The closest thing to an extensible architecture is the plugin/extension system.
18+
19+
## Main Stack
20+
21+
- Frontend: React 18, TypeScript, Vite
22+
- Global state: Easy Peasy
23+
- UI: Tailwind CSS v4, DaisyUI, Radix UI, shadcn/ui
24+
- Canvas interaction: `react-moveable`, `react-infinite-viewer`
25+
- Lightweight persistence: `localforage`
26+
- Desktop: Electron, plus signs of Tauri/Capacitor integration
27+
- Exporting: `html-to-image`
28+
29+
## Key Folders
30+
31+
- `src/`: main web/editor app
32+
- `src/pages/`: main screens such as `Editor` and `ProjectWizard`
33+
- `src/components/`: canvas, blocks, panels, modals, and reusable controls
34+
- `src/stores/AppStore.ts`: global state, history, workspaces, controls, and main actions
35+
- `src/utils/`: exporting, platform utilities, helper lists, and static data
36+
- `src/models/Extension.ts`: TypeScript contract for extensions
37+
- `docs/plugin_system.md`: functional documentation for the plugin system
38+
- `src-electron/`: main process/preload for the Vite-based Electron variant
39+
- `electron/`: additional/legacy Electron implementation based on Capacitor; do not assume both runtime paths are equally active without checking
40+
41+
## App Flow
42+
43+
1. `src/main.tsx` mounts `App` inside `StoreProvider`.
44+
2. `src/App.tsx` initializes theme/context and lazy-loads `Editor`.
45+
3. `src/pages/Editor.tsx` composes the main layout:
46+
- infinite viewer
47+
- workspace
48+
- left/right panels
49+
- status bar
50+
4. `src/components/Workspace.tsx` renders the active canvas and connects `Moveable`.
51+
5. Actual blocks are materialized through `ControlHandler` and the components in `src/components/Blocks/`.
52+
53+
## State Source of Truth
54+
55+
The source of truth is `src/stores/AppStore.ts`.
56+
57+
It contains:
58+
59+
- `workspaces`
60+
- `currentWorkspaceID`
61+
- `ControlProperties` and `initialProperties`
62+
- selected control `currentControlID`
63+
- history via `pastHistory` / `futureHistory`
64+
- editing flags such as `drag`, `crop`, `warp`, `isDrawing`, `isErasing`
65+
66+
When changing editor behavior, check first whether the change should go through a store action instead of only using local React state.
67+
68+
## How the Editor Models Elements
69+
70+
- Each control has an id like `<type>-<random>`
71+
- Many properties are stored as `History` entries with ids like `<controlId>-<property>`
72+
- The active workspace holds the list of controls, but their properties live separately in `ControlProperties`
73+
74+
That means duplicating, importing, or deleting controls usually requires touching both layers:
75+
76+
- the controls list
77+
- the associated properties
78+
79+
## Extension System
80+
81+
Extensions are not compiled into the repo; they are loaded at runtime through Electron.
82+
83+
Important touchpoints:
84+
85+
- `src/components/Panels/ExtensionsPanel.tsx` listens for IPC events and displays extensions
86+
- `src/models/Extension.ts` defines the expected shape
87+
- `docs/plugin_system.md` documents packaging
88+
- `src-electron/main.ts` reads `.kext` files from `%APPDATA%/karbonized/extensions`
89+
90+
Expected extension structure:
91+
92+
```text
93+
my-plugin/
94+
components/
95+
component1.jsx
96+
component1.json
97+
component1.png
98+
info.json
99+
```
100+
101+
At runtime, the app consumes objects shaped like:
102+
103+
```ts
104+
interface Extension {
105+
logo: string;
106+
info: {
107+
name: string;
108+
author: string;
109+
description: string;
110+
version: string;
111+
};
112+
components: Array<{
113+
properties: { name: string };
114+
code: string;
115+
image: string;
116+
}>;
117+
}
118+
```
119+
120+
## Exporting and Platforms
121+
122+
- `src/utils/Exporter.ts` exports `png`, `jpeg`, and `svg`
123+
- On web, it downloads through a temporary `a` element
124+
- On native environments, it uses Tauri APIs
125+
126+
The codebase contains mixed support for multiple targets:
127+
128+
- web/PWA
129+
- Electron
130+
- Tauri/Capacitor
131+
132+
Before refactoring platform integration, verify which runtime path is actually used by the target user flow.
133+
134+
## Useful Commands
135+
136+
- `yarn dev`: web development
137+
- `yarn electron:dev`: desktop development with Electron
138+
- `yarn build`: web build
139+
- `yarn electron:build`: desktop build
140+
- `yarn lint`: lint `src`
141+
- `yarn format`: run Prettier on `src`
142+
143+
## Practical Editing Conventions
144+
145+
- Prefer small, localized changes; editor state is fairly coupled.
146+
- Review `AppStore.ts` before changing selection, duplication, undo/redo, or workspaces.
147+
- For new block types, inspect `src/components/Blocks/` and `ControlHandler` first.
148+
- For UI work, try to preserve consistency between legacy DaisyUI components and `src/components/ui/` components.
149+
- Use the `@/` alias when the surrounding file already follows that pattern; the repo mixes relative imports and alias-based imports.
150+
- Do not assume commented-out code is dead; some features are in transition, especially templates and desktop runtimes.
151+
152+
## Visible Risks and Technical Debt
153+
154+
- Two Electron areas coexist: `electron/` and `src-electron/`
155+
- There is a mix of legacy UI components and newer UI primitives
156+
- Part of the templates/community system is commented out or incomplete
157+
- The central store is large and mixes many responsibilities
158+
- There does not appear to be an automated test suite in the repo
159+
160+
If you make deep changes, manually validate at least:
161+
162+
- block selection
163+
- drag/resize/rotate
164+
- undo/redo
165+
- workspace switching
166+
- exporting
167+
- extension loading if the change touches desktop/IPC behavior
168+
169+
## Recommendation for Future Agents
170+
171+
Before implementing a feature or fixing a bug:
172+
173+
1. identify whether the problem lives in layout, block rendering, workspace logic, or store logic
174+
2. confirm whether it affects web, Electron, or both
175+
3. check whether a store action or similar pattern already exists
176+
4. then edit the UI
177+
178+
Most of the fragile bugs in this repo are likely not in the visible JSX itself, but in synchronization between:
179+
180+
- `workspaces`
181+
- `ControlProperties`
182+
- `currentControlID`
183+
- editing history

0 commit comments

Comments
 (0)