| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
assets: share Lucide icon names and preserve default icons (#3020) ## Description Provide the complete Lucide catalog through `gpui-kit-assets::IconName` so Base and other presentation layers can share it without depending on GPUI Component. The package includes all 1,818 Lucide 1.43.0 SVGs and the 12 retained GPUI Kit icons. Keep the existing application workflow: default `Assets` embeds the original 101 component icons, and applications provide additional icons through their own `AssetSource`. Full native embedding is an explicit `AllAssets` choice. The optional `icon_assets!(ExtraIcons, [...])` macro creates a selected source that can be composed with the default bundle. WASM keeps its existing on-demand CDN loader; selected sources can embed bytes directly. ## Compatibility Existing component imports, exhaustive matches, and `IconName::Search.view(cx)` calls remain valid without additional trait imports. Component retains its original enum as a compatibility adapter; `Icon::new(...)` accepts both this enum and the new shared assets enum. Legacy names can convert into shared names using `.into()`. The extension trait is only an optional convenience for the new shared enum. Preserve `Assets::get`, `Assets::iter`, `Assets::new`, the original default path set, asset-source behavior, and Cargo icon-directory metadata. The complete catalog and default component bundle are generated separately; adding Lucide files does not expand default embedding. ## Documentation and maintenance README and both language versions of Icon / Icons & Assets have a prominent NOTE distinguishing the catalog from default embedding, plus a measured comparison table. A default-plus-10-extra-icons example adds 19,648 bytes to a Linux release/stripped resource program; those extra SVGs total 3,903 bytes. The measurement includes source composition/lookup code and is not a fixed per-icon cost or a RAM estimate. `bun script/sync-lucide.ts` replaces the Python updater. It verifies the pinned archive SHA-256, supports offline `--archive` and read-only `--check`, copies the upstream license, and preserves custom icons and the default bundle selection. ## Validation - `cargo test -p gpui-kit-assets --test icons`: 5 tests covering complete/default catalogs, selected resources, empty selection and native compatibility. - `cargo test -p gpui-kit --test assets`: 2 tests covering shared names and unchanged legacy views/conversions; 1 test also passes with `--no-default-features --features assets`. - `cargo clippy -p gpui-component -p gpui-kit-assets -p gpui-component-story -- --deny warnings`; `cargo fmt --all --check`. - `cargo check -p gpui-component --no-default-features`. - `cargo check -p gpui-kit-assets --lib --example selected_assets --target wasm32-unknown-unknown`. - `cargo package -p gpui-kit-assets --allow-dirty` verifies packaged build generation. - `cargo run -p gpui-kit-assets --release --example extra_assets -- icons/accessibility.svg` and `icons/search.svg` verify application and component fallback paths. - `bun test script/tests/sync-lucide.test.ts`: 14 assertions covering check-only behavior, synchronization, custom-file preservation, count validation and corrupt-archive rejection. Online and offline checks verify all 1,818 upstream SVGs and their license. - Website production build passes; generated HTML contains the comparison table inside each of the four NOTE callouts. - Binary inspection confirms 101 SVG payloads by default, 103 with two extras, 111 with ten extras, and 1,830 only with explicit `AllAssets`. | Native resource configuration | Embedded SVG size (KiB) | Binary increase over default (KiB) | | --- | ---: | ---: | | Default (101 icons) | 44.28 | 0.00 | | Default + 2 extras | 45.04 | 15.19 | | Default + 10 extras | 48.09 | 19.19 | | Explicit AllAssets | 731.45 | 1045.16 | 1 KiB = 1,024 bytes. Measured with Rust 1.98.0 on Linux x86_64, release optimization and stripped symbols. Every program retains the same shared-name lookup and runtime path; extra sources fall back to the default and merge/sort/deduplicate their lists. The documentation names the exact icons and explains limitations. ## Checklist - [x] Read the contribution guidelines. - [x] Reviewed the implementation, including AI-generated code. - [x] Ran targeted tests and resource examples. - [ ] Ran the interactive story gallery. - [ ] Tested native macOS and Windows behavior (Linux and WASM compilation validated). | 1 个月前 | |
kit: Add optional gpui-fast backend (#3375) Add an optional `gpui-fast` feature across GPUI Kit’s existing crates: ```toml gpui-kit = { version = "0.7", features = ["gpui-fast"] } ``` No new crates. Preserve the existing `gpui-pre-*` workspace dependencies and default backend; optional Fast dependencies and internal conditional aliases select the engine. Existing application imports and macros continue to work. This is additive, with no breaking changes. Upstream packages still compile because Cargo features are additive. ## Public API - **gpui-kit:** `gpui-fast` selects Fast for core, platforms, and enabled layers. - **gpui-base, gpui-component, gpui-kit-assets, gpui-fps, gpui-wry, gpui-shell, gpui-component-shell:** `gpui-fast` selects the matching backend for standalone consumers. - **gpui-component-macros:** `#[derive(IntoPlot)]` additionally recognizes direct Fast dependencies. - Gallery and examples expose the same feature for comparisons. ## Validation 27 focused UI/macro/assets tests and 9 documentation tests pass. Default/Fast configurations, examples, WebView, Shell, benchmarks, and nightly WebAssembly compile. Clippy, formatting, dependency, and snapshot-pin checks pass. CI adds native and WebAssembly coverage. AI-assisted with Codex. | 11 天前 | |
assets: share Lucide icon names and preserve default icons (#3020) ## Description Provide the complete Lucide catalog through `gpui-kit-assets::IconName` so Base and other presentation layers can share it without depending on GPUI Component. The package includes all 1,818 Lucide 1.43.0 SVGs and the 12 retained GPUI Kit icons. Keep the existing application workflow: default `Assets` embeds the original 101 component icons, and applications provide additional icons through their own `AssetSource`. Full native embedding is an explicit `AllAssets` choice. The optional `icon_assets!(ExtraIcons, [...])` macro creates a selected source that can be composed with the default bundle. WASM keeps its existing on-demand CDN loader; selected sources can embed bytes directly. ## Compatibility Existing component imports, exhaustive matches, and `IconName::Search.view(cx)` calls remain valid without additional trait imports. Component retains its original enum as a compatibility adapter; `Icon::new(...)` accepts both this enum and the new shared assets enum. Legacy names can convert into shared names using `.into()`. The extension trait is only an optional convenience for the new shared enum. Preserve `Assets::get`, `Assets::iter`, `Assets::new`, the original default path set, asset-source behavior, and Cargo icon-directory metadata. The complete catalog and default component bundle are generated separately; adding Lucide files does not expand default embedding. ## Documentation and maintenance README and both language versions of Icon / Icons & Assets have a prominent NOTE distinguishing the catalog from default embedding, plus a measured comparison table. A default-plus-10-extra-icons example adds 19,648 bytes to a Linux release/stripped resource program; those extra SVGs total 3,903 bytes. The measurement includes source composition/lookup code and is not a fixed per-icon cost or a RAM estimate. `bun script/sync-lucide.ts` replaces the Python updater. It verifies the pinned archive SHA-256, supports offline `--archive` and read-only `--check`, copies the upstream license, and preserves custom icons and the default bundle selection. ## Validation - `cargo test -p gpui-kit-assets --test icons`: 5 tests covering complete/default catalogs, selected resources, empty selection and native compatibility. - `cargo test -p gpui-kit --test assets`: 2 tests covering shared names and unchanged legacy views/conversions; 1 test also passes with `--no-default-features --features assets`. - `cargo clippy -p gpui-component -p gpui-kit-assets -p gpui-component-story -- --deny warnings`; `cargo fmt --all --check`. - `cargo check -p gpui-component --no-default-features`. - `cargo check -p gpui-kit-assets --lib --example selected_assets --target wasm32-unknown-unknown`. - `cargo package -p gpui-kit-assets --allow-dirty` verifies packaged build generation. - `cargo run -p gpui-kit-assets --release --example extra_assets -- icons/accessibility.svg` and `icons/search.svg` verify application and component fallback paths. - `bun test script/tests/sync-lucide.test.ts`: 14 assertions covering check-only behavior, synchronization, custom-file preservation, count validation and corrupt-archive rejection. Online and offline checks verify all 1,818 upstream SVGs and their license. - Website production build passes; generated HTML contains the comparison table inside each of the four NOTE callouts. - Binary inspection confirms 101 SVG payloads by default, 103 with two extras, 111 with ten extras, and 1,830 only with explicit `AllAssets`. | Native resource configuration | Embedded SVG size (KiB) | Binary increase over default (KiB) | | --- | ---: | ---: | | Default (101 icons) | 44.28 | 0.00 | | Default + 2 extras | 45.04 | 15.19 | | Default + 10 extras | 48.09 | 19.19 | | Explicit AllAssets | 731.45 | 1045.16 | 1 KiB = 1,024 bytes. Measured with Rust 1.98.0 on Linux x86_64, release optimization and stripped symbols. Every program retains the same shared-name lookup and runtime path; extra sources fall back to the default and merge/sort/deduplicate their lists. The documentation names the exact icons and explains limitations. ## Checklist - [x] Read the contribution guidelines. - [x] Reviewed the implementation, including AI-generated code. - [x] Ran targeted tests and resource examples. - [ ] Ran the interactive story gallery. - [ ] Tested native macOS and Windows behavior (Linux and WASM compilation validated). | 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> | 7 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 个月前 | ||
| 11 天前 | ||
| 1 个月前 | ||
| 7 个月前 |