Skip to content
Merged
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
7 changes: 2 additions & 5 deletions .github/workflows/electron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ jobs:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
Expand All @@ -24,7 +23,5 @@ jobs:
sudo apt-get update
sudo apt-get install -y xvfb libx11-dev pkg-config libpipewire-0.3-dev libspa-0.2-dev
- run: pnpm install
- name: Magnifier Test
run: pnpm test:magnifier
- name: Electron Test
run: xvfb-run --auto-servernum pnpm test:electron
run: xvfb-run --auto-servernum pnpm test:electron
8 changes: 6 additions & 2 deletions .github/workflows/ember.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ jobs:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: 'pnpm'
- run: pnpm install
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libx11-dev pkg-config libpipewire-0.3-dev libspa-0.2-dev
- run: pnpm install
- name: Ember Test
run: pnpm test:ember
8 changes: 6 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ jobs:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: 'pnpm'
- run: pnpm install
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libx11-dev pkg-config libpipewire-0.3-dev libspa-0.2-dev
- run: pnpm install
- name: Lint
run: pnpm lint
16 changes: 10 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ jobs:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: 'pnpm'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y xvfb libx11-dev pkg-config libpipewire-0.3-dev libspa-0.2-dev
- run: pnpm install
- name: Lint JS
run: pnpm lint:js
- name: Lint HBS
run: pnpm lint:hbs
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y xvfb libpipewire-0.3-dev libspa-0.2-dev libx11-dev pkg-config
- name: Browser Test
run: pnpm test:ember
- name: Electron Test
Expand All @@ -38,16 +40,18 @@ jobs:
matrix:
os: [macos-15-intel, ubuntu-24.04, ubuntu-24.04-arm, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: 'pnpm'
- run: pnpm install
- name: Install Linux dependencies
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get update && sudo apt-get install -y libpipewire-0.3-dev libx11-dev
run: |
sudo apt-get update
sudo apt-get install -y libx11-dev pkg-config libpipewire-0.3-dev libspa-0.2-dev
- run: pnpm install
- name: Add macOS certs
if: startsWith(matrix.os, 'macos') && startsWith(github.ref, 'refs/tags/')
run: chmod +x add-osx-cert.sh && ./add-osx-cert.sh
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/rust-tests.yml

This file was deleted.

1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# compiled output
/dist/
/electron-app/dist/
/electron-app/magnifier/rust-sampler/target/

# misc
/coverage/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You will need the following things properly installed on your computer.
- [pnpm](https://pnpm.io/)
- [Ember CLI](https://ember-cli.com/)
- [Google Chrome](https://google.com/chrome/)
- [Rust](https://www.rust-lang.org/) (for building the pixel sampler)
- [Rust](https://www.rust-lang.org/) (for building the hue-hunter color picker)

### Linux System Requirements

Expand All @@ -46,7 +46,7 @@ sudo apt-get install scrot xdotool
sudo apk add libxcb libxrandr dbus grim
```

**Wayland Users:** The `grim` tool is required for screenshot-based color picking on Wayland. See [rust-sampler/README.md](rust-sampler/README.md) for more details.
**Wayland Users:** The color picker uses PipeWire + XDG Portal on Wayland (no external tools needed). See the [hue-hunter README](https://github.com/RobbieTheWagner/hue-hunter) for more details.

## Installation

Expand Down
64 changes: 25 additions & 39 deletions WARP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,26 @@ This file provides guidance to WARP (warp.dev) when working with code in this re

## About Swach

Swach is a modern color palette manager built as a menubar/system tray Electron app with an Ember.js frontend. It features color picking with a pixel-perfect magnifier, palette management, contrast checking, and cloud sync.
Swach is a modern color palette manager built as a menubar/system tray Electron app with an Ember.js frontend. It features color picking with a pixel-perfect magnifier (powered by the hue-hunter package), palette management, contrast checking, and cloud sync.

## Common Commands

### Development
- `pnpm start` - Start Ember web app only (dev server at http://localhost:4200)
- `pnpm start:electron` - Start Electron app with hot-reload (builds Rust sampler in dev mode)
- `pnpm build:rust:dev` - Build Rust pixel sampler for development (with x11 and wayland features)
- `pnpm start:electron` - Start Electron app with hot-reload

### Testing
- `ember test` - Run Ember tests once
- `ember test --server` - Run Ember tests in watch mode
- `pnpm test:ember` - Build and run Ember tests in CI mode
- `pnpm test:electron` - Build, package, and run Electron tests (includes Rust build for CI with x11 only)
- `pnpm test:magnifier` - Run magnifier unit tests (vitest)
- `pnpm test:magnifier:watch` - Run magnifier tests in watch mode
- `pnpm test:rust` - Run Rust sampler tests
- `pnpm test:electron` - Build, package, and run Electron tests

### Linting & Formatting
- `pnpm lint` - Run all linters (JS, CSS, templates, types)
- `pnpm lint:fix` - Auto-fix all linting issues and format code
- `pnpm format` - Format code with Prettier

### Building & Packaging
- `pnpm build:rust` - Build production Rust sampler (with x11 and wayland features)
- `pnpm build:rust:ci` - Build Rust sampler for CI (x11 only, no wayland)
- `pnpm package` - Package Electron app for current platform (creates app bundle)
- `pnpm make` - Create distributable packages (DMG, deb, etc.) for current platform

Expand All @@ -44,7 +38,7 @@ Swach is a modern color palette manager built as a menubar/system tray Electron
- **Desktop**: Electron with Electron Forge (menubar app using `menubar` package)
- **Data Layer**: Orbit.js (client-side ORM with sync strategies)
- **Storage**: IndexedDB (local), AWS Cognito + API Gateway (cloud sync)
- **Color Picker**: Custom Rust binary for cross-platform pixel sampling
- **Color Picker**: hue-hunter package (cross-platform magnifying color picker with Rust-powered pixel sampling)

### Ember + Electron Integration

Expand Down Expand Up @@ -72,14 +66,15 @@ Configuration logic is in `config/environment.js`.

2. **Production** (`pnpm package` or `pnpm make`):
- Sets `EMBER_CLI_ELECTRON=true` environment variable
- Builds hue-hunter Rust sampler binary
- Ember renderer built by Embroider + Vite
- Electron main process built (`electron-app/main.ts`)
- Preload scripts built (`electron-app/src/preload.ts`, `electron-app/magnifier/magnifier-preload.ts`)
- Rust sampler binary included as `extraResource` in forge config
- Preload scripts built (`electron-app/src/preload.ts`)
- hue-hunter sampler binary included as `extraResource` in forge config
- Everything bundled into ASAR archive

Forge config: `forge.config.ts`
Vite configs: `vite.renderer.config.ts`, `vite.main.config.ts`, `vite.preload.config.ts`, `vite.magnifier.config.ts`
Vite configs: `vite.renderer.config.ts`, `vite.main.config.ts`, `vite.preload.config.ts`

### Data Architecture (Orbit.js)

Expand Down Expand Up @@ -125,17 +120,16 @@ Coordinate data flow between sources. Key strategies:
- Settings management (dock icon, auto-start)
- Export/import functionality

**Magnifier/Color Picker**:
- Separate BrowserWindow overlaid on screen
- Rust binary (`electron-app/magnifier/rust-sampler/`) for pixel sampling
- Communicates via stdin/stdout JSON protocol
**Color Picker**:
- Uses the `hue-hunter` npm package (https://github.com/RobbieTheWagner/hue-hunter)
Comment thread
RobbieTheWagner marked this conversation as resolved.
- Provides magnifying glass interface with Rust-powered pixel sampling
- Platform-specific implementations:
- macOS: Core Graphics APIs
- Linux X11: XGetImage/XGetPixel (native, no deps)
- Linux Wayland: XDG Portal + PipeWire (persistent token)
- Linux Wayland: XDG Portal + PipeWire (persistent token saved to `~/.local/share/hue-hunter/screencast-token`)
- Windows: GDI GetPixel API
- Manager: `electron-app/magnifier/rust-sampler-manager.ts`
- See `electron-app/magnifier/rust-sampler/README.md` for details
- Integration: `electron-app/src/color-picker.ts` uses `ColorPicker` class from hue-hunter
- Color naming via `color-name-list` and `nearest-color` packages

### Authentication & Cloud Sync

Expand All @@ -157,7 +151,7 @@ Coordinate data flow between sources. Key strategies:
### Component Structure

**Key Components** (`app/components/`):
- Color picker/magnifier integration components
- Color picker integration (launches hue-hunter picker via IPC)
- Palette management (create, edit, delete, reorder)
- Color contrast checker
- Settings panels (cloud, data management)
Expand Down Expand Up @@ -186,31 +180,23 @@ Coordinate data flow between sources. Key strategies:
- Test selectors via ember-test-selectors
- Testem for test running (Chrome in CI, Electron for electron-specific tests)

**Magnifier Tests**:
- Vitest for TypeScript magnifier code (`electron-app/magnifier/`)
- Unit tests for grid calculation, pixel utils, rust manager

**Rust Tests**:
- Cargo test for Rust sampler logic

## Important Notes

### EMBER_CLI_ELECTRON Environment Variable
This is the critical flag that switches between web and Electron modes. Always set it to `true` when packaging/building for Electron. Already configured in `package.json` scripts for `package` and `make` commands.

### Rust Sampler Binary
- Must be built before packaging: `pnpm build:rust`
- Development builds: `pnpm build:rust:dev` (includes both x11 and wayland)
- CI builds: `pnpm build:rust:ci` (x11 only, for faster CI builds)
- Location in development: `electron-app/magnifier/rust-sampler/target/[debug|release]/swach-sampler[.exe]`
- Location in production: `<app.resourcesPath>/swach-sampler[.exe]`
- Bundled via `extraResource` in `forge.config.ts`
### hue-hunter Color Picker
- Built via `pnpm build:hue-hunter` (automatically called by `package` and `make` commands)
- Binary location: `node_modules/hue-hunter/rust-sampler/target/release/hue-hunter-sampler[.exe]`
- Bundled to production as `extraResource` in `forge.config.ts`
- See hue-hunter README for Rust sampler details: https://github.com/RobbieTheWagner/hue-hunter

### Linux Platform Considerations
- X11 and Wayland support via Rust sampler feature flags
- X11 and Wayland support via hue-hunter's Rust sampler
- X11: Native direct capture (fast, no deps)
- Wayland: PipeWire + Portal (requires permission on first use, token saved to `~/.local/share/swach/screencast-token`)
- Build dependencies: `libx11-dev`, `libpipewire-0.3-dev` (see rust-sampler README)
- Wayland: PipeWire + Portal (requires permission on first use, token saved to `~/.local/share/hue-hunter/screencast-token`)
- Build dependencies: `libx11-dev`, `libpipewire-0.3-dev` (see hue-hunter README)
- Runtime: `libxcb1`, `libxrandr2`, `libdbus-1-3` auto-installed with .deb package

### Code Signing & Notarization
Expand Down Expand Up @@ -238,8 +224,8 @@ The `SCHEMA_VERSION` in `config/environment.js` can be incremented to trigger mi
## File Organization

- `app/` - Ember application code (components, routes, services, models, styles)
- `electron-app/` - Electron main process, IPC handlers, magnifier implementation
- `electron-app/magnifier/rust-sampler/` - Rust binary for pixel sampling
- `electron-app/` - Electron main process, IPC handlers, color picker integration
- `electron-app/src/color-picker.ts` - Color picker integration using hue-hunter
- `config/` - Ember environment configuration
- `tests/` - Ember test suite
- `public/` - Static assets (copied to build output)
Expand Down
Loading