ZOYKU火線榜

pierreaubert/gpui-toolkit技術文件

A UI toolkit build to on top of Zed GPUI that also works on mobile platform and wasm. Python package on Pypi for easy prototyping.

多語言回退提示:當前倉庫原作者暫未發布在地化文件,已為您無縫切換至官方英文原版(English),排版及程式碼實例完整保真。
極速安裝
cargo add gpui-toolkit

gpui-toolkit

Libraries, examples, and tooling for building GPUI applications with native div()-based rendering, reusable components, charting primitives, design tokens, working on all platforms: macOS, Linux, Windows, iOS, tvOS, Android and WASM.

License

Build your first app

Start here: generate, run, and build a small interactive app →

Choose a path What you will build
Rust: scaffold a native app Create a project, add a working counter, run a desktop window, and build a release executable. Continue to the generated iOS and Android hosts.
Python: write a native app Set up the Python package, write the same counter, and run it through the native GPUI host.
Build with an agent Discover the CLI contract, scaffold a project, look up real APIs, and verify the result.

The tutorial explains prerequisites, the difference between gpui-toolkit (the catalog and development CLI) and gpui-scaffolder (the project generator), and what to distribute. Start with desktop; mobile builds use the Rust app and platform SDKs. Python currently targets the desktop host.

The same UI from Rust, the compact layout! macro, or Python:

use gpui::div;
use gpui_ui_kit::{Button, ButtonVariant, VStack};

VStack::new()
    .child(div().child("Hi"))
    .child(Button::new("go", "Go").variant(ButtonVariant::Primary))
use gpui_ui_kit_macros::layout;

layout! {
    V {
        Tx "Hi",
        B.primary("Go") #go,
    }
}
from gpui_toolkit import ui

ui.vstack([
    ui.text("Hi"),
    ui.button("Go", id="go", action="app.go"),
])

3D mesh visualization (VTK-class)

Three focused crates bring CFD/FEA-style visualization to the toolkit, all at version 0.10.44: gpui-mesh (dataset model with VTK-style cells and named point/cell fields, bounded surface chunking for large objects), gpui-dataset-transformation (plane slice/clip, threshold, isosurface, streamlines, vorticity/divergence/Q-criterion diagnostics, VTK/VTU/XDMF I/O, optional wgpu compute), and gpui-scene3d (orbit camera, transfer functions, clip planes and transparency, volume raycasting, WGSL shaders, 1080p PNG/MP4 movies, an interactive viewer with a live cutting plane). From Python, gpui_toolkit.mesh builds structured grids and runs the same filters natively. Demos include a PC-fan airflow, an optimised speaker port, and a necking bar; see crates/gpui-scene3d/README.md.

Explore the toolkit

The browser landing page introduces the toolkit with separate paths for users and developers, direct links to all five live WASM demos, and Rust, layout!, and Python examples. Every demo has a browser menu for themes and design languages. The expandable catalog includes feature snapshots and theme/style variants generated from the real showcases.

The full Spinorama viewer includes live speaker and measurement selection, CEA-2034 curves, polar directivity, contours, and interactive 3D surface and sphere views.

UI Kit · buttons UI Kit · form controls UI Kit · workflow
UI Kit buttons UI Kit form controls UI Kit workflow
Chart · scatter Chart · heatmap Chart · contour
Chart scatter Chart heatmap Chart contour

Browse the generated snapshot gallery and live WASM demos →

The gallery is built with just demo-site; just wasm-gallery additionally captures every query-addressable section in the showcase applications.

This is pre-1.0 software with a deliberately narrow crates.io surface. The first registry wave is gpui-design, gpui-profiler, and gpui-ui-kit-macros; GPUI-dependent crates are distributed as source beta. See RELEASE.md for exact lanes and guarantees.

Examples

Two open source examples:

  • SotF available in the Apple and Windows app stores, see GH for latest versions and Linux builds, 100% built with this toolkit. It works on ARM and X86 with iOS and macOS ports underway.
  • StkOpt is a simpler example

Workspace Crates

Crate Purpose
gpui-au macOS Audio Unit platform backend for embedding GPUI rendering inside AUv3 view controllers.
gpui-android Android platform backend and JNI integration for GPUI applications.
gpui-audio-kit Audio-focused UI controls for plugin and playback interfaces, including knobs and vertical sliders.
gpui-builder Constraint-based layout solver with responsive display tiers, dividers, auto-axis behavior, and showcase examples.
gpui-component-lab Prop-driven component lab and responsive preview matrix for design-system conformance work.
gpui-d3rs D3.js-inspired visualization primitives: scales, shapes, colors, geo projections, force layouts, Delaunay/Voronoi, GPU 2D, and GPU 3D.
gpui-dataset-transformation Pure DataSet -> DataSet filters: plane slice/clip, threshold, isosurface, calculators, flow diagnostics, warp, glyphs, streamlines, probe, and VTK/VTU/XDMF I/O.
gpui-design Platform-adaptive design system tokens for spacing, corners, typography, animation, and GPUI integration.
gpui-design-tools CLI tooling for exporting, importing, and validating design tokens and conformance reports.
gpui-foreign-parent Platform-neutral core for foreign-parent editor embedding: editor registry, frame throttle, resize debounce, callback slots, and FFI helpers.
gpui-hello-web Minimal wasm/browser spike app running GPUI on the vendored gpui_web WebGPU backend via Trunk.
gpui-ios iOS/tvOS platform backend for GPUI with Metal rendering, touch input, text input, accessibility, platform views, and hot reload hooks.
gpui-keybinding Reusable keybinding framework with editor-style preset support for GPUI applications.
gpui-layout-expr Compact layout-expression AST, parser, and validation shared by the CLI and the layout! macro.
gpui-linux-foreign Linux foreign-parent binding: GPUI editors in host-owned X11 windows (VST3/CLAP) and Wayland subsurfaces (CLAP).
gpui-mesh Mesh data model only: VTK-style cells (tet/hex/wedge/pyramid), scalar/vector/tensor/complex fields, boundary extraction, and bounded surface chunking. No GPUI/wgpu/IO.
gpui-miniapp Small application shell used by examples and showcases to select the right GPUI platform backend.
gpui-pretext High-performance text measurement and multiline layout utilities.
gpui-profiler Lightweight allocation profiling and hot-path regression utilities.
gpui-px Plotly Express-style charting API built on gpui-d3rs for scatter, line, bar, heatmap, contour, surface, pie, boxplot, and treemap views.
gpui-python-runtime Retained scene specification runtime for a GPUI Python wrapper, with an optional showcase.
gpui-release-gates Release-QA metadata (stability, gates, publish plan) for the GPUI toolkit workspace.
gpui-scaffolder CLI for creating standalone GPUI mini-app projects backed by gpui-miniapp.
gpui-scene3d 3D scene rendering: orbit camera, transfer functions, WGSL clipping planes, chunked GPU buffers, software rasterizer, volume raycasting, and time playback.
gpui-spinorama Spinorama-style speaker measurement showcase (CEA-2034 and dispersion) with native and wasm entries.
gpui-themes Theme editor and theme showcase infrastructure for GPUI applications.
gpui-ui-kit Reusable UI component library: buttons, inputs, dialogs, menus, tabs, tables, QR, command palette, sidebar, wizard, workflow canvas, and more.
gpui-ui-kit-macros Procedural macros used by gpui-ui-kit, including builder and theme derivation helpers.
gpui-web-foreign Browser foreign-parent binding: GPUI editors in page-owned canvases, with DOM input tables and a renderer-provider seam.
gpui-win-foreign Windows foreign-parent binding: GPUI editors in host-owned HWNDs (VST3) via a WS_CHILD creation path.
gpui-toolkit Aggregate crate and machine-readable release, stability, and vendored-patch policy manifests.
gpui-toolkit-cli Unified gpui-toolkit CLI: component catalog, templates, themes, health checks, and layout tools for humans and agents.
gpui-showcase Desktop component showcase application.
gpui-showcase-android Android native library and Gradle host for the component showcase.
gpui-showcase-ios Static library and Swift host project for showing gpui-ui-kit on iOS, with tvOS Rust library build support.
gpui-showcase-tvos tvOS static library and Swift host for the component showcase.
Path Purpose
figma/ Figma-to-GPUI design-system rules and Code Connect mappings.
MIGRATION.md Migration notes for moving toolkit code out of the larger SOTF workspace.
CONTRIBUTING.md Contribution, testing, public API, and vendored-code workflow.
SECURITY.md Supported versions and private vulnerability reporting.
SUPPORT.md Support scope and issue-report requirements.
CODE_OF_CONDUCT.md Community conduct and enforcement expectations.
AGENTS.md Short working guide for agents and contributors.
Renderer gallery 200 validated Metal-rendered snapshots across the toolkit component stories.

GPUI Version

This workspace is currently on the 0.10.x GPUI toolkit line and vendors GPUI from Zed v1.25.2, as recorded in the GPUI snapshot provenance.

The workspace uses local path dependencies for toolkit crates and git dependencies on the consolidated sotf-3rdparties snapshot repository for the history-free vendored GPUI platform crates (mirrored at ../sotf-3rdparties/gpui/crates/ in a full checkout); the source-origin gate rejects dependencies that still resolve from zed-industries/zed.git.

Common Commands

# List tasks
just --list

# Check the workspace
just check

# Build all showcase-style demo targets
just demo

# Build maintained examples by crate family
just examples

# Run focused QA
just qa-gpui-obvious

QA & Non-Regression

The full QA suite is just qa. It runs coverage, property tests, visual checks, performance sampling, and the existing smoke tests. On Linux it runs host and WGPU checks; macOS adds the Apple-specific visual and Metal lanes. Windows and Apple targets are not run on Linux.

Common commands:

just qa           # green canonical gate; coverage floor ratchets upward
just qa-prop      # property-based tests
just qa-visual    # visual/golden/conformance checks
just qa-perf      # collect host benchmarks; compare timing on matching hosts
just qa-cov       # workspace coverage report (HTML + JSON)
just qa-cov-check # enforced current floor; 90% remains the release target
just qa-release-contract # governance, MSRV metadata, packages, docs, and API policy

The committed performance baseline was captured on macOS. Linux collects shorter portable benchmark samples and records a skipped timing comparison until a baseline from a comparable Linux host is available.

Update the committed performance baseline after intentional improvements:

just qa-perf-update

See qa.md for the detailed coverage and non-regression plan, and docs/safety.md for the enforced unsafe-Rust boundaries and review requirements.

If the pinned Rust toolchain is unavailable locally, use an installed toolchain explicitly:

cargo +stable check --workspace --all-targets

Scaffolding Mini Apps

Use gpui-scaffolder to generate a small standalone GPUI app directory:

cargo run -p gpui-scaffolder -- my-app
cd my-app
cargo run

Generated projects also include a just run recipe:

just run

To create the app somewhere else, pass --output-dir:

cargo run -p gpui-scaffolder -- my-app --output-dir /tmp

Toolkit CLI

The gpui-toolkit binary is the unified entry point for working with the design system. Run it from the workspace without installing:

cargo run -p gpui-toolkit-cli -- --help

or install it once:

cargo install --path crates/gpui-toolkit-cli
Command Purpose
init Write the managed component catalog into a project's agent docs.
component / search List components, print documents, batch-read several names, or search.
template List, preview, and copy page, block, and theme templates.
eject Copy a component's source into your tree to own and customize it.
theme List presets, export token JSON, check freshness, list token targets.
doctor Read-only health checks; exits 1 on failure, suitable as a CI step.
upgrade List migration notes, or --detect deprecated patterns in a tree.
gap-report Render a prefilled missing-capability issue for the tracker.
layout Validate and expand compact layout expressions to Rust.
manifest Self-describing capability manifest: response types, exit codes, flags.

Every command honors --json with a typed {apiVersion, type, data} envelope and stable ERR_* error codes, so agents can drive the CLI without scraping --help; manifest --json describes every command, its response types and exit codes, flags, and examples in one payload. --dense switches to token-efficient output. The companion layout! proc macro (in gpui-ui-kit-macros) expands the same layout expressions at compile time. Projects customize the CLI with a toolkit.toml file (custom layout components, tracker URL, extra upgrade rules); doctor reports whether it parses. See TUTORIAL.md for a guided walkthrough.

Demos

The aggregate just demo builds:

  • gpui-audio-kit examples
  • gpui-builder layout showcase
  • gpui-component-lab
  • gpui-d3rs showcase
  • gpui-px showcase
  • gpui-python-runtime showcase
  • gpui-themes showcase
  • gpui-ui-kit showcase

Individual recipes are available as just demo-ui-kit, just demo-d3rs, just demo-px, just demo-builder, just demo-component-lab, just demo-audio-kit, just demo-python, and just demo-themes.

The Spinorama demos live in the sibling AutoEQ workspace. Build them there with just demo-d3rs-spinorama or just demo-px-spinorama.

Examples

The Python declarations can be installed directly from PyPI:

python -m pip install gpui-toolkit

Then import the API as gpui_toolkit. Supported-platform wheels include the matching native rendering host, so no Rust installation is needed. Source installs and unsupported platforms provide the declarations only and require GPUI_TOOLKIT_HOST when launching a native app.

The aggregate just examples builds maintained example families:

just examples-audio-kit
just examples-builder
just examples-d3rs
just examples-px
just examples-ui-kit

For the QR rendering example:

just run-qr-debug

Camera scanning is deliberately left to host applications so the UI kit does not impose a native capture backend or operating-system permission model.

iOS

The iOS showcase lives in crates/gpui-showcase/ios. It builds the Rust static library and links it into the bundled Swift GPUIShowcase.xcodeproj.

# Rust static libraries
just ios-rust-sim
just ios-rust-device

# Copy static libraries into the Xcode project
just ios-build-rust-sim
just ios-build-rust-device

# Generate/update the Xcode project with XcodeGen
just ios-xcodegen

# Build the Swift host app
just ios-sim
just ios-device

# Build simulator hot-reload dylib and manifest
just ios-hot-reload

The showcase-* recipe names from the old SOTF workspace are also available, for example just showcase-build-sim.

tvOS

tvOS is a Tier 3 Rust target, so the tvOS recipes use nightly with -Zbuild-std. Install the prerequisites first:

rustup toolchain install nightly
rustup component add rust-src --toolchain nightly

Then build the showcase Rust static library for tvOS:

just tvos-rust-sim
just tvos-rust-device
just tvos-build-rust-sim
just tvos-build-rust-device
just tvos-sim
just tvos-device

This repo currently ships an iOS Swift host project. The tvOS recipes produce the Rust library artifacts and copy them next to the mobile showcase assets.

Android

The Android showcase lives in crates/gpui-showcase/android. It builds the Rust shared library with cargo-ndk and links it into the Gradle host app (org.spinorama.gpui.showcase). Install the prerequisites first:

rustup target add aarch64-linux-android
cargo install cargo-ndk
sdkmanager --install "platform-tools" "platforms;android-35" "build-tools;35.0.0" "ndk;27.2.12479018"

Then check, build, install, and run:

# Check the Rust crate for the arm64 Android target
just android-check

# Build the Rust shared library into Gradle jniLibs
just android-build-rust

# Build the debug APK (includes the Rust library)
just android-apk

# Install and launch on the connected device/emulator
just android-install
just android-run

just qa-android-emulator additionally drives the installed app on an emulator: navigation, pixel capture, and native accessibility-tree export. SDK/NDK/Java homes default to the Homebrew command-line tools, NDK 27.2.12479018, and the Android Studio runtime; override with ANDROID_HOME/ANDROID_SDK_ROOT, ANDROID_NDK_VERSION, and JAVA_HOME.

Quick Example

use gpui::*;
use gpui_ui_kit::{Button, ButtonVariant};
use gpui_px::scatter;

let button = Button::new("submit", "Submit")
    .variant(ButtonVariant::Primary)
    .on_click(|_, _| println!("Clicked"));

let chart = scatter(&x_data, &y_data)
    .title("My Data")
    .build()?;

AI policy

Assisted PRs are welcome and did work very well in the past. In this repo, models and harnesses are helpful.

License

ISC License

文件鏡像歸檔自 GitHub 官方源路徑 · 造訪原專案 GitHub
最後同步快照:2026-11-15