[package]
name = "ruvector-wasm"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
authors.workspace = true
repository.workspace = true
readme = "README.md"
description = "WASM bindings for Ruvector for browser deployment"

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

[dependencies]
ruvector-core = { version = "0.1.2", path = "../ruvector-core", default-features = false, features = ["memory-only", "uuid-support"] }
ruvector-collections = { version = "0.1.2", path = "../ruvector-collections", optional = true }
ruvector-filter = { version = "0.1.2", path = "../ruvector-filter", optional = true }
parking_lot = { workspace = true }
getrandom = { workspace = true }

# Add getrandom 0.2 with js feature for WASM compatibility
# This ensures all transitive dependencies use the WASM-compatible version
getrandom02 = { package = "getrandom", version = "0.2", features = ["js"] }

# WASM
wasm-bindgen = { workspace = true }
wasm-bindgen-futures = { workspace = true }
js-sys = { workspace = true }
web-sys = { workspace = true, features = [
    "console",
    "Window",
    "IdbDatabase",
    "IdbFactory",
    "IdbObjectStore",
    "IdbRequest",
    "IdbTransaction",
    "IdbOpenDbRequest",
] }

# Error handling
thiserror = { workspace = true }
anyhow = { workspace = true }

# Serialization
serde = { workspace = true }
serde_json = { workspace = true }
serde-wasm-bindgen = "0.6"

# Utils
console_error_panic_hook = "0.1"
tracing-wasm = "0.2"

[dev-dependencies]
wasm-bindgen-test = "0.3"

[features]
default = []
simd = ["ruvector-core/simd"]
# Collections and filter features (not available in WASM due to file I/O requirements)
# These features are provided for completeness but will not work in browser WASM
collections = ["dep:ruvector-collections", "dep:ruvector-filter"]

# Ensure getrandom uses wasm_js/js features for WASM (both 0.2 and 0.3 versions)
[target.'cfg(target_arch = "wasm32")'.dependencies]
# getrandom 0.3.x uses wasm_js feature
getrandom = { workspace = true, features = ["wasm_js"] }

[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"

[profile.release.package."*"]
opt-level = "z"
