ev_lib 0.3.2

EV-invest shared Rust libraries, one per feature
Documentation
[package]
name = "ev_lib"
version = "0.3.2"
edition = "2024"
description = "EV-invest shared Rust libraries, one per feature"
license = "BlueOak-1.0.0"
repository = "https://github.com/EV-invest/lib"

[features]
# Each library is opt-in. No default features: a consumer enables only what it uses.
architecture = ["dep:async-trait", "dep:serde", "dep:uuid", "dep:jiff"]

# Dep-light Dioxus UI kit (mirrors `@evinvest/uikit`). Renderer-agnostic RSX components;
# pulls only Dioxus + tailwind_fuse (the `cn!` engine). Unlike the kernel this
# library carries runtime deps — a UI kit can't be zero-dep; see AGENTS.md.
# `asset` + `document`: the `Fonts` component bundles the brand webfonts via
# `asset!` and injects their `@font-face` through `document::Style`.
uikit = [
    "dep:dioxus",
    "dep:tailwind_fuse",
    "tailwind_fuse?/variant",
    "dep:strum",
    "dioxus?/asset",
    "dioxus?/document",
]

# PostHog product analytics (mirrors `@evinvest/analytics`). A small typed event
# API: native (Axum) async capture over `reqwest`; the Dioxus/wasm frontend POSTs
# the same payload via reqwest's fetch backend (no PostHog JS SDK). Carries runtime
# deps — opt-in, never in the kernel; see AGENTS.md.
analytics = [
    "dep:serde",
    "dep:serde_json",
    "dep:reqwest",
    "dep:dioxus",
    "dep:js-sys",
    "dep:web-sys",
    "dep:wasm-bindgen",
    "dep:wasm-bindgen-futures",
]

# Error monitoring / Sentry (mirrors `@evinvest/error-monitoring`). Native (Axum)
# on the `sentry` crate (+ its tower/tracing integrations); the Dioxus/wasm frontend
# builds a Sentry envelope in pure Rust and POSTs it via fetch, plus a panic hook.
error_monitoring = [
    "dep:serde",
    "dep:serde_json",
    "dep:sentry",
    "dep:reqwest",
    "dep:js-sys",
    "dep:web-sys",
    "dep:wasm-bindgen",
    "dep:wasm-bindgen-futures",
]

# Frontend-only A/B testing (mirrors `@evinvest/experiments`). Cookie-bucketed
# weighted variant assignment for Dioxus; exposure is reported through an injected
# sink, so it never imports `analytics` (no cross-library coupling).
experiments = ["dep:dioxus", "dep:js-sys", "dep:web-sys", "dep:wasm-bindgen"]

# Producer SDK for landing-host microfrontends (see `mfe.rs` + the `mfe!` macro).
# wasm-only: the module is gated to `target_arch = "wasm32"`, so this is inert on
# native. A producer crate enables it; landing never compiles ev_lib at all.
# `wasm` pulls `dioxus?/web` + `web-sys`; `document` is for the bundle's `<link>`.
mfe = ["dep:dioxus", "dep:wasm-bindgen", "dep:js-sys", "dioxus?/document", "wasm"]

# One opt-in switch that layers wasm/browser backends onto whatever other
# features are enabled — each feature contributes its own wasm needs here with
# the `pkg?/feature` syntax (no-op when that feature is off). Enable it
# per-target on the consumer side (`[target.'cfg(target_arch = "wasm32")']`),
# never globally, so native builds don't link browser backends.
wasm = ["uuid?/js", "dioxus?/web", "dep:web-sys"]

[dependencies]
async-trait = { workspace = true, optional = true }
dioxus = { workspace = true, features = ["macro", "html", "signals", "hooks"], optional = true }
jiff = { workspace = true, features = ["serde"], optional = true }
serde = { workspace = true, features = ["derive"], optional = true }
serde_json = { workspace = true, optional = true }
strum = { workspace = true, optional = true }
tailwind_fuse = { workspace = true, optional = true }
uuid = { workspace = true, features = ["serde", "v4"], optional = true }

# Native (non-wasm) backends for the I/O libraries. Kept out of wasm builds so the
# browser target never links a native TLS stack or the `sentry` crate.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
reqwest = { version = "0.13", optional = true, default-features = false, features = ["rustls", "json"] }
sentry = { version = "0.48.2", optional = true, features = ["tower-axum-matched-path", "tracing"] }

# Browser backends for the I/O libraries. Enabled per-target on the consumer side
# (see the `wasm` feature); never linked into native builds.
[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys = { version = "0.3", optional = true }
reqwest = { version = "0.13", optional = true, default-features = false, features = ["json"] }
wasm-bindgen = { version = "0.2", optional = true }
wasm-bindgen-futures = { version = "0.4", optional = true }
web-sys = { version = "0.3", optional = true, features = ["Document", "Window", "HtmlDocument", "Storage", "Navigator", "Element"] }

[dev-dependencies]
async-trait.workspace = true
axum = { workspace = true, features = ["ws"] }
dioxus = { workspace = true, features = ["signals", "hooks"] }
dioxus-liveview = { workspace = true, features = ["axum"] }
dioxus-ssr.workspace = true
ev_lib = { workspace = true, features = ["architecture", "uikit", "analytics", "error_monitoring", "experiments"] }
jiff = { workspace = true, features = ["serde"] }
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
tokio = { workspace = true, features = ["macros", "rt", "net", "io-util", "time"] }
uuid = { workspace = true, features = ["serde", "v4"] }

[[example]]
name = "all_primitives"
required-features = ["uikit"]