[workspace]
members = ["crates/ruviz-gpui", "crates/ruviz-web", "python"]
# Keep plain root cargo commands focused on the cross-platform core crate.
default-members = ["."]
resolver = "2"

# Temporary workspace-wide GPUI override while crates.io still ships gpui 0.2.2.
# This applies on every target because `[patch.crates-io]` cannot be target-gated;
# the specific fix we need is the macOS right-drag delivery change from
# https://github.com/zed-industries/zed/pull/49637.
[patch.crates-io]
gpui = { git = "https://github.com/zed-industries/zed", rev = "3060e4170ea5ef0e6886b9ac1853aaead9ddd59f" }

[package]
name = "ruviz"
version = "0.4.1"
edition = "2024"
rust-version = "1.92"
authors = ["Ruviz Contributors"]
description = "High-performance 2D plotting library for Rust"
license = "MIT OR Apache-2.0"
keywords = ["plotting", "visualization", "graphics", "charts"]
categories = ["visualization", "graphics"]
repository = "https://github.com/Ameyanagi/ruviz"
readme = "README.md"
exclude = [
    # Repo-only generated preview artifacts. Keep only lightweight metadata in
    # git, and do not ship the generated tree in the crates.io package.
    "generated/",
    "docs/assets/gallery/",
    "docs/assets/rustdoc/",
    "docs/gallery/",
    "tests/",
    "benches/",
    "*.log",
    ".github/",
]

[dependencies]
# Core rendering
tiny-skia = "0.12"
tiny-skia-path = "0.12"

# Math & geometry
glam = "0.32"
nalgebra = { version = "0.34", optional = true }

# Color management
palette = "0.7"

# Text rendering - unified on cosmic-text (pure Rust)
cosmic-text = "0.16"  # Professional text layout, shaping, and font discovery
unicode-width = "0.2"
typst = { version = "0.13.1", optional = true }
typst-svg = { version = "0.13.1", optional = true }
typst-render = { version = "0.13.1", optional = true }
typst-kit = { version = "0.13.1", default-features = false, features = ["fonts", "embed-fonts"], optional = true }

# Data structures (optional)
ndarray = { version = "0.17", optional = true }
polars = { version = "0.50", optional = true }

# Image I/O
image = { version = "0.25", default-features = false, features = ["png"] }

# PDF export (SVG → PDF pipeline)
svg2pdf = { version = "0.13", optional = true }  # Uses usvg 0.43 internally

# Error handling
thiserror = "2.0"
anyhow = "1.0"

# Serialization (for themes/configs)
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }

# Performance optimization
rayon = { version = "1.11", optional = true }
num_cpus = "1.17"

# GPU acceleration (optional)
wgpu = { version = "29.0", optional = true }
bytemuck = { version = "1.25", optional = true }
wgsl_bindgen = { version = "0.21", optional = true }
pollster = { version = "0.4", optional = true }
futures-intrusive = { version = "0.5", optional = true }

# Logging
log = "0.4"

# SIMD optimization
wide = { version = "0.7", optional = true }

# Window support (optional)
winit = { version = "0.30", optional = true }
raw-window-handle = { version = "0.6", optional = true }
softbuffer = { version = "0.4", optional = true }
arboard = { version = "3.6.1", optional = true }

# Animation export
gif = { version = "0.14", optional = true }
color_quant = { version = "1.1", optional = true }
crossbeam-channel = { version = "0.5", optional = true }

# High-quality GIF (optional)
gifski = { version = "1.34", optional = true }

# Pure Rust video encoding (optional)
rav1e = { version = "0.8", optional = true, default-features = false }
av1-grain = { version = "0.4", optional = true }

# FreeBSD support
[target.'cfg(target_os = "freebsd")'.dependencies]
ctor = "0.8"
rfd = { version = "=0.15.4", optional = true, default-features = false, features = ["gtk3"] } # pinned while keeping Linux dialogs on the repo MSRV

[target.'cfg(target_os = "linux")'.dependencies]
rfd = { version = "=0.15.4", optional = true, default-features = false, features = ["gtk3"] } # pinned while keeping Linux dialogs on the repo MSRV

[target.'cfg(target_os = "macos")'.dependencies]
rfd = { version = "=0.15.4", optional = true, default-features = false } # pinned while keeping desktop dialogs on the repo MSRV

[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.61", features = ["Win32_Storage_FileSystem"] }
rfd = { version = "=0.15.4", optional = true, default-features = false } # pinned while keeping desktop dialogs on the repo MSRV

[dev-dependencies]
criterion = { version = "0.8", features = ["html_reports"] }
approx = "0.5"
tempfile = "3.27"
rand = "0.10"
tokio = { version = "1.50", features = ["full"] }
env_logger = "0.11"
regex = "1"
proptest = "1.11"
trybuild = "1.0"
sha2 = "0.10"
plotters = { version = "0.3.7", default-features = false, features = ["bitmap_backend", "line_series"] }

[features]
default = ["ndarray", "parallel"]

# Display and window features
window = ["winit", "raw-window-handle", "dep:softbuffer", "dep:rfd", "dep:arboard"]
interactive = ["window"]  # Interactive mode WITHOUT GPU (decoupled)
interactive-gpu = ["interactive", "gpu"]  # Interactive mode WITH GPU acceleration

# Serialization
serde = ["dep:serde", "serde_json", "palette/serde"]

# Data format support
ndarray_support = ["ndarray"]
polars_support = ["polars"]
nalgebra_support = ["dep:nalgebra"]
# Backward-compatibility alias (historical feature name)
nalgebra = ["nalgebra_support"]

# Performance optimization features
parallel = ["rayon"]
gpu = ["wgpu", "bytemuck", "wgsl_bindgen", "pollster", "futures-intrusive"]
simd = ["wide"]
performance = ["parallel", "simd"]

# Export format features
svg = []
pdf = ["svg2pdf"]
typst-math = ["dep:typst", "dep:typst-svg", "dep:typst-render", "dep:typst-kit"]

# Animation export features
animation = ["gif", "color_quant", "crossbeam-channel"]
animation-gif = ["animation"]
animation-hq-gif = ["animation", "gifski"]
animation-video = ["animation", "rav1e", "av1-grain"]

# Full feature set
full = ["ndarray_support", "polars_support", "nalgebra_support", "window", "serde", "performance", "gpu", "svg", "pdf", "interactive-gpu", "animation", "typst-math"]

[profile.release]
lto = true
codegen-units = 1

[profile.bench]
debug = true

[[bin]]
name = "generate_gallery"
path = "scripts/generate_gallery.rs"

# Gallery Examples
[[example]]
name = "basic_example"
path = "gallery/basic/basic_example.rs"

[[example]]
name = "simple_visual_test"
path = "gallery/basic/simple_visual_test.rs"

[[example]]
name = "axis_legend_test"
path = "gallery/basic/axis_legend_test.rs"

[[example]]
name = "legend_handles_test"
path = "gallery/basic/legend_handles_test.rs"

[[example]]
name = "legend_scatter_test"
path = "gallery/basic/legend_scatter_test.rs"

[[example]]
name = "legend_rounded_test"
path = "gallery/basic/legend_rounded_test.rs"

[[example]]
name = "legend_horizontal_test"
path = "gallery/basic/legend_horizontal_test.rs"

[[example]]
name = "font_demo"
path = "gallery/advanced/font_demo.rs"

[[example]]
name = "simple_publication_test"
path = "gallery/publication/simple_publication_test.rs"

[[example]]
name = "legend_features_example"
path = "gallery/publication/legend_features_example.rs"

[[example]]
name = "scientific_plotting"
path = "gallery/scientific/scientific_plotting.rs"

[[example]]
name = "subplot_example"
path = "examples/subplot_example.rs"

# Performance examples
[[example]]
name = "million_points"
path = "examples/performance/million_points.rs"

[[example]]
name = "streaming_demo"
path = "examples/performance/streaming_demo.rs"

[[example]]
name = "scaling_benchmark"
path = "examples/performance/scaling_benchmark.rs"

[[example]]
name = "plotting_benchmark_runner"
path = "examples/performance/plotting_benchmark_runner.rs"
required-features = ["serde"]

# GPU examples (require gpu feature)
[[example]]
name = "gpu_api_test"
path = "examples/gpu_api_test.rs"
required-features = ["gpu"]

[[example]]
name = "gpu_benchmark"
path = "examples/gpu_benchmark.rs"
required-features = ["gpu"]

[[example]]
name = "gpu_debug_test"
path = "examples/gpu_debug_test.rs"
required-features = ["gpu"]

[[example]]
name = "gpu_integration_test"
path = "examples/gpu_integration_test.rs"
required-features = ["gpu"]

[[example]]
name = "gpu_memory_test"
path = "examples/gpu_memory_test.rs"
required-features = ["gpu"]

[[example]]
name = "gpu_performance_plot"
path = "examples/gpu_performance_plot.rs"
required-features = ["gpu"]

[[example]]
name = "gpu_plot_example"
path = "examples/gpu_plot_example.rs"
required-features = ["gpu"]

[[example]]
name = "gpu_scaling_benchmark"
path = "examples/gpu_scaling_benchmark.rs"
required-features = ["gpu"]

[[example]]
name = "gpu_vs_cpu_benchmark"
path = "examples/gpu_vs_cpu_benchmark.rs"
required-features = ["gpu"]

[[example]]
name = "wgpu_test"
path = "examples/wgpu_test.rs"
required-features = ["gpu"]

[[example]]
name = "simple_scaling_test"
path = "examples/simple_scaling_test.rs"
required-features = ["gpu"]

[[example]]
name = "performance_data_collector"
path = "examples/performance_data_collector.rs"
required-features = ["gpu"]

[[example]]
name = "minimal_gpu_benchmark"
path = "examples/minimal_gpu_benchmark.rs"
required-features = ["gpu"]

# PDF examples (require pdf feature)
[[example]]
name = "pdf_export_example"
path = "examples/pdf_export_example.rs"
required-features = ["pdf"]

# Interactive examples (require interactive feature)
[[example]]
name = "basic_interaction"
path = "examples/basic_interaction.rs"
required-features = ["interactive"]

[[example]]
name = "data_brushing"
path = "examples/data_brushing.rs"
required-features = ["interactive"]

[[example]]
name = "interactive_heatmap"
path = "examples/interactive_heatmap.rs"
required-features = ["interactive"]

[[example]]
name = "interactive_multi_series"
path = "examples/interactive_multi_series.rs"
required-features = ["interactive"]

[[example]]
name = "interactive_scatter_clusters"
path = "examples/interactive_scatter_clusters.rs"
required-features = ["interactive"]

[[example]]
name = "reactive_example"
path = "examples/reactive_example.rs"
required-features = ["interactive"]

[[example]]
name = "real_time_performance"
path = "examples/real_time_performance.rs"
required-features = ["interactive"]

# Animation examples (require animation feature)
[[example]]
name = "animation_basic"
path = "examples/animation_basic.rs"
required-features = ["animation"]

[[example]]
name = "animation_easing"
path = "examples/animation_easing.rs"
required-features = ["animation"]

[[example]]
name = "animation_reactive"
path = "examples/animation_reactive.rs"
required-features = ["animation"]

[[example]]
name = "animation_simple"
path = "examples/animation_simple.rs"
required-features = ["animation"]

[[example]]
name = "animation_wave"
path = "examples/animation_wave.rs"
required-features = ["animation"]

[[example]]
name = "generate_animation_gallery"
path = "examples/generate_animation_gallery.rs"
required-features = ["animation"]

# Benchmarks
[[bench]]
name = "memory_pool_benchmarks"
harness = false


[[bench]]
name = "simple_memory_benchmark"
harness = false

[[bench]]
name = "baseline_benchmarks"
harness = false

[[bench]]
name = "memory_benchmarks"
harness = false

[[bench]]
name = "plot_traits"
harness = false
