[package]
name = "damascene-web"
version = "0.4.5"
edition.workspace = true
rust-version.workspace = true
authors.workspace = true
repository.workspace = true
homepage.workspace = true
description = "Damascene browser host for wasm apps"
license = "MIT OR Apache-2.0"
readme = "README.md"
documentation = "https://docs.rs/damascene-web"
keywords = ["ui", "gui", "wasm", "web", "wgpu"]
categories = ["gui", "rendering", "wasm", "web-programming"]

[dependencies]
# `log` is target-neutral so `install_logger`'s signature type-checks
# in shared code on native builds too (the native impl is a no-op).
log = "0.4"
damascene-core = { version = "0.4.5", path = "../damascene-core", default-features = false }
damascene-wgpu = { version = "0.4.5", path = "../damascene-wgpu" }
wgpu = "29"
winit = "0.30"

[features]
default = ["default_fonts"]
# Font passthroughs — forward to `damascene-core`'s font features so a
# consumer can opt out of the bundled set. The default preserves today's
# behavior; a wasm app that doesn't need color emoji can drop ~10 MB
# (NotoColorEmoji is CBDT bitmaps, ~incompressible) with e.g.
# `damascene-web = { default-features = false, features = ["inter", "jetbrains-mono", "symbols"] }`.
# See issue #49.
default_fonts = ["damascene-core/default_fonts"]
inter = ["damascene-core/inter"]
jetbrains-mono = ["damascene-core/jetbrains-mono"]
roboto = ["damascene-core/roboto"]
emoji = ["damascene-core/emoji"]
symbols = ["damascene-core/symbols"]
# Forwards to `damascene-core/profiling` + `damascene-wgpu/profiling` so all
# `profile_span!` calls compile in. The wasm subscriber
# (`tracing-wasm`, declared in the wasm32 target table below) emits
# each span to the browser's User Timing API, where they show up as
# named measures in DevTools → Performance. Build with
# `wasm-pack build --target web crates/damascene-web-showcase --features profiling`.
profiling = [
    "dep:tracing-wasm",
    "damascene-core/profiling",
    "damascene-wgpu/profiling",
]

[target.'cfg(target_arch = "wasm32")'.dependencies]
# wasm-bindgen is the FFI bridge wasm-pack consumes.
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
console_error_panic_hook = "0.1"
console_log = "1"
js-sys = "0.3"
# `web_time::Instant` is a wasm-safe shim for `std::time::Instant`
# (the std one panics on wasm32). Used here for the per-frame
# timing breakdown.
web-time = "1"
web-sys = { version = "0.3", features = [
    "Clipboard",
    "ClipboardEvent",
    "CssStyleDeclaration",
    # CustomEvent carries GPU-setup failures to the embedding page as
    # a bubbling `damascene-error` event on the canvas — the only
    # channel reachable after the async adapter/device setup, where a
    # panic would bypass the page's `init().catch(...)`.
    "CustomEvent",
    "CustomEventInit",
    "DataTransfer",
    "Document",
    "Element",
    "Event",
    "EventTarget",
    "HtmlCanvasElement",
    "HtmlElement",
    "HtmlInputElement",
    # InputEvent extends Event with `inputType` so the soft-keyboard
    # path can distinguish character insertion ("insertText") from
    # backspace ("deleteContentBackward") and route accordingly.
    "InputEvent",
    "KeyboardEvent",
    "MouseEvent",
    "Navigator",
    # PointerEvent is the unified mouse / touch / pen input surface.
    # The web host binds it directly so a touch tap arrives at the
    # runtime tagged as `PointerKind::Touch` rather than collapsed
    # to a mouse event by winit's compatibility layer.
    "PointerEvent",
    # ResizeObserver re-syncs the canvas backing buffer to its CSS
    # box size whenever the layout changes (window resize, devtools
    # toggle, css media-query crossing, etc). Without this the
    # canvas's drawing buffer is whatever we set it to on first
    # paint and the surface ends up stretched until the page reloads.
    "ResizeObserver",
    # VisualViewport reports the visible region of the page minus
    # platform chrome. Bound on the web host so we can detect the
    # on-screen keyboard appearing (it shrinks visualViewport.height
    # without changing the layout viewport) and propagate the
    # resulting bottom inset to apps via `BuildCx::safe_area`.
    "VisualViewport",
    "Window",
] }
# Browser wgpu backends — workspace's plain `wgpu = "29"` only enables
# native backends.
wgpu = { version = "29", features = ["webgl"] }
# Optional — bridges the `tracing` events the `profiling` feature lights
# up to the browser's User Timing API (`performance.mark` /
# `performance.measure`). Each span shows up as a named measure in
# DevTools → Performance. Off in release; pulled in only when this
# crate's `profiling` feature is on.
tracing-wasm = { version = "0.2", optional = true }
