[package]
name = "op-host-web"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
description = "OpenPencil web host — wasm32-unknown-unknown web bundle entry (Step 1b §1.2, C-hard pipeline)"

[lib]
name = "op_host_web"
path = "src/lib.rs"
crate-type = ["cdylib", "rlib"]

[dependencies]
# Phase 7.3 reorg: openpencil-shell-core dissolved — widget facade /
# theme / layout scene / scene vars / render-backend / gesture types
# all resolve through the op-editor-ui crate.
op-editor-ui = { path = "../op-editor-ui" }
# Reorg: the web host owns an `op_editor_core::EditorState` as its
# single source of truth; `op-pen-loader` bridges it into the
# read-only paint `Document` the shared widgets consume.
#
# Both are `optional` + behind the `skia` feature for the SAME reason
# `skia-safe` is: the host (`widget_host`) is `#[cfg(feature="skia")]`-
# gated, so the skia-free CI stub baseline
# (`--no-default-features --features web`) never needs them. This
# matters because `op-pen-loader` pulls `jian-skia` transitively
# (`pen_document_to_document` runs `SkiaMeasure` for text layout);
# keeping it optional preserves the wasm32-clean stub baseline.
op-editor-core = { path = "../op-editor-core", optional = true }
op-pen-loader = { path = "../op-pen-loader", optional = true }
# Step 1b §3.6: handwritten DOM mirror consumes accesskit::TreeUpdate (0.24).
accesskit = "0.24"
console_error_panic_hook = "0.1"
js-sys = "0.3"
# Phase C1 DOM event mappers build `jian_core::gesture::WheelEvent` etc
# whose position/delta fields use `jian_core::geometry::Point`. The
# `geometry` module is not re-exported by shell-core (which only
# re-exports `gesture::*`), so pull jian-core directly. Same path-with-
# version pattern as shell-core's own jian-core dep.
jian-core = { path = "../../vendor/jian/crates/jian-core", version = "0.0.1" }
# Pin to 0.2.117 — last wasm-bindgen-cli release compatible with the
# workspace's Rust 1.85 toolchain. Newer 0.2.120+ requires rustc 1.86.
# When the workspace bumps Rust, raise this bound.
wasm-bindgen = "=0.2.117"

# Step 1b §2.2 (post C-hard.2 lock-in 2026-05-09): wasm32-unknown-unknown
# via the vendor/skia-safe-op fork + crates/wasm-libc-shim. Optional dep
# behind the `skia` feature so `cargo check --target wasm32-unknown-
# unknown --no-default-features --features web` (the kickoff §1.2
# wasm32-clean CI baseline) still compile-checks without pulling skia
# — that path uses the stub mount entry. Phase A and onward opt in via
# `--features skia` to get the real WebBackend + raster paint loop.
[dependencies.skia-safe]
version = "0.97.0"
default-features = false
# Step 3 codex stop-hook fix: text rendering uses
# `Canvas::draw_str` + raw Font + Typeface (NOT skia paragraph
# builder), so the `textlayout` feature is unnecessary on web.
# Dropping it removes ICU + Harfbuzz from the bundle (~400 KB
# gzip) and avoids the env.* import explosion that came with
# textlayout's filesystem font lookups.
features = ["binary-cache"]
optional = true

# C-hard.2 libc/libcxx/libm shim — only linked when targeting
# wasm32-unknown-unknown with the `skia` feature on. The crate's lib.rs
# guards every symbol with `cfg(all(target_arch = "wasm32", target_os
# = "unknown"))` so native builds (where this would conflict with the
# host C runtime) link an empty crate.
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
wasm-libc-shim = { path = "../wasm-libc-shim", optional = true }

[dependencies.web-sys]
version = "0.3"
features = [
  "CanvasRenderingContext2d",
  "CompositionEvent",
  "console",
  "Document",
  "Element",
  "Event",
  "EventTarget",
  "FocusEvent",
  "HtmlCanvasElement",
  "HtmlElement",
  "ImageData",
  "KeyboardEvent",
  "MouseEvent",
  "Performance",
  "PointerEvent",
  "WheelEvent",
  "Window",
]

[features]
# `web` keeps the kickoff §1.2 wasm32-unknown-unknown CI baseline green —
# the crate compile-checks as a wasm32-clean stub without pulling skia.
default = ["web"]
web = []
# `skia` opts into the Phase A WebBackend (skia-safe + raster surface).
# When the cargo target is wasm32-unknown-unknown the build also links
# the libc/libcxx/libm shim crate so the bundle is runtime-loadable.
# Native targets resolve the target-conditional shim dep to nothing.
skia = ["dep:skia-safe", "dep:op-editor-core", "dep:op-pen-loader", "wasm-libc-shim"]
# Internal feature toggled on by `skia` to flip the cfg-target dep.
wasm-libc-shim = ["dep:wasm-libc-shim"]
