[package]
name = "neser"
version = "1.1.0"
edition = "2024"
description = "NESER - Nintendo Emulation Systems Engine (Rust). Desktop and WebAssembly frontends."
license = "MIT"
repository = "https://github.com/rmstdope/neser"
exclude = [
    "roms/",
    "docs/",
    ".github/",
    ".githooks/",
    ".vscode/",
    "target/",
    "dist/",
    "node_modules/",
    "pkg/",
    "test-results/",
    "vendor/",
    "package.json",
    "package-lock.json",
    "playwright.config.ts",
]

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

[dependencies]
bitflags = "2.9"
crc = "3.3"
rand = "0.9.2"
ringbuf = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
postcard = { version = "1", features = ["alloc"] }
winit = { version = "0.30", optional = true }
glutin = { version = "0.32", optional = true, default-features = false, features = ["egl", "glx", "x11", "wayland", "wgl"] }
glutin-winit = { version = "0.5", optional = true, default-features = false, features = ["egl", "glx", "x11", "wayland", "wgl"] }
raw-window-handle = { version = "0.6", optional = true }
gl = { version = "0.14", optional = true }
glow = { version = "0.14", optional = true }
librashader = { version = "0.5", optional = true, default-features = false, features = ["runtime-gl", "presets", "stable"] }
png = "0.17"
wasm-bindgen = { version = "0.2.108", optional = true }
wasm-bindgen-futures = { version = "0.4.45", optional = true }
console_error_panic_hook = { version = "0.1", optional = true }
js-sys = { version = "0.3", optional = true }
web-sys = { version = "0.3", optional = true, features = ["Window", "console"] }
wasm-bindgen-test = { version = "0.3.45", optional = true }
egui = { version = "0.34.2", optional = true, default-features = false, features = ["default_fonts"] }
egui-winit = { version = "0.34.2", optional = true, default-features = false }
egui_glow = { version = "0.34.2", optional = true, features = ["winit"] }
cpal = { version = "0.15", optional = true }
gilrs = { version = "0.11", optional = true }
num_enum = "0.7"
ratatui = { version = "0.29", optional = true }
crossterm = { version = "0.28", optional = true }
nosleep = { version = "0.2.1", optional = true }
serde_with = "3.18.0"
rusqlite = { version = "0.36", optional = true, features = ["bundled"] }
strsim = { version = "0.11", optional = true }
reqwest = { version = "0.12", optional = true, default-features = false, features = ["blocking", "rustls-tls"] }
image = { version = "0.25", optional = true, default-features = false, features = ["jpeg", "png"] }

[features]
default = ["native"]
# Meta-feature: any native desktop frontend. Required by the neser binary so
# that wasm/lib-only builds don't also compile the binary (which would cause a
# filename collision between the bin and lib wasm outputs and produce an empty
# pkg/neser.js with no wasm-bindgen exports).
frontend = []
native = [
	"frontend",
	"dep:winit",
	"dep:glutin",
	"dep:glutin-winit",
	"dep:raw-window-handle",
	"dep:gl",
	"dep:glow",
	"dep:librashader",
	"dep:cpal",
	"dep:gilrs",
	"dep:nosleep",
	"dep:rusqlite",
	"dep:strsim",
	"dep:reqwest",
	"dep:image",
	"dep:egui",
	"dep:egui-winit",
	"dep:egui_glow",
]
wasm = [
	"dep:wasm-bindgen",
	"dep:wasm-bindgen-futures",
	"dep:console_error_panic_hook",
	"dep:js-sys",
	"dep:web-sys",
	"dep:wasm-bindgen-test",
]
tui = [
	"dep:ratatui",
	"dep:crossterm",
]

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.3", features = ["wasm_js"] }

[[bin]]
name = "neser"
path = "src/main.rs"
required-features = ["frontend"]

[[bin]]
name = "frame_bench"
path = "src/bin/frame_bench.rs"
required-features = ["native"]

[[bin]]
name = "gamepad_test"
path = "src/bin/gamepad_test.rs"
required-features = ["native"]

[dev-dependencies]
hound = "3.5"
serial_test = "3.2"
tempfile = "3.24.0"
zip = { version = "2", default-features = false, features = ["deflate"] }

# Improve runtime performance in debug builds (helps reduce audio underruns) while
# keeping debuggability. This is a common setup for emulator-style workloads.
[profile.dev]
opt-level = 1

[profile.release]
incremental = false

# Dedicated profile for the WASM web build.
# LTO + codegen-units=1 enable cross-crate inlining, which is critical for
# the tight run_cpu_tick() loop and gives ~30-50% speedup over the plain
# release profile on WASM targets.
[profile.wasm-release]
inherits = "release"
opt-level = 3
lto = true
codegen-units = 1

[profile.dev.package."*"]
opt-level = 3
incremental = false
