[package]
name = "kymostudio-core"
version = "0.4.3"
edition = "2021"
rust-version = "1.74"
description = "Type it. See it appear. Watch it animate. (Core)"
license = "Apache-2.0"
repository = "https://github.com/kymostudio/kymostudio"
homepage = "https://github.com/kymostudio/kymostudio"
readme = "README.md"
keywords = ["svg", "png", "rasterizer", "diagram", "resvg"]
categories = ["multimedia::images", "wasm"]

# rlib -> the `kymostudio` CLI crate + tests; cdylib -> Python (pyo3) and wasm
# (wasm-bindgen). The `kymo` binary lives in the sibling `kymostudio` crate.
[lib]
name = "kymostudio_core"
path = "src/lib.rs"
crate-type = ["rlib", "cdylib"]

[dependencies]
# Core SVG engine. system-fonts + memmap-fonts pull in fs/mmap (no good on
# wasm) so they live behind the `system-fonts` feature, OFF for the wasm build.
resvg = { version = "0.47", default-features = false, features = ["text", "raster-images"] }

# Vector SVG→PDF. Brings its OWN usvg/resvg (0.45) — it can't share our resvg
# 0.47's usvg, so the PDF path parses with `svg2pdf::usvg` and the two engines
# coexist. A second SVG engine would ~double the wasm bundle, so this lives
# behind the `pdf` feature (ON for native/python, OFF for wasm).
svg2pdf = { version = "0.13", optional = true }

# Binding deps — each pulled in only by its feature.
pyo3 = { version = "0.28", features = ["extension-module", "abi3-py310"], optional = true }
wasm-bindgen = { version = "0.2", optional = true }

# BPMN stack deps — pure logic (no resvg), pulled in only by the `bpmn` feature.
# roxmltree: read-only DOM whose tag_name().name() yields the *local* name, so the
# importer is namespace-agnostic exactly like Python's `_local()`. serde_json: the
# canonical model JSON the cross-language conformance suite compares against.
roxmltree = { version = "0.20", optional = true }
serde_json = { version = "1", optional = true }

[dev-dependencies]
# Used by tests/bpmn_conformance.rs to load + compare the shared golden JSON.
serde_json = "1"
# sha256 for the full-corpus SVG-render hash comparison (vs conformance/golden/bpmn_svg.json).
sha2 = "0.10"

[features]
# Native builds (CLI, tests, Python wheel) load system fonts so <text> renders,
# and ship vector PDF output.
default = ["system-fonts", "pdf"]
system-fonts = ["resvg/system-fonts", "resvg/memmap-fonts"]

# Vector SVG→PDF via svg2pdf (native only — see the dep note above).
pdf = ["dep:svg2pdf"]

# Python extension module (maturin builds the cdylib with this on). Includes vector
# PDF and the BPMN stack, so the `_kymostudio_core` wheel exposes svg_to_pdf plus
# bpmn_import/bpmn_layout/bpmn_to_svg.
python = ["dep:pyo3", "system-fonts", "pdf", "bpmn"]

# wasm (browser + Node) — NO system-fonts (no fs/mmap on wasm). Includes pdf so
# the JS CLI has SVG→PDF parity with Python/Rust; this pulls a second SVG engine
# (svg2pdf's usvg 0.45) into the bundle — text still needs fonts embedded in the
# SVG since system fonts aren't available on wasm. Includes bpmn so the JS library
# delegates BPMN import/export/layout/render to this one source of truth (adds
# roxmltree + serde_json, ~+100KB).
wasm = ["dep:wasm-bindgen", "pdf", "bpmn"]

# BPMN import/export/layout/shapes — the single-source-of-truth stack. On for
# native builds + the Python wheel; validated by tests/bpmn_conformance.rs against
# the shared conformance/golden/ JSON. Pure Rust (no resvg dependency).
bpmn = ["dep:roxmltree", "dep:serde_json"]

[profile.release]
opt-level = 3
lto = true
strip = true

# wasm-pack post-processing. wasm-opt is disabled for deterministic builds
# across environments (the prebuilt binary is flaky on some hosts); re-enable
# once a pinned wasm-opt is wired into CI to shrink the ~2.4 MB module.
[package.metadata.wasm-pack.profile.release]
wasm-opt = false
