Skip to content

benalf/d2see

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

d2see

A simple, lightweight live-reload server for D2 diagrams written in Rust.

Features

  • 🔄 Instant reload - Browser refreshes automatically when you save
  • 🖱️ Pan & zoom - Navigate large diagrams easily
  • Fast - Native file watching with minimal latency
  • 📦 Single binary - No runtime dependencies

Installation

From source

cargo build --release
# Binary will be at ./target/release/d2see

Or install directly

cargo install --path .

Usage

d2see <input.d2> [OPTIONS]

Arguments:
  <input>  Input .d2 file

Options:
  -l, --layout <LAYOUT>    D2 layout engine [default: elk]
  -p, --port <PORT>        Server port (random free port if not specified)
  -b, --browser <BROWSER>  Browser command (e.g. "firefox", "qutebrowser"). Uses system default if not specified
      --no-browser         Don't open browser automatically
  -h, --help               Print help
  -V, --version            Print version

Example

# Watch full-chart.d2 with ELK layout on a free port
d2see full-chart.d2

# Use dagre layout on port 3000
d2see diagram.d2 --layout dagre --port 3000

Workflow

  1. Start the watcher: d2see mydiagram.d2
  2. Default browser automatically opens with a panzoom preview
  3. Edit the .d2 file in your editor (Vim, VS Code, etc.)
  4. Save the file - browser reloads automatically
  5. CTRL+C creates a distributable .html file with embedded panzoom.

Requirements

  • D2 must be installed and available in your PATH
  • A modern web browser

How it works

  1. Uses the notify crate for efficient cross-platform file watching
  2. Runs d2 to compile .d2.svg on each change
  3. Serves an HTML page with the SVG embedded and pan/zoom enabled
  4. Uses Server-Sent Events (SSE) to trigger browser reloads

About

A simple, lightweight live-reload server for [D2](https://d2lang.com/) diagrams written in Rust.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages