| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
web: Update to support web with WASM. (#2102) Ref https://github.com/zed-industries/zed/pull/50228 ## Summary - Refactored to share Gallery component between native and web versions - Fixed WASM compatibility issues with async/threading - Added web version of the story gallery ## Show case https://huacnlee.github.io/gpui-component-story-web/ ## Key Changes ### 1. Shared Gallery Component - Extracted Gallery to `crates/story/src/gallery.rs` - Removed duplicate code (~570 lines) from `main.rs` and `story-web/lib.rs` - Both native and web versions now use the same Gallery implementation ### 2. WASM Async Architecture Improvements **Problem:** WASM main thread cannot use blocking synchronization primitives (`Mutex`, `RwLock`) that rely on `Atomics.wait`. **Solution:** Redesigned the async architecture to avoid cross-thread locks: - Changed from `Arc<Mutex<ParsedContent>>` to direct storage in `TextViewState` - Backend tasks now use pure message-passing instead of shared locks - All state updates happen on the main thread **New workflow:** 1. User updates text → Send `UpdateOptions` to background task 2. Background task → Receives copy of current `ParsedContent`, parses text, returns new `ParsedContent` 3. Main thread → Receives result, directly replaces `parsed_content` 4. Rendering → Reads `parsed_content`, no locks needed ### 3. Cross-platform Time APIs - Replaced `std::time` with `instant` crate for cross-platform compatibility - Updated 11 files to use `instant::{Duration, Instant}` - Fixed tracing-subscriber initialization for WASM (`.without_time()`) ## Technical Details ### Files Modified - `crates/story/src/gallery.rs` - **New** shared Gallery module - `crates/story/src/main.rs` - Simplified to use shared Gallery - `crates/story-web/src/lib.rs` - Simplified to use shared Gallery (326 lines → 26 lines) - `crates/ui/src/text/state.rs` - WASM async architecture improvements - `crates/ui/src/async_util.rs` - Cross-platform async utilities - `crates/ui/Cargo.toml` - Added `instant` and `parking_lot` dependencies ### Key Architecture Changes ```rust // Before: Shared mutable state with locks (blocked on WASM) pub struct TextViewState { parsed_content: Arc<Mutex<ParsedContent>>, } // After: Direct storage with message-passing (WASM-compatible) pub struct TextViewState { parsed_content: ParsedContent, } ``` ## Test Plan - ✅ Native version compiles and runs - ✅ WASM version builds successfully - ✅ All components render correctly in both versions - ✅ No "Atomics.wait cannot be called in this context" errors ## Benefits - **Reduced code duplication**: Removed ~570 lines of duplicate code - **Single source of truth**: Gallery updates only need to happen in one place - **WASM compatibility**: Proper async architecture that works on single-threaded WASM - **Cross-platform**: Native and Web use identical code paths ## TODO - [ ] `gpui_web` not have implement the `set_menus`, app menu missing. - [ ] `tree-sitter` can't compiled for wasm, disabled to without highlight. - [ ] Input can't handle any type events. - [ ] Embed font for CJK. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> | 6 个月前 | |
website: Keep box-drawing glyphs in the gallery font subsets (#3305) ## Description The web gallery's welcome story renders `README.md` through `include_str!`, but `crates/story-web/scripts/subset-fonts.py` only collected characters from `.rs` sources. The README's `├──` / `└──` crate tree lost its glyphs from the JetBrains Mono subset, and the `EmojiAndCjk` Canvas fallback does not cover box-drawing characters, so https://gpui-kit.com/gallery/ draws them as tofu. Desktop builds are unaffected: they use complete system monospace fonts with platform fallback. - `subset-fonts.py` now also reads every file a scanned source pulls in with `include_str!` (README, fixtures, theme JSON, `examples/fixtures/test.md`). - FontTools 4.66 keeps the input flavor when `--flavor` is not given, which wrote `Inter-Regular.ttf` as WOFF2. The script passes `--flavor=none` and pins `fonttools[woff]==4.66.0` so reruns produce the same files. - Regenerated the four subsets. They were also behind the current story sources: Noto Sans SC gains 70+ Han characters the stories already use (such as 探索 and 继续编辑), and `▸ ▾ ○`, no longer used anywhere, drop out. - Updated the Noto Sans SC subset size and the subset description in `webassembly.md` and `fonts.md` (`en` and `zh-CN`). | Font file | Before (bytes) | After (bytes) | | --- | ---: | ---: | | `Inter-Regular.ttf` | 88,036 | 94,432 | | `JetBrainsMono-Regular.ttf` | 84,160 | 89,508 | | `NotoSansSC-Regular-subset.ttf` | 25,484 | 42,092 | | `IBMPlexSans-Regular.ttf` | 48,676 | 49,124 | ### Before <img alt="before" src="https://github.com/user-attachments/assets/2e3628d9-3a76-465f-94b9-d9bec1eabebd" /> ### After <img alt="after" src="https://github.com/user-attachments/assets/ab84a9ec-77c3-42cf-8cb8-91cdfdd722d2" /> ## How to Test - Run `bun run --cwd crates/story-web/www fonts` twice: the generated files are byte-identical, and all four start with the TrueType `00010000` header. - Run `make dev` in `crates/story-web` and open `/gallery/`. The Introduction page draws the crate tree with box-drawing lines; the live site shows tofu in the same place. The script change, regenerated fonts and documentation edits in this PR were AI-generated. Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: 李波 <bo.li@longbridge-inc.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> | 19 小时前 | |
website: Keep box-drawing glyphs in the gallery font subsets (#3305) ## Description The web gallery's welcome story renders `README.md` through `include_str!`, but `crates/story-web/scripts/subset-fonts.py` only collected characters from `.rs` sources. The README's `├──` / `└──` crate tree lost its glyphs from the JetBrains Mono subset, and the `EmojiAndCjk` Canvas fallback does not cover box-drawing characters, so https://gpui-kit.com/gallery/ draws them as tofu. Desktop builds are unaffected: they use complete system monospace fonts with platform fallback. - `subset-fonts.py` now also reads every file a scanned source pulls in with `include_str!` (README, fixtures, theme JSON, `examples/fixtures/test.md`). - FontTools 4.66 keeps the input flavor when `--flavor` is not given, which wrote `Inter-Regular.ttf` as WOFF2. The script passes `--flavor=none` and pins `fonttools[woff]==4.66.0` so reruns produce the same files. - Regenerated the four subsets. They were also behind the current story sources: Noto Sans SC gains 70+ Han characters the stories already use (such as 探索 and 继续编辑), and `▸ ▾ ○`, no longer used anywhere, drop out. - Updated the Noto Sans SC subset size and the subset description in `webassembly.md` and `fonts.md` (`en` and `zh-CN`). | Font file | Before (bytes) | After (bytes) | | --- | ---: | ---: | | `Inter-Regular.ttf` | 88,036 | 94,432 | | `JetBrainsMono-Regular.ttf` | 84,160 | 89,508 | | `NotoSansSC-Regular-subset.ttf` | 25,484 | 42,092 | | `IBMPlexSans-Regular.ttf` | 48,676 | 49,124 | ### Before <img alt="before" src="https://github.com/user-attachments/assets/2e3628d9-3a76-465f-94b9-d9bec1eabebd" /> ### After <img alt="after" src="https://github.com/user-attachments/assets/ab84a9ec-77c3-42cf-8cb8-91cdfdd722d2" /> ## How to Test - Run `bun run --cwd crates/story-web/www fonts` twice: the generated files are byte-identical, and all four start with the TrueType `00010000` header. - Run `make dev` in `crates/story-web` and open `/gallery/`. The Introduction page draws the crate tree with box-drawing lines; the live site shows tofu in the same place. The script change, regenerated fonts and documentation edits in this PR were AI-generated. Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: 李波 <bo.li@longbridge-inc.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> | 19 小时前 | |
website: add JSON-backed theme command palette (#3198) ## Summary - Add a searchable theme Command Palette with GPUI Component's light/dark groups, palette icons, selection highlight, checkmark, and cancel-to-restore behavior. `⌘K` / `Ctrl+K` opens it; `/` opens documentation search. Arrow keys preview themes; mouse hover highlights without previewing, and click or Enter confirms. - Read all theme variants directly from `themes/*.json` and generate shared website tokens and static JSON source files at build time. New files and changed colors are picked up on the next build. - Pass the selected theme's original JSON to the embedded WASM gallery on first load and every theme change, including switches within the same light/dark mode. Fall back to the gallery's bundled themes if a source file cannot be loaded. - Reduce the window preview title bar divider and dark-theme window shadow opacity. - Increase the story gallery WASM stack so the Button example renders in local builds. ## Test Plan - `cd website && bun run build` - `cd website && bun run test:seo` (14 passed) - `cargo +nightly check -p gpui-component-story-web --target wasm32-unknown-unknown` - `cd crates/story-web && ./scripts/build-wasm.sh` - Rendered Button and Alert examples in local Chrome; Button showed its controls in light and dark themes without page errors. - `cd crates/story-web/www && bun run build` - Verified both language homepages list 36 JSON variants plus 2 defaults, and all 21 generated JSON files match their source files. - Verified a versioned website build emits and links theme JSON under its base path. --------- Co-authored-by: Codex <codex@openai.com> | 6 天前 | |
website: add JSON-backed theme command palette (#3198) ## Summary - Add a searchable theme Command Palette with GPUI Component's light/dark groups, palette icons, selection highlight, checkmark, and cancel-to-restore behavior. `⌘K` / `Ctrl+K` opens it; `/` opens documentation search. Arrow keys preview themes; mouse hover highlights without previewing, and click or Enter confirms. - Read all theme variants directly from `themes/*.json` and generate shared website tokens and static JSON source files at build time. New files and changed colors are picked up on the next build. - Pass the selected theme's original JSON to the embedded WASM gallery on first load and every theme change, including switches within the same light/dark mode. Fall back to the gallery's bundled themes if a source file cannot be loaded. - Reduce the window preview title bar divider and dark-theme window shadow opacity. - Increase the story gallery WASM stack so the Button example renders in local builds. ## Test Plan - `cd website && bun run build` - `cd website && bun run test:seo` (14 passed) - `cargo +nightly check -p gpui-component-story-web --target wasm32-unknown-unknown` - `cd crates/story-web && ./scripts/build-wasm.sh` - Rendered Button and Alert examples in local Chrome; Button showed its controls in light and dark themes without page errors. - `cd crates/story-web/www && bun run build` - Verified both language homepages list 36 JSON variants plus 2 defaults, and all 21 generated JSON files match their source files. - Verified a versioned website build emits and links theme JSON under its base path. --------- Co-authored-by: Codex <codex@openai.com> | 6 天前 | |
Bump v0.7.0 | 1 天前 | |
web: Update to support web with WASM. (#2102) Ref https://github.com/zed-industries/zed/pull/50228 ## Summary - Refactored to share Gallery component between native and web versions - Fixed WASM compatibility issues with async/threading - Added web version of the story gallery ## Show case https://huacnlee.github.io/gpui-component-story-web/ ## Key Changes ### 1. Shared Gallery Component - Extracted Gallery to `crates/story/src/gallery.rs` - Removed duplicate code (~570 lines) from `main.rs` and `story-web/lib.rs` - Both native and web versions now use the same Gallery implementation ### 2. WASM Async Architecture Improvements **Problem:** WASM main thread cannot use blocking synchronization primitives (`Mutex`, `RwLock`) that rely on `Atomics.wait`. **Solution:** Redesigned the async architecture to avoid cross-thread locks: - Changed from `Arc<Mutex<ParsedContent>>` to direct storage in `TextViewState` - Backend tasks now use pure message-passing instead of shared locks - All state updates happen on the main thread **New workflow:** 1. User updates text → Send `UpdateOptions` to background task 2. Background task → Receives copy of current `ParsedContent`, parses text, returns new `ParsedContent` 3. Main thread → Receives result, directly replaces `parsed_content` 4. Rendering → Reads `parsed_content`, no locks needed ### 3. Cross-platform Time APIs - Replaced `std::time` with `instant` crate for cross-platform compatibility - Updated 11 files to use `instant::{Duration, Instant}` - Fixed tracing-subscriber initialization for WASM (`.without_time()`) ## Technical Details ### Files Modified - `crates/story/src/gallery.rs` - **New** shared Gallery module - `crates/story/src/main.rs` - Simplified to use shared Gallery - `crates/story-web/src/lib.rs` - Simplified to use shared Gallery (326 lines → 26 lines) - `crates/ui/src/text/state.rs` - WASM async architecture improvements - `crates/ui/src/async_util.rs` - Cross-platform async utilities - `crates/ui/Cargo.toml` - Added `instant` and `parking_lot` dependencies ### Key Architecture Changes ```rust // Before: Shared mutable state with locks (blocked on WASM) pub struct TextViewState { parsed_content: Arc<Mutex<ParsedContent>>, } // After: Direct storage with message-passing (WASM-compatible) pub struct TextViewState { parsed_content: ParsedContent, } ``` ## Test Plan - ✅ Native version compiles and runs - ✅ WASM version builds successfully - ✅ All components render correctly in both versions - ✅ No "Atomics.wait cannot be called in this context" errors ## Benefits - **Reduced code duplication**: Removed ~570 lines of duplicate code - **Single source of truth**: Gallery updates only need to happen in one place - **WASM compatibility**: Proper async architecture that works on single-threaded WASM - **Cross-platform**: Native and Web use identical code paths ## TODO - [ ] `gpui_web` not have implement the `set_menus`, app menu missing. - [ ] `tree-sitter` can't compiled for wasm, disabled to without highlight. - [ ] Input can't handle any type events. - [ ] Embed font for CJK. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> | 6 个月前 | |
Rebrand to GPUI Kit and move the site to gpui-kit.com (#2927) ## Summary GPUI Kit is now the ecosystem and product brand. GPUI Component is its styled component layer, alongside `gpui-base` and `gpui-shell`: ```text gpui-kit ├── gpui-base Unstyled behavior, state, and infrastructure ├── gpui-shell JavaScript extensions for a Rust host └── gpui-component GPUI Component: the complete styled UI system ``` The site now lives at https://gpui-kit.com (GitHub Pages custom domain is already configured). ### Brand - Site title, home nav and footer, App Stories, Skills, Contributors, Base intro, the ecosystem-level statements in the Design and Coding Guides, logo `<title>`, OG template and the application-layers SVG now say GPUI Kit. - `docs/index.md` (en + zh-CN) becomes "GPUI Kit Introduction" and lists the three crates, noting that this section documents GPUI Component. - `og.png` / `og-dark.png` regenerated from the template at 2×. - Sentences about the `gpui-component` crate itself (`gpui_component::init`, theme, icons, fluent traits, i18n, Root) keep the GPUI Component name. Repo URLs, crate names and docs.rs links are unchanged. - Skill copies of both guides re-synced. ### Domain and base path - VitePress `base` drops from `/gpui-component/` to `/`; `website/public/CNAME` added. - Gallery and Base example WASM bases move to `/gallery/` and `/examples/base/`. - Every `longbridge.github.io/gpui-component` link in the repo (crate `homepage`, story examples, skills references, docs) points at the new domain. ### READMEs and CLAUDE.md - Both READMEs describe the three-layer architecture with an updated table, diagram and comparison column, plus a documentation link. - `CLAUDE.md` brand constraint and project overview updated to match. ## Notes - Touches `website/.vitepress/config.mts`; will need a small rebase if #2926 (the Astro migration) lands first. - Verified with `bun run build`: root-path favicon and canonical URLs, `GPUI Kit` titles, CNAME in dist. - Rust changes are string literals only. Written with AI assistance (Claude Code): brand and domain replacements, README architecture rewrite. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Cqg8PQLBZsVbjm4VdvEEUc Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> | 26 天前 | |
web: Update to support web with WASM. (#2102) Ref https://github.com/zed-industries/zed/pull/50228 ## Summary - Refactored to share Gallery component between native and web versions - Fixed WASM compatibility issues with async/threading - Added web version of the story gallery ## Show case https://huacnlee.github.io/gpui-component-story-web/ ## Key Changes ### 1. Shared Gallery Component - Extracted Gallery to `crates/story/src/gallery.rs` - Removed duplicate code (~570 lines) from `main.rs` and `story-web/lib.rs` - Both native and web versions now use the same Gallery implementation ### 2. WASM Async Architecture Improvements **Problem:** WASM main thread cannot use blocking synchronization primitives (`Mutex`, `RwLock`) that rely on `Atomics.wait`. **Solution:** Redesigned the async architecture to avoid cross-thread locks: - Changed from `Arc<Mutex<ParsedContent>>` to direct storage in `TextViewState` - Backend tasks now use pure message-passing instead of shared locks - All state updates happen on the main thread **New workflow:** 1. User updates text → Send `UpdateOptions` to background task 2. Background task → Receives copy of current `ParsedContent`, parses text, returns new `ParsedContent` 3. Main thread → Receives result, directly replaces `parsed_content` 4. Rendering → Reads `parsed_content`, no locks needed ### 3. Cross-platform Time APIs - Replaced `std::time` with `instant` crate for cross-platform compatibility - Updated 11 files to use `instant::{Duration, Instant}` - Fixed tracing-subscriber initialization for WASM (`.without_time()`) ## Technical Details ### Files Modified - `crates/story/src/gallery.rs` - **New** shared Gallery module - `crates/story/src/main.rs` - Simplified to use shared Gallery - `crates/story-web/src/lib.rs` - Simplified to use shared Gallery (326 lines → 26 lines) - `crates/ui/src/text/state.rs` - WASM async architecture improvements - `crates/ui/src/async_util.rs` - Cross-platform async utilities - `crates/ui/Cargo.toml` - Added `instant` and `parking_lot` dependencies ### Key Architecture Changes ```rust // Before: Shared mutable state with locks (blocked on WASM) pub struct TextViewState { parsed_content: Arc<Mutex<ParsedContent>>, } // After: Direct storage with message-passing (WASM-compatible) pub struct TextViewState { parsed_content: ParsedContent, } ``` ## Test Plan - ✅ Native version compiles and runs - ✅ WASM version builds successfully - ✅ All components render correctly in both versions - ✅ No "Atomics.wait cannot be called in this context" errors ## Benefits - **Reduced code duplication**: Removed ~570 lines of duplicate code - **Single source of truth**: Gallery updates only need to happen in one place - **WASM compatibility**: Proper async architecture that works on single-threaded WASM - **Cross-platform**: Native and Web use identical code paths ## TODO - [ ] `gpui_web` not have implement the `set_menus`, app menu missing. - [ ] `tree-sitter` can't compiled for wasm, disabled to without highlight. - [ ] Input can't handle any type events. - [ ] Embed font for CJK. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> | 6 个月前 |
GPUI Component Story Web
Web-based component gallery for GPUI Component library.
Live Demo: https://gpui-kit.com/gallery/
Prerequisites
- Rust toolchain with
wasm32-unknown-unknowntarget - Bun (recommended) or Node.js
- wasm-bindgen-cli
Install Dependencies
# Add WASM target
rustup target add wasm32-unknown-unknown
# Install wasm-bindgen-cli
cargo install wasm-bindgen-cli
# Install Bun (macOS/Linux)
curl -fsSL https://bun.sh/install | bash
Development
Start Development Server
make dev
This will:
- Build WASM in debug mode
- Generate JavaScript bindings
- Start Vite dev server on http://localhost:3000
Production Build
Build for Production
make build-prod
This builds the project with:
- Release mode WASM
- Production optimizations
- Base path set to
/gallery/for GitHub Pages
The output will be in www/dist/ directory.
Deployment
The gallery is automatically deployed to GitHub Pages at /gallery/ when docs are released.
The deployment is handled by .github/workflows/release-docs.yml which:
- Builds WASM in release mode
- Builds frontend with production settings
- Copies output to
docs/.vitepress/dist/gallery/ - Deploys to GitHub Pages