migrate icons to gpui-native-kit
This commit is contained in:
@@ -8,7 +8,7 @@ publish.workspace = true
|
||||
gpui.workspace = true
|
||||
anyhow.workspace = true
|
||||
rust-embed.workspace = true
|
||||
gpui-kit.workspace = true
|
||||
gpui-native-kit.workspace = true
|
||||
|
||||
# On wasm there is no filesystem to read from, so rust-embed's debug-mode
|
||||
# disk loading returns nothing; embed the assets even in debug builds.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use gpui::{AssetSource, Result, SharedString};
|
||||
use gpui_native_kit::icons::IconAssets;
|
||||
use rust_embed::RustEmbed;
|
||||
|
||||
/// The Lucide icons the app and the kit components draw, vendored so they ship
|
||||
@@ -11,8 +12,7 @@ use rust_embed::RustEmbed;
|
||||
#[exclude = "*.DS_Store"]
|
||||
pub struct Assets;
|
||||
|
||||
/// Coop's bundled assets, with the GPUI Kit component icon bundle as the
|
||||
/// fallback for any icon not vendored here.
|
||||
/// Coop's bundled assets, with the native kit's icon bundle.
|
||||
pub struct CombinedAssets;
|
||||
|
||||
impl AssetSource for CombinedAssets {
|
||||
@@ -23,17 +23,13 @@ impl AssetSource for CombinedAssets {
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
// The kit bundle fetches icons over HTTP on the web; a single
|
||||
// instance keeps its download cache alive across loads.
|
||||
use std::sync::OnceLock;
|
||||
static KIT_ASSETS: OnceLock<gpui_kit::assets::Assets> = OnceLock::new();
|
||||
KIT_ASSETS
|
||||
.get_or_init(gpui_kit::assets::Assets::default)
|
||||
.load(path)
|
||||
static KIT_ASSETS: OnceLock<IconAssets> = OnceLock::new();
|
||||
KIT_ASSETS.get_or_init(|| IconAssets).load(path)
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
gpui_kit::assets::Assets.load(path)
|
||||
IconAssets.load(path)
|
||||
}
|
||||
|
||||
fn list(&self, path: &str) -> Result<Vec<SharedString>> {
|
||||
@@ -42,16 +38,12 @@ impl AssetSource for CombinedAssets {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
use std::sync::OnceLock;
|
||||
static KIT_ASSETS: OnceLock<gpui_kit::assets::Assets> = OnceLock::new();
|
||||
paths.extend(
|
||||
KIT_ASSETS
|
||||
.get_or_init(gpui_kit::assets::Assets::default)
|
||||
.list(path)?,
|
||||
);
|
||||
static KIT_ASSETS: OnceLock<IconAssets> = OnceLock::new();
|
||||
paths.extend(KIT_ASSETS.get_or_init(|| IconAssets).list(path)?);
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
paths.extend(gpui_kit::assets::Assets.list(path)?);
|
||||
paths.extend(IconAssets.list(path)?);
|
||||
|
||||
Ok(paths)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user