[workspace]
members = [".", "crates/*"]
resolver = "3"

[workspace.package]
version = "0.1.0"
edition = "2024"
license = "MPL-2.0"

[workspace.dependencies]
jacquard = { path = "../jacquard/crates/jacquard", default-features = false, features = ["derive", "api_bluesky", "streaming"] }
jacquard-axum = { path = "../jacquard/crates/jacquard-axum" }
jacquard-common = { path = "../jacquard/crates/jacquard-common" }
jacquard-derive = { path = "../jacquard/crates/jacquard-derive" }
jacquard-lexicon = { path = "../jacquard/crates/jacquard-lexicon", default-features = false }
serde = { version = "1.0", features = ["derive"] }
thiserror = "2.0"
miette = "7.6"
postcard = "1"
wasm-bindgen = "=0.2.121"

[package]
name = "polymodel"
version.workspace = true
edition.workspace = true
license.workspace = true
description = "atproto Thingiverse but good "

[features]
default = ["web"]
web = ["dioxus/web"]
desktop = ["dioxus/desktop"]
mobile = ["dioxus/mobile"]
server = [
    "dioxus/server",
    "dep:axum",
    "dep:tower",
    "dep:tower-http",
    # XRPC read endpoint handlers (jacquard-axum ExtractXrpc / IntoRouter).
    "dep:jacquard-axum",
    # Generated typed XRPC request/response/view types.

    # Indexing infrastructure (Hydrant firehose + SQLite projection)
    "dep:hydrant",
    "dep:sqlx",
    "dep:libsqlite3-sys",
    "dep:tokio",
    "dep:futures",
    "dep:anyhow",
    "dep:dotenvy",
    "dep:chrono",
    "dep:http-body-util",
    "dep:tracing-subscriber",
    "dep:rustls",
    # OAuth (PM-27): confidential client, private cookie jar key, secret sources.
    "dep:axum-extra",

    "dep:keyring",
    "dep:sha2",
    "dep:zip",
    # PM-43: server-side decode of uploaded image dimensions (for #image
    # aspectRatio) and opaque draft id generation.
    "dep:imagesize",
    "dep:ulid",
]
[dependencies]
dioxus = { version = "0.7", features = ["router", "fullstack"] }
dioxus-sdk = { version = "0.7", default-features = false, features = ["time"] }
jacquard = { workspace = true }
jacquard-axum = { workspace = true, optional = true }
jacquard-common = { workspace = true }
jacquard-derive = { workspace = true }
# PM-43: LexiconSchema::validate for draft → ThingInput assembly, so draft
# validation tracks the generated lexicon constraints instead of duplicating them.
jacquard-lexicon = { workspace = true }
# Generated lexicon bindings (typed request/response/view types for XRPC routes).
polymodel-api = { path = "crates/polymodel-api" }
polymodel-renderer-protocol = { path = "crates/polymodel-renderer-protocol" }
serde = { workspace = true }
serde_json = "1.0"
thiserror = { workspace = true }
urlencoding = "2"
tracing = { version = "0.1", default-features = false, features = ["std"] }

axum = { version = "0.8", optional = true, features = ["multipart"] }
tower = { version = "0.5", optional = true }
tower-http = { version = "0.6", optional = true, features = ["trace"] }
rustls = { version = "0.23", default-features = false, features = ["aws-lc-rs", "std"], optional = true }
# Server-only indexing infrastructure.
# hydrant is pinned to a specific commit to protect against breaking API changes.
hydrant = { git = "https://tangled.org/ptr.pet/hydrant", rev = "1145fa1bb194372ceea81ab48b5d68d304da34ad", default-features = false, features = ["indexer", "indexer_stream"], optional = true }
# Compile-time-checked queries. sqlx version matches the `sqlx-cli` provided by
# the nix dev shell so `cargo sqlx prepare` and the macros agree on the .sqlx
# cache format. `cargo sqlx prepare --features server` generates the committed
# .sqlx cache for offline/CI builds.
sqlx = { version = "0.9", default-features = false, features = [
    "runtime-tokio",
    "sqlite",
    "macros",
    "migrate",
], optional = true }
# Bundle SQLite (libsqlite3-sys bundled enables FTS5) so no system libsqlite3 is
# required. Version follows sqlx 0.9's libsqlite3-sys requirement.
libsqlite3-sys = { version = "0.37", features = ["bundled"], optional = true }
tokio = { version = "1", features = ["rt-multi-thread", "macros", "signal"], optional = true }
futures = { version = "0.3", optional = true }
anyhow = { version = "1", optional = true }
dotenvy = { version = "0.15", optional = true }
chrono = { version = "0.4", optional = true }
tracing-subscriber = { version = "0.3", optional = true, default-features = false, features = [
    "std",
    "fmt",
    "env-filter",
] }
http = "1.4"
http-body-util = { version = "0.1", optional = true }
reqwest = { version = "0.12", default-features = false, features = ["json", "charset"] }
rand = "0.9"

# PM-27 OAuth: private cookie-jar signing key and swappable secret sources
# (OS keyring preferred; env override). reqwest is shared with the client crate.
axum-extra = { version = "0.10", optional = true, features = ["cookie"] }

keyring = { version = "3", optional = true }
base64 = { version = "0.22" }
sha2 = { version = "0.10", optional = true }
zip = { version = "2", default-features = false, optional = true }
# PM-43: header-only image dimension probe (no full decode) for #image
# aspectRatio; ULID for opaque, sortable draft ids. Both server-only.
imagesize = { version = "0.13", optional = true }
ulid = { version = "1", optional = true }
bytes = { version = "1.12.0", features = ["serde"] }


[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dependencies]
console_error_panic_hook = "0.1"
js-sys = "0.3"
tracing-wasm = "0.2"
wasm-bindgen = "=0.2.121"
wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3", features = ["Window", "Document", "Element", "Event", "EventTarget", "HtmlCanvasElement", "WebGl2RenderingContext", "Performance", "MouseEvent", "WheelEvent", "PointerEvent", "DomRect", "BroadcastChannel", "console", "Response", "File", "FileList", "Blob", "HtmlAnchorElement", "HtmlInputElement", "HtmlDetailsElement", "Worker", "WorkerOptions", "WorkerType", "OffscreenCanvas", "MessageEvent", "ErrorEvent"] }

[dev-dependencies]
anyhow = "1"
axum = "0.8"
axum-extra = { version = "0.10", features = ["cookie"] }
base64 = "0.22"
chrono = "0.4"
futures = "0.3"
hydrant = { git = "https://tangled.org/ptr.pet/hydrant", rev = "1145fa1bb194372ceea81ab48b5d68d304da34ad", default-features = false, features = ["indexer", "indexer_stream"] }
http-body-util = "0.1"
imagesize = "0.13"
jacquard-axum = { workspace = true }
keyring = "3"
serde_json = "1.0"
ulid = "1"
urlencoding = "2"
libsqlite3-sys = { version = "0.37", features = ["bundled"] }
rustls = { version = "0.23", default-features = false, features = ["aws-lc-rs", "std"] }
sha2 = "0.10"
sqlx = { version = "0.9", default-features = false, features = [
    "runtime-tokio",
    "sqlite",
    "macros",
    "migrate",
] }
tokio = { version = "1", features = ["rt", "macros"] }
tower = "0.5"
tower-http = { version = "0.6", features = ["trace"] }
tracing-subscriber = { version = "0.3", default-features = false, features = [
    "std",
    "fmt",
    "env-filter",
] }

[build-dependencies]
dotenvy = "0.15"
serde_json = "1.0"

[profile.web-release]
inherits = "release"
opt-level = "z"
debug = false
lto = "fat"
codegen-units = 1
strip = "symbols"
panic = "abort"


[profile.worker-release]
inherits = "release"
opt-level = "z"
lto = "fat"
debug = false
codegen-units = 1
strip = "symbols"
panic = "abort"
