facett-wasm-demo/Cargo.toml
[package]
name = "facett-wasm-demo"
description = "Reusable WASM/native demo HOST — mount any facett panel (a facett-core `Facet`) or `eframe::App` onto a canvas as a live Codeberg-Pages web demo AND a native window, with a per-frame state hook for headless drive. The template every `<repo>-demo` copies (nornir/holger/dwarves)."
# A leaf helper other repos consume. Opted into crates.io so nornir/holger/dwarves
# can depend on a published version (polyrepo: consumers point at crate VERSIONS,
# not path deps) once it is released alongside facett.
publish = true
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
[dependencies]
# The panel contract: a `Facet` (title / ui / state_json). The host is generic over
# it — a panel is just a `Box<dyn Facet>`. No heavier facett crate is pulled, so the
# harness stays wasm-clean and cheap for any consumer.
facett-core = { path = "../facett-core", version = "0.3.0" }
egui = { workspace = true }
serde_json = { workspace = true }
# ── native (desktop host) ────────────────────────────────────────────────────
# eframe runs the **wgpu** backend to MATCH facett-demo's native build — so a
# whole-workspace build unifies eframe on `wgpu` alone. As of 2026-08-01 that is no
# longer merely a preference: the 16 `glow` dev-deps that used to force eframe's
# OpenGL backend into every whole-workspace build are gone (LAW #4), so `wgpu` is the
# ONLY renderer feature anywhere in this workspace.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# `wgpu_no_default_features`, NOT `wgpu` — same as the wasm block below: eframe's
# plain `wgpu` feature expands to `egui-wgpu/default` → `wgpu/default` + `wgpu/webgl`,
# re-admitting GLES/`glow` natively. Backends come from the workspace `wgpu` list
# via facett-core's GPU lane.
eframe = { version = "0.36", default-features = false, features = ["default_fonts", "wgpu_no_default_features", "wayland", "x11"] }
# The GPU lane ON for the native host too. Until 2026-08-22 the native window's
# backends came silently from `egui-wgpu/default` → `wgpu/default`; with the eframe
# host on `wgpu_no_default_features` the ONLY source of backend features is the
# workspace `wgpu` list behind facett-core's GPU lane — without this line the harness
# (and every native consumer: dwarves-ui, the repo demos) compiles a wgpu with NO
# backends and finds no adapter at runtime. Caught by `cargo tree -e features -i wgpu`
# on dwarves-gui (std+wgsl only), not by `cargo check` — a backend-less wgpu compiles.
facett-core = { path = "../facett-core", version = "0.3.0", features = ["wgpu"] }
# ── wasm (the LIVE WEB DEMO host) ────────────────────────────────────────────
# eframe runs the **wgpu** backend, which on wasm32 targets the browser's WebGPU
# (`navigator.gpu`) — NOT WebGL. This harness is what every `<repo>-demo` mounts on
# (nornir / holger / dwarves), so the backend it picks is the backend the whole
# constellation's web demos inherit; it was the last WebGL/glow surface in facett and
# every consuming bundle inherited that. Modern platforms only.
#
# The backend MASK and the eframe wgpu configuration are NOT restated here. They come
# from the one policy in `facett-core` (`preferred_backends()` / `facett_wgpu_options()`),
# which on wasm32 is `Backends::BROWSER_WEBGPU` — WebGPU and nothing else. Restating
# the choice locally is how a consumer's canvas would drift from every other facett
# surface, so the harness imports the decision instead of re-making it (LAW #5).
[target.'cfg(target_arch = "wasm32")'.dependencies]
# `wgpu_no_default_features`, NOT `wgpu`. eframe's plain `wgpu` feature expands to
# `egui-wgpu/default`, which re-enables `wgpu/webgl` — the dead WebGL2 backend this
# port exists to be rid of. eframe splits the two precisely so a host can take the
# renderer without the default backend set; the backends actually wanted come from
# facett-core's GPU lane below.
eframe = { version = "0.36", default-features = false, features = [
"default_fonts",
"wgpu_no_default_features",
] }
# The `wgpu` feature is wasm32-only, so a consumer's native `cargo test` of this rlib
# still carries no GPU dependency edge and needs no GPU to run.
facett-core = { path = "../facett-core", version = "0.3.0", features = ["wgpu"] }
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
# NOTE: web-sys's own `Gpu`/`Navigator::gpu()` bindings sit behind
# `--cfg=web_sys_unstable_apis`, which would force an unstable RUSTFLAG on every build
# of this crate AND of every consumer. The adapter pre-flight only needs to know
# whether `navigator.gpu` EXISTS, so it reads the property reflectively via `js-sys`
# and the harness keeps building on stable flags.
web-sys = { version = "0.3", features = ["HtmlCanvasElement", "Window", "Document", "Location", "Navigator"] }
js-sys = "0.3"
console_error_panic_hook = "0.1"
log = "0.4"