Files
koring-launcher/AGENTS.md
T

57 lines
2.4 KiB
Markdown
Raw Normal View History

2026-06-19 23:50:40 +08:00
# koring-launcher
2026-06-28 03:37:07 +08:00
Minecraft launcher built with Electron + React 19 + TypeScript + Node.js (@xmcl).
2026-06-19 23:50:40 +08:00
## Quick commands
```bash
2026-06-28 03:37:07 +08:00
pnpm dev # full app dev (renderer + main process)
pnpm dev:renderer # frontend only (vite, port 1420)
pnpm dev:main # electron main process only
pnpm build # production build (vite + tsc)
pnpm dist:win # build Windows installer
2026-06-19 23:50:40 +08:00
```
## Architecture
- **Frontend** (`src/`): React 19 + Vite 7 + Tailwind v4 + shadcn/ui + Zustand stores
2026-06-28 03:37:07 +08:00
- **Main Process** (`electron/`): Node.js/TypeScript, manages windows, IPC handlers, @xmcl/* packages
- IPC: Frontend → `ipcRenderer.invoke()``ipcMain.handle()` → main process → `webContents.send()` → Frontend
2026-06-19 23:50:40 +08:00
## Key gotchas
2026-06-28 03:37:07 +08:00
- **Electron main process**: `electron/main.ts` is the entry point. All @xmcl/* packages run here.
- **Preload script**: `electron/preload.ts` exposes `window.electronAPI` via context bridge.
- **IPC handlers**: All handlers are in `electron/handlers/` directory.
- **Config**: YAML format (`Koring.yml`) stored next to executable. Sparse save (only non-default values).
- **Auth**: JSON file (`koring-auth.json`) stored next to executable.
2026-06-19 23:50:40 +08:00
- **Path alias**: `@/` maps to `src/` (configured in `vite.config.ts` and `tsconfig.json`).
2026-06-28 03:37:07 +08:00
- **Dev mode**: Vite runs on port 1420, Electron loads from localhost.
2026-06-19 23:50:40 +08:00
## Build & bundle
```bash
2026-06-28 03:37:07 +08:00
pnpm build # Vite build + TypeScript compile
pnpm dist:win # electron-builder Windows installer
pnpm dist:mac # electron-builder macOS DMG
pnpm dist:linux # electron-builder Linux AppImage
2026-06-19 23:50:40 +08:00
```
2026-06-28 03:37:07 +08:00
## Electron notes
2026-06-19 23:50:40 +08:00
2026-06-28 03:37:07 +08:00
- `electron/main.ts`: App entry, window management, IPC handler registration
- `electron/preload.ts`: Context bridge for secure IPC
- `electron/config.ts`: YAML config management (sparse save)
- `electron/auth.ts`: Auth data persistence (JSON file)
- `electron/core/`: @xmcl/* integrations (auth, installer, launcher, modrinth, instance)
- `electron/handlers/`: IPC handlers (config, auth, install, launch, mods, instance, background, task, system, window)
2026-06-19 23:50:40 +08:00
2026-06-28 03:37:07 +08:00
## Frontend notes
- `src/api/ipc.ts`: Core IPC utilities (invoke, onIpcEvent)
- `src/api/*.ts`: API modules wrapping IPC calls
- `src/stores/`: Zustand state management
- `src/hooks/useTheme.ts`: Dark mode sync with Electron theme
- `src/components/system/WindowControls.tsx`: Custom window controls (min/max/close)
- `src/components/system/TitleBar.tsx`: Custom title bar with navigation