Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .env.example

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ out
*.log*
.eslintcache
.env
*.mas.*
*.mas.*
/native/build
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
shamefully-hoist=true
shamefully-hoist=true
registry=http://registry.npmjs.org
92 changes: 92 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

Marchen Player is a local anime video player with danmaku (bullet comments) support. It automatically matches danmaku to imported anime videos. Built with Electron, supporting Web, macOS, Windows, and Linux platforms.

## Development Commands

```bash
# Install dependencies (requires pnpm)
corepack enable
pnpm install

# Development
pnpm dev # Start Electron dev server
pnpm dev:web # Start web-only dev server

# Building
pnpm build # Full build with typecheck
pnpm build:mac # Build macOS (dmg + zip)
pnpm build:win # Build Windows installer
pnpm build:linux # Build Linux AppImage
pnpm build:web # Build web version

# Code quality
pnpm typecheck # Run TypeScript type checking
pnpm lint # Run ESLint
pnpm lint:fix # Auto-fix ESLint issues
pnpm format # Format with Prettier

# Version management
pnpm bump # Bump version (uses nbump)
```

## Architecture

### Process Structure (Electron)

- **Main Process** (`src/main/`): Node.js backend - window management, file system access, FFmpeg operations
- **Preload** (`src/preload/`): Context bridge exposing `electron`, `api`, and `platform` to renderer
- **Renderer** (`src/renderer/`): React frontend application

### IPC Communication

Uses `@egoist/tipc` for type-safe IPC between main and renderer processes:

- **Main handlers**: `src/main/tipc/` - Define routes (app, player, setting, utils)
- **Renderer client**: `src/renderer/src/lib/client.ts` - `tipcClient` for invoking main process, `handlers` for receiving events
- Routes are combined in `src/main/tipc/index.ts` and exported as `Router` type

Example usage in renderer:
```typescript
import { tipcClient } from '@renderer/lib/client'
const result = await tipcClient?.getAnimeDetailByPath({ path })
```

### State Management

- **Jotai atoms** (`src/renderer/src/atoms/`): Global state for player, progress, window, and settings
- **TanStack Query**: Server state and API data caching
- **Dexie** (`src/renderer/src/database/`): IndexedDB wrapper for local persistence (history)

### Routing

Hash-based routing with React Router v7. Routes defined in `src/renderer/src/router/router.tsx`. Main pages: Player, History.

### Path Aliases

Configured in `electron.vite.config.ts`:
- `@main` → `src/main`
- `@renderer` → `src/renderer/src`
- `@pkg` → `package.json`

### Custom Protocol

Uses `marchen://` protocol for local file access. Files are referenced with `MARCHEN_PROTOCOL_PREFIX` + absolute path.

## Key Dependencies

- **Video**: `@suemor/xgplayer` (custom xgplayer fork), `danmu.js`
- **Subtitles**: `@jellyfin/libass-wasm` (ASS/SSA rendering)
- **Media processing**: `fluent-ffmpeg` with `@ffmpeg-installer/ffmpeg`
- **UI**: Tailwind CSS, shadcn/ui (Radix), DaisyUI, Framer Motion
- **Icons**: Lucide React, Iconify (mingcute)

## Code Style

- ESLint config: `eslint-config-hyoban`
- Prettier: No semicolons, single quotes, 100 char width
- Pre-commit hook runs lint-staged on all staged files
12 changes: 0 additions & 12 deletions build/entitlements.mac.plist

This file was deleted.

Binary file removed build/icon.icns
Binary file not shown.
Binary file removed build/icon.ico
Binary file not shown.
Binary file removed build/icon.png
Binary file not shown.
12 changes: 12 additions & 0 deletions electron.vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ export default defineConfig({
},
preload: {
plugins: [externalizeDepsPlugin()],
resolve: {
alias: {
'@main': resolve('src/main'),
},
},
build: {
rollupOptions: {
external: [
/\.node$/,
],
},
},
},
renderer: {
resolve: {
Expand Down
78 changes: 78 additions & 0 deletions native/binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"targets": [
{
"target_name": "marchen_decoder",
"cflags!": ["-fno-exceptions"],
"cflags_cc!": ["-fno-exceptions"],
"sources": ["decoder.cpp"],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")"
],
"defines": ["NAPI_DISABLE_CPP_EXCEPTIONS"],
"conditions": [
[
"OS=='mac'",
{
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"CLANG_CXX_LIBRARY": "libc++",
"MACOSX_DEPLOYMENT_TARGET": "10.15",
"OTHER_CFLAGS": [
"<!@(pkg-config --cflags libavformat libavcodec libavutil libswscale)"
]
},
"libraries": [
"<!@(pkg-config --libs libavformat libavcodec libavutil libswscale)"
]
}
],
[
"OS=='linux'",
{
"cflags": [
"<!@(pkg-config --cflags libavformat libavcodec libavutil libswscale)"
],
"libraries": [
"<!@(pkg-config --libs libavformat libavcodec libavutil libswscale)"
]
}
],
[
"OS=='win'",
{
"msvs_settings": {
"VCCLCompilerTool": {
"ExceptionHandling": 1,
"AdditionalIncludeDirectories": [
"<(module_root_dir)/deps/ffmpeg/include"
]
},
"VCLinkerTool": {
"AdditionalLibraryDirectories": [
"<(module_root_dir)/deps/ffmpeg/lib"
]
}
},
"libraries": [
"-lavformat",
"-lavcodec",
"-lavutil",
"-lswscale"
],
"copies": [
{
"destination": "<(module_root_dir)/native/build/Release",
"files": [
"<(module_root_dir)/deps/ffmpeg/bin/avformat-61.dll",
"<(module_root_dir)/deps/ffmpeg/bin/avcodec-61.dll",
"<(module_root_dir)/deps/ffmpeg/bin/avutil-59.dll",
"<(module_root_dir)/deps/ffmpeg/bin/swscale-8.dll"
]
}
]
}
]
]
}
]
}
Loading
Loading