gpuikit 0.9.0

A UI toolkit for GPUI applications
Documentation
[package]
name = "gpuikit"
version = "0.9.0"
edition = "2024"
authors = ["Nate Butler <iamnbutler@gmail.com>"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/iamnbutler/gpuikit"
homepage = "https://github.com/iamnbutler/gpuikit"
description = "A UI toolkit for GPUI applications"
readme = "README.md"
keywords = ["gpui", "ui", "components", "toolkit", "gui"]
categories = ["gui", "graphics"]
# The README's screenshot lives in `.github/media/` and is linked by absolute
# URL, so crates.io renders it without the file shipping in the package. Note
# it cannot live in `assets/`: that folder is `#[folder = "assets"]` for
# rust-embed, so anything in it is compiled into every consumer's binary.
exclude = [".github/"]
# This crate's own floor, not a promise about the whole dependency tree: it uses
# async closures (stable in 1.85), and edition 2024, which needs the same 1.85.
# The declared 1.75 was never true. Dependencies already in `Cargo.lock` declare
# their own, higher numbers; edition 2024's v3 resolver prefers to respect this
# floor when it picks a new one, but only prefers — see the crate docs'
# "Minimum Rust version".
rust-version = "1.85"

[lib]
name = "gpuikit"
path = "src/lib.rs"

# Every example is gated behind the no-op `examples` feature, so that
# `cargo test`, `cargo build --all-targets` and `cargo check --all-targets` do
# not each link eight copies of gpui — see `[profile.dev]` below and
# `examples/README.md`. Run one with `--features examples`.
#
# A new example is declared here, with `required-features`. An autodiscovered
# target — any top-level `examples/*.rs`, or `examples/*/main.rs` — cannot carry
# `required-features`, so it would be built by every one of those commands
# regardless. `src/build_profile_guard.rs` reads `examples/` from disk to catch
# exactly that.

[[example]]
name = "markdown_selection"
path = "examples/markdown_selection.rs"
required-features = ["examples"]

[[example]]
name = "markdown_streaming"
path = "examples/markdown_streaming.rs"
required-features = ["examples"]

[[example]]
name = "showcase"
path = "examples/showcase.rs"
required-features = ["examples"]

[[example]]
name = "tasks"
path = "examples/tasks.rs"
required-features = ["examples"]

[[example]]
name = "input_sandbox"
path = "examples/input/sandbox.rs"
required-features = ["examples"]

[[example]]
name = "dialog_example"
path = "examples/dialog_example.rs"
required-features = ["examples"]

[[example]]
name = "popover_demo"
path = "examples/popover_demo.rs"
required-features = ["examples"]

[[example]]
name = "context_menu"
path = "examples/context_menu.rs"
required-features = ["examples"]

[dependencies]
# GPUI framework (from gpui-unofficial on crates.io)
gpui = { package = "gpui-unofficial", version = "1.14.2" }
gpui_platform = { package = "gpui-platform-gpui-unofficial", version = "1.14.2", features = ["font-kit"] }
rust-embed = "8.2.0"
anyhow = "1.0.79"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
log = "0.4"

# Input module dependencies
unicode-bidi = "0.3"
unicode-segmentation = "1.10"
# `std::time::Instant::now()` panics on wasm32-unknown-unknown; web-time
# re-exports the std types unchanged on native targets.
web-time = "1"
# No async runtime here on purpose. `smol::Timer` is `async_io::Timer`, and
# constructing one spawns the process-global `async-io` OS thread, whose
# `main_loop` has no exit path — it was still in the reactor at process exit
# and aborted the test binary after every test had passed (#190). Delays go
# through gpui's own `BackgroundExecutor::timer`, which is also the
# deterministic clock under `#[gpui::test]`. See `src/undying_thread_guard.rs`.

# Markdown parsing
pulldown-cmark = { version = "0.13.4", default-features = false, features = ["simd"] }

# Closes syntax a partially streamed markdown document leaves open, so a
# half-written `**bold` does not flash as literal asterisks (optional)
mdstitch = { version = "0.1", optional = true }

# Editor dependencies (optional)
syntect = { version = "5.3.0", optional = true }
gpui_util = { package = "gpui-util-gpui-unofficial", version = "1.14.2", optional = true }

# Schema generation (optional)
schemars = { version = "0.8", optional = true }

# rust-embed's default debug behavior reads assets from disk at runtime, and
# the browser has no disk — a debug wasm build would fail to load every icon
# and font. `debug-embed` compiles the assets in for every profile; gating it
# to wasm keeps native debug builds' fast from-disk iteration. Consumers get
# this via feature unification without knowing the trick exists.
[target.'cfg(target_family = "wasm")'.dependencies]
rust-embed = { version = "8.2.0", features = ["debug-embed"] }

[dev-dependencies]
tempfile = "3.8"
pretty_assertions = "1.4"

# Examples build with dev-dependencies unified in, and gpui's `test-support`
# (leak detection → backtrace → proptest → rusty-fork → wait-timeout) does not
# compile for wasm32. Tests never run on wasm, so the feature is asked for only
# where they do; the showcase, built as an example for the web, gets plain gpui.
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
gpui = { package = "gpui-unofficial", version = "1.14.2", features = ["test-support"] }

# The hosted showcase mirrors its active page to the URL hash, so a component
# can be linked to, and listens for the hash changing under it (back button,
# an edited address bar). Dev-dependencies: only the example reads the location.
[target.'cfg(target_family = "wasm")'.dev-dependencies]
web-sys = { version = "0.3", features = ["Window", "Location", "EventTarget"] }
wasm-bindgen = "0.2"

[features]
default = []
editor = ["dep:syntect", "dep:gpui_util"]
schema = ["dep:schemars"]
# Compile Metal shaders at runtime instead of at build time (no Xcode Metal
# toolchain required).
runtime_shaders = ["gpui_platform/runtime_shaders"]
# Close unterminated markdown syntax before parsing, so a streaming document
# does not flicker between literal markers and styled text. Off by default:
# mdstitch declares rust-version 1.95.0, above this crate's own 1.85 floor, so
# enabling it raises the toolchain a consumer needs. Keep the README's feature
# table in step with these numbers.
stitch = ["dep:mdstitch"]
# Enables nothing. It exists only so that every `[[example]]` above can require
# it, keeping eight full links of gpui out of `cargo test` and
# `cargo {build,check} --all-targets`. Note that `--all-features` turns it back
# on — cargo offers no way to exclude a feature from that flag — so
# `cargo test --all-features` still links all eight.
examples = []

# Lints
[lints.rust]
missing_docs = "warn"
rust_2018_idioms = { level = "warn", priority = -1 }
elided_lifetimes_in_paths = "allow"

[lints.clippy]
# Every callback field spells the full gpui handler signature —
# `Option<Box<dyn Fn(&ClickEvent, &mut Window, &mut App)>>` and its variants.
# The signature is the information a reader at the field wants; a type alias
# per element would hide it behind a name that differs at every site anyway.
type_complexity = "allow"

# Optimize release builds
[profile.release]
lto = true
codegen-units = 1
opt-level = 3

# Speed up debug builds
[profile.dev]
opt-level = 0
# Not `2`. Full DWARF for this crate *and* for gpui beneath it is the bulk of
# what `ld` holds in memory, and cargo sizes `-j` from the CPU count with no
# knowledge of a memory limit, so several of those links run at once and the
# kernel kills one — `ld terminated with signal 9 [Killed]`, naming no crate and
# no symbol. Line tables keep file and line in every backtrace; only the type
# and variable detail a debugger wants is gone, and a debugging session asks for
# it on that build alone with `RUSTFLAGS="-Cdebuginfo=2"`.
debug = "line-tables-only"

# Dependencies — gpui above all — are compiled once and then only linked, so
# optimizing them costs nothing on an incremental build of this crate and is
# the difference between a debug showcase that draws smoothly and one that
# does not. `"*"` matches dependencies only, never this crate, so iterating
# here compiles exactly as fast as before.
[profile.dev.package."*"]
opt-level = 2

# Package metadata for crates.io
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]