[package]
name = "kreuzberg"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
authors.workspace = true
description = "High-performance document intelligence library for Rust. Extract text, metadata, and structured data from PDFs, Office documents, images, and 75+ formats with async/sync APIs."
license.workspace = true
repository = "https://github.com/kreuzberg-dev/kreuzberg"
homepage = "https://kreuzberg.dev"
documentation = "https://docs.rs/kreuzberg"
keywords = ["document", "extraction", "pdf", "ocr", "parser"]
categories = ["parser-implementations", "text-processing"]
readme = "README.md"

[lib]
crate-type = ["rlib"]

[features]
default = ["tokio-runtime", "simd-utf8"]

profiling = ["dep:pprof"]

pool-metrics = []

simd-utf8 = ["dep:simdutf8"]

tokio-runtime = ["dep:tokio"]

pdf = ["dep:pdfium-render", "dep:lopdf", "dep:image"]
static-pdfium = ["pdf"]
bundled-pdfium = ["pdf"]
system-pdfium = ["pdf"]
excel = ["dep:calamine", "tokio-runtime"]
excel-wasm = ["dep:calamine"]
office = [
    "dep:cfb",
    "dep:roxmltree",
    "dep:zip",
    "dep:quick-xml",
    "dep:pulldown-cmark",
    "dep:biblatex",
    "dep:biblib",
    "dep:org",
    "html",
]
email = ["dep:mail-parser", "dep:cfb"]
html = ["dep:html-to-markdown-rs"]
xml = ["dep:quick-xml", "dep:roxmltree"]
archives = ["dep:zip", "dep:tar", "dep:sevenz-rust2", "dep:flate2"]
mdx = ["dep:pulldown-cmark"]

ocr = [
    "dep:kreuzberg-tesseract",
    "dep:image",
    "dep:tiff",
    "dep:fast_image_resize",
    "dep:kamadak-exif",
    "dep:hayro-jpeg2000",
    "dep:hayro-jbig2",
    "html",
]
# Minimal OCR for WASM: Tesseract + basic image support, without heavy native deps
# (tiff, fast_image_resize, kamadak-exif)
ocr-wasm = ["dep:kreuzberg-tesseract", "dep:image", "dep:hayro-jpeg2000", "dep:hayro-jbig2"]
# PaddleOCR via ONNX Runtime
# Requires 'ocr' feature for shared conversion utilities and table reconstruction
paddle-ocr = [
    "dep:kreuzberg-paddle-ocr",
    "dep:sha2",
    "dep:image",
    "dep:hf-hub",
    "html",
    "tokio-runtime",
    "ocr",
]
language-detection = ["dep:whatlang"]
chunking = ["dep:text-splitter"]
embeddings = ["dep:fastembed", "dep:reqwest", "chunking", "tokio-runtime"]
stopwords = []
quality = ["dep:unicode-normalization", "dep:chardetng", "stopwords"]

keywords-yake = ["dep:yake-rust", "stopwords"]
keywords-rake = ["dep:rake", "stopwords"]
keywords = ["keywords-yake", "keywords-rake"]

api = ["dep:axum", "dep:tower", "dep:tower-http", "dep:utoipa", "tokio-runtime", "chunking"]
mcp = ["dep:rmcp", "tokio-runtime"]
mcp-http = ["mcp", "api"]

otel = ["dep:opentelemetry", "dep:opentelemetry_sdk", "dep:tracing-opentelemetry"]

wasm-target = [
    "pdf",
    "html",
    "xml",
    "email",
    "language-detection",
    "chunking",
    "quality",
    "office",
    "mdx",
    "excel-wasm",
    "archives",
]
wasm-threads = ["dep:wasm-bindgen-rayon"]

full = [
    "pdf",
    "excel",
    "office",
    "email",
    "html",
    "xml",
    "archives",
    "ocr",
    "paddle-ocr",
    "language-detection",
    "chunking",
    "embeddings",
    "quality",
    "keywords",
    "mdx",
    "api",
    "mcp",
    "otel",
]
server = ["pdf", "excel", "html", "ocr", "paddle-ocr", "chunking", "api", "mcp"]

[build-dependencies]
tracing = { workspace = true }
pkg-config = "0.3"

[dependencies]
ahash = { workspace = true }
async-trait = { workspace = true }
base64 = { workspace = true }
bitvec = "1.0"
bytes = { workspace = true }
dashmap = "6.1"
simdutf8 = { version = "0.1", optional = true }
hex = { workspace = true }
lazy_static = { workspace = true }
libc = { workspace = true }
memchr = "2.8.0"
num_cpus = { workspace = true }
once_cell = { workspace = true }
parking_lot = { workspace = true }
pastey = "0.2"
rayon = { workspace = true }
regex = "1.12.3"
serde = { workspace = true }
serde_json = { workspace = true }
serde_yaml_ng = "0.10.0"
jotdown = "0.9"
toml = { workspace = true }
mime_guess = "2.0"
rmp-serde = "1.3"
thiserror = { workspace = true }
tokio = { workspace = true, optional = true }
indexmap = "2.13.0"
tracing = { workspace = true }
pdfium-render = { workspace = true, features = ["thread_safe", "image_latest"], optional = true }
lopdf = { version = "0.39.0", optional = true }
calamine = { version = "0.33.0", features = ["dates"], optional = true }

roxmltree = { version = "0.21.1", optional = true }
zip = { version = "8.2.0", optional = true, default-features = false, features = [
    "deflate-flate2",
] }
mail-parser = { version = "0.11.2", optional = true }
html-to-markdown-rs = { workspace = true, features = [
    "inline-images",
    "metadata",
], optional = true }
cfb = { version = "0.14.0", optional = true }
quick-xml = { version = "0.39.2", features = ["serialize"], optional = true }
tar = { version = "0.4.44", optional = true }
sevenz-rust2 = { version = "0.20.2", optional = true }
flate2 = { version = "1.1", optional = true }

pulldown-cmark = { version = "0.13", optional = true }
biblatex = { version = "0.11", optional = true }
biblib = { version = "0.4", default-features = false, features = [
    "ris",
    "pubmed",
    "xml",
    "regex",
], optional = true }
org = { version = "0.3", optional = true }

kreuzberg-tesseract = { path = "../kreuzberg-tesseract", version = "4.3", optional = true }
image = { workspace = true, default-features = false, features = [
    "png",
    "jpeg",
    "webp",
    "bmp",
    "tiff",
    "gif",
    "pnm",
    "rayon",
], optional = true }
tiff = { version = "0.11", optional = true }
fast_image_resize = { version = "6.0.0", optional = true }
kamadak-exif = { version = "0.6.1", optional = true }
hayro-jpeg2000 = { version = "0.3", default-features = false, features = [
    "std",
    "simd",
], optional = true }
hayro-jbig2 = { version = "0.1", default-features = false, features = ["std"], optional = true }
whatlang = { version = "0.18.0", optional = true }
text-splitter = { version = "0.29.3", features = ["markdown"], optional = true }
unicode-normalization = { version = "0.1.25", optional = true }
chardetng = { version = "0.1.17", optional = true }
encoding_rs = { version = "0.8.35" }
yake-rust = { version = "1.0.3", optional = true }
rake = { version = "0.3.6", optional = true }
axum = { version = "0.8", features = ["macros", "json", "multipart"], optional = true }
tower = { version = "0.5", optional = true }
tower-http = { version = "0.6", features = ["cors", "trace", "limit"], optional = true }
utoipa = { version = "5.4", features = ["axum_extras"], optional = true }
rmcp = { version = "1.1.0", features = [
    "server",
    "macros",
    "base64",
    "transport-io",
    "transport-streamable-http-server",
    "server-side-http",
], optional = true }
opentelemetry = { version = "0.31", features = ["trace"], optional = true }
opentelemetry_sdk = { version = "0.31", features = ["rt-tokio"], optional = true }
tracing-opentelemetry = { version = "0.32", optional = true }
infer = "0.19.0"
sha2 = { version = "0.10", optional = true }

[dev-dependencies]
tempfile = { workspace = true }
filetime = "0.2"
tar = "0.4.44"
zip = { version = "8.2.0", default-features = false, features = ["deflate-flate2"] }
serial_test = "3.4.0"
anyhow = { workspace = true }
tokio-test = "0.4"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
criterion = { workspace = true }
image = { workspace = true, default-features = false, features = ["png"] }

[target.'cfg(all(not(target_os = "windows"), not(target_arch = "wasm32")))'.dependencies]
pprof = { version = "0.15.0", features = ["flamegraph"], optional = true }
# PaddleOCR via ONNX Runtime - not available on WASM (vendored from paddle-ocr-rs)
kreuzberg-paddle-ocr = { path = "../kreuzberg-paddle-ocr", version = "4.3", optional = true }
# Use rustls on non-Windows platforms (Linux, macOS)
# Blocking feature needed for model downloads
reqwest = { workspace = true, default-features = false, features = [
    "json",
    "rustls",
    "blocking",
], optional = true }
# Use rustls-tls for fastembed on non-Windows platforms
fastembed = { version = "5.11", default-features = false, features = [
    "hf-hub-rustls-tls",
    "ort-load-dynamic",
], optional = true }
hf-hub = { version = "0.5", default-features = false, features = ["ureq"], optional = true }
# Force ureq (transitive dep via hf-hub) to use rustls on non-Windows
ureq = { version = "3.2", default-features = false, features = ["rustls", "json"] }

# Use native-tls on Windows to avoid aws-lc-sys CMake build issues with MinGW
[target.'cfg(all(target_os = "windows", not(target_arch = "wasm32")))'.dependencies]
# PaddleOCR via ONNX Runtime - not available on WASM (vendored from paddle-ocr-rs)
kreuzberg-paddle-ocr = { path = "../kreuzberg-paddle-ocr", version = "4.3", optional = true }
# Blocking feature needed for model downloads
reqwest = { workspace = true, default-features = false, features = [
    "json",
    "native-tls",
    "blocking",
], optional = true }
# Use native-tls for fastembed on Windows
fastembed = { version = "5.11", default-features = false, features = [
    "hf-hub-native-tls",
    "ort-load-dynamic",
], optional = true }
hf-hub = { version = "0.5", default-features = false, features = ["ureq"], optional = true }
# Force ureq (transitive dep via hf-hub) to use native-tls on Windows
ureq = { version = "3.2", default-features = false, features = ["native-tls", "json"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-rayon = { version = "1.3", optional = true }
# Override getrandom to enable js feature for WASM targets
# This is needed because ring/rustls (via ureq) depend on getrandom without js feature
getrandom = { workspace = true }

[package.metadata.cargo-machete]
ignored = ["opentelemetry", "opentelemetry_sdk", "tracing-opentelemetry", "kamadak-exif"]
