Z-2308 - Export Theme Types from Rust (#2621)

This PR adds JSON Schema definitions into GPUI's styles and adds a tool
for generating typescript types from these schema definitions.

Release Notes:

- N/A
This commit is contained in:
Nate Butler 2023-06-22 12:33:18 -04:00 committed by GitHub
commit a305d93567
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 758 additions and 1509 deletions

2
.cargo/config.toml Normal file
View file

@ -0,0 +1,2 @@
[alias]
xtask = "run --package xtask --"

2
.gitignore vendored
View file

@ -4,6 +4,8 @@
/plugins/bin /plugins/bin
/script/node_modules /script/node_modules
/styles/node_modules /styles/node_modules
/styles/src/types/zed.ts
/crates/theme/schemas/theme.json
/crates/collab/static/styles.css /crates/collab/static/styles.css
/vendor/bin /vendor/bin
/assets/themes/*.json /assets/themes/*.json

116
Cargo.lock generated
View file

@ -190,6 +190,55 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "anstream"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is-terminal 0.4.7",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd"
[[package]]
name = "anstyle-parse"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "anstyle-wincon"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188"
dependencies = [
"anstyle",
"windows-sys 0.48.0",
]
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.71" version = "1.0.71"
@ -1102,8 +1151,8 @@ checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
"clap_derive", "clap_derive 3.2.25",
"clap_lex", "clap_lex 0.2.4",
"indexmap", "indexmap",
"once_cell", "once_cell",
"strsim", "strsim",
@ -1111,6 +1160,30 @@ dependencies = [
"textwrap", "textwrap",
] ]
[[package]]
name = "clap"
version = "4.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2686c4115cb0810d9a984776e197823d08ec94f176549a89a9efded477c456dc"
dependencies = [
"clap_builder",
"clap_derive 4.3.2",
"once_cell",
]
[[package]]
name = "clap_builder"
version = "4.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e53afce1efce6ed1f633cf0e57612fe51db54a1ee4fd8f8503d078fe02d69ae"
dependencies = [
"anstream",
"anstyle",
"bitflags",
"clap_lex 0.5.0",
"strsim",
]
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "3.2.25" version = "3.2.25"
@ -1124,6 +1197,18 @@ dependencies = [
"syn 1.0.109", "syn 1.0.109",
] ]
[[package]]
name = "clap_derive"
version = "4.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f"
dependencies = [
"heck 0.4.1",
"proc-macro2",
"quote",
"syn 2.0.18",
]
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.2.4" version = "0.2.4"
@ -1133,12 +1218,18 @@ dependencies = [
"os_str_bytes", "os_str_bytes",
] ]
[[package]]
name = "clap_lex"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
[[package]] [[package]]
name = "cli" name = "cli"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap 3.2.25",
"core-foundation", "core-foundation",
"core-services", "core-services",
"dirs 3.0.2", "dirs 3.0.2",
@ -1248,7 +1339,7 @@ dependencies = [
"axum-extra", "axum-extra",
"base64 0.13.1", "base64 0.13.1",
"call", "call",
"clap", "clap 3.2.25",
"client", "client",
"collections", "collections",
"ctor", "ctor",
@ -1343,6 +1434,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]]
name = "colorchoice"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]] [[package]]
name = "command_palette" name = "command_palette"
version = "0.1.0" version = "0.1.0"
@ -8768,6 +8865,17 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
[[package]]
name = "xtask"
version = "0.1.0"
dependencies = [
"anyhow",
"clap 4.3.5",
"schemars",
"serde_json",
"theme",
]
[[package]] [[package]]
name = "yaml-rust" name = "yaml-rust"
version = "0.4.5" version = "0.4.5"

View file

@ -65,6 +65,7 @@ members = [
"crates/vim", "crates/vim",
"crates/workspace", "crates/workspace",
"crates/welcome", "crates/welcome",
"crates/xtask",
"crates/zed", "crates/zed",
] ]
default-members = ["crates/zed"] default-members = ["crates/zed"]

View file

@ -6,15 +6,16 @@ use std::{
use crate::json::ToJson; use crate::json::ToJson;
use pathfinder_color::{ColorF, ColorU}; use pathfinder_color::{ColorF, ColorU};
use schemars::JsonSchema;
use serde::{ use serde::{
de::{self, Unexpected}, de::{self, Unexpected},
Deserialize, Deserializer, Deserialize, Deserializer,
}; };
use serde_json::json; use serde_json::json;
#[derive(Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord)] #[derive(Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord, JsonSchema)]
#[repr(transparent)] #[repr(transparent)]
pub struct Color(ColorU); pub struct Color(#[schemars(with = "String")] ColorU);
impl Color { impl Color {
pub fn transparent_black() -> Self { pub fn transparent_black() -> Self {

View file

@ -12,10 +12,11 @@ use crate::{
scene::{self, Border, CursorRegion, Quad}, scene::{self, Border, CursorRegion, Quad},
AnyElement, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext, AnyElement, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext,
}; };
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde_json::json; use serde_json::json;
#[derive(Clone, Copy, Debug, Default, Deserialize)] #[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)]
pub struct ContainerStyle { pub struct ContainerStyle {
#[serde(default)] #[serde(default)]
pub margin: Margin, pub margin: Margin,
@ -332,7 +333,7 @@ impl ToJson for ContainerStyle {
} }
} }
#[derive(Clone, Copy, Debug, Default)] #[derive(Clone, Copy, Debug, Default, JsonSchema)]
pub struct Margin { pub struct Margin {
pub top: f32, pub top: f32,
pub left: f32, pub left: f32,
@ -359,7 +360,7 @@ impl ToJson for Margin {
} }
} }
#[derive(Clone, Copy, Debug, Default)] #[derive(Clone, Copy, Debug, Default, JsonSchema)]
pub struct Padding { pub struct Padding {
pub top: f32, pub top: f32,
pub left: f32, pub left: f32,
@ -486,9 +487,10 @@ impl ToJson for Padding {
} }
} }
#[derive(Clone, Copy, Debug, Default, Deserialize)] #[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)]
pub struct Shadow { pub struct Shadow {
#[serde(default, deserialize_with = "deserialize_vec2f")] #[serde(default, deserialize_with = "deserialize_vec2f")]
#[schemars(with = "Vec::<f32>")]
offset: Vector2F, offset: Vector2F,
#[serde(default)] #[serde(default)]
blur: f32, blur: f32,

View file

@ -8,6 +8,7 @@ use crate::{
scene, Border, Element, ImageData, LayoutContext, SceneBuilder, SizeConstraint, View, scene, Border, Element, ImageData, LayoutContext, SceneBuilder, SizeConstraint, View,
ViewContext, ViewContext,
}; };
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use std::{ops::Range, sync::Arc}; use std::{ops::Range, sync::Arc};
@ -21,7 +22,7 @@ pub struct Image {
style: ImageStyle, style: ImageStyle,
} }
#[derive(Copy, Clone, Default, Deserialize)] #[derive(Copy, Clone, Default, Deserialize, JsonSchema)]
pub struct ImageStyle { pub struct ImageStyle {
#[serde(default)] #[serde(default)]
pub border: Border, pub border: Border,

View file

@ -10,6 +10,7 @@ use crate::{
text_layout::{Line, RunStyle}, text_layout::{Line, RunStyle},
Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext,
}; };
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde_json::json; use serde_json::json;
use smallvec::{smallvec, SmallVec}; use smallvec::{smallvec, SmallVec};
@ -20,7 +21,7 @@ pub struct Label {
highlight_indices: Vec<usize>, highlight_indices: Vec<usize>,
} }
#[derive(Clone, Debug, Deserialize, Default)] #[derive(Clone, Debug, Deserialize, Default, JsonSchema)]
pub struct LabelStyle { pub struct LabelStyle {
pub text: TextStyle, pub text: TextStyle,
pub highlight_text: Option<TextStyle>, pub highlight_text: Option<TextStyle>,

View file

@ -9,6 +9,7 @@ use crate::{
Action, Axis, ElementStateHandle, LayoutContext, SceneBuilder, SizeConstraint, Task, View, Action, Axis, ElementStateHandle, LayoutContext, SceneBuilder, SizeConstraint, Task, View,
ViewContext, ViewContext,
}; };
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use std::{ use std::{
cell::{Cell, RefCell}, cell::{Cell, RefCell},
@ -33,7 +34,7 @@ struct TooltipState {
debounce: RefCell<Option<Task<()>>>, debounce: RefCell<Option<Task<()>>>,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct TooltipStyle { pub struct TooltipStyle {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -42,7 +43,7 @@ pub struct TooltipStyle {
pub max_text_width: Option<f32>, pub max_text_width: Option<f32>,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct KeystrokeStyle { pub struct KeystrokeStyle {
#[serde(flatten)] #[serde(flatten)]
container: ContainerStyle, container: ContainerStyle,

View file

@ -7,13 +7,14 @@ use crate::{
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use ordered_float::OrderedFloat; use ordered_float::OrderedFloat;
use parking_lot::{RwLock, RwLockUpgradableReadGuard}; use parking_lot::{RwLock, RwLockUpgradableReadGuard};
use schemars::JsonSchema;
use std::{ use std::{
collections::HashMap, collections::HashMap,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
sync::Arc, sync::Arc,
}; };
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, JsonSchema)]
pub struct FamilyId(usize); pub struct FamilyId(usize);
struct Family { struct Family {

View file

@ -16,7 +16,7 @@ use serde::{de, Deserialize, Serialize};
use serde_json::Value; use serde_json::Value;
use std::{cell::RefCell, sync::Arc}; use std::{cell::RefCell, sync::Arc};
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, JsonSchema)]
pub struct FontId(pub usize); pub struct FontId(pub usize);
pub type GlyphId = u32; pub type GlyphId = u32;
@ -59,20 +59,44 @@ pub struct Features {
pub zero: Option<bool>, pub zero: Option<bool>,
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug, JsonSchema)]
pub struct TextStyle { pub struct TextStyle {
pub color: Color, pub color: Color,
pub font_family_name: Arc<str>, pub font_family_name: Arc<str>,
pub font_family_id: FamilyId, pub font_family_id: FamilyId,
pub font_id: FontId, pub font_id: FontId,
pub font_size: f32, pub font_size: f32,
#[schemars(with = "PropertiesDef")]
pub font_properties: Properties, pub font_properties: Properties,
pub underline: Underline, pub underline: Underline,
} }
#[derive(Copy, Clone, Debug, Default, PartialEq)] #[derive(JsonSchema)]
#[serde(remote = "Properties")]
pub struct PropertiesDef {
/// The font style, as defined in CSS.
pub style: StyleDef,
/// The font weight, as defined in CSS.
pub weight: f32,
/// The font stretchiness, as defined in CSS.
pub stretch: f32,
}
#[derive(JsonSchema)]
#[schemars(remote = "Style")]
pub enum StyleDef {
/// A face that is neither italic not obliqued.
Normal,
/// A form that is generally cursive in nature.
Italic,
/// A typically-sloped version of the regular face.
Oblique,
}
#[derive(Copy, Clone, Debug, Default, PartialEq, JsonSchema)]
pub struct HighlightStyle { pub struct HighlightStyle {
pub color: Option<Color>, pub color: Option<Color>,
#[schemars(with = "Option::<f32>")]
pub weight: Option<Weight>, pub weight: Option<Weight>,
pub italic: Option<bool>, pub italic: Option<bool>,
pub underline: Option<Underline>, pub underline: Option<Underline>,
@ -81,9 +105,10 @@ pub struct HighlightStyle {
impl Eq for HighlightStyle {} impl Eq for HighlightStyle {}
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, JsonSchema)]
pub struct Underline { pub struct Underline {
pub color: Option<Color>, pub color: Option<Color>,
#[schemars(with = "f32")]
pub thickness: OrderedFloat<f32>, pub thickness: OrderedFloat<f32>,
pub squiggly: bool, pub squiggly: bool,
} }

View file

@ -25,6 +25,7 @@ use anyhow::{anyhow, bail, Result};
use async_task::Runnable; use async_task::Runnable;
pub use event::*; pub use event::*;
use postage::oneshot; use postage::oneshot;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use sqlez::{ use sqlez::{
bindable::{Bind, Column, StaticColumnCount}, bindable::{Bind, Column, StaticColumnCount},
@ -282,7 +283,7 @@ pub enum PromptLevel {
Critical, Critical,
} }
#[derive(Copy, Clone, Debug, Deserialize)] #[derive(Copy, Clone, Debug, Deserialize, JsonSchema)]
pub enum CursorStyle { pub enum CursorStyle {
Arrow, Arrow,
ResizeLeftRight, ResizeLeftRight,

View file

@ -3,6 +3,7 @@ mod mouse_region;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
use collections::HashSet; use collections::HashSet;
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use serde_json::json; use serde_json::json;
use std::{borrow::Cow, sync::Arc}; use std::{borrow::Cow, sync::Arc};
@ -99,7 +100,7 @@ pub struct Icon {
pub color: Color, pub color: Color,
} }
#[derive(Clone, Copy, Default, Debug)] #[derive(Clone, Copy, Default, Debug, JsonSchema)]
pub struct Border { pub struct Border {
pub width: f32, pub width: f32,
pub color: Color, pub color: Color,

View file

@ -8,6 +8,7 @@ use gpui::{
fonts::{HighlightStyle, TextStyle}, fonts::{HighlightStyle, TextStyle},
platform, AppContext, AssetSource, Border, MouseState, platform, AppContext, AssetSource, Border, MouseState,
}; };
use schemars::JsonSchema;
use serde::{de::DeserializeOwned, Deserialize}; use serde::{de::DeserializeOwned, Deserialize};
use serde_json::Value; use serde_json::Value;
use settings::SettingsStore; use settings::SettingsStore;
@ -36,7 +37,7 @@ pub fn init(source: impl AssetSource, cx: &mut AppContext) {
.detach(); .detach();
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct Theme { pub struct Theme {
#[serde(default)] #[serde(default)]
pub meta: ThemeMeta, pub meta: ThemeMeta,
@ -67,7 +68,7 @@ pub struct Theme {
pub color_scheme: ColorScheme, pub color_scheme: ColorScheme,
} }
#[derive(Deserialize, Default, Clone)] #[derive(Deserialize, Default, Clone, JsonSchema)]
pub struct ThemeMeta { pub struct ThemeMeta {
#[serde(skip_deserializing)] #[serde(skip_deserializing)]
pub id: usize, pub id: usize,
@ -75,7 +76,7 @@ pub struct ThemeMeta {
pub is_light: bool, pub is_light: bool,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct Workspace { pub struct Workspace {
pub background: Color, pub background: Color,
pub blank_pane: BlankPaneStyle, pub blank_pane: BlankPaneStyle,
@ -102,7 +103,7 @@ pub struct Workspace {
pub drop_target_overlay_color: Color, pub drop_target_overlay_color: Color,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct BlankPaneStyle { pub struct BlankPaneStyle {
pub logo: SvgStyle, pub logo: SvgStyle,
pub logo_shadow: SvgStyle, pub logo_shadow: SvgStyle,
@ -112,7 +113,7 @@ pub struct BlankPaneStyle {
pub keyboard_hint_width: f32, pub keyboard_hint_width: f32,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Titlebar { pub struct Titlebar {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -137,7 +138,7 @@ pub struct Titlebar {
pub toggle_contacts_badge: ContainerStyle, pub toggle_contacts_badge: ContainerStyle,
} }
#[derive(Copy, Clone, Deserialize, Default)] #[derive(Copy, Clone, Deserialize, Default, JsonSchema)]
pub struct AvatarStyle { pub struct AvatarStyle {
#[serde(flatten)] #[serde(flatten)]
pub image: ImageStyle, pub image: ImageStyle,
@ -145,14 +146,14 @@ pub struct AvatarStyle {
pub outer_corner_radius: f32, pub outer_corner_radius: f32,
} }
#[derive(Deserialize, Default, Clone)] #[derive(Deserialize, Default, Clone, JsonSchema)]
pub struct Copilot { pub struct Copilot {
pub out_link_icon: Interactive<IconStyle>, pub out_link_icon: Interactive<IconStyle>,
pub modal: ModalStyle, pub modal: ModalStyle,
pub auth: CopilotAuth, pub auth: CopilotAuth,
} }
#[derive(Deserialize, Default, Clone)] #[derive(Deserialize, Default, Clone, JsonSchema)]
pub struct CopilotAuth { pub struct CopilotAuth {
pub content_width: f32, pub content_width: f32,
pub prompting: CopilotAuthPrompting, pub prompting: CopilotAuthPrompting,
@ -162,14 +163,14 @@ pub struct CopilotAuth {
pub header: IconStyle, pub header: IconStyle,
} }
#[derive(Deserialize, Default, Clone)] #[derive(Deserialize, Default, Clone, JsonSchema)]
pub struct CopilotAuthPrompting { pub struct CopilotAuthPrompting {
pub subheading: ContainedText, pub subheading: ContainedText,
pub hint: ContainedText, pub hint: ContainedText,
pub device_code: DeviceCode, pub device_code: DeviceCode,
} }
#[derive(Deserialize, Default, Clone)] #[derive(Deserialize, Default, Clone, JsonSchema)]
pub struct DeviceCode { pub struct DeviceCode {
pub text: TextStyle, pub text: TextStyle,
pub cta: ButtonStyle, pub cta: ButtonStyle,
@ -179,19 +180,19 @@ pub struct DeviceCode {
pub right_container: Interactive<ContainerStyle>, pub right_container: Interactive<ContainerStyle>,
} }
#[derive(Deserialize, Default, Clone)] #[derive(Deserialize, Default, Clone, JsonSchema)]
pub struct CopilotAuthNotAuthorized { pub struct CopilotAuthNotAuthorized {
pub subheading: ContainedText, pub subheading: ContainedText,
pub warning: ContainedText, pub warning: ContainedText,
} }
#[derive(Deserialize, Default, Clone)] #[derive(Deserialize, Default, Clone, JsonSchema)]
pub struct CopilotAuthAuthorized { pub struct CopilotAuthAuthorized {
pub subheading: ContainedText, pub subheading: ContainedText,
pub hint: ContainedText, pub hint: ContainedText,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct ContactsPopover { pub struct ContactsPopover {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -199,7 +200,7 @@ pub struct ContactsPopover {
pub width: f32, pub width: f32,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct ContactList { pub struct ContactList {
pub user_query_editor: FieldEditor, pub user_query_editor: FieldEditor,
pub user_query_editor_height: f32, pub user_query_editor_height: f32,
@ -221,7 +222,7 @@ pub struct ContactList {
pub calling_indicator: ContainedText, pub calling_indicator: ContainedText,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct ProjectRow { pub struct ProjectRow {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -229,13 +230,13 @@ pub struct ProjectRow {
pub name: ContainedText, pub name: ContainedText,
} }
#[derive(Deserialize, Default, Clone, Copy)] #[derive(Deserialize, Default, Clone, Copy, JsonSchema)]
pub struct TreeBranch { pub struct TreeBranch {
pub width: f32, pub width: f32,
pub color: Color, pub color: Color,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct ContactFinder { pub struct ContactFinder {
pub picker: Picker, pub picker: Picker,
pub row_height: f32, pub row_height: f32,
@ -245,7 +246,7 @@ pub struct ContactFinder {
pub disabled_contact_button: IconButton, pub disabled_contact_button: IconButton,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct DropdownMenu { pub struct DropdownMenu {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -255,7 +256,7 @@ pub struct DropdownMenu {
pub row_height: f32, pub row_height: f32,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct DropdownMenuItem { pub struct DropdownMenuItem {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -266,7 +267,7 @@ pub struct DropdownMenuItem {
pub secondary_text_spacing: f32, pub secondary_text_spacing: f32,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct TabBar { pub struct TabBar {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -294,13 +295,13 @@ impl TabBar {
} }
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct TabStyles { pub struct TabStyles {
pub active_tab: Tab, pub active_tab: Tab,
pub inactive_tab: Tab, pub inactive_tab: Tab,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct AvatarRibbon { pub struct AvatarRibbon {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -308,7 +309,7 @@ pub struct AvatarRibbon {
pub height: f32, pub height: f32,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct OfflineIcon { pub struct OfflineIcon {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -316,7 +317,7 @@ pub struct OfflineIcon {
pub color: Color, pub color: Color,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Tab { pub struct Tab {
pub height: f32, pub height: f32,
#[serde(flatten)] #[serde(flatten)]
@ -333,7 +334,7 @@ pub struct Tab {
pub icon_conflict: Color, pub icon_conflict: Color,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Toolbar { pub struct Toolbar {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -342,14 +343,14 @@ pub struct Toolbar {
pub nav_button: Interactive<IconButton>, pub nav_button: Interactive<IconButton>,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Notifications { pub struct Notifications {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
pub width: f32, pub width: f32,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Search { pub struct Search {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -366,7 +367,7 @@ pub struct Search {
pub dismiss_button: Interactive<IconButton>, pub dismiss_button: Interactive<IconButton>,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct FindEditor { pub struct FindEditor {
#[serde(flatten)] #[serde(flatten)]
pub input: FieldEditor, pub input: FieldEditor,
@ -374,7 +375,7 @@ pub struct FindEditor {
pub max_width: f32, pub max_width: f32,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct StatusBar { pub struct StatusBar {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -390,7 +391,7 @@ pub struct StatusBar {
pub diagnostic_message: Interactive<ContainedText>, pub diagnostic_message: Interactive<ContainedText>,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct StatusBarPanelButtons { pub struct StatusBarPanelButtons {
pub group_left: ContainerStyle, pub group_left: ContainerStyle,
pub group_bottom: ContainerStyle, pub group_bottom: ContainerStyle,
@ -398,7 +399,7 @@ pub struct StatusBarPanelButtons {
pub button: Toggleable<Interactive<PanelButton>>, pub button: Toggleable<Interactive<PanelButton>>,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct StatusBarDiagnosticSummary { pub struct StatusBarDiagnosticSummary {
pub container_ok: ContainerStyle, pub container_ok: ContainerStyle,
pub container_warning: ContainerStyle, pub container_warning: ContainerStyle,
@ -413,7 +414,7 @@ pub struct StatusBarDiagnosticSummary {
pub summary_spacing: f32, pub summary_spacing: f32,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct StatusBarLspStatus { pub struct StatusBarLspStatus {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -424,14 +425,14 @@ pub struct StatusBarLspStatus {
pub message: TextStyle, pub message: TextStyle,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct Dock { pub struct Dock {
pub left: ContainerStyle, pub left: ContainerStyle,
pub bottom: ContainerStyle, pub bottom: ContainerStyle,
pub right: ContainerStyle, pub right: ContainerStyle,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct PanelButton { pub struct PanelButton {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -440,7 +441,7 @@ pub struct PanelButton {
pub label: ContainedText, pub label: ContainedText,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct ProjectPanel { pub struct ProjectPanel {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -453,7 +454,7 @@ pub struct ProjectPanel {
pub open_project_button: Interactive<ContainedText>, pub open_project_button: Interactive<ContainedText>,
} }
#[derive(Clone, Debug, Deserialize, Default)] #[derive(Clone, Debug, Deserialize, Default, JsonSchema)]
pub struct ProjectPanelEntry { pub struct ProjectPanelEntry {
pub height: f32, pub height: f32,
#[serde(flatten)] #[serde(flatten)]
@ -465,19 +466,19 @@ pub struct ProjectPanelEntry {
pub status: EntryStatus, pub status: EntryStatus,
} }
#[derive(Clone, Debug, Deserialize, Default)] #[derive(Clone, Debug, Deserialize, Default, JsonSchema)]
pub struct EntryStatus { pub struct EntryStatus {
pub git: GitProjectStatus, pub git: GitProjectStatus,
} }
#[derive(Clone, Debug, Deserialize, Default)] #[derive(Clone, Debug, Deserialize, Default, JsonSchema)]
pub struct GitProjectStatus { pub struct GitProjectStatus {
pub modified: Color, pub modified: Color,
pub inserted: Color, pub inserted: Color,
pub conflict: Color, pub conflict: Color,
} }
#[derive(Clone, Debug, Deserialize, Default)] #[derive(Clone, Debug, Deserialize, Default, JsonSchema)]
pub struct ContextMenu { pub struct ContextMenu {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -486,7 +487,7 @@ pub struct ContextMenu {
pub separator: ContainerStyle, pub separator: ContainerStyle,
} }
#[derive(Clone, Debug, Deserialize, Default)] #[derive(Clone, Debug, Deserialize, Default, JsonSchema)]
pub struct ContextMenuItem { pub struct ContextMenuItem {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -496,13 +497,13 @@ pub struct ContextMenuItem {
pub icon_spacing: f32, pub icon_spacing: f32,
} }
#[derive(Debug, Deserialize, Default)] #[derive(Debug, Deserialize, Default, JsonSchema)]
pub struct CommandPalette { pub struct CommandPalette {
pub key: Toggleable<ContainedLabel>, pub key: Toggleable<ContainedLabel>,
pub keystroke_spacing: f32, pub keystroke_spacing: f32,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct InviteLink { pub struct InviteLink {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -511,7 +512,7 @@ pub struct InviteLink {
pub icon: Icon, pub icon: Icon,
} }
#[derive(Deserialize, Clone, Copy, Default)] #[derive(Deserialize, Clone, Copy, Default, JsonSchema)]
pub struct Icon { pub struct Icon {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -519,7 +520,7 @@ pub struct Icon {
pub width: f32, pub width: f32,
} }
#[derive(Deserialize, Clone, Copy, Default)] #[derive(Deserialize, Clone, Copy, Default, JsonSchema)]
pub struct IconButton { pub struct IconButton {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -528,7 +529,7 @@ pub struct IconButton {
pub button_width: f32, pub button_width: f32,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct ChatMessage { pub struct ChatMessage {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -537,7 +538,7 @@ pub struct ChatMessage {
pub timestamp: ContainedText, pub timestamp: ContainedText,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct ChannelSelect { pub struct ChannelSelect {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -549,7 +550,7 @@ pub struct ChannelSelect {
pub menu: ContainerStyle, pub menu: ContainerStyle,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct ChannelName { pub struct ChannelName {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -557,7 +558,7 @@ pub struct ChannelName {
pub name: TextStyle, pub name: TextStyle,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Picker { pub struct Picker {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -568,7 +569,7 @@ pub struct Picker {
pub item: Toggleable<Interactive<ContainedLabel>>, pub item: Toggleable<Interactive<ContainedLabel>>,
} }
#[derive(Clone, Debug, Deserialize, Default)] #[derive(Clone, Debug, Deserialize, Default, JsonSchema)]
pub struct ContainedText { pub struct ContainedText {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -576,7 +577,7 @@ pub struct ContainedText {
pub text: TextStyle, pub text: TextStyle,
} }
#[derive(Clone, Debug, Deserialize, Default)] #[derive(Clone, Debug, Deserialize, Default, JsonSchema)]
pub struct ContainedLabel { pub struct ContainedLabel {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -584,7 +585,7 @@ pub struct ContainedLabel {
pub label: LabelStyle, pub label: LabelStyle,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct ProjectDiagnostics { pub struct ProjectDiagnostics {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -594,7 +595,7 @@ pub struct ProjectDiagnostics {
pub tab_summary_spacing: f32, pub tab_summary_spacing: f32,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct ContactNotification { pub struct ContactNotification {
pub header_avatar: ImageStyle, pub header_avatar: ImageStyle,
pub header_message: ContainedText, pub header_message: ContainedText,
@ -604,21 +605,21 @@ pub struct ContactNotification {
pub dismiss_button: Interactive<IconButton>, pub dismiss_button: Interactive<IconButton>,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct UpdateNotification { pub struct UpdateNotification {
pub message: ContainedText, pub message: ContainedText,
pub action_message: Interactive<ContainedText>, pub action_message: Interactive<ContainedText>,
pub dismiss_button: Interactive<IconButton>, pub dismiss_button: Interactive<IconButton>,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct MessageNotification { pub struct MessageNotification {
pub message: ContainedText, pub message: ContainedText,
pub action_message: Interactive<ContainedText>, pub action_message: Interactive<ContainedText>,
pub dismiss_button: Interactive<IconButton>, pub dismiss_button: Interactive<IconButton>,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct ProjectSharedNotification { pub struct ProjectSharedNotification {
pub window_height: f32, pub window_height: f32,
pub window_width: f32, pub window_width: f32,
@ -635,7 +636,7 @@ pub struct ProjectSharedNotification {
pub dismiss_button: ContainedText, pub dismiss_button: ContainedText,
} }
#[derive(Deserialize, Default)] #[derive(Deserialize, Default, JsonSchema)]
pub struct IncomingCallNotification { pub struct IncomingCallNotification {
pub window_height: f32, pub window_height: f32,
pub window_width: f32, pub window_width: f32,
@ -652,7 +653,7 @@ pub struct IncomingCallNotification {
pub decline_button: ContainedText, pub decline_button: ContainedText,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Editor { pub struct Editor {
pub text_color: Color, pub text_color: Color,
#[serde(default)] #[serde(default)]
@ -693,7 +694,7 @@ pub struct Editor {
pub whitespace: Color, pub whitespace: Color,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Scrollbar { pub struct Scrollbar {
pub track: ContainerStyle, pub track: ContainerStyle,
pub thumb: ContainerStyle, pub thumb: ContainerStyle,
@ -702,14 +703,14 @@ pub struct Scrollbar {
pub git: GitDiffColors, pub git: GitDiffColors,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct GitDiffColors { pub struct GitDiffColors {
pub inserted: Color, pub inserted: Color,
pub modified: Color, pub modified: Color,
pub deleted: Color, pub deleted: Color,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct DiagnosticPathHeader { pub struct DiagnosticPathHeader {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -718,7 +719,7 @@ pub struct DiagnosticPathHeader {
pub text_scale_factor: f32, pub text_scale_factor: f32,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct DiagnosticHeader { pub struct DiagnosticHeader {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -729,7 +730,7 @@ pub struct DiagnosticHeader {
pub icon_width_factor: f32, pub icon_width_factor: f32,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct DiagnosticStyle { pub struct DiagnosticStyle {
pub message: LabelStyle, pub message: LabelStyle,
#[serde(default)] #[serde(default)]
@ -737,7 +738,7 @@ pub struct DiagnosticStyle {
pub text_scale_factor: f32, pub text_scale_factor: f32,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct AutocompleteStyle { pub struct AutocompleteStyle {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -747,13 +748,13 @@ pub struct AutocompleteStyle {
pub match_highlight: HighlightStyle, pub match_highlight: HighlightStyle,
} }
#[derive(Clone, Copy, Default, Deserialize)] #[derive(Clone, Copy, Default, Deserialize, JsonSchema)]
pub struct SelectionStyle { pub struct SelectionStyle {
pub cursor: Color, pub cursor: Color,
pub selection: Color, pub selection: Color,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct FieldEditor { pub struct FieldEditor {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
@ -763,19 +764,19 @@ pub struct FieldEditor {
pub selection: SelectionStyle, pub selection: SelectionStyle,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct InteractiveColor { pub struct InteractiveColor {
pub color: Color, pub color: Color,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct CodeActions { pub struct CodeActions {
#[serde(default)] #[serde(default)]
pub indicator: Toggleable<Interactive<InteractiveColor>>, pub indicator: Toggleable<Interactive<InteractiveColor>>,
pub vertical_scale: f32, pub vertical_scale: f32,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Folds { pub struct Folds {
pub indicator: Toggleable<Interactive<InteractiveColor>>, pub indicator: Toggleable<Interactive<InteractiveColor>>,
pub ellipses: FoldEllipses, pub ellipses: FoldEllipses,
@ -785,14 +786,14 @@ pub struct Folds {
pub foldable_icon: String, pub foldable_icon: String,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct FoldEllipses { pub struct FoldEllipses {
pub text_color: Color, pub text_color: Color,
pub background: Interactive<InteractiveColor>, pub background: Interactive<InteractiveColor>,
pub corner_radius_factor: f32, pub corner_radius_factor: f32,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct DiffStyle { pub struct DiffStyle {
pub inserted: Color, pub inserted: Color,
pub modified: Color, pub modified: Color,
@ -802,7 +803,7 @@ pub struct DiffStyle {
pub corner_radius: f32, pub corner_radius: f32,
} }
#[derive(Debug, Default, Clone, Copy)] #[derive(Debug, Default, Clone, Copy, JsonSchema)]
pub struct Interactive<T> { pub struct Interactive<T> {
pub default: T, pub default: T,
pub hovered: Option<T>, pub hovered: Option<T>,
@ -810,7 +811,7 @@ pub struct Interactive<T> {
pub disabled: Option<T>, pub disabled: Option<T>,
} }
#[derive(Clone, Copy, Debug, Default, Deserialize)] #[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)]
pub struct Toggleable<T> { pub struct Toggleable<T> {
active: T, active: T,
inactive: T, inactive: T,
@ -909,7 +910,7 @@ impl Editor {
} }
} }
#[derive(Default)] #[derive(Default, JsonSchema)]
pub struct SyntaxTheme { pub struct SyntaxTheme {
pub highlights: Vec<(String, HighlightStyle)>, pub highlights: Vec<(String, HighlightStyle)>,
} }
@ -943,7 +944,7 @@ impl<'de> Deserialize<'de> for SyntaxTheme {
} }
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct HoverPopover { pub struct HoverPopover {
pub container: ContainerStyle, pub container: ContainerStyle,
pub info_container: ContainerStyle, pub info_container: ContainerStyle,
@ -955,7 +956,7 @@ pub struct HoverPopover {
pub highlight: Color, pub highlight: Color,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct TerminalStyle { pub struct TerminalStyle {
pub black: Color, pub black: Color,
pub red: Color, pub red: Color,
@ -989,7 +990,7 @@ pub struct TerminalStyle {
pub dim_foreground: Color, pub dim_foreground: Color,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct AssistantStyle { pub struct AssistantStyle {
pub container: ContainerStyle, pub container: ContainerStyle,
pub header: ContainerStyle, pub header: ContainerStyle,
@ -1006,7 +1007,7 @@ pub struct AssistantStyle {
pub api_key_prompt: ContainedText, pub api_key_prompt: ContainedText,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct FeedbackStyle { pub struct FeedbackStyle {
pub submit_button: Interactive<ContainedText>, pub submit_button: Interactive<ContainedText>,
pub button_margin: f32, pub button_margin: f32,
@ -1015,7 +1016,7 @@ pub struct FeedbackStyle {
pub link_text_hover: ContainedText, pub link_text_hover: ContainedText,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct WelcomeStyle { pub struct WelcomeStyle {
pub page_width: f32, pub page_width: f32,
pub logo: SvgStyle, pub logo: SvgStyle,
@ -1029,7 +1030,7 @@ pub struct WelcomeStyle {
pub checkbox_group: ContainerStyle, pub checkbox_group: ContainerStyle,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct ColorScheme { pub struct ColorScheme {
pub name: String, pub name: String,
pub is_light: bool, pub is_light: bool,
@ -1044,13 +1045,13 @@ pub struct ColorScheme {
pub players: Vec<Player>, pub players: Vec<Player>,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Player { pub struct Player {
pub cursor: Color, pub cursor: Color,
pub selection: Color, pub selection: Color,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct RampSet { pub struct RampSet {
pub neutral: Vec<Color>, pub neutral: Vec<Color>,
pub red: Vec<Color>, pub red: Vec<Color>,
@ -1063,7 +1064,7 @@ pub struct RampSet {
pub magenta: Vec<Color>, pub magenta: Vec<Color>,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Layer { pub struct Layer {
pub base: StyleSet, pub base: StyleSet,
pub variant: StyleSet, pub variant: StyleSet,
@ -1074,7 +1075,7 @@ pub struct Layer {
pub negative: StyleSet, pub negative: StyleSet,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct StyleSet { pub struct StyleSet {
pub default: Style, pub default: Style,
pub active: Style, pub active: Style,
@ -1084,7 +1085,7 @@ pub struct StyleSet {
pub inverted: Style, pub inverted: Style,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Style { pub struct Style {
pub background: Color, pub background: Color,
pub border: Color, pub border: Color,

View file

@ -14,12 +14,13 @@ use util::ResultExt as _;
const MIN_FONT_SIZE: f32 = 6.0; const MIN_FONT_SIZE: f32 = 6.0;
#[derive(Clone)] #[derive(Clone, JsonSchema)]
pub struct ThemeSettings { pub struct ThemeSettings {
pub buffer_font_family_name: String, pub buffer_font_family_name: String,
pub buffer_font_features: fonts::Features, pub buffer_font_features: fonts::Features,
pub buffer_font_family: FamilyId, pub buffer_font_family: FamilyId,
pub(crate) buffer_font_size: f32, pub(crate) buffer_font_size: f32,
#[serde(skip)]
pub theme: Arc<Theme>, pub theme: Arc<Theme>,
} }

View file

@ -13,11 +13,12 @@ use gpui::{
scene::MouseClick, scene::MouseClick,
Action, Element, EventContext, MouseState, View, ViewContext, Action, Element, EventContext, MouseState, View, ViewContext,
}; };
use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::{ContainedText, Interactive}; use crate::{ContainedText, Interactive};
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct CheckboxStyle { pub struct CheckboxStyle {
pub icon: SvgStyle, pub icon: SvgStyle,
pub label: ContainedText, pub label: ContainedText,
@ -93,14 +94,14 @@ where
.with_cursor_style(platform::CursorStyle::PointingHand) .with_cursor_style(platform::CursorStyle::PointingHand)
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct SvgStyle { pub struct SvgStyle {
pub color: Color, pub color: Color,
pub asset: String, pub asset: String,
pub dimensions: Dimensions, pub dimensions: Dimensions,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct Dimensions { pub struct Dimensions {
pub width: f32, pub width: f32,
pub height: f32, pub height: f32,
@ -120,7 +121,7 @@ pub fn svg<V: View>(style: &SvgStyle) -> ConstrainedBox<V> {
.with_height(style.dimensions.height) .with_height(style.dimensions.height)
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct IconStyle { pub struct IconStyle {
icon: SvgStyle, icon: SvgStyle,
container: ContainerStyle, container: ContainerStyle,
@ -182,7 +183,7 @@ where
.with_cursor_style(platform::CursorStyle::PointingHand) .with_cursor_style(platform::CursorStyle::PointingHand)
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct ModalStyle { pub struct ModalStyle {
close_icon: Interactive<IconStyle>, close_icon: Interactive<IconStyle>,
container: ContainerStyle, container: ContainerStyle,

13
crates/xtask/Cargo.toml Normal file
View file

@ -0,0 +1,13 @@
[package]
name = "xtask"
version = "0.1.0"
edition = "2021"
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0"
clap = {version = "4.0", features = ["derive"]}
theme = {path = "../theme"}
serde_json.workspace = true
schemars.workspace = true

23
crates/xtask/src/cli.rs Normal file
View file

@ -0,0 +1,23 @@
use clap::{Parser, Subcommand};
use std::path::PathBuf;
/// Common utilities for Zed developers.
// For more information, see [matklad's repository README](https://github.com/matklad/cargo-xtask/)
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
/// Command to run.
#[derive(Subcommand)]
pub enum Commands {
/// Builds theme types for interop with Typescript.
BuildThemeTypes {
#[clap(short, long, default_value = "schemas")]
out_dir: PathBuf,
#[clap(short, long, default_value = "theme.json")]
file_name: PathBuf,
},
}

29
crates/xtask/src/main.rs Normal file
View file

@ -0,0 +1,29 @@
mod cli;
use std::path::PathBuf;
use anyhow::Result;
use clap::Parser;
use schemars::schema_for;
use theme::Theme;
fn build_themes(out_dir: PathBuf, file_name: PathBuf) -> Result<()> {
let theme = schema_for!(Theme);
let output = serde_json::to_string_pretty(&theme)?;
std::fs::create_dir(&out_dir)?;
let mut file_path = out_dir;
file_path.push(file_name);
std::fs::write(file_path, output)?;
Ok(())
}
fn main() -> Result<()> {
let args = cli::Cli::parse();
match args.command {
cli::Commands::BuildThemeTypes { out_dir, file_name } => build_themes(out_dir, file_name),
}
}

1764
styles/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,7 @@
"build": "ts-node ./src/buildThemes.ts", "build": "ts-node ./src/buildThemes.ts",
"build-licenses": "ts-node ./src/buildLicenses.ts", "build-licenses": "ts-node ./src/buildLicenses.ts",
"build-tokens": "ts-node ./src/buildTokens.ts", "build-tokens": "ts-node ./src/buildTokens.ts",
"build-types": "cd ../crates/theme && cargo test && cd ../../styles && ts-node ./src/buildTypes.ts",
"test": "vitest" "test": "vitest"
}, },
"author": "", "author": "",
@ -20,6 +21,7 @@
"case-anything": "^2.1.10", "case-anything": "^2.1.10",
"chroma-js": "^2.4.2", "chroma-js": "^2.4.2",
"deepmerge": "^4.3.0", "deepmerge": "^4.3.0",
"json-schema-to-typescript": "^13.0.2",
"toml": "^3.0.0", "toml": "^3.0.0",
"ts-deepmerge": "^6.0.3", "ts-deepmerge": "^6.0.3",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",

64
styles/src/buildTypes.ts Normal file
View file

@ -0,0 +1,64 @@
import * as fs from "fs/promises"
import * as fsSync from "fs"
import * as path from "path"
import { compile } from "json-schema-to-typescript"
const BANNER = `/*
* This file is autogenerated
*/\n\n`
const dirname = __dirname
async function main() {
let schemasPath = path.join(dirname, "../../", "crates/theme/schemas")
let schemaFiles = (await fs.readdir(schemasPath)).filter((x) =>
x.endsWith(".json")
)
let compiledTypes = new Set()
for (let filename of schemaFiles) {
let filePath = path.join(schemasPath, filename)
const fileContents = await fs.readFile(filePath)
let schema = JSON.parse(fileContents.toString())
let compiled = await compile(schema, schema.title, {
bannerComment: "",
})
let eachType = compiled.split("export")
for (let type of eachType) {
if (!type) {
continue
}
compiledTypes.add("export " + type.trim())
}
}
let output = BANNER + Array.from(compiledTypes).join("\n\n")
let outputPath = path.join(dirname, "../../styles/src/types/zed.ts")
try {
let existing = await fs.readFile(outputPath)
if (existing.toString() == output) {
// Skip writing if it hasn't changed
console.log("Schemas are up to date")
return
}
} catch (e) {
// It's fine if there's no output from a previous run.
// @ts-ignore
if (e.code !== "ENOENT") {
throw e
}
}
const typesDic = path.dirname(outputPath)
if (!fsSync.existsSync(typesDic)) {
await fs.mkdir(typesDic)
}
await fs.writeFile(outputPath, output)
console.log(`Wrote Typescript types to ${outputPath}`)
}
main().catch((e) => {
console.error(e)
process.exit(1)
})