From b494b434961fde266cc405e56b247123a1fefab8 Mon Sep 17 00:00:00 2001 From: Sergey Onufrienko Date: Mon, 12 Jun 2023 22:12:24 +0200 Subject: [PATCH 001/215] chore: add ts-rs --- Cargo.lock | 26 +++++++++++++++++++++++++- crates/gpui/Cargo.toml | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 8ef48849ac..480694c4ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2832,6 +2832,7 @@ dependencies = [ "sum_tree", "time 0.3.21", "tiny-skia", + "ts-rs", "usvg", "util", "uuid 1.3.2", @@ -7559,7 +7560,7 @@ dependencies = [ [[package]] name = "tree-sitter-yaml" version = "0.0.1" -source = "git+https://github.com/zed-industries/tree-sitter-yaml?rev=5694b7f290cd9ef998829a0a6d8391a666370886#5694b7f290cd9ef998829a0a6d8391a666370886" +source = "git+https://github.com/zed-industries/tree-sitter-yaml?rev=f545a41f57502e1b5ddf2a6668896c1b0620f930#f545a41f57502e1b5ddf2a6668896c1b0620f930" dependencies = [ "cc", "tree-sitter", @@ -7571,6 +7572,29 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "ts-rs" +version = "6.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4added4070a4fdf9df03457206cd2e4b12417c8560a2954d91ffcbe60177a56a" +dependencies = [ + "thiserror", + "ts-rs-macros", +] + +[[package]] +name = "ts-rs-macros" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f807fdb3151fee75df7485b901a89624358cd07a67a8fb1a5831bf5a07681ff" +dependencies = [ + "Inflector", + "proc-macro2", + "quote", + "syn 1.0.109", + "termcolor", +] + [[package]] name = "ttf-parser" version = "0.9.0" diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 31b7db008d..a4fda7a81f 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -51,6 +51,7 @@ tiny-skia = "0.5" usvg = { version = "0.14", features = [] } uuid = { version = "1.1.2", features = ["v4"] } waker-fn = "1.1.0" +ts-rs = "6.2.1" [build-dependencies] bindgen = "0.65.1" From cfc1856210a75b00b1d44802d25eb35e2d6d5ebc Mon Sep 17 00:00:00 2001 From: Sergey Onufrienko Date: Mon, 12 Jun 2023 22:13:19 +0200 Subject: [PATCH 002/215] feat: add ts export --- crates/gpui/src/color.rs | 3 +++ crates/gpui/src/font_cache.rs | 3 +++ crates/gpui/src/fonts.rs | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/crates/gpui/src/color.rs b/crates/gpui/src/color.rs index b6c1e3aff9..46ef470180 100644 --- a/crates/gpui/src/color.rs +++ b/crates/gpui/src/color.rs @@ -11,9 +11,12 @@ use serde::{ Deserialize, Deserializer, }; use serde_json::json; +use ts_rs::TS; #[derive(Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord)] #[repr(transparent)] +#[derive(TS)] +#[ts(export, export_to = "theme/types/")] pub struct Color(ColorU); impl Color { diff --git a/crates/gpui/src/font_cache.rs b/crates/gpui/src/font_cache.rs index 57dad48e34..e40d86679e 100644 --- a/crates/gpui/src/font_cache.rs +++ b/crates/gpui/src/font_cache.rs @@ -12,8 +12,11 @@ use std::{ ops::{Deref, DerefMut}, sync::Arc, }; +use ts_rs::TS; #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +#[derive(TS)] +#[ts(export, export_to = "theme/types/")] pub struct FamilyId(usize); struct Family { diff --git a/crates/gpui/src/fonts.rs b/crates/gpui/src/fonts.rs index 5e77593d05..bfdf3e0479 100644 --- a/crates/gpui/src/fonts.rs +++ b/crates/gpui/src/fonts.rs @@ -15,8 +15,11 @@ use schemars::JsonSchema; use serde::{de, Deserialize, Serialize}; use serde_json::Value; use std::{cell::RefCell, sync::Arc}; +use ts_rs::TS; #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +#[derive(TS)] +#[ts(export, export_to = "theme/types/")] pub struct FontId(pub usize); pub type GlyphId = u32; @@ -60,6 +63,8 @@ pub struct Features { } #[derive(Clone, Debug)] +#[derive(TS)] +#[ts(export, export_to = "theme/types/")] pub struct TextStyle { pub color: Color, pub font_family_name: Arc, @@ -82,6 +87,8 @@ pub struct HighlightStyle { impl Eq for HighlightStyle {} #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] +#[derive(TS)] +#[ts(export, export_to = "theme/types/")] pub struct Underline { pub color: Option, pub thickness: OrderedFloat, From aac71fdcfef70557cfb186441cfb88e77b3c4232 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 9 Jun 2023 08:42:16 -0700 Subject: [PATCH 003/215] Remove border from sign in button Co-authored-by: Piotr --- styles/src/styleTree/workspace.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index ae8de178f8..bf0c5d3af3 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -42,6 +42,33 @@ export default function workspace(colorScheme: ColorScheme) { border: border(layer, "variant", "active"), }, } + const signInButton = { + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + //border: border(layer), + hover: { + ...text(layer, "sans", "variant", "hovered", { size: "xs" }), + background: background(layer, "variant", "hovered"), + //border: border(layer, "variant", "hovered"), + }, + clicked: { + ...text(layer, "sans", "variant", "pressed", { size: "xs" }), + background: background(layer, "variant", "pressed"), + //border: border(layer, "variant", "pressed"), + }, + active: { + ...text(layer, "sans", "variant", "active", { size: "xs" }), + background: background(layer, "variant", "active"), + //border: border(layer, "variant", "active"), + }, + } const avatarWidth = 18 const avatarOuterWidth = avatarWidth + 4 const followerAvatarWidth = 14 @@ -205,7 +232,7 @@ export default function workspace(colorScheme: ColorScheme) { margin: { left: itemSpacing, }, - ...titlebarButton, + ...signInButton, }, // Offline Indicator From 47ef800dc6e5f6391e0716717a5927d1d44c62cc Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 9 Jun 2023 09:00:38 -0700 Subject: [PATCH 004/215] WIP: Add face to right hand menu --- crates/collab_ui/src/collab_titlebar_item.rs | 33 ++++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 720a73f477..cffdb2a18f 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -92,10 +92,10 @@ impl View for CollabTitlebarItem { let status = workspace.read(cx).client().status(); let status = &*status.borrow(); - if matches!(status, client::Status::Connected { .. }) { right_container.add_child(self.render_toggle_contacts_button(&theme, cx)); - right_container.add_child(self.render_user_menu_button(&theme, cx)); + let avatar = user.as_ref().map(|user| user.avatar.clone()).flatten(); + right_container.add_child(self.render_user_menu_button(&theme, avatar, cx)); } else { right_container.add_children(self.render_connection_status(status, cx)); right_container.add_child(self.render_sign_in_button(&theme, cx)); @@ -504,24 +504,31 @@ impl CollabTitlebarItem { fn render_user_menu_button( &self, theme: &Theme, + avatar: Option>, cx: &mut ViewContext, ) -> AnyElement { let titlebar = &theme.workspace.titlebar; - + let avatar_style = &theme.workspace.titlebar.leader_avatar; Stack::new() .with_child( MouseEventHandler::::new(0, cx, |state, _| { let style = titlebar.call_control.style_for(state, false); - Svg::new("icons/ellipsis_14.svg") - .with_color(style.color) - .constrained() - .with_width(style.icon_width) - .aligned() - .constrained() - .with_width(style.button_width) - .with_height(style.button_width) - .contained() - .with_style(style.container) + + if let Some(avatar_img) = avatar { + Self::render_face(avatar_img, *avatar_style, Color::transparent_black()) + } else { + Svg::new("icons/ellipsis_14.svg") + .with_color(style.color) + .constrained() + .with_width(style.icon_width) + .aligned() + .constrained() + .with_width(style.button_width) + .with_height(style.button_width) + .contained() + .with_style(style.container) + .into_any() + } }) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, move |_, this, cx| { From 5f7fdd25eb98e64c7d57de68b77bd74dbcc1c6a1 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 9 Jun 2023 18:05:23 +0200 Subject: [PATCH 005/215] Fix compile error (use of moved value) --- crates/collab_ui/src/collab_titlebar_item.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index cffdb2a18f..405eb20dec 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -78,6 +78,7 @@ impl View for CollabTitlebarItem { let user = self.user_store.read(cx).current_user(); let peer_id = self.client.peer_id(); if let Some(((user, peer_id), room)) = user + .as_ref() .zip(peer_id) .zip(ActiveCall::global(cx).read(cx).room().cloned()) { From 0fe65b945f6de2c66a6ab2f2371c82f79083a833 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Sat, 10 Jun 2023 01:35:18 +0200 Subject: [PATCH 006/215] Remove user avatar from dropdown menu Add new options in context menu --- Cargo.lock | 1 + crates/collab_ui/Cargo.toml | 1 + crates/collab_ui/src/collab_titlebar_item.rs | 38 +++++++------------- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 24fd67f90e..9bf504bc15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1325,6 +1325,7 @@ dependencies = [ "serde_derive", "settings", "theme", + "theme_selector", "util", "workspace", ] diff --git a/crates/collab_ui/Cargo.toml b/crates/collab_ui/Cargo.toml index 16cc6b5277..9865f8a9c8 100644 --- a/crates/collab_ui/Cargo.toml +++ b/crates/collab_ui/Cargo.toml @@ -37,6 +37,7 @@ picker = { path = "../picker" } project = { path = "../project" } settings = { path = "../settings" } theme = { path = "../theme" } +theme_selector = { path = "../theme_selector" } util = { path = "../util" } workspace = { path = "../workspace" } diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 405eb20dec..d9127e707f 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -99,7 +99,7 @@ impl View for CollabTitlebarItem { right_container.add_child(self.render_user_menu_button(&theme, avatar, cx)); } else { right_container.add_children(self.render_connection_status(status, cx)); - right_container.add_child(self.render_sign_in_button(&theme, cx)); + right_container.add_child(self.render_user_menu_button(&theme, None, cx)); } Stack::new() @@ -298,42 +298,28 @@ impl CollabTitlebarItem { } pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext) { - let theme = theme::current(cx).clone(); - let avatar_style = theme.workspace.titlebar.leader_avatar.clone(); - let item_style = theme.context_menu.item.disabled_style().clone(); self.user_menu.update(cx, |user_menu, cx| { - let items = if let Some(user) = self.user_store.read(cx).current_user() { + let items = if let Some(_) = self.user_store.read(cx).current_user() { vec![ - ContextMenuItem::Static(Box::new(move |_| { - Flex::row() - .with_children(user.avatar.clone().map(|avatar| { - Self::render_face( - avatar, - avatar_style.clone(), - Color::transparent_black(), - ) - })) - .with_child(Label::new( - user.github_login.clone(), - item_style.label.clone(), - )) - .contained() - .with_style(item_style.container) - .into_any() - })), - ContextMenuItem::action("Sign out", SignOut), + ContextMenuItem::action("Settings", SignIn), + ContextMenuItem::action("Theme", theme_selector::Toggle), + ContextMenuItem::separator(), ContextMenuItem::action( - "Send Feedback", + "Share Feedback", feedback::feedback_editor::GiveFeedback, ), + ContextMenuItem::action("Sign out", SignOut), ] } else { vec![ - ContextMenuItem::action("Sign in", SignIn), + ContextMenuItem::action("Settings", SignIn), + ContextMenuItem::action("Theme", theme_selector::Toggle), + ContextMenuItem::separator(), ContextMenuItem::action( - "Send Feedback", + "Share Feedback", feedback::feedback_editor::GiveFeedback, ), + ContextMenuItem::action("Sign in", SignIn), ] }; From 4b87ce8952a2954055e702ac830139baf2b7e3d2 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 12 Jun 2023 11:51:39 +0200 Subject: [PATCH 007/215] add zed-actions crate --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + crates/zed-actions/Cargo.toml | 9 +++++++++ crates/zed-actions/src/lib.rs | 14 ++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 crates/zed-actions/Cargo.toml create mode 100644 crates/zed-actions/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 9bf504bc15..13d194440c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8909,6 +8909,13 @@ dependencies = [ "workspace", ] +[[package]] +name = "zed-actions" +version = "0.1.0" +dependencies = [ + "gpui", +] + [[package]] name = "zeroize" version = "1.3.0" diff --git a/Cargo.toml b/Cargo.toml index fca7355964..34533da51c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,6 +67,7 @@ members = [ "crates/workspace", "crates/welcome", "crates/zed", + "crates/zed-actions" ] default-members = ["crates/zed"] resolver = "2" diff --git a/crates/zed-actions/Cargo.toml b/crates/zed-actions/Cargo.toml new file mode 100644 index 0000000000..c6868b1546 --- /dev/null +++ b/crates/zed-actions/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "zed-actions" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +gpui = { path = "../gpui" } diff --git a/crates/zed-actions/src/lib.rs b/crates/zed-actions/src/lib.rs new file mode 100644 index 0000000000..7d12d9af81 --- /dev/null +++ b/crates/zed-actions/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} From 092cf93dae709025421b296f5178963cb5d96e01 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 12 Jun 2023 13:00:08 +0200 Subject: [PATCH 008/215] Move zed actions to zed-actions --- Cargo.lock | 2 + crates/collab_ui/Cargo.toml | 1 + crates/collab_ui/src/collab_titlebar_item.rs | 4 +- crates/zed-actions/src/lib.rs | 40 +++++++++++++------- crates/zed/Cargo.toml | 2 +- crates/zed/src/main.rs | 2 +- crates/zed/src/zed.rs | 28 +------------- 7 files changed, 35 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13d194440c..6d953d8dc0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1328,6 +1328,7 @@ dependencies = [ "theme_selector", "util", "workspace", + "zed-actions", ] [[package]] @@ -8907,6 +8908,7 @@ dependencies = [ "vim", "welcome", "workspace", + "zed-actions", ] [[package]] diff --git a/crates/collab_ui/Cargo.toml b/crates/collab_ui/Cargo.toml index 9865f8a9c8..ee410ccba7 100644 --- a/crates/collab_ui/Cargo.toml +++ b/crates/collab_ui/Cargo.toml @@ -40,6 +40,7 @@ theme = { path = "../theme" } theme_selector = { path = "../theme_selector" } util = { path = "../util" } workspace = { path = "../workspace" } +zed-actions = {path = "../zed-actions"} anyhow.workspace = true futures.workspace = true diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index d9127e707f..d2a9dda480 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -301,7 +301,7 @@ impl CollabTitlebarItem { self.user_menu.update(cx, |user_menu, cx| { let items = if let Some(_) = self.user_store.read(cx).current_user() { vec![ - ContextMenuItem::action("Settings", SignIn), + ContextMenuItem::action("Settings", zed_actions::OpenSettings), ContextMenuItem::action("Theme", theme_selector::Toggle), ContextMenuItem::separator(), ContextMenuItem::action( @@ -312,7 +312,7 @@ impl CollabTitlebarItem { ] } else { vec![ - ContextMenuItem::action("Settings", SignIn), + ContextMenuItem::action("Settings", zed_actions::OpenSettings), ContextMenuItem::action("Theme", theme_selector::Toggle), ContextMenuItem::separator(), ContextMenuItem::action( diff --git a/crates/zed-actions/src/lib.rs b/crates/zed-actions/src/lib.rs index 7d12d9af81..bcd086924d 100644 --- a/crates/zed-actions/src/lib.rs +++ b/crates/zed-actions/src/lib.rs @@ -1,14 +1,28 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} +use gpui::actions; -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} +actions!( + zed, + [ + About, + Hide, + HideOthers, + ShowAll, + Minimize, + Zoom, + ToggleFullScreen, + Quit, + DebugElements, + OpenLog, + OpenLicenses, + OpenTelemetryLog, + OpenKeymap, + OpenSettings, + OpenLocalSettings, + OpenDefaultSettings, + OpenDefaultKeymap, + IncreaseBufferFontSize, + DecreaseBufferFontSize, + ResetBufferFontSize, + ResetDatabase, + ] +); diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index d8e47d1c3e..e97005ec7e 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -67,7 +67,7 @@ util = { path = "../util" } vim = { path = "../vim" } workspace = { path = "../workspace" } welcome = { path = "../welcome" } - +zed-actions = {path = "../zed-actions"} anyhow.workspace = true async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] } async-tar = "0.4.2" diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index dcdf5c1ea5..5d013a6849 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -871,6 +871,6 @@ pub fn background_actions() -> &'static [(&'static str, &'static dyn Action)] { ("Go to file", &file_finder::Toggle), ("Open command palette", &command_palette::Toggle), ("Open recent projects", &recent_projects::OpenRecent), - ("Change your settings", &zed::OpenSettings), + ("Change your settings", &zed_actions::OpenSettings), ] } diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index bcdfe57a46..9f3b145793 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -50,6 +50,7 @@ use workspace::{ notifications::simple_message_notification::MessageNotification, open_new, AppState, NewFile, NewWindow, Workspace, WorkspaceSettings, }; +use zed_actions::*; #[derive(Deserialize, Clone, PartialEq)] pub struct OpenBrowser { @@ -58,33 +59,6 @@ pub struct OpenBrowser { impl_actions!(zed, [OpenBrowser]); -actions!( - zed, - [ - About, - Hide, - HideOthers, - ShowAll, - Minimize, - Zoom, - ToggleFullScreen, - Quit, - DebugElements, - OpenLog, - OpenLicenses, - OpenTelemetryLog, - OpenKeymap, - OpenSettings, - OpenLocalSettings, - OpenDefaultSettings, - OpenDefaultKeymap, - IncreaseBufferFontSize, - DecreaseBufferFontSize, - ResetBufferFontSize, - ResetDatabase, - ] -); - pub fn init(app_state: &Arc, cx: &mut gpui::AppContext) { cx.add_action(about); cx.add_global_action(|_: &Hide, cx: &mut gpui::AppContext| { From 433c5d30f57c6f973b24f87ad4bd7ce1511558b1 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 12 Jun 2023 19:38:01 +0200 Subject: [PATCH 009/215] Add Sign in button for an unregistered user --- crates/collab_ui/src/collab_titlebar_item.rs | 2 +- crates/zed-actions/Cargo.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index d2a9dda480..54caf9b26f 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -99,6 +99,7 @@ impl View for CollabTitlebarItem { right_container.add_child(self.render_user_menu_button(&theme, avatar, cx)); } else { right_container.add_children(self.render_connection_status(status, cx)); + right_container.add_child(self.render_sign_in_button(&theme, cx)); right_container.add_child(self.render_user_menu_button(&theme, None, cx)); } @@ -319,7 +320,6 @@ impl CollabTitlebarItem { "Share Feedback", feedback::feedback_editor::GiveFeedback, ), - ContextMenuItem::action("Sign in", SignIn), ] }; diff --git a/crates/zed-actions/Cargo.toml b/crates/zed-actions/Cargo.toml index c6868b1546..b3fe3cbb53 100644 --- a/crates/zed-actions/Cargo.toml +++ b/crates/zed-actions/Cargo.toml @@ -2,6 +2,7 @@ name = "zed-actions" version = "0.1.0" edition = "2021" +publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 83c1bb07bbb1824419fa3428279558ee8ea77c6c Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 12 Jun 2023 19:55:52 +0200 Subject: [PATCH 010/215] Add background to user avatar --- crates/collab_ui/src/collab_titlebar_item.rs | 27 +++++++++++--------- crates/zed/src/zed.rs | 5 ++-- styles/src/styleTree/workspace.ts | 4 +++ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 54caf9b26f..de4bb3e1b5 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -495,27 +495,30 @@ impl CollabTitlebarItem { cx: &mut ViewContext, ) -> AnyElement { let titlebar = &theme.workspace.titlebar; - let avatar_style = &theme.workspace.titlebar.leader_avatar; + let avatar_style = &theme.workspace.titlebar.follower_avatar; + let active = self.user_menu.read(cx).visible(); Stack::new() .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.call_control.style_for(state, false); + let style = titlebar.call_control.style_for(state, active); - if let Some(avatar_img) = avatar { + let img = if let Some(avatar_img) = avatar { Self::render_face(avatar_img, *avatar_style, Color::transparent_black()) } else { Svg::new("icons/ellipsis_14.svg") .with_color(style.color) - .constrained() - .with_width(style.icon_width) - .aligned() - .constrained() - .with_width(style.button_width) - .with_height(style.button_width) - .contained() - .with_style(style.container) .into_any() - } + }; + + img.constrained() + .with_width(style.icon_width) + .aligned() + .constrained() + .with_width(style.button_width) + .with_height(style.button_width) + .contained() + .with_style(style.container) + .into_any() }) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, move |_, this, cx| { diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 9f3b145793..8dbc81f62f 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -20,7 +20,6 @@ use feedback::{ }; use futures::{channel::mpsc, StreamExt}; use gpui::{ - actions, anyhow::{self, Result}, geometry::vector::vec2f, impl_actions, @@ -715,8 +714,8 @@ mod tests { use editor::{scroll::autoscroll::Autoscroll, DisplayPoint, Editor}; use fs::{FakeFs, Fs}; use gpui::{ - elements::Empty, executor::Deterministic, Action, AnyElement, AppContext, AssetSource, - Element, Entity, TestAppContext, View, ViewHandle, + actions, elements::Empty, executor::Deterministic, Action, AnyElement, AppContext, + AssetSource, Element, Entity, TestAppContext, View, ViewHandle, }; use language::LanguageRegistry; use node_runtime::NodeRuntime; diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index bf0c5d3af3..15bcbcc27c 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -270,6 +270,10 @@ export default function workspace(colorScheme: ColorScheme) { background: background(layer, "variant", "hovered"), color: foreground(layer, "variant", "hovered"), }, + active: { + background: background(layer, "variant", "active"), + color: foreground(layer, "variant", "active"), + }, }, toggleContactsButton: { margin: { left: itemSpacing }, From d079a0eb2090650aff716e2f7cf4d7808032e2c6 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 12 Jun 2023 20:19:09 +0200 Subject: [PATCH 011/215] Render user avatar only if an user is not in a call --- crates/collab_ui/src/collab_titlebar_item.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index de4bb3e1b5..2100160a6f 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -85,9 +85,9 @@ impl View for CollabTitlebarItem { left_container .add_children(self.render_in_call_share_unshare_button(&workspace, &theme, cx)); - right_container.add_children(self.render_collaborators(&workspace, &theme, &room, cx)); - right_container + left_container .add_child(self.render_current_user(&workspace, &theme, &user, peer_id, cx)); + left_container.add_children(self.render_collaborators(&workspace, &theme, &room, cx)); right_container.add_child(self.render_toggle_screen_sharing_button(&theme, &room, cx)); } @@ -95,7 +95,13 @@ impl View for CollabTitlebarItem { let status = &*status.borrow(); if matches!(status, client::Status::Connected { .. }) { right_container.add_child(self.render_toggle_contacts_button(&theme, cx)); - let avatar = user.as_ref().map(|user| user.avatar.clone()).flatten(); + let avatar = ActiveCall::global(cx) + .read(cx) + .room() + .is_none() + .then(|| user.as_ref()) + .flatten() + .and_then(|user| user.avatar.clone()); right_container.add_child(self.render_user_menu_button(&theme, avatar, cx)); } else { right_container.add_children(self.render_connection_status(status, cx)); From ae68be64c05903c6231197322876a396f76b619b Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:51:11 +0200 Subject: [PATCH 012/215] Move share button to the right hand side --- crates/collab_ui/src/collab_titlebar_item.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 2100160a6f..797a4f7066 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -82,7 +82,7 @@ impl View for CollabTitlebarItem { .zip(peer_id) .zip(ActiveCall::global(cx).read(cx).room().cloned()) { - left_container + right_container .add_children(self.render_in_call_share_unshare_button(&workspace, &theme, cx)); left_container From dedc117cca57dd2b52d1171b28435759de2ae4f3 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 16 Jun 2023 10:13:27 -0700 Subject: [PATCH 013/215] Add audio APIs to Zed Share mic on joining room --- crates/call/src/participant.rs | 4 +- crates/call/src/room.rs | 199 ++++++++++++++++--- crates/collab/src/tests/integration_tests.rs | 6 +- crates/collab_ui/src/contact_list.rs | 4 +- crates/live_kit_client/src/test.rs | 1 + crates/workspace/src/workspace.rs | 2 +- 6 files changed, 186 insertions(+), 30 deletions(-) diff --git a/crates/call/src/participant.rs b/crates/call/src/participant.rs index 4b9e7ba034..90f256489d 100644 --- a/crates/call/src/participant.rs +++ b/crates/call/src/participant.rs @@ -3,6 +3,7 @@ use client::{proto, User}; use collections::HashMap; use gpui::WeakModelHandle; pub use live_kit_client::Frame; +use live_kit_client::RemoteAudioTrack; use project::Project; use std::{fmt, sync::Arc}; @@ -42,7 +43,8 @@ pub struct RemoteParticipant { pub peer_id: proto::PeerId, pub projects: Vec, pub location: ParticipantLocation, - pub tracks: HashMap>, + pub video_tracks: HashMap>, + pub audio_tracks: HashMap>, } #[derive(Clone)] diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 775342359f..257a612f08 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -12,7 +12,9 @@ use fs::Fs; use futures::{FutureExt, StreamExt}; use gpui::{AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task, WeakModelHandle}; use language::LanguageRegistry; -use live_kit_client::{LocalTrackPublication, LocalVideoTrack, RemoteVideoTrackUpdate}; +use live_kit_client::{ + LocalAudioTrack, LocalTrackPublication, LocalVideoTrack, RemoteVideoTrackUpdate, RemoteAudioTrackUpdate, +}; use postage::stream::Stream; use project::Project; use std::{future::Future, mem, pin::Pin, sync::Arc, time::Duration}; @@ -28,6 +30,9 @@ pub enum Event { RemoteVideoTracksChanged { participant_id: proto::PeerId, }, + RemoteAudioTracksChanged { + participant_id: proto::PeerId, + }, RemoteProjectShared { owner: Arc, project_id: u64, @@ -112,9 +117,9 @@ impl Room { } }); - let mut track_changes = room.remote_video_track_updates(); - let _maintain_tracks = cx.spawn_weak(|this, mut cx| async move { - while let Some(track_change) = track_changes.next().await { + let mut track_video_changes = room.remote_video_track_updates(); + let _maintain_video_tracks = cx.spawn_weak(|this, mut cx| async move { + while let Some(track_change) = track_video_changes.next().await { let this = if let Some(this) = this.upgrade(&cx) { this } else { @@ -127,16 +132,32 @@ impl Room { } }); + let mut track_audio_changes = room.remote_audio_track_updates(); + let _maintain_audio_tracks = cx.spawn_weak(|this, mut cx| async move { + while let Some(track_change) = track_audio_changes.next().await { + let this = if let Some(this) = this.upgrade(&cx) { + this + } else { + break; + }; + + this.update(&mut cx, |this, cx| { + this.remote_audio_track_updated(track_change, cx).log_err() + }); + } + }); + cx.foreground() .spawn(room.connect(&connection_info.server_url, &connection_info.token)) .detach_and_log_err(cx); Some(LiveKitRoom { room, - screen_track: ScreenTrack::None, + screen_track: Track::None, + microphone_track: Track::None, next_publish_id: 0, _maintain_room, - _maintain_tracks, + _maintain_tracks: [_maintain_video_tracks, _maintain_audio_tracks], }) } else { None @@ -197,6 +218,12 @@ impl Room { None }; + let share_mic = room.update(&mut cx, |room, cx| { + room.share_mic(cx) + }); + + cx.background().spawn(share_mic).detach(); + match room .update(&mut cx, |room, cx| { room.leave_when_empty = true; @@ -618,20 +645,26 @@ impl Room { peer_id, projects: participant.projects, location, - tracks: Default::default(), + video_tracks: Default::default(), + audio_tracks: Default::default(), }, ); if let Some(live_kit) = this.live_kit.as_ref() { - let tracks = + let video_tracks = live_kit.room.remote_video_tracks(&user.id.to_string()); - for track in tracks { + let audio_tracks = live_kit.room.remote_audio_tracks(&user.id.to_string()); + for track in video_tracks { this.remote_video_track_updated( RemoteVideoTrackUpdate::Subscribed(track), cx, ) .log_err(); } + for track in audio_tracks { + this.remote_audio_track_updated(RemoteAudioTrackUpdate::Subscribed(track), cx) + .log_err(); + } } } } @@ -706,7 +739,7 @@ impl Room { .remote_participants .get_mut(&user_id) .ok_or_else(|| anyhow!("subscribed to track by unknown participant"))?; - participant.tracks.insert( + participant.video_tracks.insert( track_id.clone(), Arc::new(RemoteVideoTrack { live_kit_track: track, @@ -725,7 +758,7 @@ impl Room { .remote_participants .get_mut(&user_id) .ok_or_else(|| anyhow!("unsubscribed from track by unknown participant"))?; - participant.tracks.remove(&track_id); + participant.video_tracks.remove(&track_id); cx.emit(Event::RemoteVideoTracksChanged { participant_id: participant.peer_id, }); @@ -736,6 +769,47 @@ impl Room { Ok(()) } + fn remote_audio_track_updated( + &mut self, + change: RemoteAudioTrackUpdate, + cx: &mut ModelContext, + ) -> Result<()> { + match change { + RemoteAudioTrackUpdate::Subscribed(track) => { + let user_id = track.publisher_id().parse()?; + let track_id = track.sid().to_string(); + let participant = self + .remote_participants + .get_mut(&user_id) + .ok_or_else(|| anyhow!("subscribed to track by unknown participant"))?; + participant.audio_tracks.insert( + track_id.clone(), + track, + ); + cx.emit(Event::RemoteAudioTracksChanged { + participant_id: participant.peer_id, + }); + } + RemoteAudioTrackUpdate::Unsubscribed { + publisher_id, + track_id, + } => { + let user_id = publisher_id.parse()?; + let participant = self + .remote_participants + .get_mut(&user_id) + .ok_or_else(|| anyhow!("unsubscribed from track by unknown participant"))?; + participant.audio_tracks.remove(&track_id); + cx.emit(Event::RemoteAudioTracksChanged { + participant_id: participant.peer_id, + }); + } + } + + cx.notify(); + Ok(()) + } + fn check_invariants(&self) { #[cfg(any(test, feature = "test-support"))] { @@ -908,7 +982,85 @@ impl Room { pub fn is_screen_sharing(&self) -> bool { self.live_kit.as_ref().map_or(false, |live_kit| { - !matches!(live_kit.screen_track, ScreenTrack::None) + !matches!(live_kit.screen_track, Track::None) + }) + } + + pub fn is_sharing_mic(&self) -> bool { + self.live_kit.as_ref().map_or(false, |live_kit| { + !matches!(live_kit.microphone_track, Track::None) + }) + } + + pub fn share_mic(&mut self, cx: &mut ModelContext) -> Task> { + if self.status.is_offline() { + return Task::ready(Err(anyhow!("room is offline"))); + } else if self.is_sharing_mic() { + return Task::ready(Err(anyhow!("microphone was already shared"))); + } + + let publish_id = if let Some(live_kit) = self.live_kit.as_mut() { + let publish_id = post_inc(&mut live_kit.next_publish_id); + live_kit.microphone_track = Track::Pending { publish_id }; + cx.notify(); + publish_id + } else { + return Task::ready(Err(anyhow!("live-kit was not initialized"))); + }; + + cx.spawn_weak(|this, mut cx| async move { + let publish_track = async { + let track = LocalAudioTrack::create(); + this.upgrade(&cx) + .ok_or_else(|| anyhow!("room was dropped"))? + .read_with(&cx, |this, _| { + this.live_kit + .as_ref() + .map(|live_kit| live_kit.room.publish_audio_track(&track)) + }) + .ok_or_else(|| anyhow!("live-kit was not initialized"))? + .await + }; + + let publication = publish_track.await; + this.upgrade(&cx) + .ok_or_else(|| anyhow!("room was dropped"))? + .update(&mut cx, |this, cx| { + let live_kit = this + .live_kit + .as_mut() + .ok_or_else(|| anyhow!("live-kit was not initialized"))?; + + let canceled = if let Track::Pending { + publish_id: cur_publish_id, + } = &live_kit.microphone_track + { + *cur_publish_id != publish_id + } else { + true + }; + + match publication { + Ok(publication) => { + if canceled { + live_kit.room.unpublish_track(publication); + } else { + live_kit.microphone_track = Track::Published(publication); + cx.notify(); + } + Ok(()) + } + Err(error) => { + if canceled { + Ok(()) + } else { + live_kit.microphone_track = Track::None; + cx.notify(); + Err(error) + } + } + } + }) }) } @@ -921,7 +1073,7 @@ impl Room { let (displays, publish_id) = if let Some(live_kit) = self.live_kit.as_mut() { let publish_id = post_inc(&mut live_kit.next_publish_id); - live_kit.screen_track = ScreenTrack::Pending { publish_id }; + live_kit.screen_track = Track::Pending { publish_id }; cx.notify(); (live_kit.room.display_sources(), publish_id) } else { @@ -955,7 +1107,7 @@ impl Room { .as_mut() .ok_or_else(|| anyhow!("live-kit was not initialized"))?; - let canceled = if let ScreenTrack::Pending { + let canceled = if let Track::Pending { publish_id: cur_publish_id, } = &live_kit.screen_track { @@ -969,7 +1121,7 @@ impl Room { if canceled { live_kit.room.unpublish_track(publication); } else { - live_kit.screen_track = ScreenTrack::Published(publication); + live_kit.screen_track = Track::Published(publication); cx.notify(); } Ok(()) @@ -978,7 +1130,7 @@ impl Room { if canceled { Ok(()) } else { - live_kit.screen_track = ScreenTrack::None; + live_kit.screen_track = Track::None; cx.notify(); Err(error) } @@ -998,12 +1150,12 @@ impl Room { .as_mut() .ok_or_else(|| anyhow!("live-kit was not initialized"))?; match mem::take(&mut live_kit.screen_track) { - ScreenTrack::None => Err(anyhow!("screen was not shared")), - ScreenTrack::Pending { .. } => { + Track::None => Err(anyhow!("screen was not shared")), + Track::Pending { .. } => { cx.notify(); Ok(()) } - ScreenTrack::Published(track) => { + Track::Published(track) => { live_kit.room.unpublish_track(track); cx.notify(); Ok(()) @@ -1023,19 +1175,20 @@ impl Room { struct LiveKitRoom { room: Arc, - screen_track: ScreenTrack, + screen_track: Track, + microphone_track: Track, next_publish_id: usize, _maintain_room: Task<()>, - _maintain_tracks: Task<()>, + _maintain_tracks: [Task<()>; 2], } -enum ScreenTrack { +enum Track { None, Pending { publish_id: usize }, Published(LocalTrackPublication), } -impl Default for ScreenTrack { +impl Default for Track { fn default() -> Self { Self::None } diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rs index 92b63478cb..b2c85f268d 100644 --- a/crates/collab/src/tests/integration_tests.rs +++ b/crates/collab/src/tests/integration_tests.rs @@ -257,7 +257,7 @@ async fn test_basic_calls( room_b.read_with(cx_b, |room, _| { assert_eq!( room.remote_participants()[&client_a.user_id().unwrap()] - .tracks + .video_tracks .len(), 1 ); @@ -274,7 +274,7 @@ async fn test_basic_calls( room_c.read_with(cx_c, |room, _| { assert_eq!( room.remote_participants()[&client_a.user_id().unwrap()] - .tracks + .video_tracks .len(), 1 ); @@ -6993,7 +6993,7 @@ async fn test_join_call_after_screen_was_shared( room.remote_participants() .get(&client_a.user_id().unwrap()) .unwrap() - .tracks + .video_tracks .len(), 1 ); diff --git a/crates/collab_ui/src/contact_list.rs b/crates/collab_ui/src/contact_list.rs index e8dae210c4..2dc1fe3f1b 100644 --- a/crates/collab_ui/src/contact_list.rs +++ b/crates/collab_ui/src/contact_list.rs @@ -514,10 +514,10 @@ impl ContactList { project_id: project.id, worktree_root_names: project.worktree_root_names.clone(), host_user_id: participant.user.id, - is_last: projects.peek().is_none() && participant.tracks.is_empty(), + is_last: projects.peek().is_none() && participant.video_tracks.is_empty(), }); } - if !participant.tracks.is_empty() { + if !participant.video_tracks.is_empty() { participant_entries.push(ContactEntry::ParticipantScreen { peer_id: participant.peer_id, is_last: true, diff --git a/crates/live_kit_client/src/test.rs b/crates/live_kit_client/src/test.rs index 2f89617363..232fc7cf4b 100644 --- a/crates/live_kit_client/src/test.rs +++ b/crates/live_kit_client/src/test.rs @@ -517,6 +517,7 @@ impl RemoteVideoTrack { } } +#[derive(Debug)] pub struct RemoteAudioTrack { sid: Sid, publisher_id: Sid, diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index f813635941..85f2580a9a 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -2750,7 +2750,7 @@ impl Workspace { let call = self.active_call()?; let room = call.read(cx).room()?.read(cx); let participant = room.remote_participant_for_peer_id(peer_id)?; - let track = participant.tracks.values().next()?.clone(); + let track = participant.video_tracks.values().next()?.clone(); let user = participant.user.clone(); for item in pane.read(cx).items_of_type::() { From 53062e84222a4cc39176c2a958344fd96c9f867c Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 16 Jun 2023 10:44:00 -0700 Subject: [PATCH 014/215] turn mic off by default in dev builds, add enviroment variable for turning it back on --- crates/call/src/room.rs | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 257a612f08..3b76a0bb37 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -13,12 +13,13 @@ use futures::{FutureExt, StreamExt}; use gpui::{AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task, WeakModelHandle}; use language::LanguageRegistry; use live_kit_client::{ - LocalAudioTrack, LocalTrackPublication, LocalVideoTrack, RemoteVideoTrackUpdate, RemoteAudioTrackUpdate, + LocalAudioTrack, LocalTrackPublication, LocalVideoTrack, RemoteAudioTrackUpdate, + RemoteVideoTrackUpdate, }; use postage::stream::Stream; use project::Project; use std::{future::Future, mem, pin::Pin, sync::Arc, time::Duration}; -use util::{post_inc, ResultExt, TryFutureExt}; +use util::{channel::ReleaseChannel, post_inc, ResultExt, TryFutureExt}; pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(30); @@ -218,11 +219,12 @@ impl Room { None }; - let share_mic = room.update(&mut cx, |room, cx| { - room.share_mic(cx) - }); - - cx.background().spawn(share_mic).detach(); + if option_env!("START_MIC").is_some() + || &*util::channel::RELEASE_CHANNEL != &ReleaseChannel::Dev + { + let share_mic = room.update(&mut cx, |room, cx| room.share_mic(cx)); + cx.background().spawn(share_mic).detach(); + } match room .update(&mut cx, |room, cx| { @@ -653,7 +655,8 @@ impl Room { if let Some(live_kit) = this.live_kit.as_ref() { let video_tracks = live_kit.room.remote_video_tracks(&user.id.to_string()); - let audio_tracks = live_kit.room.remote_audio_tracks(&user.id.to_string()); + let audio_tracks = + live_kit.room.remote_audio_tracks(&user.id.to_string()); for track in video_tracks { this.remote_video_track_updated( RemoteVideoTrackUpdate::Subscribed(track), @@ -662,8 +665,11 @@ impl Room { .log_err(); } for track in audio_tracks { - this.remote_audio_track_updated(RemoteAudioTrackUpdate::Subscribed(track), cx) - .log_err(); + this.remote_audio_track_updated( + RemoteAudioTrackUpdate::Subscribed(track), + cx, + ) + .log_err(); } } } @@ -782,10 +788,7 @@ impl Room { .remote_participants .get_mut(&user_id) .ok_or_else(|| anyhow!("subscribed to track by unknown participant"))?; - participant.audio_tracks.insert( - track_id.clone(), - track, - ); + participant.audio_tracks.insert(track_id.clone(), track); cx.emit(Event::RemoteAudioTracksChanged { participant_id: participant.peer_id, }); From ecd2129c2f48f71af4ba2da2f7e3f6088d4062e3 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 16 Jun 2023 11:16:36 -0700 Subject: [PATCH 015/215] Add deafen and mute stubs --- crates/call/src/room.rs | 11 +++++++++++ crates/collab_ui/src/collab_ui.rs | 26 +++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 3b76a0bb37..aa0cb1f20e 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -1143,6 +1143,17 @@ impl Room { }) } + pub fn toggle_mute(&mut self, cx: &mut ModelContext) -> Task> { + // https://docs.livekit.io/client/publish/ + // Should be acessible from local participant / publication + todo!(); + } + + pub fn toggle_deafen(&mut self, cx: &mut ModelContext) -> Task> { + // iterate through publications and mute (?????) + todo!(); + } + pub fn unshare_screen(&mut self, cx: &mut ModelContext) -> Result<()> { if self.status.is_offline() { return Err(anyhow!("room is offline")); diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rs index c0734388b1..9a426b0879 100644 --- a/crates/collab_ui/src/collab_ui.rs +++ b/crates/collab_ui/src/collab_ui.rs @@ -15,7 +15,7 @@ use gpui::{actions, AppContext, Task}; use std::sync::Arc; use workspace::AppState; -actions!(collab, [ToggleScreenSharing]); +actions!(collab, [ToggleScreenSharing, ToggleMute, ToggleDeafen]); pub fn init(app_state: &Arc, cx: &mut AppContext) { collab_titlebar_item::init(cx); @@ -27,6 +27,8 @@ pub fn init(app_state: &Arc, cx: &mut AppContext) { sharing_status_indicator::init(cx); cx.add_global_action(toggle_screen_sharing); + cx.add_global_action(toggle_mute); + cx.add_global_action(toggle_deafen); } pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) { @@ -41,3 +43,25 @@ pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) { toggle_screen_sharing.detach_and_log_err(cx); } } + +pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) { + if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { + let toggle_mut = room.update(cx, |room, cx| { + if room.is_sharing_mic() { + room.toggle_mute(cx) + } else { + room.share_mic(cx) + } + }); + toggle_mut.detach_and_log_err(cx); + } +} + +pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) { + if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { + let toggle_deafan = room.update(cx, |room, cx| { + room.toggle_deafen(cx) + }); + toggle_deafan.detach_and_log_err(cx); + } +} From b45f5f04896485ded57a375e44e386b8c1b7afaa Mon Sep 17 00:00:00 2001 From: Sergey Onufrienko Date: Fri, 16 Jun 2023 21:36:42 +0200 Subject: [PATCH 016/215] feat: add JsonSchema to gpui --- crates/gpui/src/color.rs | 21 +++++++++-- crates/gpui/src/elements/container.rs | 18 ++++++++++ crates/gpui/src/elements/image.rs | 3 +- crates/gpui/src/elements/label.rs | 3 +- crates/gpui/src/elements/tooltip.rs | 5 +-- crates/gpui/src/font_cache.rs | 6 ++-- crates/gpui/src/fonts.rs | 52 +++++++++++++++++++++------ crates/gpui/src/scene.rs | 3 +- crates/settings/src/keymap_file.rs | 14 ++------ 9 files changed, 90 insertions(+), 35 deletions(-) diff --git a/crates/gpui/src/color.rs b/crates/gpui/src/color.rs index 46ef470180..7575bbc6d7 100644 --- a/crates/gpui/src/color.rs +++ b/crates/gpui/src/color.rs @@ -6,17 +6,19 @@ use std::{ use crate::json::ToJson; use pathfinder_color::{ColorF, ColorU}; +use schemars::{ + gen::SchemaGenerator, + schema::{InstanceType, Schema, SchemaObject}, + JsonSchema, +}; use serde::{ de::{self, Unexpected}, Deserialize, Deserializer, }; use serde_json::json; -use ts_rs::TS; #[derive(Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord)] #[repr(transparent)] -#[derive(TS)] -#[ts(export, export_to = "theme/types/")] pub struct Color(ColorU); impl Color { @@ -130,3 +132,16 @@ impl fmt::Debug for Color { self.0.fmt(f) } } + +impl JsonSchema for Color { + fn schema_name() -> String { + "Color".into() + } + + fn json_schema(_: &mut SchemaGenerator) -> Schema { + let mut schema = SchemaObject::default(); + schema.instance_type = Some(InstanceType::Integer.into()); + schema.format = Some("uint".to_owned()); + Schema::Object(schema) + } +} diff --git a/crates/gpui/src/elements/container.rs b/crates/gpui/src/elements/container.rs index 3ce323db09..9457ccba6c 100644 --- a/crates/gpui/src/elements/container.rs +++ b/crates/gpui/src/elements/container.rs @@ -12,6 +12,11 @@ use crate::{ scene::{self, Border, CursorRegion, Quad}, AnyElement, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext, }; +use schemars::{ + gen::SchemaGenerator, + schema::{InstanceType, Schema, SchemaObject}, + JsonSchema, +}; use serde::Deserialize; use serde_json::json; @@ -332,6 +337,19 @@ impl ToJson for ContainerStyle { } } +impl JsonSchema for ContainerStyle { + fn schema_name() -> String { + "ContainerStyle".into() + } + + fn json_schema(_: &mut SchemaGenerator) -> Schema { + let mut schema = SchemaObject::default(); + schema.instance_type = Some(InstanceType::Integer.into()); + schema.format = Some("uint".to_owned()); + Schema::Object(schema) + } +} + #[derive(Clone, Copy, Debug, Default)] pub struct Margin { pub top: f32, diff --git a/crates/gpui/src/elements/image.rs b/crates/gpui/src/elements/image.rs index 98c5ae6226..df200eae7f 100644 --- a/crates/gpui/src/elements/image.rs +++ b/crates/gpui/src/elements/image.rs @@ -8,6 +8,7 @@ use crate::{ scene, Border, Element, ImageData, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext, }; +use schemars::JsonSchema; use serde::Deserialize; use std::{ops::Range, sync::Arc}; @@ -21,7 +22,7 @@ pub struct Image { style: ImageStyle, } -#[derive(Copy, Clone, Default, Deserialize)] +#[derive(Copy, Clone, Default, Deserialize, JsonSchema)] pub struct ImageStyle { #[serde(default)] pub border: Border, diff --git a/crates/gpui/src/elements/label.rs b/crates/gpui/src/elements/label.rs index 9499841b3d..57aeba2886 100644 --- a/crates/gpui/src/elements/label.rs +++ b/crates/gpui/src/elements/label.rs @@ -10,6 +10,7 @@ use crate::{ text_layout::{Line, RunStyle}, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext, }; +use schemars::JsonSchema; use serde::Deserialize; use serde_json::json; use smallvec::{smallvec, SmallVec}; @@ -20,7 +21,7 @@ pub struct Label { highlight_indices: Vec, } -#[derive(Clone, Debug, Deserialize, Default)] +#[derive(Clone, Debug, Deserialize, Default, JsonSchema)] pub struct LabelStyle { pub text: TextStyle, pub highlight_text: Option, diff --git a/crates/gpui/src/elements/tooltip.rs b/crates/gpui/src/elements/tooltip.rs index 7b4892fc1c..f21b1c363c 100644 --- a/crates/gpui/src/elements/tooltip.rs +++ b/crates/gpui/src/elements/tooltip.rs @@ -9,6 +9,7 @@ use crate::{ Action, Axis, ElementStateHandle, LayoutContext, SceneBuilder, SizeConstraint, Task, View, ViewContext, }; +use schemars::JsonSchema; use serde::Deserialize; use std::{ cell::{Cell, RefCell}, @@ -33,7 +34,7 @@ struct TooltipState { debounce: RefCell>>, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct TooltipStyle { #[serde(flatten)] pub container: ContainerStyle, @@ -42,7 +43,7 @@ pub struct TooltipStyle { pub max_text_width: Option, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct KeystrokeStyle { #[serde(flatten)] container: ContainerStyle, diff --git a/crates/gpui/src/font_cache.rs b/crates/gpui/src/font_cache.rs index e40d86679e..4f0d4fd461 100644 --- a/crates/gpui/src/font_cache.rs +++ b/crates/gpui/src/font_cache.rs @@ -7,16 +7,14 @@ use crate::{ use anyhow::{anyhow, Result}; use ordered_float::OrderedFloat; use parking_lot::{RwLock, RwLockUpgradableReadGuard}; +use schemars::JsonSchema; use std::{ collections::HashMap, ops::{Deref, DerefMut}, sync::Arc, }; -use ts_rs::TS; -#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] -#[derive(TS)] -#[ts(export, export_to = "theme/types/")] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, JsonSchema)] pub struct FamilyId(usize); struct Family { diff --git a/crates/gpui/src/fonts.rs b/crates/gpui/src/fonts.rs index bfdf3e0479..62894452fd 100644 --- a/crates/gpui/src/fonts.rs +++ b/crates/gpui/src/fonts.rs @@ -15,11 +15,8 @@ use schemars::JsonSchema; use serde::{de, Deserialize, Serialize}; use serde_json::Value; use std::{cell::RefCell, sync::Arc}; -use ts_rs::TS; -#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] -#[derive(TS)] -#[ts(export, export_to = "theme/types/")] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, JsonSchema)] pub struct FontId(pub usize); pub type GlyphId = u32; @@ -62,22 +59,52 @@ pub struct Features { pub zero: Option, } -#[derive(Clone, Debug)] -#[derive(TS)] -#[ts(export, export_to = "theme/types/")] +#[derive(Clone, Debug, JsonSchema)] pub struct TextStyle { pub color: Color, pub font_family_name: Arc, pub font_family_id: FamilyId, pub font_id: FontId, pub font_size: f32, + #[serde(with = "PropertiesDef")] pub font_properties: Properties, 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: WeightDef, + /// The font stretchiness, as defined in CSS. + pub stretch: StretchDef, +} + +#[derive(JsonSchema)] +#[serde(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(JsonSchema)] +#[serde(remote = "Weight")] +pub struct WeightDef(pub f32); + +#[derive(JsonSchema)] +#[serde(remote = "Stretch")] +pub struct StretchDef(pub f32); + +#[derive(Copy, Clone, Debug, Default, PartialEq, JsonSchema)] pub struct HighlightStyle { pub color: Option, + #[serde(with = "WeightDef")] pub weight: Option, pub italic: Option, pub underline: Option, @@ -86,15 +113,18 @@ pub struct HighlightStyle { impl Eq for HighlightStyle {} -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] -#[derive(TS)] -#[ts(export, export_to = "theme/types/")] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, JsonSchema)] pub struct Underline { pub color: Option, + #[serde(with = "OrderedFloatDef::")] pub thickness: OrderedFloat, pub squiggly: bool, } +#[derive(JsonSchema)] +#[serde(remote = "OrderedFloat")] +pub struct OrderedFloatDef(pub T); + #[allow(non_camel_case_types)] #[derive(Deserialize)] enum WeightJson { diff --git a/crates/gpui/src/scene.rs b/crates/gpui/src/scene.rs index 96edee1757..7793a28ee0 100644 --- a/crates/gpui/src/scene.rs +++ b/crates/gpui/src/scene.rs @@ -3,6 +3,7 @@ mod mouse_region; #[cfg(debug_assertions)] use collections::HashSet; +use schemars::JsonSchema; use serde::Deserialize; use serde_json::json; use std::{borrow::Cow, sync::Arc}; @@ -99,7 +100,7 @@ pub struct Icon { pub color: Color, } -#[derive(Clone, Copy, Default, Debug)] +#[derive(Clone, Copy, Default, Debug, JsonSchema)] pub struct Border { pub width: f32, pub color: Color, diff --git a/crates/settings/src/keymap_file.rs b/crates/settings/src/keymap_file.rs index e607a254bd..9a05e35311 100644 --- a/crates/settings/src/keymap_file.rs +++ b/crates/settings/src/keymap_file.rs @@ -3,7 +3,7 @@ use anyhow::{Context, Result}; use collections::BTreeMap; use gpui::{keymap_matcher::Binding, AppContext}; use schemars::{ - gen::{SchemaGenerator, SchemaSettings}, + gen::SchemaSettings, schema::{InstanceType, Schema, SchemaObject, SingleOrVec, SubschemaValidation}, JsonSchema, }; @@ -22,20 +22,10 @@ pub struct KeymapBlock { bindings: BTreeMap, } -#[derive(Deserialize, Default, Clone)] +#[derive(Deserialize, Default, Clone, JsonSchema)] #[serde(transparent)] pub struct KeymapAction(Box); -impl JsonSchema for KeymapAction { - fn schema_name() -> String { - "KeymapAction".into() - } - - fn json_schema(_: &mut SchemaGenerator) -> Schema { - Schema::Bool(true) - } -} - #[derive(Deserialize)] struct ActionWithData(Box, Box); From a87b39a2d146df672bac273aaf454cb834054866 Mon Sep 17 00:00:00 2001 From: Sergey Onufrienko Date: Fri, 16 Jun 2023 21:37:56 +0200 Subject: [PATCH 017/215] feat: add JsonSchema to Theme --- crates/theme/src/theme.rs | 163 +++++++++++++++-------------- crates/theme/src/theme_settings.rs | 3 +- crates/theme/src/ui.rs | 11 +- 3 files changed, 90 insertions(+), 87 deletions(-) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 9bd17910d2..6d9d79de05 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -8,6 +8,7 @@ use gpui::{ fonts::{HighlightStyle, TextStyle}, platform, AppContext, AssetSource, Border, MouseState, }; +use schemars::JsonSchema; use serde::{de::DeserializeOwned, Deserialize}; use serde_json::Value; use settings::SettingsStore; @@ -36,7 +37,7 @@ pub fn init(source: impl AssetSource, cx: &mut AppContext) { .detach(); } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct Theme { #[serde(default)] pub meta: ThemeMeta, @@ -67,7 +68,7 @@ pub struct Theme { pub color_scheme: ColorScheme, } -#[derive(Deserialize, Default, Clone)] +#[derive(Deserialize, Default, Clone, JsonSchema)] pub struct ThemeMeta { #[serde(skip_deserializing)] pub id: usize, @@ -75,7 +76,7 @@ pub struct ThemeMeta { pub is_light: bool, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct Workspace { pub background: Color, pub blank_pane: BlankPaneStyle, @@ -102,7 +103,7 @@ pub struct Workspace { pub drop_target_overlay_color: Color, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct BlankPaneStyle { pub logo: SvgStyle, pub logo_shadow: SvgStyle, @@ -112,7 +113,7 @@ pub struct BlankPaneStyle { pub keyboard_hint_width: f32, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Titlebar { #[serde(flatten)] pub container: ContainerStyle, @@ -137,7 +138,7 @@ pub struct Titlebar { pub toggle_contacts_badge: ContainerStyle, } -#[derive(Copy, Clone, Deserialize, Default)] +#[derive(Copy, Clone, Deserialize, Default, JsonSchema)] pub struct AvatarStyle { #[serde(flatten)] pub image: ImageStyle, @@ -145,14 +146,14 @@ pub struct AvatarStyle { pub outer_corner_radius: f32, } -#[derive(Deserialize, Default, Clone)] +#[derive(Deserialize, Default, Clone, JsonSchema)] pub struct Copilot { pub out_link_icon: Interactive, pub modal: ModalStyle, pub auth: CopilotAuth, } -#[derive(Deserialize, Default, Clone)] +#[derive(Deserialize, Default, Clone, JsonSchema)] pub struct CopilotAuth { pub content_width: f32, pub prompting: CopilotAuthPrompting, @@ -162,14 +163,14 @@ pub struct CopilotAuth { pub header: IconStyle, } -#[derive(Deserialize, Default, Clone)] +#[derive(Deserialize, Default, Clone, JsonSchema)] pub struct CopilotAuthPrompting { pub subheading: ContainedText, pub hint: ContainedText, pub device_code: DeviceCode, } -#[derive(Deserialize, Default, Clone)] +#[derive(Deserialize, Default, Clone, JsonSchema)] pub struct DeviceCode { pub text: TextStyle, pub cta: ButtonStyle, @@ -179,19 +180,19 @@ pub struct DeviceCode { pub right_container: Interactive, } -#[derive(Deserialize, Default, Clone)] +#[derive(Deserialize, Default, Clone, JsonSchema)] pub struct CopilotAuthNotAuthorized { pub subheading: ContainedText, pub warning: ContainedText, } -#[derive(Deserialize, Default, Clone)] +#[derive(Deserialize, Default, Clone, JsonSchema)] pub struct CopilotAuthAuthorized { pub subheading: ContainedText, pub hint: ContainedText, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ContactsPopover { #[serde(flatten)] pub container: ContainerStyle, @@ -199,7 +200,7 @@ pub struct ContactsPopover { pub width: f32, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ContactList { pub user_query_editor: FieldEditor, pub user_query_editor_height: f32, @@ -221,7 +222,7 @@ pub struct ContactList { pub calling_indicator: ContainedText, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ProjectRow { #[serde(flatten)] pub container: ContainerStyle, @@ -229,13 +230,13 @@ pub struct ProjectRow { pub name: ContainedText, } -#[derive(Deserialize, Default, Clone, Copy)] +#[derive(Deserialize, Default, Clone, Copy, JsonSchema)] pub struct TreeBranch { pub width: f32, pub color: Color, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ContactFinder { pub picker: Picker, pub row_height: f32, @@ -245,7 +246,7 @@ pub struct ContactFinder { pub disabled_contact_button: IconButton, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct LspLogMenu { #[serde(flatten)] pub container: ContainerStyle, @@ -255,7 +256,7 @@ pub struct LspLogMenu { pub row_height: f32, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct TabBar { #[serde(flatten)] pub container: ContainerStyle, @@ -283,13 +284,13 @@ impl TabBar { } } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct TabStyles { pub active_tab: Tab, pub inactive_tab: Tab, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct AvatarRibbon { #[serde(flatten)] pub container: ContainerStyle, @@ -297,7 +298,7 @@ pub struct AvatarRibbon { pub height: f32, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct OfflineIcon { #[serde(flatten)] pub container: ContainerStyle, @@ -305,7 +306,7 @@ pub struct OfflineIcon { pub color: Color, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Tab { pub height: f32, #[serde(flatten)] @@ -322,7 +323,7 @@ pub struct Tab { pub icon_conflict: Color, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Toolbar { #[serde(flatten)] pub container: ContainerStyle, @@ -331,14 +332,14 @@ pub struct Toolbar { pub nav_button: Interactive, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Notifications { #[serde(flatten)] pub container: ContainerStyle, pub width: f32, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Search { #[serde(flatten)] pub container: ContainerStyle, @@ -355,7 +356,7 @@ pub struct Search { pub dismiss_button: Interactive, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct FindEditor { #[serde(flatten)] pub input: FieldEditor, @@ -363,7 +364,7 @@ pub struct FindEditor { pub max_width: f32, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct StatusBar { #[serde(flatten)] pub container: ContainerStyle, @@ -379,7 +380,7 @@ pub struct StatusBar { pub diagnostic_message: Interactive, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct StatusBarPanelButtons { pub group_left: ContainerStyle, pub group_bottom: ContainerStyle, @@ -387,7 +388,7 @@ pub struct StatusBarPanelButtons { pub button: Interactive, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct StatusBarDiagnosticSummary { pub container_ok: ContainerStyle, pub container_warning: ContainerStyle, @@ -402,7 +403,7 @@ pub struct StatusBarDiagnosticSummary { pub summary_spacing: f32, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct StatusBarLspStatus { #[serde(flatten)] pub container: ContainerStyle, @@ -413,14 +414,14 @@ pub struct StatusBarLspStatus { pub message: TextStyle, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct Dock { pub left: ContainerStyle, pub bottom: ContainerStyle, pub right: ContainerStyle, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct PanelButton { #[serde(flatten)] pub container: ContainerStyle, @@ -429,7 +430,7 @@ pub struct PanelButton { pub label: ContainedText, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ProjectPanel { #[serde(flatten)] pub container: ContainerStyle, @@ -442,7 +443,7 @@ pub struct ProjectPanel { pub open_project_button: Interactive, } -#[derive(Clone, Debug, Deserialize, Default)] +#[derive(Clone, Debug, Deserialize, Default, JsonSchema)] pub struct ProjectPanelEntry { pub height: f32, #[serde(flatten)] @@ -454,19 +455,19 @@ pub struct ProjectPanelEntry { pub status: EntryStatus, } -#[derive(Clone, Debug, Deserialize, Default)] +#[derive(Clone, Debug, Deserialize, Default, JsonSchema)] pub struct EntryStatus { pub git: GitProjectStatus, } -#[derive(Clone, Debug, Deserialize, Default)] +#[derive(Clone, Debug, Deserialize, Default, JsonSchema)] pub struct GitProjectStatus { pub modified: Color, pub inserted: Color, pub conflict: Color, } -#[derive(Clone, Debug, Deserialize, Default)] +#[derive(Clone, Debug, Deserialize, Default, JsonSchema)] pub struct ContextMenu { #[serde(flatten)] pub container: ContainerStyle, @@ -475,7 +476,7 @@ pub struct ContextMenu { pub separator: ContainerStyle, } -#[derive(Clone, Debug, Deserialize, Default)] +#[derive(Clone, Debug, Deserialize, Default, JsonSchema)] pub struct ContextMenuItem { #[serde(flatten)] pub container: ContainerStyle, @@ -485,13 +486,13 @@ pub struct ContextMenuItem { pub icon_spacing: f32, } -#[derive(Debug, Deserialize, Default)] +#[derive(Debug, Deserialize, Default, JsonSchema)] pub struct CommandPalette { pub key: Interactive, pub keystroke_spacing: f32, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct InviteLink { #[serde(flatten)] pub container: ContainerStyle, @@ -500,7 +501,7 @@ pub struct InviteLink { pub icon: Icon, } -#[derive(Deserialize, Clone, Copy, Default)] +#[derive(Deserialize, Clone, Copy, Default, JsonSchema)] pub struct Icon { #[serde(flatten)] pub container: ContainerStyle, @@ -508,7 +509,7 @@ pub struct Icon { pub width: f32, } -#[derive(Deserialize, Clone, Copy, Default)] +#[derive(Deserialize, Clone, Copy, Default, JsonSchema)] pub struct IconButton { #[serde(flatten)] pub container: ContainerStyle, @@ -517,7 +518,7 @@ pub struct IconButton { pub button_width: f32, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ChatMessage { #[serde(flatten)] pub container: ContainerStyle, @@ -526,7 +527,7 @@ pub struct ChatMessage { pub timestamp: ContainedText, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ChannelSelect { #[serde(flatten)] pub container: ContainerStyle, @@ -538,7 +539,7 @@ pub struct ChannelSelect { pub menu: ContainerStyle, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ChannelName { #[serde(flatten)] pub container: ContainerStyle, @@ -546,7 +547,7 @@ pub struct ChannelName { pub name: TextStyle, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Picker { #[serde(flatten)] pub container: ContainerStyle, @@ -557,7 +558,7 @@ pub struct Picker { pub item: Interactive, } -#[derive(Clone, Debug, Deserialize, Default)] +#[derive(Clone, Debug, Deserialize, Default, JsonSchema)] pub struct ContainedText { #[serde(flatten)] pub container: ContainerStyle, @@ -565,7 +566,7 @@ pub struct ContainedText { pub text: TextStyle, } -#[derive(Clone, Debug, Deserialize, Default)] +#[derive(Clone, Debug, Deserialize, Default, JsonSchema)] pub struct ContainedLabel { #[serde(flatten)] pub container: ContainerStyle, @@ -573,7 +574,7 @@ pub struct ContainedLabel { pub label: LabelStyle, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct ProjectDiagnostics { #[serde(flatten)] pub container: ContainerStyle, @@ -583,7 +584,7 @@ pub struct ProjectDiagnostics { pub tab_summary_spacing: f32, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ContactNotification { pub header_avatar: ImageStyle, pub header_message: ContainedText, @@ -593,21 +594,21 @@ pub struct ContactNotification { pub dismiss_button: Interactive, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct UpdateNotification { pub message: ContainedText, pub action_message: Interactive, pub dismiss_button: Interactive, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct MessageNotification { pub message: ContainedText, pub action_message: Interactive, pub dismiss_button: Interactive, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ProjectSharedNotification { pub window_height: f32, pub window_width: f32, @@ -624,7 +625,7 @@ pub struct ProjectSharedNotification { pub dismiss_button: ContainedText, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct IncomingCallNotification { pub window_height: f32, pub window_width: f32, @@ -641,7 +642,7 @@ pub struct IncomingCallNotification { pub decline_button: ContainedText, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Editor { pub text_color: Color, #[serde(default)] @@ -682,7 +683,7 @@ pub struct Editor { pub whitespace: Color, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Scrollbar { pub track: ContainerStyle, pub thumb: ContainerStyle, @@ -691,14 +692,14 @@ pub struct Scrollbar { pub git: GitDiffColors, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct GitDiffColors { pub inserted: Color, pub modified: Color, pub deleted: Color, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct DiagnosticPathHeader { #[serde(flatten)] pub container: ContainerStyle, @@ -707,7 +708,7 @@ pub struct DiagnosticPathHeader { pub text_scale_factor: f32, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct DiagnosticHeader { #[serde(flatten)] pub container: ContainerStyle, @@ -718,7 +719,7 @@ pub struct DiagnosticHeader { pub icon_width_factor: f32, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct DiagnosticStyle { pub message: LabelStyle, #[serde(default)] @@ -726,7 +727,7 @@ pub struct DiagnosticStyle { pub text_scale_factor: f32, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct AutocompleteStyle { #[serde(flatten)] pub container: ContainerStyle, @@ -736,13 +737,13 @@ pub struct AutocompleteStyle { pub match_highlight: HighlightStyle, } -#[derive(Clone, Copy, Default, Deserialize)] +#[derive(Clone, Copy, Default, Deserialize, JsonSchema)] pub struct SelectionStyle { pub cursor: Color, pub selection: Color, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct FieldEditor { #[serde(flatten)] pub container: ContainerStyle, @@ -752,19 +753,19 @@ pub struct FieldEditor { pub selection: SelectionStyle, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct InteractiveColor { pub color: Color, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct CodeActions { #[serde(default)] pub indicator: Interactive, pub vertical_scale: f32, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Folds { pub indicator: Interactive, pub ellipses: FoldEllipses, @@ -774,14 +775,14 @@ pub struct Folds { pub foldable_icon: String, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct FoldEllipses { pub text_color: Color, pub background: Interactive, pub corner_radius_factor: f32, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct DiffStyle { pub inserted: Color, pub modified: Color, @@ -791,7 +792,7 @@ pub struct DiffStyle { pub corner_radius: f32, } -#[derive(Debug, Default, Clone, Copy)] +#[derive(Debug, Default, Clone, Copy, JsonSchema)] pub struct Interactive { pub default: T, pub hover: Option, @@ -934,7 +935,7 @@ impl<'de> Deserialize<'de> for SyntaxTheme { } } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct HoverPopover { pub container: ContainerStyle, pub info_container: ContainerStyle, @@ -946,7 +947,7 @@ pub struct HoverPopover { pub highlight: Color, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct TerminalStyle { pub black: Color, pub red: Color, @@ -980,7 +981,7 @@ pub struct TerminalStyle { pub dim_foreground: Color, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct AssistantStyle { pub container: ContainerStyle, pub header: ContainerStyle, @@ -997,7 +998,7 @@ pub struct AssistantStyle { pub api_key_prompt: ContainedText, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct FeedbackStyle { pub submit_button: Interactive, pub button_margin: f32, @@ -1006,7 +1007,7 @@ pub struct FeedbackStyle { pub link_text_hover: ContainedText, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct WelcomeStyle { pub page_width: f32, pub logo: SvgStyle, @@ -1020,7 +1021,7 @@ pub struct WelcomeStyle { pub checkbox_group: ContainerStyle, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct ColorScheme { pub name: String, pub is_light: bool, @@ -1035,13 +1036,13 @@ pub struct ColorScheme { pub players: Vec, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Player { pub cursor: Color, pub selection: Color, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct RampSet { pub neutral: Vec, pub red: Vec, @@ -1054,7 +1055,7 @@ pub struct RampSet { pub magenta: Vec, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Layer { pub base: StyleSet, pub variant: StyleSet, @@ -1065,7 +1066,7 @@ pub struct Layer { pub negative: StyleSet, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct StyleSet { pub default: Style, pub active: Style, @@ -1075,7 +1076,7 @@ pub struct StyleSet { pub inverted: Style, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Style { pub background: Color, pub border: Color, diff --git a/crates/theme/src/theme_settings.rs b/crates/theme/src/theme_settings.rs index f86d3fd8dd..b9e6f7a133 100644 --- a/crates/theme/src/theme_settings.rs +++ b/crates/theme/src/theme_settings.rs @@ -14,12 +14,13 @@ use util::ResultExt as _; const MIN_FONT_SIZE: f32 = 6.0; -#[derive(Clone)] +#[derive(Clone, JsonSchema)] pub struct ThemeSettings { pub buffer_font_family_name: String, pub buffer_font_features: fonts::Features, pub buffer_font_family: FamilyId, pub(crate) buffer_font_size: f32, + #[serde(skip)] pub theme: Arc, } diff --git a/crates/theme/src/ui.rs b/crates/theme/src/ui.rs index b86bfca8c4..6cb7675ffd 100644 --- a/crates/theme/src/ui.rs +++ b/crates/theme/src/ui.rs @@ -13,11 +13,12 @@ use gpui::{ scene::MouseClick, Action, Element, EventContext, MouseState, View, ViewContext, }; +use schemars::JsonSchema; use serde::Deserialize; use crate::{ContainedText, Interactive}; -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct CheckboxStyle { pub icon: SvgStyle, pub label: ContainedText, @@ -93,14 +94,14 @@ where .with_cursor_style(platform::CursorStyle::PointingHand) } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct SvgStyle { pub color: Color, pub asset: String, pub dimensions: Dimensions, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Dimensions { pub width: f32, pub height: f32, @@ -120,7 +121,7 @@ pub fn svg(style: &SvgStyle) -> ConstrainedBox { .with_height(style.dimensions.height) } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct IconStyle { icon: SvgStyle, container: ContainerStyle, @@ -182,7 +183,7 @@ where .with_cursor_style(platform::CursorStyle::PointingHand) } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct ModalStyle { close_icon: Interactive, container: ContainerStyle, From 6d6b7020a0adb6d80d70d0e2586022bd56e522ff Mon Sep 17 00:00:00 2001 From: Sergey Onufrienko Date: Fri, 16 Jun 2023 21:38:06 +0200 Subject: [PATCH 018/215] feat: export_schema --- crates/theme/src/theme_settings.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/theme/src/theme_settings.rs b/crates/theme/src/theme_settings.rs index b9e6f7a133..859dbe636e 100644 --- a/crates/theme/src/theme_settings.rs +++ b/crates/theme/src/theme_settings.rs @@ -183,3 +183,20 @@ fn merge(target: &mut T, value: Option) { *target = value; } } + +#[cfg(test)] +mod tests { + use super::*; + use schemars::schema_for; + + #[test] + fn export_schema() { + let theme_settings_content = schema_for!(ThemeSettingsContent); + let output1 = serde_json::to_string_pretty(&theme_settings_content).unwrap(); + std::fs::write("schemas/theme_settings_content.json", output1); + + let theme_settings = schema_for!(ThemeSettings); + let output2 = serde_json::to_string_pretty(&theme_settings).unwrap(); + std::fs::write("schemas/theme_settings.json", output2); + } +} From 4badef19f1df3a8419557989f06d7322fad0f238 Mon Sep 17 00:00:00 2001 From: Sergey Onufrienko Date: Fri, 16 Jun 2023 21:39:22 +0200 Subject: [PATCH 019/215] feat: add Nodejs script to convert Json to TS --- json-to-ts/index.mjs | 55 ++++ json-to-ts/package-lock.json | 474 +++++++++++++++++++++++++++++++++++ json-to-ts/package.json | 15 ++ 3 files changed, 544 insertions(+) create mode 100644 json-to-ts/index.mjs create mode 100644 json-to-ts/package-lock.json create mode 100644 json-to-ts/package.json diff --git a/json-to-ts/index.mjs b/json-to-ts/index.mjs new file mode 100644 index 0000000000..2feac8c093 --- /dev/null +++ b/json-to-ts/index.mjs @@ -0,0 +1,55 @@ +import * as fs from 'fs/promises'; +import * as path from 'path'; +import * as url from 'url'; +import { compile } from 'json-schema-to-typescript'; + +// or just __dirname if running non-ES-Module Node +const dirname = path.dirname(url.fileURLToPath(import.meta.url)); + +async function main() { + let schemasPath = path.join(dirname, '..', 'crates/theme/schemas'); + // let schemasPath = path.join(dirname, '..', '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); + let schema = JSON.parse(await fs.readFile(filePath)); + 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 = Array.from(compiledTypes).join('\n\n'); + let outputPath = path.join(dirname, 'types', 'theme.ts'); + + try { + let existing = await fs.readFile(outputPath); + if (existing == output) { + // Skip writing if it hasn't changed, so that we don't confuse any sort + // of incremental builds. This check isn't ideal but the script runs + // quickly enough and rarely enough that it doesn't matter. + console.log('Schemas are up to date'); + return; + } + } catch (e) { + // It's fine if there's no output from a previous run. + if (e.code !== 'ENOENT') { + throw e; + } + } + + await fs.writeFile(outputPath, output); + console.log(`Wrote Typescript types to ${outputPath}`); +} + +main().catch((e) => { + console.error(e); + process.exit(1); +}); diff --git a/json-to-ts/package-lock.json b/json-to-ts/package-lock.json new file mode 100644 index 0000000000..4f308dce46 --- /dev/null +++ b/json-to-ts/package-lock.json @@ -0,0 +1,474 @@ +{ + "name": "json-to-ts", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "json-to-ts", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "json-schema-to-typescript": "^13.0.2" + } + }, + "node_modules/@bcherny/json-schema-ref-parser": { + "version": "10.0.5-fork", + "resolved": "https://registry.npmjs.org/@bcherny/json-schema-ref-parser/-/json-schema-ref-parser-10.0.5-fork.tgz", + "integrity": "sha512-E/jKbPoca1tfUPj3iSbitDZTGnq6FUFjkH6L8U2oDwSuwK1WhnnVtCG7oFOTg/DDnyoXbQYUiUiGOibHqaGVnw==", + "dependencies": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.6", + "call-me-maybe": "^1.0.1", + "js-yaml": "^4.1.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/philsturgeon" + } + }, + "node_modules/@jsdevtools/ono": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==" + }, + "node_modules/@types/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==", + "dependencies": { + "@types/minimatch": "*", + "@types/node": "*" + } + }, + "node_modules/@types/json-schema": { + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==" + }, + "node_modules/@types/lodash": { + "version": "4.14.195", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.195.tgz", + "integrity": "sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg==" + }, + "node_modules/@types/minimatch": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==" + }, + "node_modules/@types/node": { + "version": "20.3.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.1.tgz", + "integrity": "sha512-EhcH/wvidPy1WeML3TtYFGR83UzjxeWRen9V402T8aUGYsCHOmfoisV3ZSg03gAFIbLq8TnWOJ0f4cALtnSEUg==" + }, + "node_modules/@types/prettier": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", + "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==" + }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==" + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/call-me-maybe": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", + "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==" + }, + "node_modules/cli-color": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.3.tgz", + "integrity": "sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.61", + "es6-iterator": "^2.0.3", + "memoizee": "^0.4.15", + "timers-ext": "^0.1.7" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "node_modules/d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "dependencies": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "node_modules/es5-ext": { + "version": "0.10.62", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "hasInstallScript": true, + "dependencies": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "node_modules/es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "dependencies": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "node_modules/es6-weak-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.1" + } + }, + "node_modules/event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "dependencies": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, + "node_modules/ext": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "dependencies": { + "type": "^2.7.2" + } + }, + "node_modules/ext/node_modules/type": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "node_modules/get-stdin": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", + "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-promise": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/glob-promise/-/glob-promise-4.2.2.tgz", + "integrity": "sha512-xcUzJ8NWN5bktoTIX7eOclO1Npxd/dyVqUJxlLIDasT4C7KZyqlPIwkdJ0Ypiy3p2ZKahTjK4M9uC3sNSfNMzw==", + "dependencies": { + "@types/glob": "^7.1.3" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "individual", + "url": "https://github.com/sponsors/ahmadnassri" + }, + "peerDependencies": { + "glob": "^7.1.6" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-promise": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==" + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-schema-to-typescript": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-13.0.2.tgz", + "integrity": "sha512-TCaEVW4aI2FmMQe7f98mvr3/oiVmXEC1xZjkTZ9L/BSoTXFlC7p64mD5AD2d8XWycNBQZUnHwXL5iVXt1HWwNQ==", + "dependencies": { + "@bcherny/json-schema-ref-parser": "10.0.5-fork", + "@types/json-schema": "^7.0.11", + "@types/lodash": "^4.14.182", + "@types/prettier": "^2.6.1", + "cli-color": "^2.0.2", + "get-stdin": "^8.0.0", + "glob": "^7.1.6", + "glob-promise": "^4.2.2", + "is-glob": "^4.0.3", + "lodash": "^4.17.21", + "minimist": "^1.2.6", + "mkdirp": "^1.0.4", + "mz": "^2.7.0", + "prettier": "^2.6.2" + }, + "bin": { + "json2ts": "dist/src/cli.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/lru-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", + "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==", + "dependencies": { + "es5-ext": "~0.10.2" + } + }, + "node_modules/memoizee": { + "version": "0.4.15", + "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", + "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.53", + "es6-weak-map": "^2.0.3", + "event-emitter": "^0.3.5", + "is-promise": "^2.2.2", + "lru-queue": "^0.1.0", + "next-tick": "^1.1.0", + "timers-ext": "^0.1.7" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "node_modules/next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/timers-ext": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", + "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==", + "dependencies": { + "es5-ext": "~0.10.46", + "next-tick": "1" + } + }, + "node_modules/type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + } + } +} diff --git a/json-to-ts/package.json b/json-to-ts/package.json new file mode 100644 index 0000000000..79ff207146 --- /dev/null +++ b/json-to-ts/package.json @@ -0,0 +1,15 @@ +{ + "name": "json-to-ts", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "json-schema-to-typescript": "^13.0.2" + } +} From ac42522987ebd590e5b509b4c8e803263e9b9643 Mon Sep 17 00:00:00 2001 From: Sergey Onufrienko Date: Fri, 16 Jun 2023 21:45:37 +0200 Subject: [PATCH 020/215] chore: remove ts-rs --- Cargo.lock | 24 ------------------------ crates/gpui/Cargo.toml | 1 - 2 files changed, 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 480694c4ca..fba46c59cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2832,7 +2832,6 @@ dependencies = [ "sum_tree", "time 0.3.21", "tiny-skia", - "ts-rs", "usvg", "util", "uuid 1.3.2", @@ -7572,29 +7571,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" -[[package]] -name = "ts-rs" -version = "6.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4added4070a4fdf9df03457206cd2e4b12417c8560a2954d91ffcbe60177a56a" -dependencies = [ - "thiserror", - "ts-rs-macros", -] - -[[package]] -name = "ts-rs-macros" -version = "6.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f807fdb3151fee75df7485b901a89624358cd07a67a8fb1a5831bf5a07681ff" -dependencies = [ - "Inflector", - "proc-macro2", - "quote", - "syn 1.0.109", - "termcolor", -] - [[package]] name = "ttf-parser" version = "0.9.0" diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index a4fda7a81f..31b7db008d 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -51,7 +51,6 @@ tiny-skia = "0.5" usvg = { version = "0.14", features = [] } uuid = { version = "1.1.2", features = ["v4"] } waker-fn = "1.1.0" -ts-rs = "6.2.1" [build-dependencies] bindgen = "0.65.1" From 882009bc759dd510e5eddbb9952a83e732f7266d Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 16 Jun 2023 16:15:07 -0600 Subject: [PATCH 021/215] Save conversations to ~/.config/zed/conversations Still need to implement loading / listing. I'd really be rather write operations to a database. Maybe we should be auto-saving? Integrating with panes? I just did the simple thing for now. --- assets/keymaps/default.json | 1 + crates/ai/src/ai.rs | 7 +++++ crates/ai/src/assistant.rs | 58 +++++++++++++++++++++++++++++++++---- crates/util/src/paths.rs | 1 + 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index a642697a37..cce8b07d17 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -200,6 +200,7 @@ "context": "AssistantEditor > Editor", "bindings": { "cmd-enter": "assistant::Assist", + "cmd-s": "workspace::Save", "cmd->": "assistant::QuoteSelection", "shift-enter": "assistant::Split", "ctrl-r": "assistant::CycleMessageRole" diff --git a/crates/ai/src/ai.rs b/crates/ai/src/ai.rs index 40224b3229..a46076831f 100644 --- a/crates/ai/src/ai.rs +++ b/crates/ai/src/ai.rs @@ -14,6 +14,13 @@ struct OpenAIRequest { stream: bool, } +#[derive(Serialize, Deserialize)] +struct SavedConversation { + zed: String, + version: String, + messages: Vec, +} + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] struct RequestMessage { role: Role, diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 853f7262d3..a84666d3bf 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -1,6 +1,6 @@ use crate::{ assistant_settings::{AssistantDockPosition, AssistantSettings}, - OpenAIRequest, OpenAIResponseStreamEvent, RequestMessage, Role, + OpenAIRequest, OpenAIResponseStreamEvent, RequestMessage, Role, SavedConversation, }; use anyhow::{anyhow, Result}; use chrono::{DateTime, Local}; @@ -29,11 +29,14 @@ use std::{ borrow::Cow, cell::RefCell, cmp, fmt::Write, io, iter, ops::Range, rc::Rc, sync::Arc, time::Duration, }; -use util::{channel::ReleaseChannel, post_inc, truncate_and_trailoff, ResultExt, TryFutureExt}; +use util::{ + channel::ReleaseChannel, paths::CONVERSATIONS_DIR, post_inc, truncate_and_trailoff, ResultExt, + TryFutureExt, +}; use workspace::{ dock::{DockPosition, Panel}, item::Item, - pane, Pane, Workspace, + pane, Pane, Save, Workspace, }; const OPENAI_API_URL: &'static str = "https://api.openai.com/v1"; @@ -47,7 +50,7 @@ actions!( CycleMessageRole, QuoteSelection, ToggleFocus, - ResetKey + ResetKey, ] ); @@ -70,6 +73,7 @@ pub fn init(cx: &mut AppContext) { ); cx.add_action(AssistantEditor::assist); cx.capture_action(AssistantEditor::cancel_last_assist); + cx.capture_action(AssistantEditor::save); cx.add_action(AssistantEditor::quote_selection); cx.capture_action(AssistantEditor::copy); cx.capture_action(AssistantEditor::split); @@ -215,8 +219,14 @@ impl AssistantPanel { fn add_context(&mut self, cx: &mut ViewContext) { let focus = self.has_focus(cx); - let editor = cx - .add_view(|cx| AssistantEditor::new(self.api_key.clone(), self.languages.clone(), cx)); + let editor = cx.add_view(|cx| { + AssistantEditor::new( + self.api_key.clone(), + self.languages.clone(), + self.fs.clone(), + cx, + ) + }); self.subscriptions .push(cx.subscribe(&editor, Self::handle_assistant_editor_event)); self.pane.update(cx, |pane, cx| { @@ -922,6 +932,33 @@ impl Assistant { None }) } + + fn save(&self, fs: Arc, cx: &mut ModelContext) -> Task> { + let conversation = SavedConversation { + zed: "conversation".into(), + version: "0.1".into(), + messages: self.open_ai_request_messages(cx), + }; + + let mut path = CONVERSATIONS_DIR.join(self.summary.as_deref().unwrap_or("conversation-1")); + + cx.background().spawn(async move { + while fs.is_file(&path).await { + let file_name = path.file_name().ok_or_else(|| anyhow!("no filename"))?; + let file_name = file_name.to_string_lossy(); + + if let Some((prefix, suffix)) = file_name.rsplit_once('-') { + let new_version = suffix.parse::().ok().unwrap_or(1) + 1; + path.set_file_name(format!("{}-{}", prefix, new_version)); + }; + } + + fs.create_dir(CONVERSATIONS_DIR.as_ref()).await?; + fs.atomic_write(path, serde_json::to_string(&conversation).unwrap()) + .await?; + Ok(()) + }) + } } struct PendingCompletion { @@ -941,6 +978,7 @@ struct ScrollPosition { struct AssistantEditor { assistant: ModelHandle, + fs: Arc, editor: ViewHandle, blocks: HashSet, scroll_position: Option, @@ -951,6 +989,7 @@ impl AssistantEditor { fn new( api_key: Rc>>, language_registry: Arc, + fs: Arc, cx: &mut ViewContext, ) -> Self { let assistant = cx.add_model(|cx| Assistant::new(api_key, language_registry, cx)); @@ -972,6 +1011,7 @@ impl AssistantEditor { editor, blocks: Default::default(), scroll_position: None, + fs, _subscriptions, }; this.update_message_headers(cx); @@ -1299,6 +1339,12 @@ impl AssistantEditor { }); } + fn save(&mut self, _: &Save, cx: &mut ViewContext) { + self.assistant.update(cx, |assistant, cx| { + assistant.save(self.fs.clone(), cx).detach_and_log_err(cx); + }); + } + fn cycle_model(&mut self, cx: &mut ViewContext) { self.assistant.update(cx, |assistant, cx| { let new_model = match assistant.model.as_str() { diff --git a/crates/util/src/paths.rs b/crates/util/src/paths.rs index e3397a1557..7ef55a9918 100644 --- a/crates/util/src/paths.rs +++ b/crates/util/src/paths.rs @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize}; lazy_static::lazy_static! { pub static ref HOME: PathBuf = dirs::home_dir().expect("failed to determine home directory"); pub static ref CONFIG_DIR: PathBuf = HOME.join(".config").join("zed"); + pub static ref CONVERSATIONS_DIR: PathBuf = HOME.join(".config/zed/conversations"); pub static ref LOGS_DIR: PathBuf = HOME.join("Library/Logs/Zed"); pub static ref SUPPORT_DIR: PathBuf = HOME.join("Library/Application Support/Zed"); pub static ref LANGUAGES_DIR: PathBuf = HOME.join("Library/Application Support/Zed/languages"); From ffd1190ccad54acc4f73d7f4d20013ef5927cff1 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 16 Jun 2023 23:02:32 -0400 Subject: [PATCH 022/215] Update rose pine theme family --- styles/src/themes/rose-pine/common.ts | 73 +++++++++++++++++++ styles/src/themes/rose-pine/rose-pine-dawn.ts | 40 +++++----- styles/src/themes/rose-pine/rose-pine-moon.ts | 40 +++++----- styles/src/themes/rose-pine/rose-pine.ts | 37 +++++----- 4 files changed, 129 insertions(+), 61 deletions(-) create mode 100644 styles/src/themes/rose-pine/common.ts diff --git a/styles/src/themes/rose-pine/common.ts b/styles/src/themes/rose-pine/common.ts new file mode 100644 index 0000000000..28ed090c5d --- /dev/null +++ b/styles/src/themes/rose-pine/common.ts @@ -0,0 +1,73 @@ +export const color = { + default: { + base: '#191724', + surface: '#1f1d2e', + overlay: '#26233a', + muted: '#6e6a86', + subtle: '#908caa', + text: '#e0def4', + love: '#eb6f92', + gold: '#f6c177', + rose: '#ebbcba', + pine: '#31748f', + foam: '#9ccfd8', + iris: '#c4a7e7', + highlightLow: '#21202e', + highlightMed: '#403d52', + highlightHigh: '#524f67', + }, + moon: { + base: '#232136', + surface: '#2a273f', + overlay: '#393552', + muted: '#6e6a86', + subtle: '#908caa', + text: '#e0def4', + love: '#eb6f92', + gold: '#f6c177', + rose: '#ea9a97', + pine: '#3e8fb0', + foam: '#9ccfd8', + iris: '#c4a7e7', + highlightLow: '#2a283e', + highlightMed: '#44415a', + highlightHigh: '#56526e', + }, + dawn: { + base: "#faf4ed", + surface: "#fffaf3", + overlay: "#f2e9e1", + muted: "#9893a5", + subtle: "#797593", + text: "#575279", + love: "#b4637a", + gold: "#ea9d34", + rose: "#d7827e", + pine: "#286983", + foam: "#56949f", + iris: "#907aa9", + highlightLow: "#f4ede8", + highlightMed: "#dfdad9", + highlightHigh: "#cecacd", + } +}; + +export const syntax = (c: typeof color.default) => { + return { + comment: { color: c.muted }, + operator: { color: c.subtle }, + punctuation: { color: c.subtle }, + variable: { color: c.text }, + string: { color: c.gold }, + "type.builtin": { color: c.rose }, + boolean: { color: c.rose }, + function: { color: c.rose }, + keyword: { color: c.pine }, + tag: { color: c.foam }, + type: { color: c.foam }, + "function.method": { color: c.iris }, + title: { color: c.gold }, + linkText: { color: c.foam, italic: false }, + linkUri: { color: c.rose }, + } +} diff --git a/styles/src/themes/rose-pine/rose-pine-dawn.ts b/styles/src/themes/rose-pine/rose-pine-dawn.ts index a373ed378c..3ec5d30bb6 100644 --- a/styles/src/themes/rose-pine/rose-pine-dawn.ts +++ b/styles/src/themes/rose-pine/rose-pine-dawn.ts @@ -6,6 +6,13 @@ import { ThemeConfig, } from "../../common" +import { color as c, syntax } from "./common"; + +const color = c.dawn + +const green = chroma.mix(color.foam, "#10b981", 0.6, 'lab'); +const magenta = chroma.mix(color.love, color.pine, 0.5, 'lab'); + export const theme: ThemeConfig = { name: "Rosé Pine Dawn", author: "edunfelt", @@ -14,26 +21,17 @@ export const theme: ThemeConfig = { licenseUrl: "https://github.com/edunfelt/base16-rose-pine-scheme", licenseFile: `${__dirname}/LICENSE`, inputColor: { - neutral: chroma - .scale([ - "#575279", - "#797593", - "#9893A5", - "#B5AFB8", - "#D3CCCC", - "#F2E9E1", - "#FFFAF3", - "#FAF4ED", - ]) - .domain([0, 0.35, 0.45, 0.65, 0.7, 0.8, 0.9, 1]), - red: colorRamp(chroma("#B4637A")), - orange: colorRamp(chroma("#D7827E")), - yellow: colorRamp(chroma("#EA9D34")), - green: colorRamp(chroma("#679967")), - cyan: colorRamp(chroma("#286983")), - blue: colorRamp(chroma("#56949F")), - violet: colorRamp(chroma("#907AA9")), - magenta: colorRamp(chroma("#79549F")), + neutral: chroma.scale([color.base, color.surface, color.highlightHigh, color.overlay, color.muted, color.subtle, color.text].reverse()).domain([0, 0.35, 0.45, 0.65, 0.7, 0.8, 0.9, 1]), + red: colorRamp(chroma(color.love)), + orange: colorRamp(chroma(color.iris)), + yellow: colorRamp(chroma(color.gold)), + green: colorRamp(chroma(green)), + cyan: colorRamp(chroma(color.pine)), + blue: colorRamp(chroma(color.foam)), + violet: colorRamp(chroma(color.iris)), + magenta: colorRamp(chroma(magenta)), }, - override: { syntax: {} }, + override: { + syntax: syntax(color) + } } diff --git a/styles/src/themes/rose-pine/rose-pine-moon.ts b/styles/src/themes/rose-pine/rose-pine-moon.ts index 94b8166cb3..4e70d2f0ad 100644 --- a/styles/src/themes/rose-pine/rose-pine-moon.ts +++ b/styles/src/themes/rose-pine/rose-pine-moon.ts @@ -6,6 +6,13 @@ import { ThemeConfig, } from "../../common" +import { color as c, syntax } from "./common"; + +const color = c.moon + +const green = chroma.mix(color.foam, "#10b981", 0.6, 'lab'); +const magenta = chroma.mix(color.love, color.pine, 0.5, 'lab'); + export const theme: ThemeConfig = { name: "Rosé Pine Moon", author: "edunfelt", @@ -14,26 +21,17 @@ export const theme: ThemeConfig = { licenseUrl: "https://github.com/edunfelt/base16-rose-pine-scheme", licenseFile: `${__dirname}/LICENSE`, inputColor: { - neutral: chroma - .scale([ - "#232136", - "#2A273F", - "#393552", - "#3E3A53", - "#56526C", - "#6E6A86", - "#908CAA", - "#E0DEF4", - ]) - .domain([0, 0.3, 0.55, 1]), - red: colorRamp(chroma("#EB6F92")), - orange: colorRamp(chroma("#EBBCBA")), - yellow: colorRamp(chroma("#F6C177")), - green: colorRamp(chroma("#8DBD8D")), - cyan: colorRamp(chroma("#409BBE")), - blue: colorRamp(chroma("#9CCFD8")), - violet: colorRamp(chroma("#C4A7E7")), - magenta: colorRamp(chroma("#AB6FE9")), + neutral: chroma.scale([color.base, color.surface, color.highlightHigh, color.overlay, color.muted, color.subtle, color.text]).domain([0, 0.3, 0.55, 1]), + red: colorRamp(chroma(color.love)), + orange: colorRamp(chroma(color.iris)), + yellow: colorRamp(chroma(color.gold)), + green: colorRamp(chroma(green)), + cyan: colorRamp(chroma(color.pine)), + blue: colorRamp(chroma(color.foam)), + violet: colorRamp(chroma(color.iris)), + magenta: colorRamp(chroma(magenta)), }, - override: { syntax: {} }, + override: { + syntax: syntax(color) + } } diff --git a/styles/src/themes/rose-pine/rose-pine.ts b/styles/src/themes/rose-pine/rose-pine.ts index 3aabe3f10e..6c4a6ac49b 100644 --- a/styles/src/themes/rose-pine/rose-pine.ts +++ b/styles/src/themes/rose-pine/rose-pine.ts @@ -5,6 +5,12 @@ import { ThemeLicenseType, ThemeConfig, } from "../../common" +import { color as c, syntax } from "./common"; + +const color = c.default + +const green = chroma.mix(color.foam, "#10b981", 0.6, 'lab'); +const magenta = chroma.mix(color.love, color.pine, 0.5, 'lab'); export const theme: ThemeConfig = { name: "Rosé Pine", @@ -14,24 +20,17 @@ export const theme: ThemeConfig = { licenseUrl: "https://github.com/edunfelt/base16-rose-pine-scheme", licenseFile: `${__dirname}/LICENSE`, inputColor: { - neutral: chroma.scale([ - "#191724", - "#1f1d2e", - "#26233A", - "#3E3A53", - "#56526C", - "#6E6A86", - "#908CAA", - "#E0DEF4", - ]), - red: colorRamp(chroma("#EB6F92")), - orange: colorRamp(chroma("#EBBCBA")), - yellow: colorRamp(chroma("#F6C177")), - green: colorRamp(chroma("#8DBD8D")), - cyan: colorRamp(chroma("#409BBE")), - blue: colorRamp(chroma("#9CCFD8")), - violet: colorRamp(chroma("#C4A7E7")), - magenta: colorRamp(chroma("#AB6FE9")), + neutral: chroma.scale([color.base, color.surface, color.highlightHigh, color.overlay, color.muted, color.subtle, color.text]), + red: colorRamp(chroma(color.love)), + orange: colorRamp(chroma(color.iris)), + yellow: colorRamp(chroma(color.gold)), + green: colorRamp(chroma(green)), + cyan: colorRamp(chroma(color.pine)), + blue: colorRamp(chroma(color.foam)), + violet: colorRamp(chroma(color.iris)), + magenta: colorRamp(chroma(magenta)), }, - override: { syntax: {} }, + override: { + syntax: syntax(color) + } } From 91f2f31daa16e36febd0880655bd16344bc3ef02 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 19 Jun 2023 12:06:42 +0200 Subject: [PATCH 023/215] Split git/project label into a flex row --- crates/collab_ui/src/collab_titlebar_item.rs | 62 ++++++++------------ 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 797a4f7066..919e712ad1 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -17,7 +17,7 @@ use gpui::{ AppContext, Entity, ImageData, LayoutContext, ModelHandle, SceneBuilder, Subscription, View, ViewContext, ViewHandle, WeakViewHandle, }; -use project::Project; +use project::{Project, RepositoryEntry}; use std::{ops::Range, sync::Arc}; use theme::{AvatarStyle, Theme}; use util::ResultExt; @@ -193,37 +193,16 @@ impl CollabTitlebarItem { theme: Arc, cx: &ViewContext, ) -> AnyElement { - let names_and_branches = project.visible_worktrees(cx).map(|worktree| { + let mut names_and_branches = project.visible_worktrees(cx).map(|worktree| { let worktree = worktree.read(cx); (worktree.root_name(), worktree.root_git_entry()) }); - fn push_str(buffer: &mut String, index: &mut usize, str: &str) { - buffer.push_str(str); - *index += str.chars().count(); - } - - let mut indices = Vec::new(); - let mut index = 0; - let mut title = String::new(); - let mut names_and_branches = names_and_branches.peekable(); - while let Some((name, entry)) = names_and_branches.next() { - let pre_index = index; - push_str(&mut title, &mut index, name); - indices.extend((pre_index..index).into_iter()); - if let Some(branch) = entry.and_then(|entry| entry.branch()) { - push_str(&mut title, &mut index, "/"); - push_str(&mut title, &mut index, &branch); - } - if names_and_branches.peek().is_some() { - push_str(&mut title, &mut index, ", "); - if index >= MAX_TITLE_LENGTH { - title.push_str(" …"); - break; - } - } - } - + let (name, entry) = names_and_branches.next().unwrap_or(("", None)); + let branch_prepended = entry + .as_ref() + .and_then(RepositoryEntry::branch) + .map(|branch| format!("/{branch}")); let text_style = theme.workspace.titlebar.title.clone(); let item_spacing = theme.workspace.titlebar.item_spacing; @@ -234,14 +213,25 @@ impl CollabTitlebarItem { text: text_style, highlight_text: Some(highlight), }; - - Label::new(title, style) - .with_highlights(indices) - .contained() - .with_margin_right(item_spacing) - .aligned() - .left() - .into_any_named("title-with-git-information") + let mut ret = Flex::row().with_child( + Label::new(name.to_owned(), style.clone()) + .with_highlights((0..name.len()).into_iter().collect()) + .contained() + .aligned() + .left() + .into_any_named("title-project-name"), + ); + if let Some(git_branch) = branch_prepended { + ret = ret.with_child( + Label::new(git_branch, style) + .contained() + .with_margin_right(item_spacing) + .aligned() + .left() + .into_any_named("title-project-branch"), + ) + } + ret.into_any() } fn window_activation_changed(&mut self, active: bool, cx: &mut ViewContext) { From 3e3079b513699964166a00205edc7c1a1fe829d9 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 19 Jun 2023 12:07:02 +0200 Subject: [PATCH 024/215] cargo fmt --- crates/collab_ui/src/collab_ui.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rs index 9a426b0879..d6e62d146f 100644 --- a/crates/collab_ui/src/collab_ui.rs +++ b/crates/collab_ui/src/collab_ui.rs @@ -59,9 +59,7 @@ pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) { pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) { if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { - let toggle_deafan = room.update(cx, |room, cx| { - room.toggle_deafen(cx) - }); + let toggle_deafan = room.update(cx, |room, cx| room.toggle_deafen(cx)); toggle_deafan.detach_and_log_err(cx); } } From 193ad64d18dc50453442d1b95edb03060f111e63 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 19 Jun 2023 11:31:17 -0700 Subject: [PATCH 025/215] Add JsonSchema to container style and fix compile errors --- crates/gpui/src/elements/container.rs | 23 +++++------------------ crates/gpui/src/platform.rs | 3 ++- crates/settings/src/keymap_file.rs | 17 +++++++++++++---- crates/theme/src/theme.rs | 2 +- crates/theme/src/theme_settings.rs | 4 ++-- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/crates/gpui/src/elements/container.rs b/crates/gpui/src/elements/container.rs index 9457ccba6c..eaeee6f0d9 100644 --- a/crates/gpui/src/elements/container.rs +++ b/crates/gpui/src/elements/container.rs @@ -13,14 +13,12 @@ use crate::{ AnyElement, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext, }; use schemars::{ - gen::SchemaGenerator, - schema::{InstanceType, Schema, SchemaObject}, JsonSchema, }; use serde::Deserialize; use serde_json::json; -#[derive(Clone, Copy, Debug, Default, Deserialize)] +#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)] pub struct ContainerStyle { #[serde(default)] pub margin: Margin, @@ -337,20 +335,8 @@ impl ToJson for ContainerStyle { } } -impl JsonSchema for ContainerStyle { - fn schema_name() -> String { - "ContainerStyle".into() - } - fn json_schema(_: &mut SchemaGenerator) -> Schema { - let mut schema = SchemaObject::default(); - schema.instance_type = Some(InstanceType::Integer.into()); - schema.format = Some("uint".to_owned()); - Schema::Object(schema) - } -} - -#[derive(Clone, Copy, Debug, Default)] +#[derive(Clone, Copy, Debug, Default, JsonSchema)] pub struct Margin { pub top: f32, pub left: f32, @@ -377,7 +363,7 @@ impl ToJson for Margin { } } -#[derive(Clone, Copy, Debug, Default)] +#[derive(Clone, Copy, Debug, Default, JsonSchema)] pub struct Padding { pub top: f32, pub left: f32, @@ -504,9 +490,10 @@ impl ToJson for Padding { } } -#[derive(Clone, Copy, Debug, Default, Deserialize)] +#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)] pub struct Shadow { #[serde(default, deserialize_with = "deserialize_vec2f")] + #[schemars(with = "Vec::")] offset: Vector2F, #[serde(default)] blur: f32, diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs index 7fc02b0548..67f8e52c04 100644 --- a/crates/gpui/src/platform.rs +++ b/crates/gpui/src/platform.rs @@ -25,6 +25,7 @@ use anyhow::{anyhow, bail, Result}; use async_task::Runnable; pub use event::*; use postage::oneshot; +use schemars::JsonSchema; use serde::Deserialize; use sqlez::{ bindable::{Bind, Column, StaticColumnCount}, @@ -282,7 +283,7 @@ pub enum PromptLevel { Critical, } -#[derive(Copy, Clone, Debug, Deserialize)] +#[derive(Copy, Clone, Debug, Deserialize, JsonSchema)] pub enum CursorStyle { Arrow, ResizeLeftRight, diff --git a/crates/settings/src/keymap_file.rs b/crates/settings/src/keymap_file.rs index 9a05e35311..c843c53e99 100644 --- a/crates/settings/src/keymap_file.rs +++ b/crates/settings/src/keymap_file.rs @@ -3,9 +3,8 @@ use anyhow::{Context, Result}; use collections::BTreeMap; use gpui::{keymap_matcher::Binding, AppContext}; use schemars::{ - gen::SchemaSettings, - schema::{InstanceType, Schema, SchemaObject, SingleOrVec, SubschemaValidation}, - JsonSchema, + gen::{SchemaGenerator, SchemaSettings}, + schema::{InstanceType, Schema, SchemaObject, SingleOrVec, SubschemaValidation}, JsonSchema, }; use serde::Deserialize; use serde_json::{value::RawValue, Value}; @@ -22,10 +21,20 @@ pub struct KeymapBlock { bindings: BTreeMap, } -#[derive(Deserialize, Default, Clone, JsonSchema)] +#[derive(Deserialize, Default, Clone)] #[serde(transparent)] pub struct KeymapAction(Box); +impl JsonSchema for KeymapAction { + fn schema_name() -> String { + "KeymapAction".into() + } + + fn json_schema(_: &mut SchemaGenerator) -> Schema { + Schema::Bool(true) + } +} + #[derive(Deserialize)] struct ActionWithData(Box, Box); diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 6d9d79de05..97223911f5 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -901,7 +901,7 @@ impl Editor { } } -#[derive(Default)] +#[derive(Default, JsonSchema)] pub struct SyntaxTheme { pub highlights: Vec<(String, HighlightStyle)>, } diff --git a/crates/theme/src/theme_settings.rs b/crates/theme/src/theme_settings.rs index 859dbe636e..7e275c399c 100644 --- a/crates/theme/src/theme_settings.rs +++ b/crates/theme/src/theme_settings.rs @@ -193,10 +193,10 @@ mod tests { fn export_schema() { let theme_settings_content = schema_for!(ThemeSettingsContent); let output1 = serde_json::to_string_pretty(&theme_settings_content).unwrap(); - std::fs::write("schemas/theme_settings_content.json", output1); + std::fs::write("schemas/theme_settings_content.json", output1).ok(); let theme_settings = schema_for!(ThemeSettings); let output2 = serde_json::to_string_pretty(&theme_settings).unwrap(); - std::fs::write("schemas/theme_settings.json", output2); + std::fs::write("schemas/theme_settings.json", output2).ok(); } } From ea469474893496588204902abb92c47b3c57e8bd Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 19 Jun 2023 11:36:42 -0700 Subject: [PATCH 026/215] Tidy up font schema a little --- crates/gpui/src/fonts.rs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/crates/gpui/src/fonts.rs b/crates/gpui/src/fonts.rs index 62894452fd..3b4a94dd0e 100644 --- a/crates/gpui/src/fonts.rs +++ b/crates/gpui/src/fonts.rs @@ -66,7 +66,7 @@ pub struct TextStyle { pub font_family_id: FamilyId, pub font_id: FontId, pub font_size: f32, - #[serde(with = "PropertiesDef")] + #[schemars(with = "PropertiesDef")] pub font_properties: Properties, pub underline: Underline, } @@ -77,13 +77,13 @@ pub struct PropertiesDef { /// The font style, as defined in CSS. pub style: StyleDef, /// The font weight, as defined in CSS. - pub weight: WeightDef, + pub weight: f32, /// The font stretchiness, as defined in CSS. - pub stretch: StretchDef, + pub stretch: f32, } #[derive(JsonSchema)] -#[serde(remote = "Style")] +#[schemars(remote = "Style")] pub enum StyleDef { /// A face that is neither italic not obliqued. Normal, @@ -93,18 +93,10 @@ pub enum StyleDef { Oblique, } -#[derive(JsonSchema)] -#[serde(remote = "Weight")] -pub struct WeightDef(pub f32); - -#[derive(JsonSchema)] -#[serde(remote = "Stretch")] -pub struct StretchDef(pub f32); - #[derive(Copy, Clone, Debug, Default, PartialEq, JsonSchema)] pub struct HighlightStyle { pub color: Option, - #[serde(with = "WeightDef")] + #[schemars(with = "Option::")] pub weight: Option, pub italic: Option, pub underline: Option, @@ -116,15 +108,11 @@ impl Eq for HighlightStyle {} #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, JsonSchema)] pub struct Underline { pub color: Option, - #[serde(with = "OrderedFloatDef::")] + #[schemars(with = "f32")] pub thickness: OrderedFloat, pub squiggly: bool, } -#[derive(JsonSchema)] -#[serde(remote = "OrderedFloat")] -pub struct OrderedFloatDef(pub T); - #[allow(non_camel_case_types)] #[derive(Deserialize)] enum WeightJson { From 6ad0b5d79f86ca635b77e8346833879c6f117cdb Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 19 Jun 2023 11:47:11 -0700 Subject: [PATCH 027/215] Change color representation in json schema --- crates/gpui/src/color.rs | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/crates/gpui/src/color.rs b/crates/gpui/src/color.rs index 7575bbc6d7..2a0c2c1dc1 100644 --- a/crates/gpui/src/color.rs +++ b/crates/gpui/src/color.rs @@ -6,20 +6,16 @@ use std::{ use crate::json::ToJson; use pathfinder_color::{ColorF, ColorU}; -use schemars::{ - gen::SchemaGenerator, - schema::{InstanceType, Schema, SchemaObject}, - JsonSchema, -}; +use schemars::JsonSchema; use serde::{ de::{self, Unexpected}, Deserialize, Deserializer, }; 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)] -pub struct Color(ColorU); +pub struct Color(#[schemars(with = "String")] ColorU); impl Color { pub fn transparent_black() -> Self { @@ -132,16 +128,3 @@ impl fmt::Debug for Color { self.0.fmt(f) } } - -impl JsonSchema for Color { - fn schema_name() -> String { - "Color".into() - } - - fn json_schema(_: &mut SchemaGenerator) -> Schema { - let mut schema = SchemaObject::default(); - schema.instance_type = Some(InstanceType::Integer.into()); - schema.format = Some("uint".to_owned()); - Schema::Object(schema) - } -} From e58f0ac72fce79b4e4f45a813e4b31cee3427cf3 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 09:32:16 -0700 Subject: [PATCH 028/215] Add mute toggling controls --- crates/call/src/room.rs | 110 +++++++++++++----- crates/collab_ui/src/collab_ui.rs | 15 +-- .../Sources/LiveKitBridge/LiveKitBridge.swift | 44 ++++--- crates/live_kit_client/src/prod.rs | 67 ++++++++++- crates/live_kit_client/src/test.rs | 14 +++ 5 files changed, 189 insertions(+), 61 deletions(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index aa0cb1f20e..b8da95bfb5 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -154,8 +154,8 @@ impl Room { Some(LiveKitRoom { room, - screen_track: Track::None, - microphone_track: Track::None, + screen_track: LocalTrack::None, + microphone_track: LocalTrack::None, next_publish_id: 0, _maintain_room, _maintain_tracks: [_maintain_video_tracks, _maintain_audio_tracks], @@ -985,13 +985,13 @@ impl Room { pub fn is_screen_sharing(&self) -> bool { self.live_kit.as_ref().map_or(false, |live_kit| { - !matches!(live_kit.screen_track, Track::None) + !matches!(live_kit.screen_track, LocalTrack::None) }) } pub fn is_sharing_mic(&self) -> bool { self.live_kit.as_ref().map_or(false, |live_kit| { - !matches!(live_kit.microphone_track, Track::None) + !matches!(live_kit.microphone_track, LocalTrack::None) }) } @@ -1004,7 +1004,10 @@ impl Room { let publish_id = if let Some(live_kit) = self.live_kit.as_mut() { let publish_id = post_inc(&mut live_kit.next_publish_id); - live_kit.microphone_track = Track::Pending { publish_id }; + live_kit.microphone_track = LocalTrack::Pending { + publish_id, + muted: false, + }; cx.notify(); publish_id } else { @@ -1034,13 +1037,14 @@ impl Room { .as_mut() .ok_or_else(|| anyhow!("live-kit was not initialized"))?; - let canceled = if let Track::Pending { + let (canceled, muted) = if let LocalTrack::Pending { publish_id: cur_publish_id, + muted } = &live_kit.microphone_track { - *cur_publish_id != publish_id + (*cur_publish_id != publish_id, *muted) } else { - true + (true, false) }; match publication { @@ -1048,7 +1052,13 @@ impl Room { if canceled { live_kit.room.unpublish_track(publication); } else { - live_kit.microphone_track = Track::Published(publication); + if muted { + cx.background().spawn(publication.mute()).detach(); + } + live_kit.microphone_track = LocalTrack::Published { + track_publication: publication, + muted + }; cx.notify(); } Ok(()) @@ -1057,7 +1067,7 @@ impl Room { if canceled { Ok(()) } else { - live_kit.microphone_track = Track::None; + live_kit.microphone_track = LocalTrack::None; cx.notify(); Err(error) } @@ -1076,7 +1086,10 @@ impl Room { let (displays, publish_id) = if let Some(live_kit) = self.live_kit.as_mut() { let publish_id = post_inc(&mut live_kit.next_publish_id); - live_kit.screen_track = Track::Pending { publish_id }; + live_kit.screen_track = LocalTrack::Pending { + publish_id, + muted: false, + }; cx.notify(); (live_kit.room.display_sources(), publish_id) } else { @@ -1110,13 +1123,14 @@ impl Room { .as_mut() .ok_or_else(|| anyhow!("live-kit was not initialized"))?; - let canceled = if let Track::Pending { + let (canceled, muted) = if let LocalTrack::Pending { publish_id: cur_publish_id, + muted, } = &live_kit.screen_track { - *cur_publish_id != publish_id + (*cur_publish_id != publish_id, *muted) } else { - true + (true, false) }; match publication { @@ -1124,7 +1138,13 @@ impl Room { if canceled { live_kit.room.unpublish_track(publication); } else { - live_kit.screen_track = Track::Published(publication); + if muted { + cx.background().spawn(publication.mute()).detach(); + } + live_kit.screen_track = LocalTrack::Published { + track_publication: publication, + muted, + }; cx.notify(); } Ok(()) @@ -1133,7 +1153,7 @@ impl Room { if canceled { Ok(()) } else { - live_kit.screen_track = Track::None; + live_kit.screen_track = LocalTrack::None; cx.notify(); Err(error) } @@ -1143,13 +1163,33 @@ impl Room { }) } - pub fn toggle_mute(&mut self, cx: &mut ModelContext) -> Task> { - // https://docs.livekit.io/client/publish/ - // Should be acessible from local participant / publication - todo!(); + pub fn toggle_mute(&mut self, cx: &mut ModelContext) -> Result>> { + if let Some(live_kit) = self.live_kit.as_mut() { + match &mut live_kit.microphone_track { + LocalTrack::None => Err(anyhow!("microphone was not shared")), + LocalTrack::Pending { muted, .. } => { + *muted = !*muted; + Ok(Task::Ready(Some(Ok(())))) + } + LocalTrack::Published { + track_publication, + muted, + } => { + *muted = !*muted; + + if *muted { + Ok(cx.background().spawn(track_publication.mute())) + } else { + Ok(cx.background().spawn(track_publication.unmute())) + } + } + } + } else { + Err(anyhow!("LiveKit not started")) + } } - pub fn toggle_deafen(&mut self, cx: &mut ModelContext) -> Task> { + pub fn toggle_deafen(&mut self, _cx: &mut ModelContext) -> Task> { // iterate through publications and mute (?????) todo!(); } @@ -1164,13 +1204,15 @@ impl Room { .as_mut() .ok_or_else(|| anyhow!("live-kit was not initialized"))?; match mem::take(&mut live_kit.screen_track) { - Track::None => Err(anyhow!("screen was not shared")), - Track::Pending { .. } => { + LocalTrack::None => Err(anyhow!("screen was not shared")), + LocalTrack::Pending { .. } => { cx.notify(); Ok(()) } - Track::Published(track) => { - live_kit.room.unpublish_track(track); + LocalTrack::Published { + track_publication, .. + } => { + live_kit.room.unpublish_track(track_publication); cx.notify(); Ok(()) } @@ -1189,20 +1231,26 @@ impl Room { struct LiveKitRoom { room: Arc, - screen_track: Track, - microphone_track: Track, + screen_track: LocalTrack, + microphone_track: LocalTrack, next_publish_id: usize, _maintain_room: Task<()>, _maintain_tracks: [Task<()>; 2], } -enum Track { +enum LocalTrack { None, - Pending { publish_id: usize }, - Published(LocalTrackPublication), + Pending { + publish_id: usize, + muted: bool, + }, + Published { + track_publication: LocalTrackPublication, + muted: bool, + }, } -impl Default for Track { +impl Default for LocalTrack { fn default() -> Self { Self::None } diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rs index d6e62d146f..9de8cbf9dd 100644 --- a/crates/collab_ui/src/collab_ui.rs +++ b/crates/collab_ui/src/collab_ui.rs @@ -9,9 +9,10 @@ mod notifications; mod project_shared_notification; mod sharing_status_indicator; -use call::ActiveCall; +use call::{ActiveCall, Room}; pub use collab_titlebar_item::{CollabTitlebarItem, ToggleContactsMenu}; use gpui::{actions, AppContext, Task}; +use util::ResultExt; use std::sync::Arc; use workspace::AppState; @@ -46,20 +47,12 @@ pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) { pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) { if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { - let toggle_mut = room.update(cx, |room, cx| { - if room.is_sharing_mic() { - room.toggle_mute(cx) - } else { - room.share_mic(cx) - } - }); - toggle_mut.detach_and_log_err(cx); + room.update(cx, Room::toggle_mute).map(Task::detach).log_err(); } } pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) { if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { - let toggle_deafan = room.update(cx, |room, cx| room.toggle_deafen(cx)); - toggle_deafan.detach_and_log_err(cx); + room.update(cx, Room::toggle_deafen).detach_and_log_err(cx); } } diff --git a/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift b/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift index 40c1319e8f..d28dc828f1 100644 --- a/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift +++ b/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift @@ -201,19 +201,6 @@ public func LKCreateScreenShareTrackForDisplay(display: UnsafeMutableRawPointer) return Unmanaged.passRetained(track).toOpaque() } -@_cdecl("LKRemoteAudioTrackStart") -public func LKRemoteAudioTrackStart(track: UnsafeRawPointer, onStart: @escaping @convention(c) (UnsafeRawPointer, Bool) -> Void, callbackData: UnsafeRawPointer) { - let track = Unmanaged.fromOpaque(track).takeUnretainedValue() as! RemoteAudioTrack - - track.start().then { success in - onStart(callbackData, success) - } - .catch { _ in - onStart(callbackData, false) - } -} - - @_cdecl("LKVideoRendererCreate") public func LKVideoRendererCreate(data: UnsafeRawPointer, onFrame: @escaping @convention(c) (UnsafeRawPointer, CVPixelBuffer) -> Bool, onDrop: @escaping @convention(c) (UnsafeRawPointer) -> Void) -> UnsafeMutableRawPointer { Unmanaged.passRetained(LKVideoRenderer(data: data, onFrame: onFrame, onDrop: onDrop)).toOpaque() @@ -247,3 +234,34 @@ public func LKDisplaySources(data: UnsafeRawPointer, callback: @escaping @conven callback(data, nil, error.localizedDescription as CFString) } } + +@_cdecl("LKLocalTrackPublicationMute") +public func LKLocalTrackPublicationMute( + publication: UnsafeRawPointer, + on_complete: @escaping @convention(c) (UnsafeRawPointer, CFString?) -> Void, + callback_data: UnsafeRawPointer +) { + let publication = Unmanaged.fromOpaque(publication).takeUnretainedValue() + + publication.mute().then { + on_complete(callback_data, nil) + }.catch { error in + on_complete(callback_data, error.localizedDescription as CFString) + } + +} + +@_cdecl("LKLocalTrackPublicationUnmute") +public func LKLocalTrackPublicationUnmute( + publication: UnsafeRawPointer, + on_complete: @escaping @convention(c) (UnsafeRawPointer, CFString?) -> Void, + callback_data: UnsafeRawPointer +) { + let publication = Unmanaged.fromOpaque(publication).takeUnretainedValue() + + publication.unmute().then { + on_complete(callback_data, nil) + }.catch { error in + on_complete(callback_data, error.localizedDescription as CFString) + } +} diff --git a/crates/live_kit_client/src/prod.rs b/crates/live_kit_client/src/prod.rs index 6ae493d306..46516d49be 100644 --- a/crates/live_kit_client/src/prod.rs +++ b/crates/live_kit_client/src/prod.rs @@ -84,12 +84,6 @@ extern "C" { ) -> *const c_void; fn LKRemoteAudioTrackGetSid(track: *const c_void) -> CFStringRef; - // fn LKRemoteAudioTrackStart( - // track: *const c_void, - // callback: extern "C" fn(*mut c_void, bool), - // callback_data: *mut c_void - // ); - fn LKVideoTrackAddRenderer(track: *const c_void, renderer: *const c_void); fn LKRemoteVideoTrackGetSid(track: *const c_void) -> CFStringRef; @@ -103,6 +97,17 @@ extern "C" { ); fn LKCreateScreenShareTrackForDisplay(display: *const c_void) -> *const c_void; fn LKLocalAudioTrackCreateTrack() -> *const c_void; + + fn LKLocalTrackPublicationMute( + publication: *const c_void, + on_complete: extern "C" fn(callback_data: *mut c_void, error: CFStringRef), + callback_data: *mut c_void, + ); + fn LKLocalTrackPublicationUnmute( + publication: *const c_void, + on_complete: extern "C" fn(callback_data: *mut c_void, error: CFStringRef), + callback_data: *mut c_void, + ); } pub type Sid = String; @@ -525,6 +530,56 @@ impl Drop for LocalVideoTrack { pub struct LocalTrackPublication(*const c_void); +impl LocalTrackPublication { + pub fn mute(&self) -> impl Future> { + let (tx, rx) = futures::channel::oneshot::channel(); + + extern "C" fn complete_callback(callback_data: *mut c_void, error: CFStringRef) { + let tx = unsafe { Box::from_raw(callback_data as *mut oneshot::Sender>) }; + if error.is_null() { + tx.send(Ok(())).ok(); + } else { + let error = unsafe { CFString::wrap_under_get_rule(error).to_string() }; + tx.send(Err(anyhow!(error))).ok(); + } + } + + unsafe { + LKLocalTrackPublicationMute( + self.0, + complete_callback, + Box::into_raw(Box::new(tx)) as *mut c_void, + ) + } + + async move { rx.await.unwrap() } + } + + pub fn unmute(&self) -> impl Future> { + let (tx, rx) = futures::channel::oneshot::channel(); + + extern "C" fn complete_callback(callback_data: *mut c_void, error: CFStringRef) { + let tx = unsafe { Box::from_raw(callback_data as *mut oneshot::Sender>) }; + if error.is_null() { + tx.send(Ok(())).ok(); + } else { + let error = unsafe { CFString::wrap_under_get_rule(error).to_string() }; + tx.send(Err(anyhow!(error))).ok(); + } + } + + unsafe { + LKLocalTrackPublicationUnmute( + self.0, + complete_callback, + Box::into_raw(Box::new(tx)) as *mut c_void, + ) + } + + async move { rx.await.unwrap() } + } +} + impl Drop for LocalTrackPublication { fn drop(&mut self) { unsafe { CFRelease(self.0) } diff --git a/crates/live_kit_client/src/test.rs b/crates/live_kit_client/src/test.rs index 232fc7cf4b..21211ce473 100644 --- a/crates/live_kit_client/src/test.rs +++ b/crates/live_kit_client/src/test.rs @@ -475,6 +475,20 @@ impl Drop for Room { pub struct LocalTrackPublication; +impl LocalTrackPublication { + pub fn mute(&self) -> impl Future> { + async { + Ok(()) + } + } + + pub fn unmute(&self) -> impl Future> { + async { + Ok(()) + } + } +} + #[derive(Clone)] pub struct LocalVideoTrack { frames_rx: async_broadcast::Receiver, From 31a70efe662667c7a9b8aac5404b6420374dc906 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 20 Jun 2023 19:10:52 +0200 Subject: [PATCH 029/215] Autosave conversations --- crates/ai/src/assistant.rs | 114 +++++++++++++++++++++++++++++-------- 1 file changed, 90 insertions(+), 24 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 114e23c9ff..39fcd5c583 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -26,8 +26,8 @@ use language::{language_settings::SoftWrap, Buffer, LanguageRegistry, ToOffset a use serde::Deserialize; use settings::SettingsStore; use std::{ - borrow::Cow, cell::RefCell, cmp, fmt::Write, io, iter, ops::Range, rc::Rc, sync::Arc, - time::Duration, + borrow::Cow, cell::RefCell, cmp, fmt::Write, io, iter, ops::Range, path::PathBuf, rc::Rc, + sync::Arc, time::Duration, }; use util::{ channel::ReleaseChannel, paths::CONVERSATIONS_DIR, post_inc, truncate_and_trailoff, ResultExt, @@ -456,6 +456,12 @@ enum AssistantEvent { StreamedCompletion, } +#[derive(Clone, PartialEq, Eq)] +struct SavedConversationPath { + path: PathBuf, + had_summary: bool, +} + struct Assistant { buffer: ModelHandle, message_anchors: Vec, @@ -470,6 +476,8 @@ struct Assistant { max_token_count: usize, pending_token_count: Task>, api_key: Rc>>, + pending_save: Task>, + path: Option, _subscriptions: Vec, } @@ -515,6 +523,8 @@ impl Assistant { pending_token_count: Task::ready(None), model: model.into(), _subscriptions: vec![cx.subscribe(&buffer, Self::handle_buffer_event)], + pending_save: Task::ready(Ok(())), + path: None, api_key, buffer, }; @@ -1024,31 +1034,79 @@ impl Assistant { }) } - fn save(&self, fs: Arc, cx: &mut ModelContext) -> Task> { - let conversation = SavedConversation { - zed: "conversation".into(), - version: "0.1".into(), - messages: self.open_ai_request_messages(cx), - }; + fn save( + &mut self, + debounce: Option, + fs: Arc, + cx: &mut ModelContext, + ) { + self.pending_save = cx.spawn(|this, mut cx| async move { + if let Some(debounce) = debounce { + cx.background().timer(debounce).await; + } + let conversation = SavedConversation { + zed: "conversation".into(), + version: "0.1".into(), + messages: this.read_with(&cx, |this, cx| { + this.messages(cx) + .map(|message| message.to_open_ai_message(this.buffer.read(cx))) + .collect() + }), + }; - let mut path = CONVERSATIONS_DIR.join(self.summary.as_deref().unwrap_or("conversation-1")); - - cx.background().spawn(async move { - while fs.is_file(&path).await { - let file_name = path.file_name().ok_or_else(|| anyhow!("no filename"))?; - let file_name = file_name.to_string_lossy(); - - if let Some((prefix, suffix)) = file_name.rsplit_once('-') { - let new_version = suffix.parse::().ok().unwrap_or(1) + 1; - path.set_file_name(format!("{}-{}", prefix, new_version)); - }; + let (old_path, summary) = + this.read_with(&cx, |this, _| (this.path.clone(), this.summary.clone())); + let mut new_path = None; + if let Some(old_path) = old_path.as_ref() { + if old_path.had_summary || summary.is_none() { + new_path = Some(old_path.clone()); + } } + let new_path = if let Some(new_path) = new_path { + new_path + } else { + let mut path = + CONVERSATIONS_DIR.join(summary.as_deref().unwrap_or("conversation-1")); + + while fs.is_file(&path).await { + let file_name = path.file_name().ok_or_else(|| anyhow!("no filename"))?; + let file_name = file_name.to_string_lossy(); + + if let Some((prefix, suffix)) = file_name.rsplit_once('-') { + let new_version = suffix.parse::().ok().unwrap_or(1) + 1; + path.set_file_name(format!("{}-{}", prefix, new_version)); + }; + } + + SavedConversationPath { + path, + had_summary: summary.is_some(), + } + }; + fs.create_dir(CONVERSATIONS_DIR.as_ref()).await?; - fs.atomic_write(path, serde_json::to_string(&conversation).unwrap()) - .await?; + fs.atomic_write( + new_path.path.clone(), + serde_json::to_string(&conversation).unwrap(), + ) + .await?; + this.update(&mut cx, |this, _| this.path = Some(new_path.clone())); + if let Some(old_path) = old_path { + if new_path.path != old_path.path { + fs.remove_file( + &old_path.path, + fs::RemoveOptions { + recursive: false, + ignore_if_not_exists: true, + }, + ) + .await?; + } + } + Ok(()) - }) + }); } } @@ -1176,9 +1234,17 @@ impl AssistantEditor { cx: &mut ViewContext, ) { match event { - AssistantEvent::MessagesEdited => self.update_message_headers(cx), + AssistantEvent::MessagesEdited => { + self.update_message_headers(cx); + self.assistant.update(cx, |assistant, cx| { + assistant.save(Some(Duration::from_millis(500)), self.fs.clone(), cx); + }); + } AssistantEvent::SummaryChanged => { cx.emit(AssistantEditorEvent::TabContentChanged); + self.assistant.update(cx, |assistant, cx| { + assistant.save(None, self.fs.clone(), cx); + }); } AssistantEvent::StreamedCompletion => { self.editor.update(cx, |editor, cx| { @@ -1469,7 +1535,7 @@ impl AssistantEditor { fn save(&mut self, _: &Save, cx: &mut ViewContext) { self.assistant.update(cx, |assistant, cx| { - assistant.save(self.fs.clone(), cx).detach_and_log_err(cx); + assistant.save(None, self.fs.clone(), cx) }); } From f904698457ab5181f7dbc313bb80faeb14c75e43 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 20 Jun 2023 19:18:25 +0200 Subject: [PATCH 030/215] Use the `OPENAI_API_KEY` environment variable when present --- crates/ai/src/assistant.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 39fcd5c583..b147bab3b3 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -26,7 +26,7 @@ use language::{language_settings::SoftWrap, Buffer, LanguageRegistry, ToOffset a use serde::Deserialize; use settings::SettingsStore; use std::{ - borrow::Cow, cell::RefCell, cmp, fmt::Write, io, iter, ops::Range, path::PathBuf, rc::Rc, + borrow::Cow, cell::RefCell, cmp, env, fmt::Write, io, iter, ops::Range, path::PathBuf, rc::Rc, sync::Arc, time::Duration, }; use util::{ @@ -393,7 +393,9 @@ impl Panel for AssistantPanel { if active { if self.api_key.borrow().is_none() && !self.has_read_credentials { self.has_read_credentials = true; - let api_key = if let Some((_, api_key)) = cx + let api_key = if let Ok(api_key) = env::var("OPENAI_API_KEY") { + Some(api_key) + } else if let Some((_, api_key)) = cx .platform() .read_credentials(OPENAI_API_URL) .log_err() From c416551318bfc297114566a53977449980abdd9d Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 20 Jun 2023 19:19:02 +0200 Subject: [PATCH 031/215] Don't use the summary as the filename if it's not done yet --- crates/ai/src/assistant.rs | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index b147bab3b3..c15b46d0e9 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -464,12 +464,18 @@ struct SavedConversationPath { had_summary: bool, } +#[derive(Default)] +struct Summary { + text: String, + done: bool, +} + struct Assistant { buffer: ModelHandle, message_anchors: Vec, messages_metadata: HashMap, next_message_id: MessageId, - summary: Option, + summary: Option, pending_summary: Task>, completion_count: usize, pending_completions: Vec, @@ -954,12 +960,22 @@ impl Assistant { if let Some(choice) = message.choices.pop() { let text = choice.delta.content.unwrap_or_default(); this.update(&mut cx, |this, cx| { - this.summary.get_or_insert(String::new()).push_str(&text); + this.summary + .get_or_insert(Default::default()) + .text + .push_str(&text); cx.emit(AssistantEvent::SummaryChanged); }); } } + this.update(&mut cx, |this, cx| { + if let Some(summary) = this.summary.as_mut() { + summary.done = true; + cx.emit(AssistantEvent::SummaryChanged); + } + }); + anyhow::Ok(()) } .log_err() @@ -1056,8 +1072,19 @@ impl Assistant { }), }; - let (old_path, summary) = - this.read_with(&cx, |this, _| (this.path.clone(), this.summary.clone())); + let (old_path, summary) = this.read_with(&cx, |this, _| { + let path = this.path.clone(); + let summary = if let Some(summary) = this.summary.as_ref() { + if summary.done { + Some(summary.text.clone()) + } else { + None + } + } else { + None + }; + (path, summary) + }); let mut new_path = None; if let Some(old_path) = old_path.as_ref() { if old_path.had_summary || summary.is_none() { @@ -1555,7 +1582,8 @@ impl AssistantEditor { self.assistant .read(cx) .summary - .clone() + .as_ref() + .map(|summary| summary.text.clone()) .unwrap_or_else(|| "New Context".into()) } } From 9f783944a740c39bce32e7c080ea24208f76db7f Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 20 Jun 2023 13:03:23 -0600 Subject: [PATCH 032/215] Wait until we have a summary before saving a conversation Also, avoid collisions by adding a discriminant. Co-Authored-By: Kyle Caverly --- crates/ai/src/assistant.rs | 92 ++++++++++++++------------------------ 1 file changed, 33 insertions(+), 59 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index c15b46d0e9..b7b0335a70 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -458,12 +458,6 @@ enum AssistantEvent { StreamedCompletion, } -#[derive(Clone, PartialEq, Eq)] -struct SavedConversationPath { - path: PathBuf, - had_summary: bool, -} - #[derive(Default)] struct Summary { text: String, @@ -485,7 +479,7 @@ struct Assistant { pending_token_count: Task>, api_key: Rc>>, pending_save: Task>, - path: Option, + path: Option, _subscriptions: Vec, } @@ -1062,15 +1056,6 @@ impl Assistant { if let Some(debounce) = debounce { cx.background().timer(debounce).await; } - let conversation = SavedConversation { - zed: "conversation".into(), - version: "0.1".into(), - messages: this.read_with(&cx, |this, cx| { - this.messages(cx) - .map(|message| message.to_open_ai_message(this.buffer.read(cx))) - .collect() - }), - }; let (old_path, summary) = this.read_with(&cx, |this, _| { let path = this.path.clone(); @@ -1085,53 +1070,42 @@ impl Assistant { }; (path, summary) }); - let mut new_path = None; - if let Some(old_path) = old_path.as_ref() { - if old_path.had_summary || summary.is_none() { - new_path = Some(old_path.clone()); - } - } - let new_path = if let Some(new_path) = new_path { - new_path - } else { - let mut path = - CONVERSATIONS_DIR.join(summary.as_deref().unwrap_or("conversation-1")); + if let Some(summary) = summary { + let conversation = SavedConversation { + zed: "conversation".into(), + version: "0.1".into(), + messages: this.read_with(&cx, |this, cx| { + this.messages(cx) + .map(|message| message.to_open_ai_message(this.buffer.read(cx))) + .collect() + }), + }; - while fs.is_file(&path).await { - let file_name = path.file_name().ok_or_else(|| anyhow!("no filename"))?; - let file_name = file_name.to_string_lossy(); + let path = if let Some(old_path) = old_path { + old_path + } else { + let mut discriminant = 1; + let mut new_path; + loop { + new_path = CONVERSATIONS_DIR.join(&format!( + "{} - {}.zed.json", + summary.trim(), + discriminant + )); + if fs.is_file(&new_path).await { + discriminant += 1; + } else { + break; + } + } + new_path + }; - if let Some((prefix, suffix)) = file_name.rsplit_once('-') { - let new_version = suffix.parse::().ok().unwrap_or(1) + 1; - path.set_file_name(format!("{}-{}", prefix, new_version)); - }; - } - - SavedConversationPath { - path, - had_summary: summary.is_some(), - } - }; - - fs.create_dir(CONVERSATIONS_DIR.as_ref()).await?; - fs.atomic_write( - new_path.path.clone(), - serde_json::to_string(&conversation).unwrap(), - ) - .await?; - this.update(&mut cx, |this, _| this.path = Some(new_path.clone())); - if let Some(old_path) = old_path { - if new_path.path != old_path.path { - fs.remove_file( - &old_path.path, - fs::RemoveOptions { - recursive: false, - ignore_if_not_exists: true, - }, - ) + fs.create_dir(CONVERSATIONS_DIR.as_ref()).await?; + fs.atomic_write(path.clone(), serde_json::to_string(&conversation).unwrap()) .await?; - } + this.update(&mut cx, |this, _| this.path = Some(path)); } Ok(()) From 230b4d237e1cd2266f6049d7cc07ef74c650911e Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 20 Jun 2023 13:29:34 -0600 Subject: [PATCH 033/215] Add SavedConversation::list() method Co-Authored-By: Kyle Caverly --- Cargo.lock | 1 + crates/ai/Cargo.toml | 1 + crates/ai/src/ai.rs | 49 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index a4b12223e5..cdabeb26ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,6 +109,7 @@ dependencies = [ "isahc", "language", "menu", + "regex", "schemars", "search", "serde", diff --git a/crates/ai/Cargo.toml b/crates/ai/Cargo.toml index 7f8954bb21..76aaf41017 100644 --- a/crates/ai/Cargo.toml +++ b/crates/ai/Cargo.toml @@ -25,6 +25,7 @@ anyhow.workspace = true chrono = "0.4" futures.workspace = true isahc.workspace = true +regex.workspace = true schemars.workspace = true serde.workspace = true serde_json.workspace = true diff --git a/crates/ai/src/ai.rs b/crates/ai/src/ai.rs index f6bcb670ad..a676737d87 100644 --- a/crates/ai/src/ai.rs +++ b/crates/ai/src/ai.rs @@ -1,10 +1,21 @@ pub mod assistant; mod assistant_settings; +use anyhow::Result; pub use assistant::AssistantPanel; +use chrono::{DateTime, Local}; +use fs::Fs; +use futures::StreamExt; use gpui::AppContext; +use regex::Regex; use serde::{Deserialize, Serialize}; -use std::fmt::{self, Display}; +use std::{ + fmt::{self, Display}, + path::PathBuf, + sync::Arc, + time::SystemTime, +}; +use util::paths::CONVERSATIONS_DIR; // Data types for chat completion requests #[derive(Debug, Serialize)] @@ -21,6 +32,42 @@ struct SavedConversation { messages: Vec, } +impl SavedConversation { + pub async fn list(fs: Arc) -> Result> { + let mut paths = fs.read_dir(&CONVERSATIONS_DIR).await?; + + let mut conversations = Vec::::new(); + while let Some(path) = paths.next().await { + let path = path?; + + let pattern = r" - \d+.zed.json$"; + let re = Regex::new(pattern).unwrap(); + + let metadata = fs.metadata(&path).await?; + if let Some((file_name, metadata)) = path + .file_name() + .and_then(|name| name.to_str()) + .zip(metadata) + { + let title = re.replace(file_name, ""); + conversations.push(SavedConversationMetadata { + title: title.into_owned(), + path, + mtime: metadata.mtime, + }); + } + } + + Ok(conversations) + } +} + +struct SavedConversationMetadata { + title: String, + path: PathBuf, + mtime: SystemTime, +} + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] struct RequestMessage { role: Role, From b828a74ad66e6b1367d98263f8cd4e144fbe26c8 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 12:34:32 -0700 Subject: [PATCH 034/215] Add deafen controls --- crates/call/src/room.rs | 49 ++++++-- crates/collab_ui/src/collab_titlebar_item.rs | 2 +- crates/collab_ui/src/collab_ui.rs | 4 +- crates/gpui/src/executor.rs | 6 +- .../Sources/LiveKitBridge/LiveKitBridge.swift | 46 +++++-- crates/live_kit_client/src/prod.rs | 112 +++++++++++++----- crates/live_kit_client/src/test.rs | 43 +++++-- 7 files changed, 197 insertions(+), 65 deletions(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index b8da95bfb5..613a52a908 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -157,6 +157,7 @@ impl Room { screen_track: LocalTrack::None, microphone_track: LocalTrack::None, next_publish_id: 0, + deafened: false, _maintain_room, _maintain_tracks: [_maintain_video_tracks, _maintain_audio_tracks], }) @@ -223,7 +224,9 @@ impl Room { || &*util::channel::RELEASE_CHANNEL != &ReleaseChannel::Dev { let share_mic = room.update(&mut cx, |room, cx| room.share_mic(cx)); - cx.background().spawn(share_mic).detach(); + cx.update(|cx| { + cx.background().spawn(share_mic).detach_and_log_err(cx); + }); } match room @@ -1039,7 +1042,7 @@ impl Room { let (canceled, muted) = if let LocalTrack::Pending { publish_id: cur_publish_id, - muted + muted, } = &live_kit.microphone_track { (*cur_publish_id != publish_id, *muted) @@ -1053,11 +1056,11 @@ impl Room { live_kit.room.unpublish_track(publication); } else { if muted { - cx.background().spawn(publication.mute()).detach(); + cx.background().spawn(publication.set_mute(muted)).detach(); } live_kit.microphone_track = LocalTrack::Published { track_publication: publication, - muted + muted, }; cx.notify(); } @@ -1139,7 +1142,7 @@ impl Room { live_kit.room.unpublish_track(publication); } else { if muted { - cx.background().spawn(publication.mute()).detach(); + cx.background().spawn(publication.set_mute(muted)).detach(); } live_kit.screen_track = LocalTrack::Published { track_publication: publication, @@ -1177,11 +1180,7 @@ impl Room { } => { *muted = !*muted; - if *muted { - Ok(cx.background().spawn(track_publication.mute())) - } else { - Ok(cx.background().spawn(track_publication.unmute())) - } + Ok(cx.background().spawn(track_publication.set_mute(*muted))) } } } else { @@ -1189,9 +1188,32 @@ impl Room { } } - pub fn toggle_deafen(&mut self, _cx: &mut ModelContext) -> Task> { - // iterate through publications and mute (?????) - todo!(); + pub fn toggle_deafen(&mut self, cx: &mut ModelContext) -> Result>> { + if let Some(live_kit) = &mut self.live_kit { + (*live_kit).deafened = !live_kit.deafened + } + + if let Some(live_kit) = &self.live_kit { + let mut tasks = Vec::with_capacity(self.remote_participants.len()); + + for participant in self.remote_participants.values() { + for track in live_kit + .room + .remote_audio_track_publications(&participant.user.id.to_string()) + { + tasks.push(cx.background().spawn(track.set_enabled(live_kit.deafened))); + } + } + + Ok(cx.background().spawn(async move { + for task in tasks { + task.await?; + } + Ok(()) + })) + } else { + Err(anyhow!("LiveKit not started")) + } } pub fn unshare_screen(&mut self, cx: &mut ModelContext) -> Result<()> { @@ -1233,6 +1255,7 @@ struct LiveKitRoom { room: Arc, screen_track: LocalTrack, microphone_track: LocalTrack, + deafened: bool, next_publish_id: usize, _maintain_room: Task<()>, _maintain_tracks: [Task<()>; 2], diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 919e712ad1..87fd7470d6 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -23,7 +23,7 @@ use theme::{AvatarStyle, Theme}; use util::ResultExt; use workspace::{FollowNextCollaborator, Workspace}; -const MAX_TITLE_LENGTH: usize = 75; +// const MAX_TITLE_LENGTH: usize = 75; actions!( collab, diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rs index 9de8cbf9dd..940700a526 100644 --- a/crates/collab_ui/src/collab_ui.rs +++ b/crates/collab_ui/src/collab_ui.rs @@ -47,12 +47,12 @@ pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) { pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) { if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { - room.update(cx, Room::toggle_mute).map(Task::detach).log_err(); + room.update(cx, Room::toggle_mute).map(|task| task.detach_and_log_err(cx)).log_err(); } } pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) { if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { - room.update(cx, Room::toggle_deafen).detach_and_log_err(cx); + room.update(cx, Room::toggle_deafen).map(|task| task.detach_and_log_err(cx)).log_err(); } } diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rs index 365766fb9d..0923826a09 100644 --- a/crates/gpui/src/executor.rs +++ b/crates/gpui/src/executor.rs @@ -12,7 +12,7 @@ use std::{ sync::Arc, task::{Context, Poll}, thread, - time::Duration, + time::Duration, panic::Location, }; use crate::{ @@ -965,10 +965,12 @@ impl Task { } impl Task> { + #[track_caller] pub fn detach_and_log_err(self, cx: &mut AppContext) { cx.spawn(|_| async move { if let Err(err) = self.await { - log::error!("{:#}", err); + let caller = Location::caller(); + log::error!("{}:{}: {:#}", caller.file(), caller.line(), err); } }) .detach(); diff --git a/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift b/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift index d28dc828f1..666da3d533 100644 --- a/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift +++ b/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift @@ -169,6 +169,18 @@ public func LKRoomAudioTracksForRemoteParticipant(room: UnsafeRawPointer, partic return nil; } +@_cdecl("LKRoomAudioTrackPublicationsForRemoteParticipant") +public func LKRoomAudioTrackPublicationsForRemoteParticipant(room: UnsafeRawPointer, participantId: CFString) -> CFArray? { + let room = Unmanaged.fromOpaque(room).takeUnretainedValue() + + for (_, participant) in room.remoteParticipants { + if participant.identity == participantId as String { + return participant.audioTracks.compactMap { $0 as? RemoteTrackPublication } as CFArray? + } + } + + return nil; +} @_cdecl("LKRoomVideoTracksForRemoteParticipant") public func LKRoomVideoTracksForRemoteParticipant(room: UnsafeRawPointer, participantId: CFString) -> CFArray? { @@ -235,33 +247,45 @@ public func LKDisplaySources(data: UnsafeRawPointer, callback: @escaping @conven } } -@_cdecl("LKLocalTrackPublicationMute") -public func LKLocalTrackPublicationMute( +@_cdecl("LKLocalTrackPublicationSetMute") +public func LKLocalTrackPublicationSetMute( publication: UnsafeRawPointer, + muted: Bool, on_complete: @escaping @convention(c) (UnsafeRawPointer, CFString?) -> Void, callback_data: UnsafeRawPointer ) { let publication = Unmanaged.fromOpaque(publication).takeUnretainedValue() - publication.mute().then { - on_complete(callback_data, nil) - }.catch { error in - on_complete(callback_data, error.localizedDescription as CFString) + if muted { + publication.mute().then { + on_complete(callback_data, nil) + }.catch { error in + on_complete(callback_data, error.localizedDescription as CFString) + } + } else { + publication.unmute().then { + on_complete(callback_data, nil) + }.catch { error in + on_complete(callback_data, error.localizedDescription as CFString) + } } - } -@_cdecl("LKLocalTrackPublicationUnmute") -public func LKLocalTrackPublicationUnmute( +@_cdecl("LKRemoteTrackPublicationSetEnabled") +public func LKRemoteTrackPublicationSetEnabled( publication: UnsafeRawPointer, + enabled: Bool, on_complete: @escaping @convention(c) (UnsafeRawPointer, CFString?) -> Void, callback_data: UnsafeRawPointer ) { - let publication = Unmanaged.fromOpaque(publication).takeUnretainedValue() + let publication = Unmanaged.fromOpaque(publication).takeUnretainedValue() - publication.unmute().then { + publication.set(enabled: enabled).then { on_complete(callback_data, nil) }.catch { error in on_complete(callback_data, error.localizedDescription as CFString) } } + + + diff --git a/crates/live_kit_client/src/prod.rs b/crates/live_kit_client/src/prod.rs index 46516d49be..76f06b562f 100644 --- a/crates/live_kit_client/src/prod.rs +++ b/crates/live_kit_client/src/prod.rs @@ -72,6 +72,11 @@ extern "C" { participant_id: CFStringRef, ) -> CFArrayRef; + fn LKRoomAudioTrackPublicationsForRemoteParticipant( + room: *const c_void, + participant_id: CFStringRef, + ) -> CFArrayRef; + fn LKRoomVideoTracksForRemoteParticipant( room: *const c_void, participant_id: CFStringRef, @@ -98,13 +103,16 @@ extern "C" { fn LKCreateScreenShareTrackForDisplay(display: *const c_void) -> *const c_void; fn LKLocalAudioTrackCreateTrack() -> *const c_void; - fn LKLocalTrackPublicationMute( + fn LKLocalTrackPublicationSetMute( publication: *const c_void, + muted: bool, on_complete: extern "C" fn(callback_data: *mut c_void, error: CFStringRef), callback_data: *mut c_void, ); - fn LKLocalTrackPublicationUnmute( + + fn LKRemoteTrackPublicationSetEnabled( publication: *const c_void, + enabled: bool, on_complete: extern "C" fn(callback_data: *mut c_void, error: CFStringRef), callback_data: *mut c_void, ); @@ -318,6 +326,29 @@ impl Room { } } + pub fn remote_audio_track_publications(&self, participant_id: &str) -> Vec> { + unsafe { + let tracks = LKRoomAudioTrackPublicationsForRemoteParticipant( + self.native_room, + CFString::new(participant_id).as_concrete_TypeRef(), + ); + + if tracks.is_null() { + Vec::new() + } else { + let tracks = CFArray::wrap_under_get_rule(tracks); + tracks + .into_iter() + .map(|native_track_publication| { + let native_track_publication = *native_track_publication; + Arc::new(RemoteTrackPublication(native_track_publication)) + }) + .collect() + } + } + } + + pub fn remote_audio_track_updates(&self) -> mpsc::UnboundedReceiver { let (tx, rx) = mpsc::unbounded(); self.remote_audio_track_subscribers.lock().push(tx); @@ -531,7 +562,7 @@ impl Drop for LocalVideoTrack { pub struct LocalTrackPublication(*const c_void); impl LocalTrackPublication { - pub fn mute(&self) -> impl Future> { + pub fn set_mute(&self, muted: bool) -> impl Future> { let (tx, rx) = futures::channel::oneshot::channel(); extern "C" fn complete_callback(callback_data: *mut c_void, error: CFStringRef) { @@ -545,32 +576,9 @@ impl LocalTrackPublication { } unsafe { - LKLocalTrackPublicationMute( - self.0, - complete_callback, - Box::into_raw(Box::new(tx)) as *mut c_void, - ) - } - - async move { rx.await.unwrap() } - } - - pub fn unmute(&self) -> impl Future> { - let (tx, rx) = futures::channel::oneshot::channel(); - - extern "C" fn complete_callback(callback_data: *mut c_void, error: CFStringRef) { - let tx = unsafe { Box::from_raw(callback_data as *mut oneshot::Sender>) }; - if error.is_null() { - tx.send(Ok(())).ok(); - } else { - let error = unsafe { CFString::wrap_under_get_rule(error).to_string() }; - tx.send(Err(anyhow!(error))).ok(); - } - } - - unsafe { - LKLocalTrackPublicationUnmute( + LKLocalTrackPublicationSetMute( self.0, + muted, complete_callback, Box::into_raw(Box::new(tx)) as *mut c_void, ) @@ -586,6 +594,42 @@ impl Drop for LocalTrackPublication { } } +pub struct RemoteTrackPublication(*const c_void); + +impl RemoteTrackPublication { + pub fn set_enabled(&self, enabled: bool) -> impl Future> { + let (tx, rx) = futures::channel::oneshot::channel(); + + extern "C" fn complete_callback(callback_data: *mut c_void, error: CFStringRef) { + let tx = unsafe { Box::from_raw(callback_data as *mut oneshot::Sender>) }; + if error.is_null() { + tx.send(Ok(())).ok(); + } else { + let error = unsafe { CFString::wrap_under_get_rule(error).to_string() }; + tx.send(Err(anyhow!(error))).ok(); + } + } + + unsafe { + LKRemoteTrackPublicationSetEnabled( + self.0, + enabled, + complete_callback, + Box::into_raw(Box::new(tx)) as *mut c_void, + ) + } + + async move { rx.await.unwrap() } + } +} + +impl Drop for RemoteTrackPublication { + fn drop(&mut self) { + unsafe { CFRelease(self.0) } + } +} + + #[derive(Debug)] pub struct RemoteAudioTrack { _native_track: *const c_void, @@ -612,6 +656,18 @@ impl RemoteAudioTrack { pub fn publisher_id(&self) -> &str { &self.publisher_id } + + pub fn enable(&self) -> impl Future> { + async { + Ok(()) + } + } + + pub fn disable(&self) -> impl Future> { + async { + Ok(()) + } + } } #[derive(Debug)] diff --git a/crates/live_kit_client/src/test.rs b/crates/live_kit_client/src/test.rs index 21211ce473..e8c5247f53 100644 --- a/crates/live_kit_client/src/test.rs +++ b/crates/live_kit_client/src/test.rs @@ -410,6 +410,25 @@ impl Room { .collect() } + pub fn remote_audio_track_publications( + &self, + publisher_id: &str, + ) -> Vec> { + if !self.is_connected() { + return Vec::new(); + } + + self.test_server() + .audio_tracks(self.token()) + .unwrap() + .into_iter() + .filter(|track| track.publisher_id() == publisher_id) + .map(|_track| { + Arc::new(RemoteTrackPublication {}) + }) + .collect() + } + pub fn remote_video_tracks(&self, publisher_id: &str) -> Vec> { if !self.is_connected() { return Vec::new(); @@ -476,16 +495,16 @@ impl Drop for Room { pub struct LocalTrackPublication; impl LocalTrackPublication { - pub fn mute(&self) -> impl Future> { - async { - Ok(()) - } + pub fn set_mute(&self, _mute: bool) -> impl Future> { + async { Ok(()) } } +} - pub fn unmute(&self) -> impl Future> { - async { - Ok(()) - } +pub struct RemoteTrackPublication; + +impl RemoteTrackPublication { + pub fn set_enabled(&self, _enabled: bool) -> impl Future> { + async { Ok(()) } } } @@ -545,6 +564,14 @@ impl RemoteAudioTrack { pub fn publisher_id(&self) -> &str { &self.publisher_id } + + pub fn enable(&self) -> impl Future> { + async { Ok(()) } + } + + pub fn disable(&self) -> impl Future> { + async { Ok(()) } + } } #[derive(Clone)] From dbd95e35cfa21f5e01b881eedd2251720aea20f2 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 12:36:36 -0700 Subject: [PATCH 035/215] fmt --- crates/collab_ui/src/collab_ui.rs | 10 +++++++--- crates/gpui/src/executor.rs | 3 ++- crates/live_kit_client/src/prod.rs | 15 ++++++--------- crates/live_kit_client/src/test.rs | 6 ++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rs index 940700a526..36ee58242a 100644 --- a/crates/collab_ui/src/collab_ui.rs +++ b/crates/collab_ui/src/collab_ui.rs @@ -12,8 +12,8 @@ mod sharing_status_indicator; use call::{ActiveCall, Room}; pub use collab_titlebar_item::{CollabTitlebarItem, ToggleContactsMenu}; use gpui::{actions, AppContext, Task}; -use util::ResultExt; use std::sync::Arc; +use util::ResultExt; use workspace::AppState; actions!(collab, [ToggleScreenSharing, ToggleMute, ToggleDeafen]); @@ -47,12 +47,16 @@ pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) { pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) { if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { - room.update(cx, Room::toggle_mute).map(|task| task.detach_and_log_err(cx)).log_err(); + room.update(cx, Room::toggle_mute) + .map(|task| task.detach_and_log_err(cx)) + .log_err(); } } pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) { if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { - room.update(cx, Room::toggle_deafen).map(|task| task.detach_and_log_err(cx)).log_err(); + room.update(cx, Room::toggle_deafen) + .map(|task| task.detach_and_log_err(cx)) + .log_err(); } } diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rs index 0923826a09..fb175d9d5d 100644 --- a/crates/gpui/src/executor.rs +++ b/crates/gpui/src/executor.rs @@ -7,12 +7,13 @@ use std::{ fmt::{self, Display}, marker::PhantomData, mem, + panic::Location, pin::Pin, rc::Rc, sync::Arc, task::{Context, Poll}, thread, - time::Duration, panic::Location, + time::Duration, }; use crate::{ diff --git a/crates/live_kit_client/src/prod.rs b/crates/live_kit_client/src/prod.rs index 76f06b562f..ed040fd5cc 100644 --- a/crates/live_kit_client/src/prod.rs +++ b/crates/live_kit_client/src/prod.rs @@ -326,7 +326,10 @@ impl Room { } } - pub fn remote_audio_track_publications(&self, participant_id: &str) -> Vec> { + pub fn remote_audio_track_publications( + &self, + participant_id: &str, + ) -> Vec> { unsafe { let tracks = LKRoomAudioTrackPublicationsForRemoteParticipant( self.native_room, @@ -348,7 +351,6 @@ impl Room { } } - pub fn remote_audio_track_updates(&self) -> mpsc::UnboundedReceiver { let (tx, rx) = mpsc::unbounded(); self.remote_audio_track_subscribers.lock().push(tx); @@ -629,7 +631,6 @@ impl Drop for RemoteTrackPublication { } } - #[derive(Debug)] pub struct RemoteAudioTrack { _native_track: *const c_void, @@ -658,15 +659,11 @@ impl RemoteAudioTrack { } pub fn enable(&self) -> impl Future> { - async { - Ok(()) - } + async { Ok(()) } } pub fn disable(&self) -> impl Future> { - async { - Ok(()) - } + async { Ok(()) } } } diff --git a/crates/live_kit_client/src/test.rs b/crates/live_kit_client/src/test.rs index e8c5247f53..9db57a3294 100644 --- a/crates/live_kit_client/src/test.rs +++ b/crates/live_kit_client/src/test.rs @@ -423,9 +423,7 @@ impl Room { .unwrap() .into_iter() .filter(|track| track.publisher_id() == publisher_id) - .map(|_track| { - Arc::new(RemoteTrackPublication {}) - }) + .map(|_track| Arc::new(RemoteTrackPublication {})) .collect() } @@ -495,7 +493,7 @@ impl Drop for Room { pub struct LocalTrackPublication; impl LocalTrackPublication { - pub fn set_mute(&self, _mute: bool) -> impl Future> { + pub fn set_mute(&self, _mute: bool) -> impl Future> { async { Ok(()) } } } From cf4251fb55f833555dba3dc6a5ef3f260281b8e5 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 15:17:49 -0700 Subject: [PATCH 036/215] Fix deafened -> enabled mistranslation Fix mislocation of caller query in detach_and_log_error Fix incorrect wording on livekit integration Add share_mic action for manually enabling the microphone Make mic sharing wait until the room has been fully established --- crates/call/src/room.rs | 24 +++++++++++++----------- crates/collab_ui/src/collab_ui.rs | 9 ++++++++- crates/gpui/src/executor.rs | 2 +- crates/live_kit_client/src/prod.rs | 2 +- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 613a52a908..b673a0a874 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -220,15 +220,6 @@ impl Room { None }; - if option_env!("START_MIC").is_some() - || &*util::channel::RELEASE_CHANNEL != &ReleaseChannel::Dev - { - let share_mic = room.update(&mut cx, |room, cx| room.share_mic(cx)); - cx.update(|cx| { - cx.background().spawn(share_mic).detach_and_log_err(cx); - }); - } - match room .update(&mut cx, |room, cx| { room.leave_when_empty = true; @@ -236,7 +227,18 @@ impl Room { }) .await { - Ok(()) => Ok(room), + Ok(()) => { + if option_env!("START_MIC").is_some() + || &*util::channel::RELEASE_CHANNEL != &ReleaseChannel::Dev + { + let share_mic = room.update(&mut cx, |room, cx| room.share_mic(cx)); + cx.update(|cx| { + cx.background().spawn(share_mic).detach_and_log_err(cx); + }); + } + + Ok(room) + }, Err(error) => Err(anyhow!("room creation failed: {:?}", error)), } }) @@ -1201,7 +1203,7 @@ impl Room { .room .remote_audio_track_publications(&participant.user.id.to_string()) { - tasks.push(cx.background().spawn(track.set_enabled(live_kit.deafened))); + tasks.push(cx.background().spawn(track.set_enabled(!live_kit.deafened))); } } diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rs index 36ee58242a..4b5deaa0be 100644 --- a/crates/collab_ui/src/collab_ui.rs +++ b/crates/collab_ui/src/collab_ui.rs @@ -16,7 +16,7 @@ use std::sync::Arc; use util::ResultExt; use workspace::AppState; -actions!(collab, [ToggleScreenSharing, ToggleMute, ToggleDeafen]); +actions!(collab, [ToggleScreenSharing, ToggleMute, ToggleDeafen, ShareMic]); pub fn init(app_state: &Arc, cx: &mut AppContext) { collab_titlebar_item::init(cx); @@ -30,6 +30,7 @@ pub fn init(app_state: &Arc, cx: &mut AppContext) { cx.add_global_action(toggle_screen_sharing); cx.add_global_action(toggle_mute); cx.add_global_action(toggle_deafen); + cx.add_global_action(share_mic); } pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) { @@ -60,3 +61,9 @@ pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) { .log_err(); } } + +pub fn share_mic(_: &ShareMic, cx: &mut AppContext) { + if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { + room.update(cx, Room::share_mic).detach_and_log_err(cx) + } +} diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rs index fb175d9d5d..712c854488 100644 --- a/crates/gpui/src/executor.rs +++ b/crates/gpui/src/executor.rs @@ -968,9 +968,9 @@ impl Task { impl Task> { #[track_caller] pub fn detach_and_log_err(self, cx: &mut AppContext) { + let caller = Location::caller(); cx.spawn(|_| async move { if let Err(err) = self.await { - let caller = Location::caller(); log::error!("{}:{}: {:#}", caller.file(), caller.line(), err); } }) diff --git a/crates/live_kit_client/src/prod.rs b/crates/live_kit_client/src/prod.rs index ed040fd5cc..2ec4f96dd5 100644 --- a/crates/live_kit_client/src/prod.rs +++ b/crates/live_kit_client/src/prod.rs @@ -259,7 +259,7 @@ impl Room { Box::into_raw(Box::new(tx)) as *mut c_void, ); } - async { rx.await.unwrap().context("error publishing video track") } + async { rx.await.unwrap().context("error publishing audio track") } } pub fn unpublish_track(&self, publication: LocalTrackPublication) { From bd7f8e8b3810689c7bfc470133e4771c798b3164 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 20 Jun 2023 16:19:43 -0600 Subject: [PATCH 037/215] Scan conversations dir on assistant panel open and on changes Co-Authored-By: Julia Risley --- crates/ai/src/ai.rs | 22 +++++++++++----------- crates/ai/src/assistant.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/crates/ai/src/ai.rs b/crates/ai/src/ai.rs index a676737d87..728648a293 100644 --- a/crates/ai/src/ai.rs +++ b/crates/ai/src/ai.rs @@ -3,7 +3,6 @@ mod assistant_settings; use anyhow::Result; pub use assistant::AssistantPanel; -use chrono::{DateTime, Local}; use fs::Fs; use futures::StreamExt; use gpui::AppContext; @@ -32,10 +31,17 @@ struct SavedConversation { messages: Vec, } -impl SavedConversation { - pub async fn list(fs: Arc) -> Result> { - let mut paths = fs.read_dir(&CONVERSATIONS_DIR).await?; +struct SavedConversationMetadata { + title: String, + path: PathBuf, + mtime: SystemTime, +} +impl SavedConversationMetadata { + pub async fn list(fs: Arc) -> Result> { + fs.create_dir(&CONVERSATIONS_DIR).await?; + + let mut paths = fs.read_dir(&CONVERSATIONS_DIR).await?; let mut conversations = Vec::::new(); while let Some(path) = paths.next().await { let path = path?; @@ -50,7 +56,7 @@ impl SavedConversation { .zip(metadata) { let title = re.replace(file_name, ""); - conversations.push(SavedConversationMetadata { + conversations.push(Self { title: title.into_owned(), path, mtime: metadata.mtime, @@ -62,12 +68,6 @@ impl SavedConversation { } } -struct SavedConversationMetadata { - title: String, - path: PathBuf, - mtime: SystemTime, -} - #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] struct RequestMessage { role: Role, diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index b7b0335a70..f7929006c6 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -1,6 +1,7 @@ use crate::{ assistant_settings::{AssistantDockPosition, AssistantSettings}, OpenAIRequest, OpenAIResponseStreamEvent, RequestMessage, Role, SavedConversation, + SavedConversationMetadata, }; use anyhow::{anyhow, Result}; use chrono::{DateTime, Local}; @@ -105,6 +106,8 @@ pub struct AssistantPanel { languages: Arc, fs: Arc, subscriptions: Vec, + saved_conversations: Vec, + _watch_saved_conversations: Task>, } impl AssistantPanel { @@ -113,6 +116,12 @@ impl AssistantPanel { cx: AsyncAppContext, ) -> Task>> { cx.spawn(|mut cx| async move { + let fs = workspace.read_with(&cx, |workspace, _| workspace.app_state().fs.clone())?; + let saved_conversations = SavedConversationMetadata::list(fs.clone()) + .await + .log_err() + .unwrap_or_default(); + // TODO: deserialize state. workspace.update(&mut cx, |workspace, cx| { cx.add_view::(|cx| { @@ -171,6 +180,25 @@ impl AssistantPanel { pane }); + const CONVERSATION_WATCH_DURATION: Duration = Duration::from_millis(100); + let _watch_saved_conversations = cx.spawn(move |this, mut cx| async move { + let mut events = fs + .watch(&CONVERSATIONS_DIR, CONVERSATION_WATCH_DURATION) + .await; + while events.next().await.is_some() { + let saved_conversations = SavedConversationMetadata::list(fs.clone()) + .await + .log_err() + .unwrap_or_default(); + this.update(&mut cx, |this, _| { + this.saved_conversations = saved_conversations + }) + .ok(); + } + + anyhow::Ok(()) + }); + let mut this = Self { pane, api_key: Rc::new(RefCell::new(None)), @@ -181,6 +209,8 @@ impl AssistantPanel { width: None, height: None, subscriptions: Default::default(), + saved_conversations, + _watch_saved_conversations, }; let mut old_dock_position = this.position(cx); From 8273e08d4a064158b28710c79ba87015318628c7 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 15:23:06 -0700 Subject: [PATCH 038/215] Add is_muted and is_deafened --- crates/call/src/room.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index b673a0a874..a2ef659156 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -1000,6 +1000,22 @@ impl Room { }) } + pub fn is_muted(&self) -> Option { + self.live_kit.as_ref().and_then(|live_kit| { + match &live_kit.microphone_track { + LocalTrack::None => None, + LocalTrack::Pending { muted, .. } => Some(*muted), + LocalTrack::Published { muted, .. } => Some(*muted), + } + }) + } + + pub fn is_deafened(&self) -> Option { + self.live_kit.as_ref().map(|live_kit| { + live_kit.deafened + }) + } + pub fn share_mic(&mut self, cx: &mut ModelContext) -> Task> { if self.status.is_offline() { return Task::ready(Err(anyhow!("room is offline"))); From 9b77cafd7b4e9a65f31bf1006751097a5b32c3ae Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 15:35:19 -0700 Subject: [PATCH 039/215] Add a mic sharing to room joining --- crates/call/src/room.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index a2ef659156..9f9a64c1ac 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -238,7 +238,7 @@ impl Room { } Ok(room) - }, + } Err(error) => Err(anyhow!("room creation failed: {:?}", error)), } }) @@ -266,6 +266,14 @@ impl Room { room.update(&mut cx, |room, cx| { room.leave_when_empty = true; room.apply_room_update(room_proto, cx)?; + + if option_env!("START_MIC").is_some() + || &*util::channel::RELEASE_CHANNEL != &ReleaseChannel::Dev + { + let share_mic = room.share_mic(cx); + cx.background().spawn(share_mic).detach_and_log_err(cx); + } + anyhow::Ok(()) })?; Ok(room) @@ -1001,19 +1009,17 @@ impl Room { } pub fn is_muted(&self) -> Option { - self.live_kit.as_ref().and_then(|live_kit| { - match &live_kit.microphone_track { + self.live_kit + .as_ref() + .and_then(|live_kit| match &live_kit.microphone_track { LocalTrack::None => None, LocalTrack::Pending { muted, .. } => Some(*muted), LocalTrack::Published { muted, .. } => Some(*muted), - } - }) + }) } pub fn is_deafened(&self) -> Option { - self.live_kit.as_ref().map(|live_kit| { - live_kit.deafened - }) + self.live_kit.as_ref().map(|live_kit| live_kit.deafened) } pub fn share_mic(&mut self, cx: &mut ModelContext) -> Task> { From e92015b12fde6a0ab7c9d0a4dc5723d3312321d0 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 14 Jun 2023 14:02:32 +0200 Subject: [PATCH 040/215] Split out Interactive into Toggle and Interactive --- crates/ai/src/assistant.rs | 8 +- crates/auto_update/src/update_notification.rs | 4 +- crates/breadcrumbs/src/breadcrumbs.rs | 2 +- crates/collab_ui/src/collab_titlebar_item.rs | 29 +++-- crates/collab_ui/src/contact_finder.rs | 3 +- crates/collab_ui/src/contact_list.rs | 41 ++++--- crates/collab_ui/src/notifications.rs | 4 +- crates/command_palette/src/command_palette.rs | 8 +- crates/context_menu/src/context_menu.rs | 32 ++++-- crates/copilot/src/sign_in.rs | 6 +- crates/copilot_button/src/copilot_button.rs | 5 +- crates/diagnostics/src/items.rs | 4 +- crates/editor/src/editor.rs | 18 +-- crates/editor/src/element.rs | 2 +- crates/feedback/src/deploy_feedback_button.rs | 3 +- crates/feedback/src/submit_feedback_button.rs | 2 +- crates/file_finder/src/file_finder.rs | 2 +- .../src/active_buffer_language.rs | 2 +- .../src/language_selector.rs | 2 +- crates/language_tools/src/lsp_log.rs | 8 +- crates/language_tools/src/syntax_tree_view.rs | 5 +- crates/outline/src/outline.rs | 2 +- crates/project_panel/src/project_panel.rs | 11 +- crates/project_symbols/src/project_symbols.rs | 4 +- crates/recent_projects/src/recent_projects.rs | 2 +- crates/search/src/buffer_search.rs | 10 +- crates/search/src/project_search.rs | 8 +- crates/theme/src/theme.rs | 105 ++++++++++-------- crates/theme/src/ui.rs | 6 +- crates/theme_selector/src/theme_selector.rs | 2 +- crates/welcome/src/base_keymap_picker.rs | 2 +- crates/workspace/src/dock.rs | 11 +- crates/workspace/src/notifications.rs | 4 +- crates/workspace/src/pane.rs | 4 +- crates/workspace/src/toolbar.rs | 6 +- 35 files changed, 223 insertions(+), 144 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index ce816f147b..5b254fac4b 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -1233,19 +1233,19 @@ impl AssistantEditor { cx, |state, _| match message.role { Role::User => { - let style = style.user_sender.style_for(state, false); + let style = style.user_sender.style_for(state); Label::new("You", style.text.clone()) .contained() .with_style(style.container) } Role::Assistant => { - let style = style.assistant_sender.style_for(state, false); + let style = style.assistant_sender.style_for(state); Label::new("Assistant", style.text.clone()) .contained() .with_style(style.container) } Role::System => { - let style = style.system_sender.style_for(state, false); + let style = style.system_sender.style_for(state); Label::new("System", style.text.clone()) .contained() .with_style(style.container) @@ -1484,7 +1484,7 @@ impl View for AssistantEditor { Flex::row() .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.model.style_for(state, false); + let style = theme.model.style_for(state); Label::new(model, style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/auto_update/src/update_notification.rs b/crates/auto_update/src/update_notification.rs index 6f31df614d..cd2e53905d 100644 --- a/crates/auto_update/src/update_notification.rs +++ b/crates/auto_update/src/update_notification.rs @@ -49,7 +49,7 @@ impl View for UpdateNotification { ) .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.dismiss_button.style_for(state, false); + let style = theme.dismiss_button.style_for(state); Svg::new("icons/x_mark_8.svg") .with_color(style.color) .constrained() @@ -74,7 +74,7 @@ impl View for UpdateNotification { ), ) .with_child({ - let style = theme.action_message.style_for(state, false); + let style = theme.action_message.style_for(state); Text::new("View the release notes", style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/breadcrumbs/src/breadcrumbs.rs b/crates/breadcrumbs/src/breadcrumbs.rs index 906d70abb7..433dbed29b 100644 --- a/crates/breadcrumbs/src/breadcrumbs.rs +++ b/crates/breadcrumbs/src/breadcrumbs.rs @@ -83,7 +83,7 @@ impl View for Breadcrumbs { } MouseEventHandler::::new(0, cx, |state, _| { - let style = style.style_for(state, false); + let style = style.style_for(state); crumbs.with_style(style.container) }) .on_click(MouseButton::Left, |_, this, cx| { diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 720a73f477..aa643f4416 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -299,7 +299,7 @@ impl CollabTitlebarItem { pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext) { let theme = theme::current(cx).clone(); let avatar_style = theme.workspace.titlebar.leader_avatar.clone(); - let item_style = theme.context_menu.item.disabled_style().clone(); + let item_style = theme.context_menu.item.off_state().disabled_style().clone(); self.user_menu.update(cx, |user_menu, cx| { let items = if let Some(user) = self.user_store.read(cx).current_user() { vec![ @@ -361,8 +361,20 @@ impl CollabTitlebarItem { .contained() .with_style(titlebar.toggle_contacts_badge) .contained() - .with_margin_left(titlebar.toggle_contacts_button.default.icon_width) - .with_margin_top(titlebar.toggle_contacts_button.default.icon_width) + .with_margin_left( + titlebar + .toggle_contacts_button + .off_state() + .default + .icon_width, + ) + .with_margin_top( + titlebar + .toggle_contacts_button + .off_state() + .default + .icon_width, + ) .aligned(), ) }; @@ -372,7 +384,8 @@ impl CollabTitlebarItem { MouseEventHandler::::new(0, cx, |state, _| { let style = titlebar .toggle_contacts_button - .style_for(state, self.contacts_popover.is_some()); + .in_state(self.contacts_popover.is_some()) + .style_for(state); Svg::new("icons/user_plus_16.svg") .with_color(style.color) .constrained() @@ -419,7 +432,7 @@ impl CollabTitlebarItem { let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.call_control.style_for(state, false); + let style = titlebar.call_control.style_for(state); Svg::new(icon) .with_color(style.color) .constrained() @@ -473,7 +486,7 @@ impl CollabTitlebarItem { .with_child( MouseEventHandler::::new(0, cx, |state, _| { //TODO: Ensure this button has consistent width for both text variations - let style = titlebar.share_button.style_for(state, false); + let style = titlebar.share_button.style_for(state); Label::new(label, style.text.clone()) .contained() .with_style(style.container) @@ -511,7 +524,7 @@ impl CollabTitlebarItem { Stack::new() .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.call_control.style_for(state, false); + let style = titlebar.call_control.style_for(state); Svg::new("icons/ellipsis_14.svg") .with_color(style.color) .constrained() @@ -549,7 +562,7 @@ impl CollabTitlebarItem { fn render_sign_in_button(&self, theme: &Theme, cx: &mut ViewContext) -> AnyElement { let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.sign_in_prompt.style_for(state, false); + let style = titlebar.sign_in_prompt.style_for(state); Label::new("Sign In", style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/collab_ui/src/contact_finder.rs b/crates/collab_ui/src/contact_finder.rs index b5f2416a5b..af59817ece 100644 --- a/crates/collab_ui/src/contact_finder.rs +++ b/crates/collab_ui/src/contact_finder.rs @@ -117,7 +117,8 @@ impl PickerDelegate for ContactFinderDelegate { .contact_finder .picker .item - .style_for(mouse_state, selected); + .in_state(selected) + .style_for(mouse_state); Flex::row() .with_children(user.avatar.clone().map(|avatar| { Image::from_data(avatar) diff --git a/crates/collab_ui/src/contact_list.rs b/crates/collab_ui/src/contact_list.rs index e8dae210c4..c0839249f2 100644 --- a/crates/collab_ui/src/contact_list.rs +++ b/crates/collab_ui/src/contact_list.rs @@ -774,7 +774,8 @@ impl ContactList { .with_style( *theme .contact_row - .style_for(&mut Default::default(), is_selected), + .in_state(is_selected) + .style_for(&mut Default::default()), ) .into_any() } @@ -797,7 +798,7 @@ impl ContactList { .width .or(theme.contact_avatar.height) .unwrap_or(0.); - let row = &theme.project_row.default; + let row = &theme.project_row.off_state().default; let tree_branch = theme.tree_branch; let line_height = row.name.text.line_height(font_cache); let cap_height = row.name.text.cap_height(font_cache); @@ -810,8 +811,11 @@ impl ContactList { }; MouseEventHandler::::new(project_id as usize, cx, |mouse_state, _| { - let tree_branch = *tree_branch.style_for(mouse_state, is_selected); - let row = theme.project_row.style_for(mouse_state, is_selected); + let tree_branch = *tree_branch.in_state(is_selected).style_for(mouse_state); + let row = theme + .project_row + .in_state(is_selected) + .style_for(mouse_state); Flex::row() .with_child( @@ -893,7 +897,7 @@ impl ContactList { .width .or(theme.contact_avatar.height) .unwrap_or(0.); - let row = &theme.project_row.default; + let row = &theme.project_row.off_state().default; let tree_branch = theme.tree_branch; let line_height = row.name.text.line_height(font_cache); let cap_height = row.name.text.cap_height(font_cache); @@ -904,8 +908,11 @@ impl ContactList { peer_id.as_u64() as usize, cx, |mouse_state, _| { - let tree_branch = *tree_branch.style_for(mouse_state, is_selected); - let row = theme.project_row.style_for(mouse_state, is_selected); + let tree_branch = *tree_branch.in_state(is_selected).style_for(mouse_state); + let row = theme + .project_row + .in_state(is_selected) + .style_for(mouse_state); Flex::row() .with_child( @@ -989,7 +996,8 @@ impl ContactList { let header_style = theme .header_row - .style_for(&mut Default::default(), is_selected); + .in_state(is_selected) + .style_for(&mut Default::default()); let text = match section { Section::ActiveCall => "Collaborators", Section::Requests => "Contact Requests", @@ -999,7 +1007,7 @@ impl ContactList { let leave_call = if section == Section::ActiveCall { Some( MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.leave_call.style_for(state, false); + let style = theme.leave_call.style_for(state); Label::new("Leave Call", style.text.clone()) .contained() .with_style(style.container) @@ -1110,8 +1118,7 @@ impl ContactList { contact.user.id as usize, cx, |mouse_state, _| { - let button_style = - theme.contact_button.style_for(mouse_state, false); + let button_style = theme.contact_button.style_for(mouse_state); render_icon_button(button_style, "icons/x_mark_8.svg") .aligned() .flex_float() @@ -1146,7 +1153,8 @@ impl ContactList { .with_style( *theme .contact_row - .style_for(&mut Default::default(), is_selected), + .in_state(is_selected) + .style_for(&mut Default::default()), ) }) .on_click(MouseButton::Left, move |_, this, cx| { @@ -1204,7 +1212,7 @@ impl ContactList { let button_style = if is_contact_request_pending { &theme.disabled_button } else { - theme.contact_button.style_for(mouse_state, false) + theme.contact_button.style_for(mouse_state) }; render_icon_button(button_style, "icons/x_mark_8.svg").aligned() }) @@ -1227,7 +1235,7 @@ impl ContactList { let button_style = if is_contact_request_pending { &theme.disabled_button } else { - theme.contact_button.style_for(mouse_state, false) + theme.contact_button.style_for(mouse_state) }; render_icon_button(button_style, "icons/check_8.svg") .aligned() @@ -1250,7 +1258,7 @@ impl ContactList { let button_style = if is_contact_request_pending { &theme.disabled_button } else { - theme.contact_button.style_for(mouse_state, false) + theme.contact_button.style_for(mouse_state) }; render_icon_button(button_style, "icons/x_mark_8.svg") .aligned() @@ -1277,7 +1285,8 @@ impl ContactList { .with_style( *theme .contact_row - .style_for(&mut Default::default(), is_selected), + .in_state(is_selected) + .style_for(&mut Default::default()), ) .into_any() } diff --git a/crates/collab_ui/src/notifications.rs b/crates/collab_ui/src/notifications.rs index abeb65b1dc..cbd072fe89 100644 --- a/crates/collab_ui/src/notifications.rs +++ b/crates/collab_ui/src/notifications.rs @@ -53,7 +53,7 @@ where ) .with_child( MouseEventHandler::::new(user.id as usize, cx, |state, _| { - let style = theme.dismiss_button.style_for(state, false); + let style = theme.dismiss_button.style_for(state); Svg::new("icons/x_mark_8.svg") .with_color(style.color) .constrained() @@ -93,7 +93,7 @@ where .with_children(buttons.into_iter().enumerate().map( |(ix, (message, handler))| { MouseEventHandler::::new(ix, cx, |state, _| { - let button = theme.button.style_for(state, false); + let button = theme.button.style_for(state); Label::new(message, button.text.clone()) .contained() .with_style(button.container) diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rs index 2ee93a0734..e7e7462fd9 100644 --- a/crates/command_palette/src/command_palette.rs +++ b/crates/command_palette/src/command_palette.rs @@ -185,8 +185,12 @@ impl PickerDelegate for CommandPaletteDelegate { let mat = &self.matches[ix]; let command = &self.actions[mat.candidate_id]; let theme = theme::current(cx); - let style = theme.picker.item.style_for(mouse_state, selected); - let key_style = &theme.command_palette.key.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); + let key_style = &theme + .command_palette + .key + .in_state(selected) + .style_for(mouse_state); let keystroke_spacing = theme.command_palette.keystroke_spacing; Flex::row() diff --git a/crates/context_menu/src/context_menu.rs b/crates/context_menu/src/context_menu.rs index fb455fe1d0..e9ab24f06e 100644 --- a/crates/context_menu/src/context_menu.rs +++ b/crates/context_menu/src/context_menu.rs @@ -9,6 +9,7 @@ use gpui::{ }; use menu::*; use std::{any::TypeId, borrow::Cow, sync::Arc, time::Duration}; +use theme::ToggleState; pub fn init(cx: &mut AppContext) { cx.add_action(ContextMenu::select_first); @@ -328,10 +329,13 @@ impl ContextMenu { Flex::column().with_children(self.items.iter().enumerate().map(|(ix, item)| { match item { ContextMenuItem::Item { label, .. } => { - let style = style.item.style_for( - &mut Default::default(), - Some(ix) == self.selected_index, - ); + let toggle_state = if Some(ix) == self.selected_index { + ToggleState::On + } else { + ToggleState::Off + }; + let style = style.item.in_state(toggle_state); + let style = style.style_for(&mut Default::default()); match label { ContextMenuItemLabel::String(label) => { @@ -363,10 +367,13 @@ impl ContextMenu { .with_children(self.items.iter().enumerate().map(|(ix, item)| { match item { ContextMenuItem::Item { action, .. } => { - let style = style.item.style_for( - &mut Default::default(), - Some(ix) == self.selected_index, - ); + let toggle_state = if Some(ix) == self.selected_index { + ToggleState::On + } else { + ToggleState::Off + }; + let style = style.item.in_state(toggle_state); + let style = style.style_for(&mut Default::default()); match action { ContextMenuItemAction::Action(action) => KeystrokeLabel::new( @@ -412,8 +419,13 @@ impl ContextMenu { let action = action.clone(); let view_id = self.parent_view_id; MouseEventHandler::::new(ix, cx, |state, _| { - let style = - style.item.style_for(state, Some(ix) == self.selected_index); + let toggle_state = if Some(ix) == self.selected_index { + ToggleState::On + } else { + ToggleState::Off + }; + let style = style.item.in_state(toggle_state); + let style = style.style_for(state); let keystroke = match &action { ContextMenuItemAction::Action(action) => Some( KeystrokeLabel::new( diff --git a/crates/copilot/src/sign_in.rs b/crates/copilot/src/sign_in.rs index 0993a33e6c..803cb5cc85 100644 --- a/crates/copilot/src/sign_in.rs +++ b/crates/copilot/src/sign_in.rs @@ -127,16 +127,16 @@ impl CopilotCodeVerification { .with_child( Label::new( if copied { "Copied!" } else { "Copy" }, - device_code_style.cta.style_for(state, false).text.clone(), + device_code_style.cta.style_for(state).text.clone(), ) .aligned() .contained() - .with_style(*device_code_style.right_container.style_for(state, false)) + .with_style(*device_code_style.right_container.style_for(state)) .constrained() .with_width(device_code_style.right), ) .contained() - .with_style(device_code_style.cta.style_for(state, false).container) + .with_style(device_code_style.cta.style_for(state).container) }) .on_click(gpui::platform::MouseButton::Left, { let user_code = data.user_code.clone(); diff --git a/crates/copilot_button/src/copilot_button.rs b/crates/copilot_button/src/copilot_button.rs index 2454074d45..9b0581492f 100644 --- a/crates/copilot_button/src/copilot_button.rs +++ b/crates/copilot_button/src/copilot_button.rs @@ -71,7 +71,8 @@ impl View for CopilotButton { .status_bar .panel_buttons .button - .style_for(state, active); + .in_state(active) + .style_for(state); Flex::row() .with_child( @@ -255,7 +256,7 @@ impl CopilotButton { move |state: &mut MouseState, style: &theme::ContextMenuItem| { Flex::row() .with_child(Label::new("Copilot Settings", style.label.clone())) - .with_child(theme::ui::icon(icon_style.style_for(state, false))) + .with_child(theme::ui::icon(icon_style.style_for(state))) .align_children_center() .into_any() }, diff --git a/crates/diagnostics/src/items.rs b/crates/diagnostics/src/items.rs index f84846eae1..c106f042b5 100644 --- a/crates/diagnostics/src/items.rs +++ b/crates/diagnostics/src/items.rs @@ -100,7 +100,7 @@ impl View for DiagnosticIndicator { .workspace .status_bar .diagnostic_summary - .style_for(state, false); + .style_for(state); let mut summary_row = Flex::row(); if self.summary.error_count > 0 { @@ -198,7 +198,7 @@ impl View for DiagnosticIndicator { MouseEventHandler::::new(1, cx, |state, _| { Label::new( diagnostic.message.split('\n').next().unwrap().to_string(), - message_style.style_for(state, false).text.clone(), + message_style.style_for(state).text.clone(), ) .aligned() .contained() diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 2e0d444e04..e438d0dc2e 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3320,15 +3320,21 @@ impl Editor { pub fn render_code_actions_indicator( &self, style: &EditorStyle, - active: bool, + is_active: bool, cx: &mut ViewContext, ) -> Option> { if self.available_code_actions.is_some() { enum CodeActions {} Some( MouseEventHandler::::new(0, cx, |state, _| { - Svg::new("icons/bolt_8.svg") - .with_color(style.code_actions.indicator.style_for(state, active).color) + Svg::new("icons/bolt_8.svg").with_color( + style + .code_actions + .indicator + .in_state(is_active) + .style_for(state) + .color, + ) }) .with_cursor_style(CursorStyle::PointingHand) .with_padding(Padding::uniform(3.)) @@ -3378,10 +3384,8 @@ impl Editor { .with_color( style .indicator - .style_for( - mouse_state, - fold_status == FoldStatus::Folded, - ) + .in_state(fold_status == FoldStatus::Folded) + .style_for(mouse_state) .color, ) .constrained() diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index d6f9a2e906..835d53bc8c 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -2090,7 +2090,7 @@ impl Element for EditorElement { .folds .ellipses .background - .style_for(&mut cx.mouse_state::(id as usize), false) + .style_for(&mut cx.mouse_state::(id as usize)) .color; (id, fold, color) diff --git a/crates/feedback/src/deploy_feedback_button.rs b/crates/feedback/src/deploy_feedback_button.rs index d32a3e5b4c..beb5284031 100644 --- a/crates/feedback/src/deploy_feedback_button.rs +++ b/crates/feedback/src/deploy_feedback_button.rs @@ -41,7 +41,8 @@ impl View for DeployFeedbackButton { .status_bar .panel_buttons .button - .style_for(state, active); + .in_state(active) + .style_for(state); Svg::new("icons/feedback_16.svg") .with_color(style.icon_color) diff --git a/crates/feedback/src/submit_feedback_button.rs b/crates/feedback/src/submit_feedback_button.rs index 56bc235570..15f77bd561 100644 --- a/crates/feedback/src/submit_feedback_button.rs +++ b/crates/feedback/src/submit_feedback_button.rs @@ -48,7 +48,7 @@ impl View for SubmitFeedbackButton { let theme = theme::current(cx).clone(); enum SubmitFeedbackButton {} MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.feedback.submit_button.style_for(state, false); + let style = theme.feedback.submit_button.style_for(state); Label::new("Submit as Markdown", style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index 73e7ca6eaa..3f6bd83760 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -546,7 +546,7 @@ impl PickerDelegate for FileFinderDelegate { .get(ix) .expect("Invalid matches state: no element for index {ix}"); let theme = theme::current(cx); - let style = theme.picker.item.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); let (file_name, file_name_positions, full_path, full_path_positions) = self.labels_for_match(path_match, cx, ix); Flex::column() diff --git a/crates/language_selector/src/active_buffer_language.rs b/crates/language_selector/src/active_buffer_language.rs index 2c78b89f31..b97417580f 100644 --- a/crates/language_selector/src/active_buffer_language.rs +++ b/crates/language_selector/src/active_buffer_language.rs @@ -55,7 +55,7 @@ impl View for ActiveBufferLanguage { MouseEventHandler::::new(0, cx, |state, cx| { let theme = &theme::current(cx).workspace.status_bar; - let style = theme.active_language.style_for(state, false); + let style = theme.active_language.style_for(state); Label::new(active_language_text, style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/language_selector/src/language_selector.rs b/crates/language_selector/src/language_selector.rs index 817901cd3a..6362b8247d 100644 --- a/crates/language_selector/src/language_selector.rs +++ b/crates/language_selector/src/language_selector.rs @@ -180,7 +180,7 @@ impl PickerDelegate for LanguageSelectorDelegate { ) -> AnyElement> { let theme = theme::current(cx); let mat = &self.matches[ix]; - let style = theme.picker.item.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); let buffer_language_name = self.buffer.read(cx).language().map(|l| l.name()); let mut label = mat.string.clone(); if buffer_language_name.as_deref() == Some(mat.string.as_str()) { diff --git a/crates/language_tools/src/lsp_log.rs b/crates/language_tools/src/lsp_log.rs index 04f47885c0..12d8c6b34d 100644 --- a/crates/language_tools/src/lsp_log.rs +++ b/crates/language_tools/src/lsp_log.rs @@ -681,7 +681,7 @@ impl LspLogToolbarItemView { ) }) .unwrap_or_else(|| "No server selected".into()); - let style = theme.toolbar_dropdown_menu.header.style_for(state, false); + let style = theme.toolbar_dropdown_menu.header.style_for(state); Label::new(label, style.text.clone()) .contained() .with_style(style.container) @@ -722,7 +722,8 @@ impl LspLogToolbarItemView { let style = theme .toolbar_dropdown_menu .item - .style_for(state, logs_selected); + .in_state(logs_selected) + .style_for(state); Label::new(SERVER_LOGS, style.text.clone()) .contained() .with_style(style.container) @@ -739,7 +740,8 @@ impl LspLogToolbarItemView { let style = theme .toolbar_dropdown_menu .item - .style_for(state, rpc_trace_selected); + .in_state(rpc_trace_selected) + .style_for(state); Flex::row() .with_child( Label::new(RPC_MESSAGES, style.text.clone()) diff --git a/crates/language_tools/src/syntax_tree_view.rs b/crates/language_tools/src/syntax_tree_view.rs index 075df76653..3e6727bbf4 100644 --- a/crates/language_tools/src/syntax_tree_view.rs +++ b/crates/language_tools/src/syntax_tree_view.rs @@ -565,7 +565,7 @@ impl SyntaxTreeToolbarItemView { ) -> impl Element { enum ToggleMenu {} MouseEventHandler::::new(0, cx, move |state, _| { - let style = theme.toolbar_dropdown_menu.header.style_for(state, false); + let style = theme.toolbar_dropdown_menu.header.style_for(state); Flex::row() .with_child( Label::new(active_layer.language.name().to_string(), style.text.clone()) @@ -601,7 +601,8 @@ impl SyntaxTreeToolbarItemView { let style = theme .toolbar_dropdown_menu .item - .style_for(state, is_selected); + .in_state(is_selected) + .style_for(state); Flex::row() .with_child( Label::new(layer.language.name().to_string(), style.text.clone()) diff --git a/crates/outline/src/outline.rs b/crates/outline/src/outline.rs index 1e364f5fc8..f93fa10052 100644 --- a/crates/outline/src/outline.rs +++ b/crates/outline/src/outline.rs @@ -204,7 +204,7 @@ impl PickerDelegate for OutlineViewDelegate { cx: &AppContext, ) -> AnyElement> { let theme = theme::current(cx); - let style = theme.picker.item.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); let string_match = &self.matches[ix]; let outline_item = &self.outline.items[string_match.candidate_id]; diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 9563d54be8..a4ac8a5743 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1253,7 +1253,10 @@ impl ProjectPanel { let show_editor = details.is_editing && !details.is_processing; MouseEventHandler::::new(entry_id.to_usize(), cx, |state, cx| { - let mut style = entry_style.style_for(state, details.is_selected).clone(); + let mut style = entry_style + .in_state(details.is_selected) + .style_for(state) + .clone(); if cx .global::>() @@ -1264,7 +1267,7 @@ impl ProjectPanel { .filter(|destination| details.path.starts_with(destination)) .is_some() { - style = entry_style.active.clone().unwrap(); + style = entry_style.on_state().default.clone(); } let row_container_style = if show_editor { @@ -1405,9 +1408,9 @@ impl View for ProjectPanel { let button_style = theme.open_project_button.clone(); let context_menu_item_style = theme::current(cx).context_menu.item.clone(); move |state, cx| { - let button_style = button_style.style_for(state, false).clone(); + let button_style = button_style.style_for(state).clone(); let context_menu_item = - context_menu_item_style.style_for(state, true).clone(); + context_menu_item_style.on_state().style_for(state).clone(); theme::ui::keystroke_label( "Open a project", diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rs index 0dc5dad3bf..dbfad48e87 100644 --- a/crates/project_symbols/src/project_symbols.rs +++ b/crates/project_symbols/src/project_symbols.rs @@ -196,7 +196,7 @@ impl PickerDelegate for ProjectSymbolsDelegate { ) -> AnyElement> { let theme = theme::current(cx); let style = &theme.picker.item; - let current_style = style.style_for(mouse_state, selected); + let current_style = style.in_state(selected).style_for(mouse_state); let string_match = &self.matches[ix]; let symbol = &self.symbols[string_match.candidate_id]; @@ -229,7 +229,7 @@ impl PickerDelegate for ProjectSymbolsDelegate { .with_child( // Avoid styling the path differently when it is selected, since // the symbol's syntax highlighting doesn't change when selected. - Label::new(path.to_string(), style.default.label.clone()), + Label::new(path.to_string(), style.off_state().default.label.clone()), ) .contained() .with_style(current_style.container) diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs index a1dc8982c7..b13f72da0b 100644 --- a/crates/recent_projects/src/recent_projects.rs +++ b/crates/recent_projects/src/recent_projects.rs @@ -173,7 +173,7 @@ impl PickerDelegate for RecentProjectsDelegate { cx: &gpui::AppContext, ) -> AnyElement> { let theme = theme::current(cx); - let style = theme.picker.item.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); let string_match = &self.matches[ix]; diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 87a8b265fb..1a059f5df7 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -328,7 +328,11 @@ impl BufferSearchBar { Some( MouseEventHandler::::new(option as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.style_for(state, is_active); + let style = theme + .search + .option_button + .in_state(is_active) + .style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) @@ -371,7 +375,7 @@ impl BufferSearchBar { enum NavButton {} MouseEventHandler::::new(direction as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.style_for(state, false); + let style = theme.search.option_button.off_state().style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) @@ -403,7 +407,7 @@ impl BufferSearchBar { enum CloseButton {} MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.dismiss_button.style_for(state, false); + let style = theme.dismiss_button.style_for(state); Svg::new("icons/x_mark_8.svg") .with_color(style.color) .constrained() diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 27aac1762b..a379fa80e1 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -896,7 +896,7 @@ impl ProjectSearchBar { enum NavButton {} MouseEventHandler::::new(direction as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.style_for(state, false); + let style = theme.search.option_button.off_state().style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) @@ -927,7 +927,11 @@ impl ProjectSearchBar { let is_active = self.is_option_enabled(option, cx); MouseEventHandler::::new(option as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.style_for(state, is_active); + let style = theme + .search + .option_button + .in_state(is_active) + .style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index c7563ec87a..812659078f 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -132,7 +132,7 @@ pub struct Titlebar { pub outdated_warning: ContainedText, pub share_button: Interactive, pub call_control: Interactive, - pub toggle_contacts_button: Interactive, + pub toggle_contacts_button: Toggleable>, pub user_menu_button: Interactive, pub toggle_contacts_badge: ContainerStyle, } @@ -204,12 +204,12 @@ pub struct ContactList { pub user_query_editor: FieldEditor, pub user_query_editor_height: f32, pub add_contact_button: IconButton, - pub header_row: Interactive, + pub header_row: Toggleable>, pub leave_call: Interactive, - pub contact_row: Interactive, + pub contact_row: Toggleable>, pub row_height: f32, - pub project_row: Interactive, - pub tree_branch: Interactive, + pub project_row: Toggleable>, + pub tree_branch: Toggleable>, pub contact_avatar: ImageStyle, pub contact_status_free: ContainerStyle, pub contact_status_busy: ContainerStyle, @@ -251,7 +251,7 @@ pub struct DropdownMenu { pub container: ContainerStyle, pub header: Interactive, pub section_header: ContainedText, - pub item: Interactive, + pub item: Toggleable>, pub row_height: f32, } @@ -270,7 +270,7 @@ pub struct DropdownMenuItem { pub struct TabBar { #[serde(flatten)] pub container: ContainerStyle, - pub pane_button: Interactive, + pub pane_button: Toggleable>, pub pane_button_container: ContainerStyle, pub active_pane: TabStyles, pub inactive_pane: TabStyles, @@ -339,7 +339,7 @@ pub struct Toolbar { pub container: ContainerStyle, pub height: f32, pub item_spacing: f32, - pub nav_button: Interactive, + pub nav_button: Toggleable>, } #[derive(Clone, Deserialize, Default)] @@ -359,7 +359,7 @@ pub struct Search { pub include_exclude_editor: FindEditor, pub invalid_include_exclude_editor: ContainerStyle, pub include_exclude_inputs: ContainedText, - pub option_button: Interactive, + pub option_button: Toggleable>, pub match_background: Color, pub match_index: ContainedText, pub results_status: TextStyle, @@ -395,7 +395,7 @@ pub struct StatusBarPanelButtons { pub group_left: ContainerStyle, pub group_bottom: ContainerStyle, pub group_right: ContainerStyle, - pub button: Interactive, + pub button: Toggleable>, } #[derive(Deserialize, Default)] @@ -444,10 +444,10 @@ pub struct PanelButton { pub struct ProjectPanel { #[serde(flatten)] pub container: ContainerStyle, - pub entry: Interactive, + pub entry: Toggleable>, pub dragged_entry: ProjectPanelEntry, - pub ignored_entry: Interactive, - pub cut_entry: Interactive, + pub ignored_entry: Toggleable>, + pub cut_entry: Toggleable>, pub filename_editor: FieldEditor, pub indent_width: f32, pub open_project_button: Interactive, @@ -481,7 +481,7 @@ pub struct GitProjectStatus { pub struct ContextMenu { #[serde(flatten)] pub container: ContainerStyle, - pub item: Interactive, + pub item: Toggleable>, pub keystroke_margin: f32, pub separator: ContainerStyle, } @@ -498,7 +498,7 @@ pub struct ContextMenuItem { #[derive(Debug, Deserialize, Default)] pub struct CommandPalette { - pub key: Interactive, + pub key: Toggleable>, pub keystroke_spacing: f32, } @@ -565,7 +565,7 @@ pub struct Picker { pub input_editor: FieldEditor, pub empty_input_editor: FieldEditor, pub no_matches: ContainedLabel, - pub item: Interactive, + pub item: Toggleable>, } #[derive(Clone, Debug, Deserialize, Default)] @@ -771,13 +771,13 @@ pub struct InteractiveColor { #[derive(Clone, Deserialize, Default)] pub struct CodeActions { #[serde(default)] - pub indicator: Interactive, + pub indicator: Toggleable>, pub vertical_scale: f32, } #[derive(Clone, Deserialize, Default)] pub struct Folds { - pub indicator: Interactive, + pub indicator: Toggleable>, pub ellipses: FoldEllipses, pub fold_background: Color, pub icon_margin_scale: f32, @@ -806,29 +806,52 @@ pub struct DiffStyle { pub struct Interactive { pub default: T, pub hover: Option, - pub hover_and_active: Option, pub clicked: Option, - pub click_and_active: Option, - pub active: Option, pub disabled: Option, } +#[derive(Clone, Copy, Debug, Default, Deserialize)] +pub struct Toggleable { + on: T, + off: T, +} + +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +pub enum ToggleState { + Off, + On, +} + +impl> From for ToggleState { + fn from(item: T) -> Self { + match *item.borrow() { + true => Self::On, + false => Self::Off, + } + } +} + +impl Toggleable { + pub fn new(on: T, off: T) -> Self { + Self { on, off } + } + pub fn in_state(&self, state: impl Into) -> &T { + match state.into() { + ToggleState::Off => &self.off, + ToggleState::On => &self.on, + } + } + pub fn on_state(&self) -> &T { + self.in_state(ToggleState::On) + } + pub fn off_state(&self) -> &T { + self.in_state(ToggleState::Off) + } +} + impl Interactive { - pub fn style_for(&self, state: &mut MouseState, active: bool) -> &T { - if active { - if state.hovered() { - self.hover_and_active - .as_ref() - .unwrap_or(self.active.as_ref().unwrap_or(&self.default)) - } else if state.clicked() == Some(platform::MouseButton::Left) && self.clicked.is_some() - { - self.click_and_active - .as_ref() - .unwrap_or(self.active.as_ref().unwrap_or(&self.default)) - } else { - self.active.as_ref().unwrap_or(&self.default) - } - } else if state.clicked() == Some(platform::MouseButton::Left) && self.clicked.is_some() { + pub fn style_for(&self, state: &mut MouseState) -> &T { + if state.clicked() == Some(platform::MouseButton::Left) && self.clicked.is_some() { self.clicked.as_ref().unwrap() } else if state.hovered() { self.hover.as_ref().unwrap_or(&self.default) @@ -836,7 +859,6 @@ impl Interactive { &self.default } } - pub fn disabled_style(&self) -> &T { self.disabled.as_ref().unwrap_or(&self.default) } @@ -852,10 +874,7 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive { #[serde(flatten)] default: Value, hover: Option, - hover_and_active: Option, clicked: Option, - click_and_active: Option, - active: Option, disabled: Option, } @@ -881,20 +900,14 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive { }; let hover = deserialize_state(json.hover)?; - let hover_and_active = deserialize_state(json.hover_and_active)?; let clicked = deserialize_state(json.clicked)?; - let click_and_active = deserialize_state(json.click_and_active)?; - let active = deserialize_state(json.active)?; let disabled = deserialize_state(json.disabled)?; let default = serde_json::from_value(json.default).map_err(serde::de::Error::custom)?; Ok(Interactive { default, hover, - hover_and_active, clicked, - click_and_active, - active, disabled, }) } diff --git a/crates/theme/src/ui.rs b/crates/theme/src/ui.rs index b86bfca8c4..a0fd741d1d 100644 --- a/crates/theme/src/ui.rs +++ b/crates/theme/src/ui.rs @@ -170,7 +170,7 @@ where F: Fn(MouseClick, &mut V, &mut EventContext) + 'static, { MouseEventHandler::::new(0, cx, |state, _| { - let style = style.style_for(state, false); + let style = style.style_for(state); Label::new(label, style.text.to_owned()) .aligned() .contained() @@ -220,13 +220,13 @@ where title, style .title_text - .style_for(&mut MouseState::default(), false) + .style_for(&mut MouseState::default()) .clone(), )) .with_child( // FIXME: Get a better tag type MouseEventHandler::::new(999999, cx, |state, _cx| { - let style = style.close_icon.style_for(state, false); + let style = style.close_icon.style_for(state); icon(style) }) .on_click(platform::MouseButton::Left, move |_, _, cx| { diff --git a/crates/theme_selector/src/theme_selector.rs b/crates/theme_selector/src/theme_selector.rs index a6c84d1d91..5775f1b3e7 100644 --- a/crates/theme_selector/src/theme_selector.rs +++ b/crates/theme_selector/src/theme_selector.rs @@ -208,7 +208,7 @@ impl PickerDelegate for ThemeSelectorDelegate { cx: &AppContext, ) -> AnyElement> { let theme = theme::current(cx); - let style = theme.picker.item.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); let theme_match = &self.matches[ix]; Label::new(theme_match.string.clone(), style.label.clone()) diff --git a/crates/welcome/src/base_keymap_picker.rs b/crates/welcome/src/base_keymap_picker.rs index e44b391d84..cf24a9127e 100644 --- a/crates/welcome/src/base_keymap_picker.rs +++ b/crates/welcome/src/base_keymap_picker.rs @@ -141,7 +141,7 @@ impl PickerDelegate for BaseKeymapSelectorDelegate { ) -> gpui::AnyElement> { let theme = &theme::current(cx); let keymap_match = &self.matches[ix]; - let style = theme.picker.item.style_for(mouse_state, selected); + let style = theme.picker.item.in_state(selected).style_for(mouse_state); Label::new(keymap_match.string.clone(), style.label.clone()) .with_highlights(keymap_match.positions.clone()) diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index c174b8d3a5..376fb85b21 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -6,7 +6,7 @@ use gpui::{ }; use serde::Deserialize; use std::rc::Rc; -use theme::ThemeSettings; +use theme::{ThemeSettings, ToggleState}; pub trait Panel: View { fn position(&self, cx: &WindowContext) -> DockPosition; @@ -498,7 +498,14 @@ impl View for PanelButtons { Stack::new() .with_child( MouseEventHandler::::new(panel_ix, cx, |state, cx| { - let style = button_style.style_for(state, is_active); + let toggle_state = if is_active { + ToggleState::On + } else { + ToggleState::Off + }; + let style = button_style.in_state(toggle_state); + + let style = style.style_for(state); Flex::row() .with_child( Svg::new(view.icon_path(cx)) diff --git a/crates/workspace/src/notifications.rs b/crates/workspace/src/notifications.rs index 1e3c6044a1..09cfb4d5d8 100644 --- a/crates/workspace/src/notifications.rs +++ b/crates/workspace/src/notifications.rs @@ -291,7 +291,7 @@ pub mod simple_message_notification { ) .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.dismiss_button.style_for(state, false); + let style = theme.dismiss_button.style_for(state); Svg::new("icons/x_mark_8.svg") .with_color(style.color) .constrained() @@ -323,7 +323,7 @@ pub mod simple_message_notification { 0, cx, |state, _| { - let style = theme.action_message.style_for(state, false); + let style = theme.action_message.style_for(state); Flex::row() .with_child( diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 551bc831d3..5136db1d18 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -1410,7 +1410,7 @@ impl Pane { pub fn render_tab_bar_button)>( index: usize, icon: &'static str, - active: bool, + is_active: bool, tooltip: Option<(String, Option>)>, cx: &mut ViewContext, on_click: F, @@ -1420,7 +1420,7 @@ impl Pane { let mut button = MouseEventHandler::::new(index, cx, |mouse_state, cx| { let theme = &settings::get::(cx).theme.workspace.tab_bar; - let style = theme.pane_button.style_for(mouse_state, active); + let style = theme.pane_button.in_state(is_active).style_for(mouse_state); Svg::new(icon) .with_color(style.color) .constrained() diff --git a/crates/workspace/src/toolbar.rs b/crates/workspace/src/toolbar.rs index 8b26b1181b..59f39f1d93 100644 --- a/crates/workspace/src/toolbar.rs +++ b/crates/workspace/src/toolbar.rs @@ -219,7 +219,7 @@ impl View for Toolbar { #[allow(clippy::too_many_arguments)] fn nav_button)>( svg_path: &'static str, - style: theme::Interactive, + style: theme::Toggleable>, nav_button_height: f32, tooltip_style: TooltipStyle, enabled: bool, @@ -231,9 +231,9 @@ fn nav_button ) -> AnyElement { MouseEventHandler::::new(0, cx, |state, _| { let style = if enabled { - style.style_for(state, false) + style.off_state().style_for(state) } else { - style.disabled_style() + style.off_state().disabled_style() }; Svg::new(svg_path) .with_color(style.color) From 0256f89dd66c693523d8fa19aefa5cdd7ddd34b2 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 14 Jun 2023 15:12:38 +0200 Subject: [PATCH 041/215] Rename on/off states to active/inactive --- crates/collab_ui/src/collab_titlebar_item.rs | 11 +++++-- crates/collab_ui/src/contact_list.rs | 4 +-- crates/context_menu/src/context_menu.rs | 12 +++---- crates/project_panel/src/project_panel.rs | 8 +++-- crates/project_symbols/src/project_symbols.rs | 5 ++- crates/search/src/buffer_search.rs | 2 +- crates/search/src/project_search.rs | 2 +- crates/theme/src/theme.rs | 31 ++++++++++--------- crates/workspace/src/dock.rs | 4 +-- crates/workspace/src/toolbar.rs | 4 +-- 10 files changed, 47 insertions(+), 36 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index aa643f4416..cf699d1988 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -299,7 +299,12 @@ impl CollabTitlebarItem { pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext) { let theme = theme::current(cx).clone(); let avatar_style = theme.workspace.titlebar.leader_avatar.clone(); - let item_style = theme.context_menu.item.off_state().disabled_style().clone(); + let item_style = theme + .context_menu + .item + .inactive_state() + .disabled_style() + .clone(); self.user_menu.update(cx, |user_menu, cx| { let items = if let Some(user) = self.user_store.read(cx).current_user() { vec![ @@ -364,14 +369,14 @@ impl CollabTitlebarItem { .with_margin_left( titlebar .toggle_contacts_button - .off_state() + .inactive_state() .default .icon_width, ) .with_margin_top( titlebar .toggle_contacts_button - .off_state() + .inactive_state() .default .icon_width, ) diff --git a/crates/collab_ui/src/contact_list.rs b/crates/collab_ui/src/contact_list.rs index c0839249f2..0c8b27a151 100644 --- a/crates/collab_ui/src/contact_list.rs +++ b/crates/collab_ui/src/contact_list.rs @@ -798,7 +798,7 @@ impl ContactList { .width .or(theme.contact_avatar.height) .unwrap_or(0.); - let row = &theme.project_row.off_state().default; + let row = &theme.project_row.inactive_state().default; let tree_branch = theme.tree_branch; let line_height = row.name.text.line_height(font_cache); let cap_height = row.name.text.cap_height(font_cache); @@ -897,7 +897,7 @@ impl ContactList { .width .or(theme.contact_avatar.height) .unwrap_or(0.); - let row = &theme.project_row.off_state().default; + let row = &theme.project_row.inactive_state().default; let tree_branch = theme.tree_branch; let line_height = row.name.text.line_height(font_cache); let cap_height = row.name.text.cap_height(font_cache); diff --git a/crates/context_menu/src/context_menu.rs b/crates/context_menu/src/context_menu.rs index e9ab24f06e..e140177c5c 100644 --- a/crates/context_menu/src/context_menu.rs +++ b/crates/context_menu/src/context_menu.rs @@ -330,9 +330,9 @@ impl ContextMenu { match item { ContextMenuItem::Item { label, .. } => { let toggle_state = if Some(ix) == self.selected_index { - ToggleState::On + ToggleState::Active } else { - ToggleState::Off + ToggleState::Inactive }; let style = style.item.in_state(toggle_state); let style = style.style_for(&mut Default::default()); @@ -368,9 +368,9 @@ impl ContextMenu { match item { ContextMenuItem::Item { action, .. } => { let toggle_state = if Some(ix) == self.selected_index { - ToggleState::On + ToggleState::Active } else { - ToggleState::Off + ToggleState::Inactive }; let style = style.item.in_state(toggle_state); let style = style.style_for(&mut Default::default()); @@ -420,9 +420,9 @@ impl ContextMenu { let view_id = self.parent_view_id; MouseEventHandler::::new(ix, cx, |state, _| { let toggle_state = if Some(ix) == self.selected_index { - ToggleState::On + ToggleState::Active } else { - ToggleState::Off + ToggleState::Inactive }; let style = style.item.in_state(toggle_state); let style = style.style_for(state); diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index a4ac8a5743..dc592b7588 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1267,7 +1267,7 @@ impl ProjectPanel { .filter(|destination| details.path.starts_with(destination)) .is_some() { - style = entry_style.on_state().default.clone(); + style = entry_style.active_state().default.clone(); } let row_container_style = if show_editor { @@ -1409,8 +1409,10 @@ impl View for ProjectPanel { let context_menu_item_style = theme::current(cx).context_menu.item.clone(); move |state, cx| { let button_style = button_style.style_for(state).clone(); - let context_menu_item = - context_menu_item_style.on_state().style_for(state).clone(); + let context_menu_item = context_menu_item_style + .active_state() + .style_for(state) + .clone(); theme::ui::keystroke_label( "Open a project", diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rs index dbfad48e87..fc17b57c6d 100644 --- a/crates/project_symbols/src/project_symbols.rs +++ b/crates/project_symbols/src/project_symbols.rs @@ -229,7 +229,10 @@ impl PickerDelegate for ProjectSymbolsDelegate { .with_child( // Avoid styling the path differently when it is selected, since // the symbol's syntax highlighting doesn't change when selected. - Label::new(path.to_string(), style.off_state().default.label.clone()), + Label::new( + path.to_string(), + style.inactive_state().default.label.clone(), + ), ) .contained() .with_style(current_style.container) diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 1a059f5df7..c6a86b2f6a 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -375,7 +375,7 @@ impl BufferSearchBar { enum NavButton {} MouseEventHandler::::new(direction as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.off_state().style_for(state); + let style = theme.search.option_button.inactive_state().style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index a379fa80e1..135194df6a 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -896,7 +896,7 @@ impl ProjectSearchBar { enum NavButton {} MouseEventHandler::::new(direction as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.off_state().style_for(state); + let style = theme.search.option_button.inactive_state().style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 812659078f..7c4c8c1ce2 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -812,40 +812,41 @@ pub struct Interactive { #[derive(Clone, Copy, Debug, Default, Deserialize)] pub struct Toggleable { - on: T, - off: T, + active: T, + inactive: T, } -#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, Default, Hash, PartialEq, Eq)] pub enum ToggleState { - Off, - On, + #[default] + Inactive, + Active, } impl> From for ToggleState { fn from(item: T) -> Self { match *item.borrow() { - true => Self::On, - false => Self::Off, + true => Self::Active, + false => Self::Inactive, } } } impl Toggleable { - pub fn new(on: T, off: T) -> Self { - Self { on, off } + pub fn new(active: T, inactive: T) -> Self { + Self { active, inactive } } pub fn in_state(&self, state: impl Into) -> &T { match state.into() { - ToggleState::Off => &self.off, - ToggleState::On => &self.on, + ToggleState::Inactive => &self.inactive, + ToggleState::Active => &self.active, } } - pub fn on_state(&self) -> &T { - self.in_state(ToggleState::On) + pub fn active_state(&self) -> &T { + self.in_state(ToggleState::Active) } - pub fn off_state(&self) -> &T { - self.in_state(ToggleState::Off) + pub fn inactive_state(&self) -> &T { + self.in_state(ToggleState::Inactive) } } diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 376fb85b21..ec00ddece8 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -499,9 +499,9 @@ impl View for PanelButtons { .with_child( MouseEventHandler::::new(panel_ix, cx, |state, cx| { let toggle_state = if is_active { - ToggleState::On + ToggleState::Active } else { - ToggleState::Off + ToggleState::Inactive }; let style = button_style.in_state(toggle_state); diff --git a/crates/workspace/src/toolbar.rs b/crates/workspace/src/toolbar.rs index 59f39f1d93..d74e7f046a 100644 --- a/crates/workspace/src/toolbar.rs +++ b/crates/workspace/src/toolbar.rs @@ -231,9 +231,9 @@ fn nav_button ) -> AnyElement { MouseEventHandler::::new(0, cx, |state, _| { let style = if enabled { - style.off_state().style_for(state) + style.inactive_state().style_for(state) } else { - style.off_state().disabled_style() + style.inactive_state().disabled_style() }; Svg::new(svg_path) .with_color(style.color) From b9959ffdc0811e01fb6b87a18c3f61741000bce0 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 14 Jun 2023 17:26:47 +0200 Subject: [PATCH 042/215] Do not flatten Interactive::default --- crates/theme/src/theme.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 7c4c8c1ce2..a82bb18cf1 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -872,7 +872,6 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive { { #[derive(Deserialize)] struct Helper { - #[serde(flatten)] default: Value, hover: Option, clicked: Option, From c47d1e9f5178d1a14122405f0872e305c6da562e Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 14 Jun 2023 17:26:58 +0200 Subject: [PATCH 043/215] Add toggle.ts and interactive.ts --- styles/src/styleTree/interactive.ts | 26 ++++++++++++++++++++++++++ styles/src/styleTree/toggle.ts | 17 +++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 styles/src/styleTree/interactive.ts create mode 100644 styles/src/styleTree/toggle.ts diff --git a/styles/src/styleTree/interactive.ts b/styles/src/styleTree/interactive.ts new file mode 100644 index 0000000000..2f7181900c --- /dev/null +++ b/styles/src/styleTree/interactive.ts @@ -0,0 +1,26 @@ +interface Interactive { + default: T, + hover?: T, + clicked?: T, + disabled?: T, +} + +export function interactive(base: T, modifications: Partial>): Interactive { + const interactiveObj: Interactive = { + default: base, + }; + + if (modifications.hover !== undefined) { + interactiveObj.hover = { ...base, ...modifications.hover }; + } + + if (modifications.clicked !== undefined) { + interactiveObj.clicked = { ...base, ...modifications.clicked }; + } + + if (modifications.disabled !== undefined) { + interactiveObj.disabled = { ...base, ...modifications.disabled }; + } + + return interactiveObj; +} diff --git a/styles/src/styleTree/toggle.ts b/styles/src/styleTree/toggle.ts new file mode 100644 index 0000000000..0602ae6b59 --- /dev/null +++ b/styles/src/styleTree/toggle.ts @@ -0,0 +1,17 @@ +interface Toggleable { + inactive: T + active: T, +} + +export function toggleable(inactive: T, modifications: Partial>): Toggleable { + let active: T = inactive; + if (modifications.active !== undefined) { + active = { ...inactive, ...modifications.active }; + } + return { + inactive: inactive, + active: active + }; + + d +} From 198a446b03a168fc96f68f8de2e0ebf96068c1ac Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 15 Jun 2023 13:09:22 +0200 Subject: [PATCH 044/215] Implement Toggleable and Interactive properly --- styles/package-lock.json | 30 ++++++++++++++- styles/package.json | 4 +- styles/src/styleTree/commandPalette.ts | 53 +++++++++++++++----------- styles/src/styleTree/interactive.ts | 19 ++++++--- styles/src/styleTree/toggle.ts | 40 +++++++++++++------ 5 files changed, 104 insertions(+), 42 deletions(-) diff --git a/styles/package-lock.json b/styles/package-lock.json index d1d0ed0eb8..b4bdd52c66 100644 --- a/styles/package-lock.json +++ b/styles/package-lock.json @@ -18,7 +18,9 @@ "chroma-js": "^2.4.2", "deepmerge": "^4.3.0", "toml": "^3.0.0", - "ts-node": "^10.9.1" + "ts-deepmerge": "^6.0.3", + "ts-node": "^10.9.1", + "utility-types": "^3.10.0" } }, "node_modules/@cspotcode/source-map-support": { @@ -180,6 +182,14 @@ "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" }, + "node_modules/ts-deepmerge": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/ts-deepmerge/-/ts-deepmerge-6.0.3.tgz", + "integrity": "sha512-MBBJL0UK/mMnZRONMz4J1CRu5NsGtsh+gR1nkn8KLE9LXo/PCzeHhQduhNary8m5/m9ryOOyFwVKxq81cPlaow==", + "engines": { + "node": ">=14.13.1" + } + }, "node_modules/ts-node": { "version": "10.9.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", @@ -235,6 +245,14 @@ "node": ">=4.2.0" } }, + "node_modules/utility-types": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", + "integrity": "sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==", + "engines": { + "node": ">= 4" + } + }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", @@ -382,6 +400,11 @@ "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" }, + "ts-deepmerge": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/ts-deepmerge/-/ts-deepmerge-6.0.3.tgz", + "integrity": "sha512-MBBJL0UK/mMnZRONMz4J1CRu5NsGtsh+gR1nkn8KLE9LXo/PCzeHhQduhNary8m5/m9ryOOyFwVKxq81cPlaow==" + }, "ts-node": { "version": "10.9.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", @@ -408,6 +431,11 @@ "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "peer": true }, + "utility-types": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", + "integrity": "sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==" + }, "v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", diff --git a/styles/package.json b/styles/package.json index 2a0881863b..30336d5c51 100644 --- a/styles/package.json +++ b/styles/package.json @@ -20,7 +20,9 @@ "chroma-js": "^2.4.2", "deepmerge": "^4.3.0", "toml": "^3.0.0", - "ts-node": "^10.9.1" + "ts-deepmerge": "^6.0.3", + "ts-node": "^10.9.1", + "utility-types": "^3.10.0" }, "prettier": { "semi": false, diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index c49e1f194c..5fe7b74f92 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -1,30 +1,37 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, background } from "./components" +import { toggleable } from "./toggle" +import { interactive } from "./interactive" export default function commandPalette(colorScheme: ColorScheme) { - let layer = colorScheme.highest - return { - keystrokeSpacing: 8, - key: { - text: text(layer, "mono", "variant", "default", { size: "xs" }), - cornerRadius: 2, - background: background(layer, "on"), - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - margin: { - top: 1, - bottom: 1, - left: 2, - }, - active: { - text: text(layer, "mono", "on", "default", { size: "xs" }), - background: withOpacity(background(layer, "on"), 0.2), - }, + let layer = colorScheme.highest + return { + keystrokeSpacing: 8, + key: + toggleable(interactive({ + text: text(layer, "mono", "variant", "default", { size: "xs" }), + cornerRadius: 2, + background: background(layer, "on"), + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, }, - } + margin: { + top: 1, + bottom: 1, + left: 2, + }, + }, { hover: { cornerRadius: 4, padding: { top: 17 } } }), { + default: { + text: text(layer, "mono", "on", "default", { size: "xs" }), + background: withOpacity(background(layer, "on"), 0.2), + } + + }) + , + + } } diff --git a/styles/src/styleTree/interactive.ts b/styles/src/styleTree/interactive.ts index 2f7181900c..7135cecd90 100644 --- a/styles/src/styleTree/interactive.ts +++ b/styles/src/styleTree/interactive.ts @@ -1,3 +1,5 @@ +import { DeepPartial } from "utility-types"; +import merge from "ts-deepmerge" interface Interactive { default: T, hover?: T, @@ -5,21 +7,26 @@ interface Interactive { disabled?: T, } -export function interactive(base: T, modifications: Partial>): Interactive { - const interactiveObj: Interactive = { +// Helper function for creating Interactive objects that works pretty much like Toggle. +// It takes a object to be used as a value for `default` field and then fills out other fields +// with fields from either `base` or `modifications`. Notably, it does not touch `hover`, `clicked` and `disabled` if there are no modifications for it. +export function interactive(base: T, modifications: DeepPartial>): Interactive { + let interactiveObj: Interactive = { default: base, }; - + if (modifications.default !== undefined) { + interactiveObj.default = merge(interactiveObj.default, modifications.default) as T; + } if (modifications.hover !== undefined) { - interactiveObj.hover = { ...base, ...modifications.hover }; + interactiveObj.hover = merge(interactiveObj.default, modifications.hover) as T; } if (modifications.clicked !== undefined) { - interactiveObj.clicked = { ...base, ...modifications.clicked }; + interactiveObj.clicked = merge(interactiveObj.default, modifications.clicked) as T; } if (modifications.disabled !== undefined) { - interactiveObj.disabled = { ...base, ...modifications.disabled }; + interactiveObj.disabled = merge(interactiveObj.default, modifications.disabled) as T; } return interactiveObj; diff --git a/styles/src/styleTree/toggle.ts b/styles/src/styleTree/toggle.ts index 0602ae6b59..9c35b8337c 100644 --- a/styles/src/styleTree/toggle.ts +++ b/styles/src/styleTree/toggle.ts @@ -1,17 +1,35 @@ +import { DeepPartial } from 'utility-types'; +import merge from 'ts-deepmerge'; + interface Toggleable { inactive: T active: T, } -export function toggleable(inactive: T, modifications: Partial>): Toggleable { - let active: T = inactive; - if (modifications.active !== undefined) { - active = { ...inactive, ...modifications.active }; - } - return { - inactive: inactive, - active: active - }; - - d +/// Helper function for creating Toggleable objects; it takes a object of type T that is used as +/// `inactive` member of result Toggleable. `active` member is created by applying `modifications` on top of `inactive` argument. +// Thus, the following call: +// ``` +// toggleable({day: 1, month: "January"}, {day: 3}) +// ``` +// To return the following object: +// ``` +// Toggleable<_>{ +// inactive: { day: 1, month: "January" }, +// active: { day: 3, month: "January" } +// } +// ``` +// Remarkably, it also works for nested structures: +// ``` +// toggleable({first_level: "foo", second_level: {nested_member: "nested"}}, {second_level: {nested_member: "another nested thing"}}) +// ``` +// ``` +// Toggleable<_> { +// inactive: {first_level: "foo", second_level: {nested_member: "nested"}}, +// active: { first_level: "foo", second_level: {nested_member: "another nested thing"}} +// } +// ``` +export function toggleable(inactive: T, modifications: DeepPartial): Toggleable { + let active: T = merge(inactive, modifications) as T; + return { active: active, inactive: inactive }; } From 31c1177737501b742e3522a52a4045a6c718e279 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 15 Jun 2023 16:24:05 +0200 Subject: [PATCH 045/215] Adjust some of the styles to the new Toggleable format --- crates/collab_ui/src/collab_titlebar_item.rs | 4 +- crates/theme/src/theme.rs | 8 +- crates/workspace/src/toolbar.rs | 6 +- styles/src/styleTree/components.ts | 436 ++++++------ styles/src/styleTree/contactList.ts | 360 +++++----- styles/src/styleTree/contactNotification.ts | 81 ++- styles/src/styleTree/contextMenu.ts | 91 +-- styles/src/styleTree/copilot.ts | 515 +++++++------- styles/src/styleTree/editor.ts | 537 +++++++-------- styles/src/styleTree/picker.ts | 154 ++--- styles/src/styleTree/projectPanel.ts | 208 +++--- styles/src/styleTree/statusBar.ts | 241 +++---- styles/src/styleTree/tabBar.ts | 191 +++--- styles/src/styleTree/welcome.ts | 240 +++---- styles/src/styleTree/workspace.ts | 668 ++++++++++--------- 15 files changed, 1932 insertions(+), 1808 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index cf699d1988..04fc9650eb 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -491,7 +491,7 @@ impl CollabTitlebarItem { .with_child( MouseEventHandler::::new(0, cx, |state, _| { //TODO: Ensure this button has consistent width for both text variations - let style = titlebar.share_button.style_for(state); + let style = titlebar.share_button.inactive_state().style_for(state); Label::new(label, style.text.clone()) .contained() .with_style(style.container) @@ -567,7 +567,7 @@ impl CollabTitlebarItem { fn render_sign_in_button(&self, theme: &Theme, cx: &mut ViewContext) -> AnyElement { let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.sign_in_prompt.style_for(state); + let style = titlebar.sign_in_prompt.inactive_state().style_for(state); Label::new("Sign In", style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index a82bb18cf1..fd30387ad8 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -128,12 +128,12 @@ pub struct Titlebar { pub leader_avatar: AvatarStyle, pub follower_avatar: AvatarStyle, pub inactive_avatar_grayscale: bool, - pub sign_in_prompt: Interactive, + pub sign_in_prompt: Toggleable>, pub outdated_warning: ContainedText, - pub share_button: Interactive, + pub share_button: Toggleable>, pub call_control: Interactive, pub toggle_contacts_button: Toggleable>, - pub user_menu_button: Interactive, + pub user_menu_button: Toggleable>, pub toggle_contacts_badge: ContainerStyle, } @@ -339,7 +339,7 @@ pub struct Toolbar { pub container: ContainerStyle, pub height: f32, pub item_spacing: f32, - pub nav_button: Toggleable>, + pub nav_button: Interactive, } #[derive(Clone, Deserialize, Default)] diff --git a/crates/workspace/src/toolbar.rs b/crates/workspace/src/toolbar.rs index d74e7f046a..49f9db12e6 100644 --- a/crates/workspace/src/toolbar.rs +++ b/crates/workspace/src/toolbar.rs @@ -219,7 +219,7 @@ impl View for Toolbar { #[allow(clippy::too_many_arguments)] fn nav_button)>( svg_path: &'static str, - style: theme::Toggleable>, + style: theme::Interactive, nav_button_height: f32, tooltip_style: TooltipStyle, enabled: bool, @@ -231,9 +231,9 @@ fn nav_button ) -> AnyElement { MouseEventHandler::::new(0, cx, |state, _| { let style = if enabled { - style.inactive_state().style_for(state) + style.style_for(state) } else { - style.inactive_state().disabled_style() + style.disabled_style() }; Svg::new(svg_path) .with_color(style.color) diff --git a/styles/src/styleTree/components.ts b/styles/src/styleTree/components.ts index a575dad527..3aa5d9176e 100644 --- a/styles/src/styleTree/components.ts +++ b/styles/src/styleTree/components.ts @@ -2,297 +2,297 @@ import { fontFamilies, fontSizes, FontWeight } from "../common" import { Layer, Styles, StyleSets, Style } from "../theme/colorScheme" function isStyleSet(key: any): key is StyleSets { - return [ - "base", - "variant", - "on", - "accent", - "positive", - "warning", - "negative", - ].includes(key) + return [ + "base", + "variant", + "on", + "accent", + "positive", + "warning", + "negative", + ].includes(key) } function isStyle(key: any): key is Styles { - return [ - "default", - "active", - "disabled", - "hovered", - "pressed", - "inverted", - ].includes(key) + return [ + "default", + "active", + "disabled", + "hovered", + "pressed", + "inverted", + ].includes(key) } function getStyle( - layer: Layer, - possibleStyleSetOrStyle?: any, - possibleStyle?: any + layer: Layer, + possibleStyleSetOrStyle?: any, + possibleStyle?: any ): Style { - let styleSet: StyleSets = "base" - let style: Styles = "default" - if (isStyleSet(possibleStyleSetOrStyle)) { - styleSet = possibleStyleSetOrStyle - } else if (isStyle(possibleStyleSetOrStyle)) { - style = possibleStyleSetOrStyle - } + let styleSet: StyleSets = "base" + let style: Styles = "default" + if (isStyleSet(possibleStyleSetOrStyle)) { + styleSet = possibleStyleSetOrStyle + } else if (isStyle(possibleStyleSetOrStyle)) { + style = possibleStyleSetOrStyle + } - if (isStyle(possibleStyle)) { - style = possibleStyle - } + if (isStyle(possibleStyle)) { + style = possibleStyle + } - return layer[styleSet][style] + return layer[styleSet][style] } export function background(layer: Layer, style?: Styles): string export function background( - layer: Layer, - styleSet?: StyleSets, - style?: Styles + layer: Layer, + styleSet?: StyleSets, + style?: Styles ): string export function background( - layer: Layer, - styleSetOrStyles?: StyleSets | Styles, - style?: Styles + layer: Layer, + styleSetOrStyles?: StyleSets | Styles, + style?: Styles ): string { - return getStyle(layer, styleSetOrStyles, style).background + return getStyle(layer, styleSetOrStyles, style).background } export function borderColor(layer: Layer, style?: Styles): string export function borderColor( - layer: Layer, - styleSet?: StyleSets, - style?: Styles + layer: Layer, + styleSet?: StyleSets, + style?: Styles ): string export function borderColor( - layer: Layer, - styleSetOrStyles?: StyleSets | Styles, - style?: Styles + layer: Layer, + styleSetOrStyles?: StyleSets | Styles, + style?: Styles ): string { - return getStyle(layer, styleSetOrStyles, style).border + return getStyle(layer, styleSetOrStyles, style).border } export function foreground(layer: Layer, style?: Styles): string export function foreground( - layer: Layer, - styleSet?: StyleSets, - style?: Styles + layer: Layer, + styleSet?: StyleSets, + style?: Styles ): string export function foreground( - layer: Layer, - styleSetOrStyles?: StyleSets | Styles, - style?: Styles + layer: Layer, + styleSetOrStyles?: StyleSets | Styles, + style?: Styles ): string { - return getStyle(layer, styleSetOrStyles, style).foreground + return getStyle(layer, styleSetOrStyles, style).foreground } -interface Text { - family: keyof typeof fontFamilies - color: string - size: number - weight?: FontWeight - underline?: boolean +interface Text extends Object { + family: keyof typeof fontFamilies + color: string + size: number + weight?: FontWeight + underline?: boolean } export interface TextProperties { - size?: keyof typeof fontSizes - weight?: FontWeight - underline?: boolean - color?: string - features?: FontFeatures + size?: keyof typeof fontSizes + weight?: FontWeight + underline?: boolean + color?: string + features?: FontFeatures } interface FontFeatures { - /** Contextual Alternates: Applies a second substitution feature based on a match of a character pattern within a context of surrounding patterns */ - calt?: boolean - /** Case-Sensitive Forms: Shifts various punctuation marks up to a position that works better with all-capital sequences */ - case?: boolean - /** Capital Spacing: Adjusts inter-glyph spacing for all-capital text */ - cpsp?: boolean - /** Fractions: Replaces figures separated by a slash with diagonal fractions */ - frac?: boolean - /** Standard Ligatures: Replaces a sequence of glyphs with a single glyph which is preferred for typographic purposes */ - liga?: boolean - /** Oldstyle Figures: Changes selected figures from the default or lining style to oldstyle form. */ - onum?: boolean - /** Ordinals: Replaces default alphabetic glyphs with the corresponding ordinal forms for use after figures */ - ordn?: boolean - /** Proportional Figures: Replaces figure glyphs set on uniform (tabular) widths with corresponding glyphs set on proportional widths */ - pnum?: boolean - /** Stylistic set 01 */ - ss01?: boolean - /** Stylistic set 02 */ - ss02?: boolean - /** Stylistic set 03 */ - ss03?: boolean - /** Stylistic set 04 */ - ss04?: boolean - /** Stylistic set 05 */ - ss05?: boolean - /** Stylistic set 06 */ - ss06?: boolean - /** Stylistic set 07 */ - ss07?: boolean - /** Stylistic set 08 */ - ss08?: boolean - /** Stylistic set 09 */ - ss09?: boolean - /** Stylistic set 10 */ - ss10?: boolean - /** Stylistic set 11 */ - ss11?: boolean - /** Stylistic set 12 */ - ss12?: boolean - /** Stylistic set 13 */ - ss13?: boolean - /** Stylistic set 14 */ - ss14?: boolean - /** Stylistic set 15 */ - ss15?: boolean - /** Stylistic set 16 */ - ss16?: boolean - /** Stylistic set 17 */ - ss17?: boolean - /** Stylistic set 18 */ - ss18?: boolean - /** Stylistic set 19 */ - ss19?: boolean - /** Stylistic set 20 */ - ss20?: boolean - /** Subscript: Replaces default glyphs with subscript glyphs */ - subs?: boolean - /** Superscript: Replaces default glyphs with superscript glyphs */ - sups?: boolean - /** Swash: Replaces default glyphs with swash glyphs for stylistic purposes */ - swsh?: boolean - /** Titling: Replaces default glyphs with titling glyphs for use in large-size settings */ - titl?: boolean - /** Tabular Figures: Replaces figure glyphs set on proportional widths with corresponding glyphs set on uniform (tabular) widths */ - tnum?: boolean - /** Slashed Zero: Replaces default zero with a slashed zero for better distinction between "0" and "O" */ - zero?: boolean + /** Contextual Alternates: Applies a second substitution feature based on a match of a character pattern within a context of surrounding patterns */ + calt?: boolean + /** Case-Sensitive Forms: Shifts various punctuation marks up to a position that works better with all-capital sequences */ + case?: boolean + /** Capital Spacing: Adjusts inter-glyph spacing for all-capital text */ + cpsp?: boolean + /** Fractions: Replaces figures separated by a slash with diagonal fractions */ + frac?: boolean + /** Standard Ligatures: Replaces a sequence of glyphs with a single glyph which is preferred for typographic purposes */ + liga?: boolean + /** Oldstyle Figures: Changes selected figures from the default or lining style to oldstyle form. */ + onum?: boolean + /** Ordinals: Replaces default alphabetic glyphs with the corresponding ordinal forms for use after figures */ + ordn?: boolean + /** Proportional Figures: Replaces figure glyphs set on uniform (tabular) widths with corresponding glyphs set on proportional widths */ + pnum?: boolean + /** Stylistic set 01 */ + ss01?: boolean + /** Stylistic set 02 */ + ss02?: boolean + /** Stylistic set 03 */ + ss03?: boolean + /** Stylistic set 04 */ + ss04?: boolean + /** Stylistic set 05 */ + ss05?: boolean + /** Stylistic set 06 */ + ss06?: boolean + /** Stylistic set 07 */ + ss07?: boolean + /** Stylistic set 08 */ + ss08?: boolean + /** Stylistic set 09 */ + ss09?: boolean + /** Stylistic set 10 */ + ss10?: boolean + /** Stylistic set 11 */ + ss11?: boolean + /** Stylistic set 12 */ + ss12?: boolean + /** Stylistic set 13 */ + ss13?: boolean + /** Stylistic set 14 */ + ss14?: boolean + /** Stylistic set 15 */ + ss15?: boolean + /** Stylistic set 16 */ + ss16?: boolean + /** Stylistic set 17 */ + ss17?: boolean + /** Stylistic set 18 */ + ss18?: boolean + /** Stylistic set 19 */ + ss19?: boolean + /** Stylistic set 20 */ + ss20?: boolean + /** Subscript: Replaces default glyphs with subscript glyphs */ + subs?: boolean + /** Superscript: Replaces default glyphs with superscript glyphs */ + sups?: boolean + /** Swash: Replaces default glyphs with swash glyphs for stylistic purposes */ + swsh?: boolean + /** Titling: Replaces default glyphs with titling glyphs for use in large-size settings */ + titl?: boolean + /** Tabular Figures: Replaces figure glyphs set on proportional widths with corresponding glyphs set on uniform (tabular) widths */ + tnum?: boolean + /** Slashed Zero: Replaces default zero with a slashed zero for better distinction between "0" and "O" */ + zero?: boolean } export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - styleSet: StyleSets, - style: Styles, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + styleSet: StyleSets, + style: Styles, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - styleSet: StyleSets, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + styleSet: StyleSets, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - style: Styles, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + style: Styles, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - styleSetStyleOrProperties?: StyleSets | Styles | TextProperties, - styleOrProperties?: Styles | TextProperties, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + styleSetStyleOrProperties?: StyleSets | Styles | TextProperties, + styleOrProperties?: Styles | TextProperties, + properties?: TextProperties ) { - let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) + let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) - if (typeof styleSetStyleOrProperties === "object") { - properties = styleSetStyleOrProperties - } - if (typeof styleOrProperties === "object") { - properties = styleOrProperties - } + if (typeof styleSetStyleOrProperties === "object") { + properties = styleSetStyleOrProperties + } + if (typeof styleOrProperties === "object") { + properties = styleOrProperties + } - let size = fontSizes[properties?.size || "sm"] - let color = properties?.color || style.foreground + let size = fontSizes[properties?.size || "sm"] + let color = properties?.color || style.foreground - return { - family: fontFamilies[fontFamily], - ...properties, - color, - size, - } + return { + family: fontFamilies[fontFamily], + ...properties, + color, + size, + } } export interface Border { - color: string - width: number - top?: boolean - bottom?: boolean - left?: boolean - right?: boolean - overlay?: boolean + color: string + width: number + top?: boolean + bottom?: boolean + left?: boolean + right?: boolean + overlay?: boolean } export interface BorderProperties { - width?: number - top?: boolean - bottom?: boolean - left?: boolean - right?: boolean - overlay?: boolean + width?: number + top?: boolean + bottom?: boolean + left?: boolean + right?: boolean + overlay?: boolean } export function border( - layer: Layer, - styleSet: StyleSets, - style: Styles, - properties?: BorderProperties + layer: Layer, + styleSet: StyleSets, + style: Styles, + properties?: BorderProperties ): Border export function border( - layer: Layer, - styleSet: StyleSets, - properties?: BorderProperties + layer: Layer, + styleSet: StyleSets, + properties?: BorderProperties ): Border export function border( - layer: Layer, - style: Styles, - properties?: BorderProperties + layer: Layer, + style: Styles, + properties?: BorderProperties ): Border export function border(layer: Layer, properties?: BorderProperties): Border export function border( - layer: Layer, - styleSetStyleOrProperties?: StyleSets | Styles | BorderProperties, - styleOrProperties?: Styles | BorderProperties, - properties?: BorderProperties + layer: Layer, + styleSetStyleOrProperties?: StyleSets | Styles | BorderProperties, + styleOrProperties?: Styles | BorderProperties, + properties?: BorderProperties ): Border { - let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) + let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) - if (typeof styleSetStyleOrProperties === "object") { - properties = styleSetStyleOrProperties - } - if (typeof styleOrProperties === "object") { - properties = styleOrProperties - } + if (typeof styleSetStyleOrProperties === "object") { + properties = styleSetStyleOrProperties + } + if (typeof styleOrProperties === "object") { + properties = styleOrProperties + } - return { - color: style.border, - width: 1, - ...properties, - } + return { + color: style.border, + width: 1, + ...properties, + } } export function svg( - color: string, - asset: String, - width: Number, - height: Number + color: string, + asset: String, + width: Number, + height: Number ) { - return { - color, - asset, - dimensions: { - width, - height, - }, - } + return { + color, + asset, + dimensions: { + width, + height, + }, + } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index a597e44d9f..b3e30f4aa7 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -1,182 +1,206 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, foreground, text } from "./components" - +import { toggleable } from "./toggle" +import { interactive } from "./interactive" export default function contactsPanel(colorScheme: ColorScheme) { - const nameMargin = 8 - const sidePadding = 12 + const nameMargin = 8 + const sidePadding = 12 - let layer = colorScheme.middle + let layer = colorScheme.middle - const contactButton = { - background: background(layer, "on"), - color: foreground(layer, "on"), - iconWidth: 8, - buttonWidth: 16, - cornerRadius: 8, - } - const projectRow = { - guestAvatarSpacing: 4, - height: 24, - guestAvatar: { - cornerRadius: 8, - width: 14, + const contactButton = { + background: background(layer, "on"), + color: foreground(layer, "on"), + iconWidth: 8, + buttonWidth: 16, + cornerRadius: 8, + } + const projectRow = { + guestAvatarSpacing: 4, + height: 24, + guestAvatar: { + cornerRadius: 8, + width: 14, + }, + name: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + right: 6, + }, + }, + guests: { + margin: { + left: nameMargin, + right: nameMargin, + }, + }, + padding: { + left: sidePadding, + right: sidePadding, + }, + } + + return { + background: background(layer), + padding: { top: 12 }, + userQueryEditor: { + background: background(layer, "on"), + cornerRadius: 6, + text: text(layer, "mono", "on"), + placeholderText: text(layer, "mono", "on", "disabled", { + size: "xs", + }), + selection: colorScheme.players[0], + border: border(layer, "on"), + padding: { + bottom: 4, + left: 8, + right: 8, + top: 4, + }, + margin: { + left: 6, + }, + }, + userQueryEditorHeight: 33, + addContactButton: { + margin: { left: 6, right: 12 }, + color: foreground(layer, "on"), + buttonWidth: 28, + iconWidth: 16, + }, + rowHeight: 28, + sectionIconSize: 8, + headerRow: toggleable(interactive({ + ...text(layer, "mono", { size: "sm" }), + margin: { top: 14 }, + padding: { + left: sidePadding, + right: sidePadding, + }, + background: background(layer, "default"),// posiewic: breaking change + }, {}), + { + default: { + ...text(layer, "mono", "active", { size: "sm" }), + background: background(layer, "active"), }, - name: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - right: 6, - }, - }, - guests: { - margin: { - left: nameMargin, - right: nameMargin, - }, - }, - padding: { + }), + leaveCall: interactive({ + background: background(layer), + border: border(layer), + cornerRadius: 6, + margin: { + top: 1, + }, + padding: { + top: 1, + bottom: 1, + left: 7, + right: 7, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + }, + { + hover: { + ...text(layer, "sans", "hovered", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "hovered"), + } + } + ), + contactRow: { + inactive: { + default: { + padding: { left: sidePadding, right: sidePadding, + } }, - } + }, + active: { + default: { + background: background(layer, "active"), + padding: { + left: sidePadding, + right: sidePadding, + } + } + }, + }, - return { - background: background(layer), - padding: { top: 12 }, - userQueryEditor: { - background: background(layer, "on"), - cornerRadius: 6, - text: text(layer, "mono", "on"), - placeholderText: text(layer, "mono", "on", "disabled", { - size: "xs", - }), - selection: colorScheme.players[0], - border: border(layer, "on"), - padding: { - bottom: 4, - left: 8, - right: 8, - top: 4, - }, - margin: { - left: 6, - }, + contactAvatar: { + cornerRadius: 10, + width: 18, + }, + contactStatusFree: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "positive"), + }, + contactStatusBusy: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "negative"), + }, + contactUsername: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + }, + }, + contactButtonSpacing: nameMargin, + contactButton: interactive( + contactButton, + { + hover: { + background: background(layer, "hovered"), }, - userQueryEditorHeight: 33, - addContactButton: { - margin: { left: 6, right: 12 }, - color: foreground(layer, "on"), - buttonWidth: 28, - iconWidth: 16, + }), + disabledButton: { + ...contactButton, + background: background(layer, "on"), + color: foreground(layer, "on"), + }, + callingIndicator: { + ...text(layer, "mono", "variant", { size: "xs" }), + }, + treeBranch: toggleable(interactive({ + color: borderColor(layer), + width: 1, + }, + { + hover: { + color: borderColor(layer), }, - rowHeight: 28, - sectionIconSize: 8, - headerRow: { - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, - }, - active: { - ...text(layer, "mono", "active", { size: "sm" }), - background: background(layer, "active"), - }, + }), + { + default: { + color: borderColor(layer), }, - leaveCall: { - background: background(layer), - border: border(layer), - cornerRadius: 6, - margin: { - top: 1, - }, - padding: { - top: 1, - bottom: 1, - left: 7, - right: 7, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - hover: { - ...text(layer, "sans", "hovered", { size: "xs" }), - background: background(layer, "hovered"), - border: border(layer, "hovered"), - }, - }, - contactRow: { - padding: { - left: sidePadding, - right: sidePadding, - }, - active: { - background: background(layer, "active"), - }, - }, - contactAvatar: { - cornerRadius: 10, - width: 18, - }, - contactStatusFree: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "positive"), - }, - contactStatusBusy: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "negative"), - }, - contactUsername: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - }, - }, - contactButtonSpacing: nameMargin, - contactButton: { - ...contactButton, - hover: { - background: background(layer, "hovered"), - }, - }, - disabledButton: { - ...contactButton, - background: background(layer, "on"), - color: foreground(layer, "on"), - }, - callingIndicator: { - ...text(layer, "mono", "variant", { size: "xs" }), - }, - treeBranch: { - color: borderColor(layer), - width: 1, - hover: { - color: borderColor(layer), - }, - active: { - color: borderColor(layer), - }, - }, - projectRow: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, - }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), - }, - hover: { - background: background(layer, "hovered"), - }, - active: { - background: background(layer, "active"), - }, - }, - } + } + ), + projectRow: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, + }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), + }, + hover: { + background: background(layer, "hovered"), + }, + active: { + background: background(layer, "active"), + }, + }, + } } diff --git a/styles/src/styleTree/contactNotification.ts b/styles/src/styleTree/contactNotification.ts index 85a0b9d0de..edef8dac20 100644 --- a/styles/src/styleTree/contactNotification.ts +++ b/styles/src/styleTree/contactNotification.ts @@ -1,45 +1,52 @@ import { ColorScheme } from "../theme/colorScheme" import { background, foreground, text } from "./components" - +import { interactive } from "./interactive" const avatarSize = 12 const headerPadding = 8 export default function contactNotification(colorScheme: ColorScheme): Object { - let layer = colorScheme.lowest - return { - headerAvatar: { - height: avatarSize, - width: avatarSize, - cornerRadius: 6, + let layer = colorScheme.lowest + return { + headerAvatar: { + height: avatarSize, + width: avatarSize, + cornerRadius: 6, + }, + headerMessage: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, right: headerPadding }, + }, + headerHeight: 18, + bodyMessage: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: avatarSize + headerPadding, top: 6, bottom: 6 }, + }, + button: + interactive({ + ...text(layer, "sans", "on", { size: "xs" }), + background: background(layer, "on"), + padding: 4, + cornerRadius: 6, + margin: { left: 6 } + }, + + { + hover: { + background: background(layer, "on", "hovered"), + } + }), + + dismissButton: { + default: { + color: foreground(layer, "variant"), + iconWidth: 8, + iconHeight: 8, + buttonWidth: 8, + buttonHeight: 8, + hover: { + color: foreground(layer, "hovered"), }, - headerMessage: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, right: headerPadding }, - }, - headerHeight: 18, - bodyMessage: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: avatarSize + headerPadding, top: 6, bottom: 6 }, - }, - button: { - ...text(layer, "sans", "on", { size: "xs" }), - background: background(layer, "on"), - padding: 4, - cornerRadius: 6, - margin: { left: 6 }, - hover: { - background: background(layer, "on", "hovered"), - }, - }, - dismissButton: { - color: foreground(layer, "variant"), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - hover: { - color: foreground(layer, "hovered"), - }, - }, - } + } + }, + } } diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index f14cd90219..b030d27972 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -1,49 +1,54 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, text } from "./components" +import { interactive } from "./interactive" +import { toggleable } from "./toggle" export default function contextMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle - return { - background: background(layer), - cornerRadius: 10, - padding: 4, - shadow: colorScheme.popoverShadow, - border: border(layer), - keystrokeMargin: 30, - item: { - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "variant", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - hover: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "hovered", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - }, - active: { - background: background(layer, "active"), - }, - activeHover: { - background: background(layer, "active"), - }, + let layer = colorScheme.middle + return { + background: background(layer), + cornerRadius: 10, + padding: 4, + shadow: colorScheme.popoverShadow, + border: border(layer), + keystrokeMargin: 30, + item: toggleable(interactive({ + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + } + }, { + hover: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "hovered", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, }, - separator: { - background: borderColor(layer), - margin: { top: 2, bottom: 2 }, - }, - } + } + }), { + default: { + background: background(layer, "active"), + }, + hover: { + background: background(layer, "active"), + }, + }), + + separator: { + background: borderColor(layer), + margin: { top: 2, bottom: 2 }, + }, + } } diff --git a/styles/src/styleTree/copilot.ts b/styles/src/styleTree/copilot.ts index 8614cb6976..090d05eaee 100644 --- a/styles/src/styleTree/copilot.ts +++ b/styles/src/styleTree/copilot.ts @@ -1,267 +1,278 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, svg, text } from "./components" - +import { interactive } from "./interactive" export default function copilot(colorScheme: ColorScheme) { - let layer = colorScheme.middle + let layer = colorScheme.middle - let content_width = 264 + let content_width = 264 - let ctaButton = { - // Copied from welcome screen. FIXME: Move this into a ZDS component - background: background(layer), - border: border(layer, "default"), - cornerRadius: 4, - margin: { + let ctaButton = + // Copied from welcome screen. FIXME: Move this into a ZDS component + interactive({ + background: background(layer), + border: border(layer, "default"), + cornerRadius: 4, + margin: { + top: 4, + bottom: 4, + left: 8, + right: 8, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }) + }, + { + hover: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + }); + + return { + outLinkIcon: + interactive({ + icon: svg( + foreground(layer, "variant"), + "icons/link_out_12.svg", + 12, + 12 + ), + container: { + cornerRadius: 6, + padding: { left: 6 }, + }, + }, + { + hover: { + icon: { + color: + foreground(layer, "hovered") + } + }, + }), + + modal: { + titleText: { + default: { + ...text(layer, "sans", { size: "xs", weight: "bold" }) + } + }, + titlebar: { + background: background(colorScheme.lowest), + border: border(layer, "active"), + padding: { + top: 4, + bottom: 4, + left: 8, + right: 8, + }, + }, + container: { + background: background(colorScheme.lowest), + padding: { + top: 0, + left: 0, + right: 0, + bottom: 8, + }, + }, + closeIcon: interactive( + { + icon: svg( + foreground(layer, "variant"), + "icons/x_mark_8.svg", + 8, + 8 + ), + container: { + cornerRadius: 2, + padding: { + top: 4, + bottom: 4, + left: 4, + right: 4, + }, + margin: { + right: 0, + }, + } + }, + { + hover: { + icon: svg( + foreground(layer, "on"), + "icons/x_mark_8.svg", + 8, + 8 + ), + }, + clicked: { + icon: svg( + foreground(layer, "base"), + "icons/x_mark_8.svg", + 8, + 8 + ), + }, + }), + dimensions: { + width: 280, + height: 280, + }, + }, + + auth: { + content_width, + + ctaButton, + + header: { + icon: svg( + foreground(layer, "default"), + "icons/zed_plus_copilot_32.svg", + 92, + 32 + ), + container: { + margin: { + top: 35, + bottom: 5, + left: 0, + right: 0, + }, + }, + }, + + prompting: { + subheading: { + ...text(layer, "sans", { size: "xs" }), + margin: { + top: 6, + bottom: 12, + left: 0, + right: 0, + }, + }, + + hint: { + ...text(layer, "sans", { size: "xs", color: "#838994" }), + margin: { + top: 6, + bottom: 2, + }, + }, + + deviceCode: { + text: text(layer, "mono", { size: "sm" }), + cta: { + ...ctaButton, + background: background(colorScheme.lowest), + border: border(colorScheme.lowest, "inverted"), + padding: { + top: 0, + bottom: 0, + left: 16, + right: 16, + }, + margin: { + left: 16, + right: 16, + }, + }, + left: content_width / 2, + leftContainer: { + padding: { + top: 3, + bottom: 3, + left: 0, + right: 6, + }, + }, + right: (content_width * 1) / 3, + rightContainer: interactive({ + border: border(colorScheme.lowest, "inverted", { + bottom: false, + right: false, + top: false, + left: true, + }), + padding: { + top: 3, + bottom: 5, + left: 8, + right: 0, + } + }, { + hover: { + border: border(layer, "active", { + bottom: false, + right: false, + top: false, + left: true, + }), + }, + }) + }, + }, + + notAuthorized: { + subheading: { + ...text(layer, "sans", { size: "xs" }), + + margin: { + top: 16, + bottom: 16, + left: 0, + right: 0, + }, + }, + + warning: { + ...text(layer, "sans", { + size: "xs", + color: foreground(layer, "warning"), + }), + border: border(layer, "warning"), + background: background(layer, "warning"), + cornerRadius: 2, + padding: { top: 4, + left: 4, bottom: 4, + right: 4, + }, + margin: { + bottom: 16, left: 8, right: 8, + }, }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }), - hover: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - } + }, - return { - outLinkIcon: { - icon: svg( - foreground(layer, "variant"), - "icons/link_out_12.svg", - 12, - 12 - ), - container: { - cornerRadius: 6, - padding: { left: 6 }, - }, - hover: { - icon: svg( - foreground(layer, "hovered"), - "icons/link_out_12.svg", - 12, - 12 - ), - }, - }, - modal: { - titleText: { - ...text(layer, "sans", { size: "xs", weight: "bold" }), - }, - titlebar: { - background: background(colorScheme.lowest), - border: border(layer, "active"), - padding: { - top: 4, - bottom: 4, - left: 8, - right: 8, - }, - }, - container: { - background: background(colorScheme.lowest), - padding: { - top: 0, - left: 0, - right: 0, - bottom: 8, - }, - }, - closeIcon: { - icon: svg( - foreground(layer, "variant"), - "icons/x_mark_8.svg", - 8, - 8 - ), - container: { - cornerRadius: 2, - padding: { - top: 4, - bottom: 4, - left: 4, - right: 4, - }, - margin: { - right: 0, - }, - }, - hover: { - icon: svg( - foreground(layer, "on"), - "icons/x_mark_8.svg", - 8, - 8 - ), - }, - clicked: { - icon: svg( - foreground(layer, "base"), - "icons/x_mark_8.svg", - 8, - 8 - ), - }, - }, - dimensions: { - width: 280, - height: 280, - }, + authorized: { + subheading: { + ...text(layer, "sans", { size: "xs" }), + + margin: { + top: 16, + bottom: 16, + }, }, - auth: { - content_width, - - ctaButton, - - header: { - icon: svg( - foreground(layer, "default"), - "icons/zed_plus_copilot_32.svg", - 92, - 32 - ), - container: { - margin: { - top: 35, - bottom: 5, - left: 0, - right: 0, - }, - }, - }, - - prompting: { - subheading: { - ...text(layer, "sans", { size: "xs" }), - margin: { - top: 6, - bottom: 12, - left: 0, - right: 0, - }, - }, - - hint: { - ...text(layer, "sans", { size: "xs", color: "#838994" }), - margin: { - top: 6, - bottom: 2, - }, - }, - - deviceCode: { - text: text(layer, "mono", { size: "sm" }), - cta: { - ...ctaButton, - background: background(colorScheme.lowest), - border: border(colorScheme.lowest, "inverted"), - padding: { - top: 0, - bottom: 0, - left: 16, - right: 16, - }, - margin: { - left: 16, - right: 16, - }, - }, - left: content_width / 2, - leftContainer: { - padding: { - top: 3, - bottom: 3, - left: 0, - right: 6, - }, - }, - right: (content_width * 1) / 3, - rightContainer: { - border: border(colorScheme.lowest, "inverted", { - bottom: false, - right: false, - top: false, - left: true, - }), - padding: { - top: 3, - bottom: 5, - left: 8, - right: 0, - }, - hover: { - border: border(layer, "active", { - bottom: false, - right: false, - top: false, - left: true, - }), - }, - }, - }, - }, - - notAuthorized: { - subheading: { - ...text(layer, "sans", { size: "xs" }), - - margin: { - top: 16, - bottom: 16, - left: 0, - right: 0, - }, - }, - - warning: { - ...text(layer, "sans", { - size: "xs", - color: foreground(layer, "warning"), - }), - border: border(layer, "warning"), - background: background(layer, "warning"), - cornerRadius: 2, - padding: { - top: 4, - left: 4, - bottom: 4, - right: 4, - }, - margin: { - bottom: 16, - left: 8, - right: 8, - }, - }, - }, - - authorized: { - subheading: { - ...text(layer, "sans", { size: "xs" }), - - margin: { - top: 16, - bottom: 16, - }, - }, - - hint: { - ...text(layer, "sans", { size: "xs", color: "#838994" }), - margin: { - top: 24, - bottom: 4, - }, - }, - }, + hint: { + ...text(layer, "sans", { size: "xs", color: "#838994" }), + margin: { + top: 24, + bottom: 4, + }, }, - } + }, + }, + } } diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 55f3da6e90..ac7447de42 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -4,275 +4,284 @@ import { background, border, borderColor, foreground, text } from "./components" import hoverPopover from "./hoverPopover" import { buildSyntax } from "../theme/syntax" +import { interactive } from "./interactive" +import { toggleable } from "./toggle" export default function editor(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.highest + let layer = colorScheme.highest - const autocompleteItem = { - cornerRadius: 6, - padding: { - bottom: 2, - left: 6, - right: 6, - top: 2, - }, - } - - function diagnostic(layer: Layer, styleSet: StyleSets) { - return { - textScaleFactor: 0.857, - header: { - border: border(layer, { - top: true, - }), - }, - message: { - text: text(layer, "sans", styleSet, "default", { size: "sm" }), - highlightText: text(layer, "sans", styleSet, "default", { - size: "sm", - weight: "bold", - }), - }, - } - } - - const syntax = buildSyntax(colorScheme) + const autocompleteItem = { + cornerRadius: 6, + padding: { + bottom: 2, + left: 6, + right: 6, + top: 2, + }, + } + function diagnostic(layer: Layer, styleSet: StyleSets) { return { - textColor: syntax.primary.color, - background: background(layer), - activeLineBackground: withOpacity(background(layer, "on"), 0.75), - highlightedLineBackground: background(layer, "on"), - // Inline autocomplete suggestions, Co-pilot suggestions, etc. - suggestion: syntax.predictive, - codeActions: { - indicator: { - color: foreground(layer, "variant"), - - clicked: { - color: foreground(layer, "base"), - }, - hover: { - color: foreground(layer, "on"), - }, - active: { - color: foreground(layer, "on"), - }, - }, - verticalScale: 0.55, - }, - folds: { - iconMarginScale: 2.5, - foldedIcon: "icons/chevron_right_8.svg", - foldableIcon: "icons/chevron_down_8.svg", - indicator: { - color: foreground(layer, "variant"), - - clicked: { - color: foreground(layer, "base"), - }, - hover: { - color: foreground(layer, "on"), - }, - active: { - color: foreground(layer, "on"), - }, - }, - ellipses: { - textColor: colorScheme.ramps.neutral(0.71).hex(), - cornerRadiusFactor: 0.15, - background: { - // Copied from hover_popover highlight - color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), - - hover: { - color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), - }, - - clicked: { - color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), - }, - }, - }, - foldBackground: foreground(layer, "variant"), - }, - diff: { - deleted: isLight - ? colorScheme.ramps.red(0.5).hex() - : colorScheme.ramps.red(0.4).hex(), - modified: isLight - ? colorScheme.ramps.yellow(0.5).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.4).hex() - : colorScheme.ramps.green(0.5).hex(), - removedWidthEm: 0.275, - widthEm: 0.15, - cornerRadius: 0.05, - }, - /** Highlights matching occurrences of what is under the cursor - * as well as matched brackets - */ - documentHighlightReadBackground: withOpacity( - foreground(layer, "accent"), - 0.1 - ), - documentHighlightWriteBackground: colorScheme.ramps - .neutral(0.5) - .alpha(0.4) - .hex(), // TODO: This was blend * 2 - errorColor: background(layer, "negative"), - gutterBackground: background(layer), - gutterPaddingFactor: 3.5, - lineNumber: withOpacity(foreground(layer), 0.35), - lineNumberActive: foreground(layer), - renameFade: 0.6, - unnecessaryCodeFade: 0.5, - selection: colorScheme.players[0], - whitespace: colorScheme.ramps.neutral(0.5).hex(), - guestSelections: [ - colorScheme.players[1], - colorScheme.players[2], - colorScheme.players[3], - colorScheme.players[4], - colorScheme.players[5], - colorScheme.players[6], - colorScheme.players[7], - ], - autocomplete: { - background: background(colorScheme.middle), - cornerRadius: 8, - padding: 4, - margin: { - left: -14, - }, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - matchHighlight: foreground(colorScheme.middle, "accent"), - item: autocompleteItem, - hoveredItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "hovered" - ), - background: background(colorScheme.middle, "hovered"), - }, - selectedItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "active" - ), - background: background(colorScheme.middle, "active"), - }, - }, - diagnosticHeader: { - background: background(colorScheme.middle), - iconWidthFactor: 1.5, - textScaleFactor: 0.857, - border: border(colorScheme.middle, { - bottom: true, - top: true, - }), - code: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 10, - }, - }, - source: { - text: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - }, - message: { - highlightText: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - text: text(colorScheme.middle, "sans", { size: "sm" }), - }, - }, - diagnosticPathHeader: { - background: background(colorScheme.middle), - textScaleFactor: 0.857, - filename: text(colorScheme.middle, "mono", { size: "sm" }), - path: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 12, - }, - }, - }, - errorDiagnostic: diagnostic(colorScheme.middle, "negative"), - warningDiagnostic: diagnostic(colorScheme.middle, "warning"), - informationDiagnostic: diagnostic(colorScheme.middle, "accent"), - hintDiagnostic: diagnostic(colorScheme.middle, "warning"), - invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), - hoverPopover: hoverPopover(colorScheme), - linkDefinition: { - color: syntax.linkUri.color, - underline: syntax.linkUri.underline, - }, - jumpIcon: { - color: foreground(layer, "on"), - iconWidth: 20, - buttonWidth: 20, - cornerRadius: 6, - padding: { - top: 6, - bottom: 6, - left: 6, - right: 6, - }, - hover: { - background: background(layer, "on", "hovered"), - }, - }, - scrollbar: { - width: 12, - minHeightFactor: 1.0, - track: { - border: border(layer, "variant", { left: true }), - }, - thumb: { - background: withOpacity(background(layer, "inverted"), 0.3), - border: { - width: 1, - color: borderColor(layer, "variant"), - top: false, - right: true, - left: true, - bottom: false, - }, - }, - git: { - deleted: isLight - ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), - modified: isLight - ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), - inserted: isLight - ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), - }, - }, - compositionMark: { - underline: { - thickness: 1.0, - color: borderColor(layer), - }, - }, - syntax, + textScaleFactor: 0.857, + header: { + border: border(layer, { + top: true, + }), + }, + message: { + text: text(layer, "sans", styleSet, "default", { size: "sm" }), + highlightText: text(layer, "sans", styleSet, "default", { + size: "sm", + weight: "bold", + }), + }, } + } + + const syntax = buildSyntax(colorScheme) + + return { + textColor: syntax.primary.color, + background: background(layer), + activeLineBackground: withOpacity(background(layer, "on"), 0.75), + highlightedLineBackground: background(layer, "on"), + // Inline autocomplete suggestions, Co-pilot suggestions, etc. + suggestion: syntax.predictive, + codeActions: { + indicator: toggleable(interactive({ + color: foreground(layer, "variant"), + }, { + clicked: { + color: foreground(layer, "base"), + }, + hover: { + color: foreground(layer, "on"), + }, + }), + { + default: { + color: foreground(layer, "on"), + } + }), + + verticalScale: 0.55, + }, + folds: { + iconMarginScale: 2.5, + foldedIcon: "icons/chevron_right_8.svg", + foldableIcon: "icons/chevron_down_8.svg", + indicator: toggleable(interactive({ + color: foreground(layer, "variant"), + }, { + clicked: { + color: foreground(layer, "base"), + }, + hover: { + color: foreground(layer, "on"), + }, + }), + { + default: { + color: foreground(layer, "on"), + } + }), + ellipses: { + textColor: colorScheme.ramps.neutral(0.71).hex(), + cornerRadiusFactor: 0.15, + background: { + // Copied from hover_popover highlight + default: { color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex() }, + + hover: { + color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), + }, + + clicked: { + color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), + }, + }, + }, + foldBackground: foreground(layer, "variant"), + }, + diff: { + deleted: isLight + ? colorScheme.ramps.red(0.5).hex() + : colorScheme.ramps.red(0.4).hex(), + modified: isLight + ? colorScheme.ramps.yellow(0.5).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.4).hex() + : colorScheme.ramps.green(0.5).hex(), + removedWidthEm: 0.275, + widthEm: 0.15, + cornerRadius: 0.05, + }, + /** Highlights matching occurrences of what is under the cursor + * as well as matched brackets + */ + documentHighlightReadBackground: withOpacity( + foreground(layer, "accent"), + 0.1 + ), + documentHighlightWriteBackground: colorScheme.ramps + .neutral(0.5) + .alpha(0.4) + .hex(), // TODO: This was blend * 2 + errorColor: background(layer, "negative"), + gutterBackground: background(layer), + gutterPaddingFactor: 3.5, + lineNumber: withOpacity(foreground(layer), 0.35), + lineNumberActive: foreground(layer), + renameFade: 0.6, + unnecessaryCodeFade: 0.5, + selection: colorScheme.players[0], + whitespace: colorScheme.ramps.neutral(0.5).hex(), + guestSelections: [ + colorScheme.players[1], + colorScheme.players[2], + colorScheme.players[3], + colorScheme.players[4], + colorScheme.players[5], + colorScheme.players[6], + colorScheme.players[7], + ], + autocomplete: { + background: background(colorScheme.middle), + cornerRadius: 8, + padding: 4, + margin: { + left: -14, + }, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + matchHighlight: foreground(colorScheme.middle, "accent"), + item: autocompleteItem, + hoveredItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "hovered" + ), + background: background(colorScheme.middle, "hovered"), + }, + selectedItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "active" + ), + background: background(colorScheme.middle, "active"), + }, + }, + diagnosticHeader: { + background: background(colorScheme.middle), + iconWidthFactor: 1.5, + textScaleFactor: 0.857, + border: border(colorScheme.middle, { + bottom: true, + top: true, + }), + code: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 10, + }, + }, + source: { + text: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + }, + message: { + highlightText: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + text: text(colorScheme.middle, "sans", { size: "sm" }), + }, + }, + diagnosticPathHeader: { + background: background(colorScheme.middle), + textScaleFactor: 0.857, + filename: text(colorScheme.middle, "mono", { size: "sm" }), + path: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 12, + }, + }, + }, + errorDiagnostic: diagnostic(colorScheme.middle, "negative"), + warningDiagnostic: diagnostic(colorScheme.middle, "warning"), + informationDiagnostic: diagnostic(colorScheme.middle, "accent"), + hintDiagnostic: diagnostic(colorScheme.middle, "warning"), + invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), + hoverPopover: hoverPopover(colorScheme), + linkDefinition: { + color: syntax.linkUri.color, + underline: syntax.linkUri.underline, + }, + jumpIcon: interactive({ + color: foreground(layer, "on"), + iconWidth: 20, + buttonWidth: 20, + cornerRadius: 6, + padding: { + top: 6, + bottom: 6, + left: 6, + right: 6, + } + }, { + hover: { + background: background(layer, "on", "hovered"), + } + }), + + scrollbar: { + width: 12, + minHeightFactor: 1.0, + track: { + border: border(layer, "variant", { left: true }), + }, + thumb: { + background: withOpacity(background(layer, "inverted"), 0.3), + border: { + width: 1, + color: borderColor(layer, "variant"), + top: false, + right: true, + left: true, + bottom: false, + }, + }, + git: { + deleted: isLight + ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), + modified: isLight + ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), + inserted: isLight + ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), + }, + }, + compositionMark: { + underline: { + thickness: 1.0, + color: borderColor(layer), + }, + }, + syntax, + } } diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index d84bd6fc7a..ecf34a9927 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -1,82 +1,86 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, text } from "./components" +import { toggleable } from "./toggle" +import { interactive } from "./interactive" export default function picker(colorScheme: ColorScheme): any { - let layer = colorScheme.lowest - const container = { - background: background(layer), - border: border(layer), - shadow: colorScheme.modalShadow, - cornerRadius: 12, - padding: { - bottom: 4, - }, - } - const inputEditor = { - placeholderText: text(layer, "sans", "on", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "on"), - border: border(layer, { bottom: true }), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - margin: { - bottom: 4, - }, - } - const emptyInputEditor: any = { ...inputEditor } - delete emptyInputEditor.border - delete emptyInputEditor.margin + let layer = colorScheme.lowest + const container = { + background: background(layer), + border: border(layer), + shadow: colorScheme.modalShadow, + cornerRadius: 12, + padding: { + bottom: 4, + }, + } + const inputEditor = { + placeholderText: text(layer, "sans", "on", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "on"), + border: border(layer, { bottom: true }), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + margin: { + bottom: 4, + }, + } + const emptyInputEditor: any = { ...inputEditor } + delete emptyInputEditor.border + delete emptyInputEditor.margin - return { - ...container, - emptyContainer: { - ...container, - padding: {}, - }, - item: { - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, - }, - margin: { - top: 1, - left: 4, - right: 4, - }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { weight: "bold" }), - active: { - background: withOpacity( - background(layer, "base", "active"), - 0.5 - ), - text: text(layer, "sans", "base", "active"), - highlightText: text(layer, "sans", "accent", { - weight: "bold", - }), - }, - hover: { - background: withOpacity(background(layer, "hovered"), 0.5), - }, - }, - inputEditor, - emptyInputEditor, - noMatches: { - text: text(layer, "sans", "variant"), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - }, - } + return { + ...container, + emptyContainer: { + ...container, + padding: {}, + }, + item: toggleable(interactive({ + padding: { + bottom: 4, + left: 12, + right: 12, + top: 4, + }, + margin: { + top: 1, + left: 4, + right: 4, + }, + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { weight: "bold" }), + }, { + hover: { + background: withOpacity(background(layer, "hovered"), 0.5), + } + }), + { + default: { + background: withOpacity( + background(layer, "base", "active"), + 0.5 + ), + //text: text(layer, "sans", "base", "active"), + } + }), + + + inputEditor, + emptyInputEditor, + noMatches: { + text: text(layer, "sans", "variant"), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + }, + } } diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index a86ae010b6..57abd0dafc 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -1,107 +1,119 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" - +import { interactive } from "./interactive" +import { toggleable } from "./toggle" export default function projectPanel(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.middle + let layer = colorScheme.middle - let baseEntry = { - height: 22, + let baseEntry = { + height: 22, + iconColor: foreground(layer, "variant"), + iconSize: 7, + iconSpacing: 5, + } + + let status = { + git: { + modified: isLight + ? colorScheme.ramps.yellow(0.6).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.45).hex() + : colorScheme.ramps.green(0.5).hex(), + conflict: isLight + ? colorScheme.ramps.red(0.6).hex() + : colorScheme.ramps.red(0.5).hex(), + }, + } + + let entry = toggleable(interactive({ + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, + { + hover: { + background: background(layer, "variant", "hovered"), + } + }), + { + default: { + /*background: colorScheme.isLight + ? withOpacity(background(layer, "active"), 0.5) + : background(layer, "active") ,*/ // todo posiewic + text: text(layer, "mono", "active", { size: "sm" }), + }, + hover: { + //background: background(layer, "active"), + text: text(layer, "mono", "active", { size: "sm" }), + }, + + }); + + return { + openProjectButton: interactive({ + background: background(layer), + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 16, + left: 16, + right: 16, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }) + }, { + hover: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + }), + background: background(layer), + padding: { left: 6, right: 6, top: 0, bottom: 6 }, + indentWidth: 12, + entry, + draggedEntry: { + ...baseEntry, + text: text(layer, "mono", "on", { size: "sm" }), + background: withOpacity(background(layer, "on"), 0.9), + border: border(layer), + status, + }, + ignoredEntry: { + ...entry, + iconColor: foreground(layer, "disabled"), + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, iconColor: foreground(layer, "variant"), - iconSize: 7, - iconSpacing: 5, - } + }, + }, + cutEntry: { + ...entry, + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + default: { + ...entry.active.default, + background: background(layer, "active"), + text: text(layer, "mono", "disabled", { size: "sm" }), + }, - let status = { - git: { - modified: isLight - ? colorScheme.ramps.yellow(0.6).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.45).hex() - : colorScheme.ramps.green(0.5).hex(), - conflict: isLight - ? colorScheme.ramps.red(0.6).hex() - : colorScheme.ramps.red(0.5).hex(), - }, - } - - let entry = { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - hover: { - background: background(layer, "variant", "hovered"), - }, - active: { - background: colorScheme.isLight - ? withOpacity(background(layer, "active"), 0.5) - : background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), - }, - activeHover: { - background: background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), - }, - status, - } - - return { - openProjectButton: { - background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 16, - left: 16, - right: 16, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }), - hover: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - }, - background: background(layer), - padding: { left: 6, right: 6, top: 0, bottom: 6 }, - indentWidth: 12, - entry, - draggedEntry: { - ...baseEntry, - text: text(layer, "mono", "on", { size: "sm" }), - background: withOpacity(background(layer, "on"), 0.9), - border: border(layer), - status, - }, - ignoredEntry: { - ...entry, - iconColor: foreground(layer, "disabled"), - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - iconColor: foreground(layer, "variant"), - }, - }, - cutEntry: { - ...entry, - text: text(layer, "mono", "disabled"), - active: { - background: background(layer, "active"), - text: text(layer, "mono", "disabled", { size: "sm" }), - }, - }, - filenameEditor: { - background: background(layer, "on"), - text: text(layer, "mono", "on", { size: "sm" }), - selection: colorScheme.players[0], - }, - } + }, + }, + filenameEditor: { + background: background(layer, "on"), + text: text(layer, "mono", "on", { size: "sm" }), + selection: colorScheme.players[0], + }, + } } diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index a8d926f40e..66643dbde1 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -1,126 +1,135 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" - +import { interactive } from "./interactive" +import { toggleable } from "./toggle" export default function statusBar(colorScheme: ColorScheme) { - let layer = colorScheme.lowest + let layer = colorScheme.lowest - const statusContainer = { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 6, right: 6 }, - } + const statusContainer = { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 6, right: 6 }, + } - const diagnosticStatusContainer = { - cornerRadius: 6, - padding: { top: 1, bottom: 1, left: 6, right: 6 }, - } + const diagnosticStatusContainer = { + cornerRadius: 6, + padding: { top: 1, bottom: 1, left: 6, right: 6 }, + } - return { - height: 30, - itemSpacing: 8, - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, + return { + height: 30, + itemSpacing: 8, + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + border: border(layer, { top: true, overlay: true }), + cursorPosition: text(layer, "sans", "variant"), + activeLanguage: interactive({ + padding: { left: 6, right: 6 }, + ...text(layer, "sans", "variant") + }, + { + hover: { + ...text(layer, "sans", "on"), + } + }, + ), + autoUpdateProgressMessage: text(layer, "sans", "variant"), + autoUpdateDoneMessage: text(layer, "sans", "variant"), + lspStatus: interactive({ + ...diagnosticStatusContainer, + iconSpacing: 4, + iconWidth: 14, + height: 18, + message: text(layer, "sans"), + iconColor: foreground(layer) + }, + { + hover: { + message: text(layer, "sans"), + iconColor: foreground(layer), + background: background(layer, "hovered"), + } + }), + diagnosticMessage: interactive({ + ...text(layer, "sans") + }, + { hover: text(layer, "sans", "hovered") }, + ), + diagnosticSummary: + interactive({ + height: 20, + iconWidth: 16, + iconSpacing: 2, + summarySpacing: 6, + text: text(layer, "sans", { size: "sm" }), + iconColorOk: foreground(layer, "variant"), + iconColorWarning: foreground(layer, "warning"), + iconColorError: foreground(layer, "negative"), + containerOk: { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 7, right: 7 }, }, - border: border(layer, { top: true, overlay: true }), - cursorPosition: text(layer, "sans", "variant"), - activeLanguage: { - padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant"), - hover: { - ...text(layer, "sans", "on"), - }, + containerWarning: { + ...diagnosticStatusContainer, + background: background(layer, "warning"), + border: border(layer, "warning"), }, - autoUpdateProgressMessage: text(layer, "sans", "variant"), - autoUpdateDoneMessage: text(layer, "sans", "variant"), - lspStatus: { - ...diagnosticStatusContainer, - iconSpacing: 4, - iconWidth: 14, - height: 18, - message: text(layer, "sans"), - iconColor: foreground(layer), - hover: { - message: text(layer, "sans"), - iconColor: foreground(layer), - background: background(layer, "hovered"), - }, + containerError: { + ...diagnosticStatusContainer, + background: background(layer, "negative"), + border: border(layer, "negative"), + } + }, { + hover: { + iconColorOk: foreground(layer, "on"), + containerOk: { + background: background(layer, "on", "hovered"), + }, + containerWarning: { + background: background(layer, "warning", "hovered"), + border: border(layer, "warning", "hovered"), + }, + containerError: { + background: background(layer, "negative", "hovered"), + border: border(layer, "negative", "hovered"), + } + } + } + ), + panelButtons: { + groupLeft: {}, + groupBottom: {}, + groupRight: {}, + button: toggleable(interactive({ + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), }, - diagnosticMessage: { - ...text(layer, "sans"), - hover: text(layer, "sans", "hovered"), - }, - diagnosticSummary: { - height: 20, - iconWidth: 16, - iconSpacing: 2, - summarySpacing: 6, - text: text(layer, "sans", { size: "sm" }), - iconColorOk: foreground(layer, "variant"), - iconColorWarning: foreground(layer, "warning"), - iconColorError: foreground(layer, "negative"), - containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, - }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), - }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - }, - hover: { - iconColorOk: foreground(layer, "on"), - containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, - background: background(layer, "on", "hovered"), - }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), - }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), - }, - }, - }, - panelButtons: { - groupLeft: {}, - groupBottom: {}, - groupRight: {}, - button: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), - }, - hover: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - }, - active: { - iconColor: foreground(layer, "active"), - background: background(layer, "active"), - }, - }, - badge: { - cornerRadius: 3, - padding: 2, - margin: { bottom: -1, right: -1 }, - border: border(layer), - background: background(layer, "accent"), - }, - }, - } + }, { + hover: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), + } + }), + { + default: { + iconColor: foreground(layer, "active"), + background: background(layer, "active"), + } + }), + badge: { + cornerRadius: 3, + padding: 2, + margin: { bottom: -1, right: -1 }, + border: border(layer), + background: background(layer, "accent"), + }, + }, + } } diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index c5b397b34a..6799b0a9e3 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -1,109 +1,116 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, border, background, foreground } from "./components" +import { toggleable } from "./toggle" +import { interactive } from "./interactive" export default function tabBar(colorScheme: ColorScheme) { - const height = 32 + const height = 32 - let activeLayer = colorScheme.highest - let layer = colorScheme.middle + let activeLayer = colorScheme.highest + let layer = colorScheme.middle - const tab = { - height, - text: text(layer, "sans", "variant", { size: "sm" }), - background: background(layer), - border: border(layer, { - right: true, - bottom: true, - overlay: true, - }), - padding: { - left: 8, - right: 12, - }, - spacing: 8, + const tab = { + height, + text: text(layer, "sans", "variant", { size: "sm" }), + background: background(layer), + border: border(layer, { + right: true, + bottom: true, + overlay: true, + }), + padding: { + left: 8, + right: 12, + }, + spacing: 8, - // Tab type icons (e.g. Project Search) - typeIconWidth: 14, + // Tab type icons (e.g. Project Search) + typeIconWidth: 14, - // Close icons - closeIconWidth: 8, - iconClose: foreground(layer, "variant"), - iconCloseActive: foreground(layer, "hovered"), + // Close icons + closeIconWidth: 8, + iconClose: foreground(layer, "variant"), + iconCloseActive: foreground(layer, "hovered"), - // Indicators - iconConflict: foreground(layer, "warning"), - iconDirty: foreground(layer, "accent"), + // Indicators + iconConflict: foreground(layer, "warning"), + iconDirty: foreground(layer, "accent"), - // When two tabs of the same name are open, a label appears next to them - description: { - margin: { left: 8 }, - ...text(layer, "sans", "disabled", { size: "2xs" }), - }, - } + // When two tabs of the same name are open, a label appears next to them + description: { + margin: { left: 8 }, + ...text(layer, "sans", "disabled", { size: "2xs" }), + }, + } - const activePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(activeLayer, "sans", "active", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const activePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(activeLayer, "sans", "active", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const inactivePaneInactiveTab = { - ...tab, - background: background(layer), - text: text(layer, "sans", "variant", { size: "sm" }), - } + const inactivePaneInactiveTab = { + ...tab, + background: background(layer), + text: text(layer, "sans", "variant", { size: "sm" }), + } - const inactivePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(layer, "sans", "variant", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const inactivePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(layer, "sans", "variant", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const draggedTab = { - ...activePaneActiveTab, - background: withOpacity(tab.background, 0.9), - border: undefined as any, - shadow: colorScheme.popoverShadow, - } + const draggedTab = { + ...activePaneActiveTab, + background: withOpacity(tab.background, 0.9), + border: undefined as any, + shadow: colorScheme.popoverShadow, + } - return { - height, - background: background(layer), - activePane: { - activeTab: activePaneActiveTab, - inactiveTab: tab, - }, - inactivePane: { - activeTab: inactivePaneActiveTab, - inactiveTab: inactivePaneInactiveTab, - }, - draggedTab, - paneButton: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - hover: { - color: foreground(layer, "hovered"), - }, - active: { - color: foreground(layer, "accent"), - }, - }, - paneButtonContainer: { - background: tab.background, - border: { - ...tab.border, - right: false, - }, - }, - } + return { + height, + background: background(layer), + activePane: { + activeTab: activePaneActiveTab, + inactiveTab: tab, + }, + inactivePane: { + activeTab: inactivePaneActiveTab, + inactiveTab: inactivePaneInactiveTab, + }, + draggedTab, + paneButton: toggleable(interactive({ + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + { + hover: { + color: foreground(layer, "hovered"), + } + }), + { + default: { + color: foreground(layer, "accent"), + } + }, + ), + paneButtonContainer: { + background: tab.background, + border: { + ...tab.border, + right: false, + }, + }, + } } diff --git a/styles/src/styleTree/welcome.ts b/styles/src/styleTree/welcome.ts index 10e6e02b95..dbabc55383 100644 --- a/styles/src/styleTree/welcome.ts +++ b/styles/src/styleTree/welcome.ts @@ -1,129 +1,131 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { - border, - background, - foreground, - text, - TextProperties, - svg, + border, + background, + foreground, + text, + TextProperties, + svg, } from "./components" +import { interactive } from "./interactive" export default function welcome(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - let checkboxBase = { - cornerRadius: 4, - padding: { - left: 3, - right: 3, - top: 3, - bottom: 3, - }, - // shadow: colorScheme.popoverShadow, - border: border(layer), - margin: { - right: 8, - top: 5, - bottom: 5, - }, - } + let checkboxBase = { + cornerRadius: 4, + padding: { + left: 3, + right: 3, + top: 3, + bottom: 3, + }, + // shadow: colorScheme.popoverShadow, + border: border(layer), + margin: { + right: 8, + top: 5, + bottom: 5, + }, + } - let interactive_text_size: TextProperties = { size: "sm" } + let interactive_text_size: TextProperties = { size: "sm" } - return { - pageWidth: 320, - logo: svg(foreground(layer, "default"), "icons/logo_96.svg", 64, 64), - logoSubheading: { - ...text(layer, "sans", "variant", { size: "md" }), - margin: { - top: 10, - bottom: 7, - }, - }, - buttonGroup: { - margin: { - top: 8, - bottom: 16, - }, - }, - headingGroup: { - margin: { - top: 8, - bottom: 12, - }, - }, - checkboxGroup: { - border: border(layer, "variant"), - background: withOpacity(background(layer, "hovered"), 0.25), - cornerRadius: 4, - padding: { - left: 12, - top: 2, - bottom: 2, - }, - }, - button: { - background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 4, - bottom: 4, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", interactive_text_size), - hover: { - ...text(layer, "sans", "default", interactive_text_size), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - }, - usageNote: { - ...text(layer, "sans", "variant", { size: "2xs" }), - padding: { - top: -4, - }, - }, - checkboxContainer: { - margin: { - top: 4, - }, - padding: { - bottom: 8, - }, - }, - checkbox: { - label: { - ...text(layer, "sans", interactive_text_size), - // Also supports margin, container, border, etc. - }, - icon: svg(foreground(layer, "on"), "icons/check_12.svg", 12, 12), - default: { - ...checkboxBase, - background: background(layer, "default"), - border: border(layer, "active"), - }, - checked: { - ...checkboxBase, - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - hovered: { - ...checkboxBase, - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - hoveredAndChecked: { - ...checkboxBase, - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - }, - } + return { + pageWidth: 320, + logo: svg(foreground(layer, "default"), "icons/logo_96.svg", 64, 64), + logoSubheading: { + ...text(layer, "sans", "variant", { size: "md" }), + margin: { + top: 10, + bottom: 7, + }, + }, + buttonGroup: { + margin: { + top: 8, + bottom: 16, + }, + }, + headingGroup: { + margin: { + top: 8, + bottom: 12, + }, + }, + checkboxGroup: { + border: border(layer, "variant"), + background: withOpacity(background(layer, "hovered"), 0.25), + cornerRadius: 4, + padding: { + left: 12, + top: 2, + bottom: 2, + }, + }, + button: interactive({ + background: background(layer), + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 4, + bottom: 4, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", interactive_text_size) + }, { + hover: { + ...text(layer, "sans", "default", interactive_text_size), + background: background(layer, "hovered"), + } + }), + + usageNote: { + ...text(layer, "sans", "variant", { size: "2xs" }), + padding: { + top: -4, + }, + }, + checkboxContainer: { + margin: { + top: 4, + }, + padding: { + bottom: 8, + }, + }, + checkbox: { + label: { + ...text(layer, "sans", interactive_text_size), + // Also supports margin, container, border, etc. + }, + icon: svg(foreground(layer, "on"), "icons/check_12.svg", 12, 12), + default: { + ...checkboxBase, + background: background(layer, "default"), + border: border(layer, "active"), + }, + checked: { + ...checkboxBase, + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + hovered: { + ...checkboxBase, + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + hoveredAndChecked: { + ...checkboxBase, + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + }, + } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index ae8de178f8..18341fc51e 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -1,338 +1,372 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" +import { toggleable } from "./toggle" import { - background, - border, - borderColor, - foreground, - svg, - text, + background, + border, + borderColor, + foreground, + svg, + text, } from "./components" import statusBar from "./statusBar" import tabBar from "./tabBar" - +import { interactive } from "./interactive" +import merge from 'ts-deepmerge'; export default function workspace(colorScheme: ColorScheme) { - const layer = colorScheme.lowest - const isLight = colorScheme.isLight - const itemSpacing = 8 - const titlebarButton = { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, + const layer = colorScheme.lowest + const isLight = colorScheme.isLight + const itemSpacing = 8 + const titlebarButton = toggleable(interactive({ + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), + }, { + hover: { + ...text(layer, "sans", "variant", "hovered", { size: "xs" }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), + }, + clicked: { + ...text(layer, "sans", "variant", "pressed", { size: "xs" }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + } + }), + { + default: { + ...text(layer, "sans", "variant", "active", { size: "xs" }), + background: background(layer, "variant", "active"), + border: border(layer, "variant", "active"), + } + }, + ); + const avatarWidth = 18 + const avatarOuterWidth = avatarWidth + 4 + const followerAvatarWidth = 14 + const followerAvatarOuterWidth = followerAvatarWidth + 4 + + return { + background: background(colorScheme.lowest), + blankPane: { + logoContainer: { + width: 256, + height: 256, + }, + logo: svg( + withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), + "icons/logo_96.svg", + 256, + 256 + ), + + logoShadow: svg( + withOpacity( + colorScheme.isLight + ? "#FFFFFF" + : colorScheme.lowest.base.default.background, + colorScheme.isLight ? 1 : 0.6 + ), + "icons/logo_96.svg", + 256, + 256 + ), + keyboardHints: { + margin: { + top: 96, + }, + cornerRadius: 4, + }, + keyboardHint: + interactive({ + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, left: 8, right: 8, + bottom: 3, + }, + cornerRadius: 8 + }, { + hover: { + ...text(layer, "sans", "active", { size: "sm" }), + } + }), + + keyboardHintWidth: 320, + }, + joiningProjectAvatar: { + cornerRadius: 40, + width: 80, + }, + joiningProjectMessage: { + padding: 12, + ...text(layer, "sans", { size: "lg" }), + }, + externalLocationMessage: { + background: background(colorScheme.middle, "accent"), + border: border(colorScheme.middle, "accent"), + cornerRadius: 6, + padding: 12, + margin: { bottom: 8, right: 8 }, + ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), + }, + leaderBorderOpacity: 0.7, + leaderBorderWidth: 2.0, + tabBar: tabBar(colorScheme), + modal: { + margin: { + bottom: 52, + top: 52, + }, + cursor: "Arrow", + }, + zoomedBackground: { + cursor: "Arrow", + background: isLight + ? withOpacity(background(colorScheme.lowest), 0.8) + : withOpacity(background(colorScheme.highest), 0.6), + }, + zoomedPaneForeground: { + margin: 16, + shadow: colorScheme.modalShadow, + border: border(colorScheme.lowest, { overlay: true }), + }, + zoomedPanelForeground: { + margin: 16, + border: border(colorScheme.lowest, { overlay: true }), + }, + dock: { + left: { + border: border(layer, { right: true }), + }, + bottom: { + border: border(layer, { top: true }), + }, + right: { + border: border(layer, { left: true }), + }, + }, + paneDivider: { + color: borderColor(layer), + width: 1, + }, + statusBar: statusBar(colorScheme), + titlebar: { + itemSpacing, + facePileSpacing: 2, + height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. + background: background(layer), + border: border(layer, { bottom: true }), + padding: { + left: 80, + right: itemSpacing, + }, + + // Project + title: text(layer, "sans", "variant"), + highlight_color: text(layer, "sans", "active").color, + + // Collaborators + leaderAvatar: { + width: avatarWidth, + outerWidth: avatarOuterWidth, + cornerRadius: avatarWidth / 2, + outerCornerRadius: avatarOuterWidth / 2, + }, + followerAvatar: { + width: followerAvatarWidth, + outerWidth: followerAvatarOuterWidth, + cornerRadius: followerAvatarWidth / 2, + outerCornerRadius: followerAvatarOuterWidth / 2, + }, + inactiveAvatarGrayscale: true, + followerAvatarOverlap: 8, + leaderSelection: { + margin: { + top: 4, + bottom: 4, }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), + padding: { + left: 2, + right: 2, + top: 2, + bottom: 2, + }, + cornerRadius: 6, + }, + avatarRibbon: { + height: 3, + width: 12, + // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. + }, + + // Sign in buttom + // FlatButton, Variant + signInPrompt: + merge(titlebarButton, + { + inactive: { + default: { + margin: { + left: itemSpacing, + }, + } + } + }), + + + // Offline Indicator + offlineIcon: { + color: foreground(layer, "variant"), + width: 16, + margin: { + left: itemSpacing, + }, + padding: { + right: 4, + }, + }, + + // Notice that the collaboration server is out of date + outdatedWarning: { + ...text(layer, "sans", "warning", { size: "xs" }), + background: withOpacity(background(layer, "warning"), 0.3), + border: border(layer, "warning"), + margin: { + left: itemSpacing, + }, + padding: { + left: 8, + right: 8, + }, + cornerRadius: 6, + }, + callControl: interactive({ + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 20, + }, { hover: { - ...text(layer, "sans", "variant", "hovered", { size: "xs" }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { size: "xs" }), + }), + toggleContactsButton: toggleable(interactive({ + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + { + clicked: { background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - }, - active: { - ...text(layer, "sans", "variant", "active", { size: "xs" }), + color: foreground(layer, "variant", "pressed"), + }, + hover: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + } + }), + { + default: { background: background(layer, "variant", "active"), - border: border(layer, "variant", "active"), + color: foreground(layer, "variant", "active") + } }, - } - const avatarWidth = 18 - const avatarOuterWidth = avatarWidth + 4 - const followerAvatarWidth = 14 - const followerAvatarOuterWidth = followerAvatarWidth + 4 + ), + userMenuButton: merge(titlebarButton, { + inactive: { + default: { + buttonWidth: 20, + iconWidth: 12 + } + }, active: { // posiewic: these properties are not currently set on main + default: { + iconWidth: 12, + button_width: 20, + } + } + }), - return { - background: background(colorScheme.lowest), - blankPane: { - logoContainer: { - width: 256, - height: 256, - }, - logo: svg( - withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), - "icons/logo_96.svg", - 256, - 256 - ), - logoShadow: svg( - withOpacity( - colorScheme.isLight - ? "#FFFFFF" - : colorScheme.lowest.base.default.background, - colorScheme.isLight ? 1 : 0.6 - ), - "icons/logo_96.svg", - 256, - 256 - ), - keyboardHints: { - margin: { - top: 96, - }, - cornerRadius: 4, - }, - keyboardHint: { - ...text(layer, "sans", "variant", { size: "sm" }), - padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, - }, - cornerRadius: 8, - hover: { - ...text(layer, "sans", "active", { size: "sm" }), - }, - }, - keyboardHintWidth: 320, - }, - joiningProjectAvatar: { - cornerRadius: 40, - width: 80, - }, - joiningProjectMessage: { - padding: 12, - ...text(layer, "sans", { size: "lg" }), - }, - externalLocationMessage: { - background: background(colorScheme.middle, "accent"), - border: border(colorScheme.middle, "accent"), - cornerRadius: 6, - padding: 12, - margin: { bottom: 8, right: 8 }, - ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), - }, - leaderBorderOpacity: 0.7, - leaderBorderWidth: 2.0, - tabBar: tabBar(colorScheme), - modal: { - margin: { - bottom: 52, - top: 52, - }, - cursor: "Arrow", - }, - zoomedBackground: { - cursor: "Arrow", - background: isLight - ? withOpacity(background(colorScheme.lowest), 0.8) - : withOpacity(background(colorScheme.highest), 0.6), - }, - zoomedPaneForeground: { - margin: 16, - shadow: colorScheme.modalShadow, - border: border(colorScheme.lowest, { overlay: true }), - }, - zoomedPanelForeground: { - margin: 16, - border: border(colorScheme.lowest, { overlay: true }), - }, - dock: { - left: { - border: border(layer, { right: true }), - }, - bottom: { - border: border(layer, { top: true }), - }, - right: { - border: border(layer, { left: true }), - }, - }, - paneDivider: { - color: borderColor(layer), - width: 1, - }, - statusBar: statusBar(colorScheme), - titlebar: { - itemSpacing, - facePileSpacing: 2, - height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. - background: background(layer), - border: border(layer, { bottom: true }), - padding: { - left: 80, - right: itemSpacing, - }, + toggleContactsBadge: { + cornerRadius: 3, + padding: 2, + margin: { top: 3, left: 3 }, + border: border(layer), + background: foreground(layer, "accent"), + }, + shareButton: { + ...titlebarButton, + }, + }, - // Project - title: text(layer, "sans", "variant"), - highlight_color: text(layer, "sans", "active").color, - - // Collaborators - leaderAvatar: { - width: avatarWidth, - outerWidth: avatarOuterWidth, - cornerRadius: avatarWidth / 2, - outerCornerRadius: avatarOuterWidth / 2, - }, - followerAvatar: { - width: followerAvatarWidth, - outerWidth: followerAvatarOuterWidth, - cornerRadius: followerAvatarWidth / 2, - outerCornerRadius: followerAvatarOuterWidth / 2, - }, - inactiveAvatarGrayscale: true, - followerAvatarOverlap: 8, - leaderSelection: { - margin: { - top: 4, - bottom: 4, - }, - padding: { - left: 2, - right: 2, - top: 2, - bottom: 2, - }, - cornerRadius: 6, - }, - avatarRibbon: { - height: 3, - width: 12, - // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. - }, - - // Sign in buttom - // FlatButton, Variant - signInPrompt: { - margin: { - left: itemSpacing, - }, - ...titlebarButton, - }, - - // Offline Indicator - offlineIcon: { - color: foreground(layer, "variant"), - width: 16, - margin: { - left: itemSpacing, - }, - padding: { - right: 4, - }, - }, - - // Notice that the collaboration server is out of date - outdatedWarning: { - ...text(layer, "sans", "warning", { size: "xs" }), - background: withOpacity(background(layer, "warning"), 0.3), - border: border(layer, "warning"), - margin: { - left: itemSpacing, - }, - padding: { - left: 8, - right: 8, - }, - cornerRadius: 6, - }, - callControl: { - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 20, - hover: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - }, - toggleContactsButton: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, - active: { - background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active"), - }, - clicked: { - background: background(layer, "variant", "pressed"), - color: foreground(layer, "variant", "pressed"), - }, - hover: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - }, - userMenuButton: { - buttonWidth: 20, - iconWidth: 12, - ...titlebarButton, - }, - toggleContactsBadge: { - cornerRadius: 3, - padding: 2, - margin: { top: 3, left: 3 }, - border: border(layer), - background: foreground(layer, "accent"), - }, - shareButton: { - ...titlebarButton, - }, + toolbar: { + height: 34, + background: background(colorScheme.highest), + border: border(colorScheme.highest, { bottom: true }), + itemSpacing: 8, + navButton: interactive( + { + color: foreground(colorScheme.highest, "on"), + iconWidth: 12, + buttonWidth: 24, + cornerRadius: 6, + }, { + hover: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), }, - - toolbar: { - height: 34, - background: background(colorScheme.highest), - border: border(colorScheme.highest, { bottom: true }), - itemSpacing: 8, - navButton: { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, - cornerRadius: 6, - hover: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - disabled: { - color: foreground(colorScheme.highest, "on", "disabled"), - }, - }, - padding: { left: 8, right: 8, top: 4, bottom: 4 }, + disabled: { + color: foreground(colorScheme.highest, "on", "disabled"), }, - breadcrumbHeight: 24, - breadcrumbs: { - ...text(colorScheme.highest, "sans", "variant"), - cornerRadius: 6, - padding: { - left: 6, - right: 6, - }, - hover: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background(colorScheme.highest, "on", "hovered"), - }, - }, - disconnectedOverlay: { - ...text(layer, "sans"), - background: withOpacity(background(layer), 0.8), - }, - notification: { - margin: { top: 10 }, - background: background(colorScheme.middle), - cornerRadius: 6, - padding: 12, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - }, - notifications: { - width: 400, - margin: { right: 10, bottom: 10 }, - }, - dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), - } + }), + padding: { left: 8, right: 8, top: 4, bottom: 4 }, + }, + breadcrumbHeight: 24, + breadcrumbs: interactive({ + ...text(colorScheme.highest, "sans", "variant"), + cornerRadius: 6, + padding: { + left: 6, + right: 6, + } + }, { + hover: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background(colorScheme.highest, "on", "hovered"), + }, + }), + disconnectedOverlay: { + ...text(layer, "sans"), + background: withOpacity(background(layer), 0.8), + }, + notification: { + margin: { top: 10 }, + background: background(colorScheme.middle), + cornerRadius: 6, + padding: 12, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + }, + notifications: { + width: 400, + margin: { right: 10, bottom: 10 }, + }, + dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), + } } From 16564707df836c12fe785dc6aa51999bdded0b4b Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 15 Jun 2023 11:10:37 -0400 Subject: [PATCH 046/215] Use TS-flavored doc comments --- styles/src/styleTree/interactive.ts | 54 +++++++++++++++----------- styles/src/styleTree/toggle.ts | 60 ++++++++++++++++------------- 2 files changed, 64 insertions(+), 50 deletions(-) diff --git a/styles/src/styleTree/interactive.ts b/styles/src/styleTree/interactive.ts index 7135cecd90..230a05515d 100644 --- a/styles/src/styleTree/interactive.ts +++ b/styles/src/styleTree/interactive.ts @@ -1,33 +1,41 @@ import { DeepPartial } from "utility-types"; import merge from "ts-deepmerge" interface Interactive { - default: T, - hover?: T, - clicked?: T, - disabled?: T, + default: T, + hover?: T, + clicked?: T, + disabled?: T, } -// Helper function for creating Interactive objects that works pretty much like Toggle. -// It takes a object to be used as a value for `default` field and then fills out other fields -// with fields from either `base` or `modifications`. Notably, it does not touch `hover`, `clicked` and `disabled` if there are no modifications for it. +/** + * Helper function for creating Interactive objects that works pretty much like Toggle. + * It takes a object to be used as a value for `default` field and then fills out other fields + * with fields from either `base` or `modifications`. + * Notably, it does not touch `hover`, `clicked` and `disabled` if there are no modifications for it. + * + * @param defaultObj Object to be used as the value for `default` field. + * @param base Object containing base fields to be included in the resulting object. + * @param modifications Object containing modified fields to be included in the resulting object. + * @returns Interactive object with fields from `base` and `modifications`. + */ export function interactive(base: T, modifications: DeepPartial>): Interactive { - let interactiveObj: Interactive = { - default: base, - }; - if (modifications.default !== undefined) { - interactiveObj.default = merge(interactiveObj.default, modifications.default) as T; - } - if (modifications.hover !== undefined) { - interactiveObj.hover = merge(interactiveObj.default, modifications.hover) as T; - } + let interactiveObj: Interactive = { + default: base, + }; + if (modifications.default !== undefined) { + interactiveObj.default = merge(interactiveObj.default, modifications.default) as T; + } + if (modifications.hover !== undefined) { + interactiveObj.hover = merge(interactiveObj.default, modifications.hover) as T; + } - if (modifications.clicked !== undefined) { - interactiveObj.clicked = merge(interactiveObj.default, modifications.clicked) as T; - } + if (modifications.clicked !== undefined) { + interactiveObj.clicked = merge(interactiveObj.default, modifications.clicked) as T; + } - if (modifications.disabled !== undefined) { - interactiveObj.disabled = merge(interactiveObj.default, modifications.disabled) as T; - } + if (modifications.disabled !== undefined) { + interactiveObj.disabled = merge(interactiveObj.default, modifications.disabled) as T; + } - return interactiveObj; + return interactiveObj; } diff --git a/styles/src/styleTree/toggle.ts b/styles/src/styleTree/toggle.ts index 9c35b8337c..d6b37dde9e 100644 --- a/styles/src/styleTree/toggle.ts +++ b/styles/src/styleTree/toggle.ts @@ -2,34 +2,40 @@ import { DeepPartial } from 'utility-types'; import merge from 'ts-deepmerge'; interface Toggleable { - inactive: T - active: T, + inactive: T + active: T, } -/// Helper function for creating Toggleable objects; it takes a object of type T that is used as -/// `inactive` member of result Toggleable. `active` member is created by applying `modifications` on top of `inactive` argument. -// Thus, the following call: -// ``` -// toggleable({day: 1, month: "January"}, {day: 3}) -// ``` -// To return the following object: -// ``` -// Toggleable<_>{ -// inactive: { day: 1, month: "January" }, -// active: { day: 3, month: "January" } -// } -// ``` -// Remarkably, it also works for nested structures: -// ``` -// toggleable({first_level: "foo", second_level: {nested_member: "nested"}}, {second_level: {nested_member: "another nested thing"}}) -// ``` -// ``` -// Toggleable<_> { -// inactive: {first_level: "foo", second_level: {nested_member: "nested"}}, -// active: { first_level: "foo", second_level: {nested_member: "another nested thing"}} -// } -// ``` +/** + * Helper function for creating Toggleable objects. + * @template T The type of the object being toggled. + * @param inactive The initial state of the toggleable object. + * @param modifications The modifications to be applied to the initial state to create the active state. + * @returns A Toggleable object containing both the inactive and active states. + * @example + * ``` + * toggleable({day: 1, month: "January"}, {day: 3}) + * ``` + * This returns the following object: + * ``` + * Toggleable<_>{ + * inactive: { day: 1, month: "January" }, + * active: { day: 3, month: "January" } + * } + * ``` + * The function also works for nested structures: + * ``` + * toggleable({first_level: "foo", second_level: {nested_member: "nested"}}, {second_level: {nested_member: "another nested thing"}}) + * ``` + * Which returns: + * ``` + * Toggleable<_> { + * inactive: {first_level: "foo", second_level: {nested_member: "nested"}}, + * active: { first_level: "foo", second_level: {nested_member: "another nested thing"}} + * } + * ``` + */ export function toggleable(inactive: T, modifications: DeepPartial): Toggleable { - let active: T = merge(inactive, modifications) as T; - return { active: active, inactive: inactive }; + let active: T = merge(inactive, modifications) as T; + return { active: active, inactive: inactive }; } From 247f618d4f5419acacf86e4ac3b276437a755990 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 15 Jun 2023 15:33:02 -0400 Subject: [PATCH 047/215] Update the interactive function --- styles/src/styleTree/interactive.ts | 58 ++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/styles/src/styleTree/interactive.ts b/styles/src/styleTree/interactive.ts index 230a05515d..6bc6ca048b 100644 --- a/styles/src/styleTree/interactive.ts +++ b/styles/src/styleTree/interactive.ts @@ -1,10 +1,18 @@ -import { DeepPartial } from "utility-types"; import merge from "ts-deepmerge" -interface Interactive { + +type InteractiveState = "default" | "hovered" | "clicked" | "selected" | "disabled"; + +type Interactive = { default: T, - hover?: T, + hovered?: T, clicked?: T, + selected?: T, disabled?: T, +}; + +interface InteractiveProps { + base?: T, + state: Partial> } /** @@ -18,23 +26,45 @@ interface Interactive { * @param modifications Object containing modified fields to be included in the resulting object. * @returns Interactive object with fields from `base` and `modifications`. */ -export function interactive(base: T, modifications: DeepPartial>): Interactive { +export function interactive({ base, state }: InteractiveProps): Interactive { + if (!base && !state.default) throw new Error("An interactive object must have a default state, or a base property."); + + let defaultState: T; + + if (state.default && base) { + defaultState = merge(base, state.default) as T; + } else { + defaultState = base ? base : state.default as T; + } + let interactiveObj: Interactive = { - default: base, + default: defaultState, }; - if (modifications.default !== undefined) { - interactiveObj.default = merge(interactiveObj.default, modifications.default) as T; - } - if (modifications.hover !== undefined) { - interactiveObj.hover = merge(interactiveObj.default, modifications.hover) as T; + + let stateCount = 0; + + if (state.hovered !== undefined) { + interactiveObj.hovered = merge(interactiveObj.default, state.hovered) as T; + stateCount++; } - if (modifications.clicked !== undefined) { - interactiveObj.clicked = merge(interactiveObj.default, modifications.clicked) as T; + if (state.clicked !== undefined) { + interactiveObj.clicked = merge(interactiveObj.default, state.clicked) as T; + stateCount++; } - if (modifications.disabled !== undefined) { - interactiveObj.disabled = merge(interactiveObj.default, modifications.disabled) as T; + if (state.selected !== undefined) { + interactiveObj.selected = merge(interactiveObj.default, state.selected) as T; + stateCount++; + } + + if (state.disabled !== undefined) { + interactiveObj.disabled = merge(interactiveObj.default, state.disabled) as T; + stateCount++; + } + + if (stateCount < 1) { + throw new Error("An interactive object must have a default and at least one other state."); } return interactiveObj; From 63630949ba96ef6b0b36aafad7558d31774e92b1 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 15 Jun 2023 21:58:08 +0200 Subject: [PATCH 048/215] Fix up uses of interactive --- styles/src/styleTree/commandPalette.ts | 32 ++-- styles/src/styleTree/contactList.ts | 79 +++++----- styles/src/styleTree/contactNotification.ts | 20 +-- styles/src/styleTree/contextMenu.ts | 40 ++--- styles/src/styleTree/copilot.ts | 112 ++++++------- styles/src/styleTree/editor.ts | 64 ++++---- styles/src/styleTree/picker.ts | 37 +++-- styles/src/styleTree/projectPanel.ts | 58 +++---- styles/src/styleTree/statusBar.ts | 128 ++++++++------- styles/src/styleTree/tabBar.ts | 16 +- styles/src/styleTree/welcome.ts | 38 ++--- styles/src/styleTree/workspace.ts | 164 +++++++++++--------- 12 files changed, 425 insertions(+), 363 deletions(-) diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index 5fe7b74f92..d6cb196770 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -10,21 +10,23 @@ export default function commandPalette(colorScheme: ColorScheme) { keystrokeSpacing: 8, key: toggleable(interactive({ - text: text(layer, "mono", "variant", "default", { size: "xs" }), - cornerRadius: 2, - background: background(layer, "on"), - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - margin: { - top: 1, - bottom: 1, - left: 2, - }, - }, { hover: { cornerRadius: 4, padding: { top: 17 } } }), { + base: { + text: text(layer, "mono", "variant", "default", { size: "xs" }), + cornerRadius: 2, + background: background(layer, "on"), + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + margin: { + top: 1, + bottom: 1, + left: 2, + }, + }, state: { hovered: { cornerRadius: 4, padding: { top: 17 } } } + }), { default: { text: text(layer, "mono", "on", "default", { size: "xs" }), background: withOpacity(background(layer, "on"), 0.2), diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index b3e30f4aa7..5837720401 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -73,14 +73,17 @@ export default function contactsPanel(colorScheme: ColorScheme) { rowHeight: 28, sectionIconSize: 8, headerRow: toggleable(interactive({ - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, - }, - background: background(layer, "default"),// posiewic: breaking change - }, {}), + base: { + ...text(layer, "mono", { size: "sm" }), + margin: { top: 14 }, + padding: { + left: sidePadding, + right: sidePadding, + }, + background: background(layer, "default"),// posiewic: breaking change + } + , state: { hovered: { background: background(layer, "default") } } // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. + }), { default: { ...text(layer, "mono", "active", { size: "sm" }), @@ -88,27 +91,30 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, }), leaveCall: interactive({ - background: background(layer), - border: border(layer), - cornerRadius: 6, - margin: { - top: 1, - }, - padding: { - top: 1, - bottom: 1, - left: 7, - right: 7, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - }, - { - hover: { + base: { + background: background(layer), + border: border(layer), + cornerRadius: 6, + margin: { + top: 1, + }, + padding: { + top: 1, + bottom: 1, + left: 7, + right: 7, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + } + , + state: { + hovered: { ...text(layer, "sans", "hovered", { size: "xs" }), background: background(layer, "hovered"), border: border(layer, "hovered"), } } + } ), contactRow: { inactive: { @@ -153,13 +159,14 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, }, contactButtonSpacing: nameMargin, - contactButton: interactive( - contactButton, - { - hover: { + contactButton: interactive({ + base: { ...contactButton }, + state: { + hovered: { background: background(layer, "hovered"), }, - }), + } + }), disabledButton: { ...contactButton, background: background(layer, "on"), @@ -169,14 +176,16 @@ export default function contactsPanel(colorScheme: ColorScheme) { ...text(layer, "mono", "variant", { size: "xs" }), }, treeBranch: toggleable(interactive({ - color: borderColor(layer), - width: 1, - }, - { - hover: { + base: { + color: borderColor(layer), + width: 1, + }, + state: { + hovered: { color: borderColor(layer), }, - }), + } + }), { default: { color: borderColor(layer), diff --git a/styles/src/styleTree/contactNotification.ts b/styles/src/styleTree/contactNotification.ts index edef8dac20..5b29e15e6b 100644 --- a/styles/src/styleTree/contactNotification.ts +++ b/styles/src/styleTree/contactNotification.ts @@ -23,18 +23,20 @@ export default function contactNotification(colorScheme: ColorScheme): Object { }, button: interactive({ - ...text(layer, "sans", "on", { size: "xs" }), - background: background(layer, "on"), - padding: 4, - cornerRadius: 6, - margin: { left: 6 } - }, + base: { + ...text(layer, "sans", "on", { size: "xs" }), + background: background(layer, "on"), + padding: 4, + cornerRadius: 6, + margin: { left: 6 } + }, - { - hover: { + state: { + hovered: { background: background(layer, "on", "hovered"), } - }), + } + }), dismissButton: { default: { diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index b030d27972..2d5e84dcf0 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -13,35 +13,37 @@ export default function contextMenu(colorScheme: ColorScheme) { border: border(layer), keystrokeMargin: 30, item: toggleable(interactive({ - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "variant", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - } - }, { - hover: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), + base: { + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), keystroke: { - ...text(layer, "sans", "hovered", { + ...text(layer, "sans", "variant", { size: "sm", weight: "bold", }), padding: { left: 3, right: 3 }, - }, + } + }, state: { + hovered: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "hovered", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + } } }), { default: { background: background(layer, "active"), }, - hover: { + hovered: { background: background(layer, "active"), }, }), diff --git a/styles/src/styleTree/copilot.ts b/styles/src/styleTree/copilot.ts index 090d05eaee..6440941e64 100644 --- a/styles/src/styleTree/copilot.ts +++ b/styles/src/styleTree/copilot.ts @@ -9,53 +9,57 @@ export default function copilot(colorScheme: ColorScheme) { let ctaButton = // Copied from welcome screen. FIXME: Move this into a ZDS component interactive({ - background: background(layer), - border: border(layer, "default"), - cornerRadius: 4, - margin: { - top: 4, - bottom: 4, - left: 8, - right: 8, + base: { + background: background(layer), + border: border(layer, "default"), + cornerRadius: 4, + margin: { + top: 4, + bottom: 4, + left: 8, + right: 8, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }) }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }) - }, - { - hover: { + state: { + hovered: { ...text(layer, "sans", "default", { size: "sm" }), background: background(layer, "hovered"), border: border(layer, "active"), }, - }); + } + }); return { outLinkIcon: interactive({ - icon: svg( - foreground(layer, "variant"), - "icons/link_out_12.svg", - 12, - 12 - ), - container: { - cornerRadius: 6, - padding: { left: 6 }, + base: { + icon: svg( + foreground(layer, "variant"), + "icons/link_out_12.svg", + 12, + 12 + ), + container: { + cornerRadius: 6, + padding: { left: 6 }, + }, }, - }, - { - hover: { + state: { + hovered: { icon: { color: foreground(layer, "hovered") } }, - }), + } + }), modal: { titleText: { @@ -82,7 +86,8 @@ export default function copilot(colorScheme: ColorScheme) { bottom: 8, }, }, - closeIcon: interactive( + closeIcon: interactive({ + base: { icon: svg( foreground(layer, "variant"), @@ -103,8 +108,8 @@ export default function copilot(colorScheme: ColorScheme) { }, } }, - { - hover: { + state: { + hovered: { icon: svg( foreground(layer, "on"), "icons/x_mark_8.svg", @@ -120,7 +125,8 @@ export default function copilot(colorScheme: ColorScheme) { 8 ), }, - }), + } + }), dimensions: { width: 280, height: 280, @@ -196,27 +202,29 @@ export default function copilot(colorScheme: ColorScheme) { }, right: (content_width * 1) / 3, rightContainer: interactive({ - border: border(colorScheme.lowest, "inverted", { - bottom: false, - right: false, - top: false, - left: true, - }), - padding: { - top: 3, - bottom: 5, - left: 8, - right: 0, - } - }, { - hover: { - border: border(layer, "active", { + base: { + border: border(colorScheme.lowest, "inverted", { bottom: false, right: false, top: false, left: true, }), - }, + padding: { + top: 3, + bottom: 5, + left: 8, + right: 0, + } + }, state: { + hovered: { + border: border(layer, "active", { + bottom: false, + right: false, + top: false, + left: true, + }), + }, + } }) }, }, diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index ac7447de42..b3b22f3c8b 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -51,14 +51,16 @@ export default function editor(colorScheme: ColorScheme) { suggestion: syntax.predictive, codeActions: { indicator: toggleable(interactive({ - color: foreground(layer, "variant"), - }, { - clicked: { - color: foreground(layer, "base"), - }, - hover: { - color: foreground(layer, "on"), - }, + base: { + color: foreground(layer, "variant"), + }, state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + } }), { default: { @@ -73,14 +75,16 @@ export default function editor(colorScheme: ColorScheme) { foldedIcon: "icons/chevron_right_8.svg", foldableIcon: "icons/chevron_down_8.svg", indicator: toggleable(interactive({ - color: foreground(layer, "variant"), - }, { - clicked: { - color: foreground(layer, "base"), - }, - hover: { - color: foreground(layer, "on"), - }, + base: { + color: foreground(layer, "variant"), + }, state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + } }), { default: { @@ -231,19 +235,21 @@ export default function editor(colorScheme: ColorScheme) { underline: syntax.linkUri.underline, }, jumpIcon: interactive({ - color: foreground(layer, "on"), - iconWidth: 20, - buttonWidth: 20, - cornerRadius: 6, - padding: { - top: 6, - bottom: 6, - left: 6, - right: 6, - } - }, { - hover: { - background: background(layer, "on", "hovered"), + base: { + color: foreground(layer, "on"), + iconWidth: 20, + buttonWidth: 20, + cornerRadius: 6, + padding: { + top: 6, + bottom: 6, + left: 6, + right: 6, + } + }, state: { + hovered: { + background: background(layer, "on", "hovered"), + } } }), diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index ecf34a9927..89b6cd0614 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -41,23 +41,26 @@ export default function picker(colorScheme: ColorScheme): any { padding: {}, }, item: toggleable(interactive({ - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, - }, - margin: { - top: 1, - left: 4, - right: 4, - }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { weight: "bold" }), - }, { - hover: { - background: withOpacity(background(layer, "hovered"), 0.5), + base: { + padding: { + bottom: 4, + left: 12, + right: 12, + top: 4, + }, + margin: { + top: 1, + left: 4, + right: 4, + }, + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { weight: "bold" }), + } + , state: { + hovered: { + background: withOpacity(background(layer, "hovered"), 0.5), + } } }), { diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 57abd0dafc..782c781156 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -30,15 +30,17 @@ export default function projectPanel(colorScheme: ColorScheme) { } let entry = toggleable(interactive({ - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - status, - }, + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, state: { - hover: { + hovered: { background: background(layer, "variant", "hovered"), } - }), + } + }), { default: { /*background: colorScheme.isLight @@ -46,7 +48,7 @@ export default function projectPanel(colorScheme: ColorScheme) { : background(layer, "active") ,*/ // todo posiewic text: text(layer, "mono", "active", { size: "sm" }), }, - hover: { + hovered: { //background: background(layer, "active"), text: text(layer, "mono", "active", { size: "sm" }), }, @@ -55,27 +57,29 @@ export default function projectPanel(colorScheme: ColorScheme) { return { openProjectButton: interactive({ - background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 16, - left: 16, - right: 16, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }) - }, { - hover: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), + base: { + background: background(layer), border: border(layer, "active"), - }, + cornerRadius: 4, + margin: { + top: 16, + left: 16, + right: 16, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }) + }, state: { + hovered: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + } }), background: background(layer), padding: { left: 6, right: 6, top: 0, bottom: 6 }, diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 66643dbde1..754703c2b9 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -27,74 +27,82 @@ export default function statusBar(colorScheme: ColorScheme) { border: border(layer, { top: true, overlay: true }), cursorPosition: text(layer, "sans", "variant"), activeLanguage: interactive({ - padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant") - }, - { - hover: { + base: { + padding: { left: 6, right: 6 }, + ...text(layer, "sans", "variant") + }, + state: { + hovered: { ...text(layer, "sans", "on"), } - }, + } + }, ), autoUpdateProgressMessage: text(layer, "sans", "variant"), autoUpdateDoneMessage: text(layer, "sans", "variant"), lspStatus: interactive({ - ...diagnosticStatusContainer, - iconSpacing: 4, - iconWidth: 14, - height: 18, - message: text(layer, "sans"), - iconColor: foreground(layer) - }, - { - hover: { + base: { + ...diagnosticStatusContainer, + iconSpacing: 4, + iconWidth: 14, + height: 18, + message: text(layer, "sans"), + iconColor: foreground(layer) + }, + state: { + hovered: { message: text(layer, "sans"), iconColor: foreground(layer), background: background(layer, "hovered"), } - }), + } + }), diagnosticMessage: interactive({ - ...text(layer, "sans") + base: { + ...text(layer, "sans") + }, + state: { hovered: text(layer, "sans", "hovered") } }, - { hover: text(layer, "sans", "hovered") }, ), diagnosticSummary: interactive({ - height: 20, - iconWidth: 16, - iconSpacing: 2, - summarySpacing: 6, - text: text(layer, "sans", { size: "sm" }), - iconColorOk: foreground(layer, "variant"), - iconColorWarning: foreground(layer, "warning"), - iconColorError: foreground(layer, "negative"), - containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, - }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), - }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - } - }, { - hover: { - iconColorOk: foreground(layer, "on"), + base: { + height: 20, + iconWidth: 16, + iconSpacing: 2, + summarySpacing: 6, + text: text(layer, "sans", { size: "sm" }), + iconColorOk: foreground(layer, "variant"), + iconColorWarning: foreground(layer, "warning"), + iconColorError: foreground(layer, "negative"), containerOk: { - background: background(layer, "on", "hovered"), + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 7, right: 7 }, }, containerWarning: { - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), + ...diagnosticStatusContainer, + background: background(layer, "warning"), + border: border(layer, "warning"), }, containerError: { - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), + ...diagnosticStatusContainer, + background: background(layer, "negative"), + border: border(layer, "negative"), + } + }, state: { + hovered: { + iconColorOk: foreground(layer, "on"), + containerOk: { + background: background(layer, "on", "hovered"), + }, + containerWarning: { + background: background(layer, "warning", "hovered"), + border: border(layer, "warning", "hovered"), + }, + containerError: { + background: background(layer, "negative", "hovered"), + border: border(layer, "negative", "hovered"), + } } } } @@ -104,17 +112,19 @@ export default function statusBar(colorScheme: ColorScheme) { groupBottom: {}, groupRight: {}, button: toggleable(interactive({ - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), - }, - }, { - hover: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), + base: { + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), + }, + }, state: { + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), + } } }), { diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index 6799b0a9e3..9da63b9518 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -90,15 +90,17 @@ export default function tabBar(colorScheme: ColorScheme) { }, draggedTab, paneButton: toggleable(interactive({ - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - }, - { - hover: { + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { color: foreground(layer, "hovered"), } - }), + } + }), { default: { color: foreground(layer, "accent"), diff --git a/styles/src/styleTree/welcome.ts b/styles/src/styleTree/welcome.ts index dbabc55383..7ba7b30430 100644 --- a/styles/src/styleTree/welcome.ts +++ b/styles/src/styleTree/welcome.ts @@ -65,24 +65,26 @@ export default function welcome(colorScheme: ColorScheme) { }, }, button: interactive({ - background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 4, - bottom: 4, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", interactive_text_size) - }, { - hover: { - ...text(layer, "sans", "default", interactive_text_size), - background: background(layer, "hovered"), + base: { + background: background(layer), + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 4, + bottom: 4, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", interactive_text_size) + }, state: { + hovered: { + ...text(layer, "sans", "default", interactive_text_size), + background: background(layer, "hovered"), + } } }), diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index 18341fc51e..fcada68a28 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -18,26 +18,28 @@ export default function workspace(colorScheme: ColorScheme) { const isLight = colorScheme.isLight const itemSpacing = 8 const titlebarButton = toggleable(interactive({ - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), - }, { - hover: { - ...text(layer, "sans", "variant", "hovered", { size: "xs" }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { size: "xs" }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), + base: { + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), + }, state: { + hovered: { + ...text(layer, "sans", "variant", "hovered", { size: "xs" }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), + }, + clicked: { + ...text(layer, "sans", "variant", "pressed", { size: "xs" }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + } } }), { @@ -86,17 +88,19 @@ export default function workspace(colorScheme: ColorScheme) { }, keyboardHint: interactive({ - ...text(layer, "sans", "variant", { size: "sm" }), - padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, - }, - cornerRadius: 8 - }, { - hover: { - ...text(layer, "sans", "active", { size: "sm" }), + base: { + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, + left: 8, + right: 8, + bottom: 3, + }, + cornerRadius: 8 + }, state: { + hovered: { + ...text(layer, "sans", "active", { size: "sm" }), + } } }), @@ -250,33 +254,37 @@ export default function workspace(colorScheme: ColorScheme) { cornerRadius: 6, }, callControl: interactive({ - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 20, - }, { - hover: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, + base: { + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 20, + }, state: { + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + } }), toggleContactsButton: toggleable(interactive({ - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, - }, - { + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { clicked: { background: background(layer, "variant", "pressed"), color: foreground(layer, "variant", "pressed"), }, - hover: { + hovered: { background: background(layer, "variant", "hovered"), color: foreground(layer, "variant", "hovered"), } - }), + } + }), { default: { background: background(layer, "variant", "active"), @@ -318,38 +326,42 @@ export default function workspace(colorScheme: ColorScheme) { itemSpacing: 8, navButton: interactive( { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, - cornerRadius: 6, - }, { - hover: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - disabled: { - color: foreground(colorScheme.highest, "on", "disabled"), - }, - }), + base: { + color: foreground(colorScheme.highest, "on"), + iconWidth: 12, + buttonWidth: 24, + cornerRadius: 6, + }, state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, + disabled: { + color: foreground(colorScheme.highest, "on", "disabled"), + }, + } + }), padding: { left: 8, right: 8, top: 4, bottom: 4 }, }, breadcrumbHeight: 24, breadcrumbs: interactive({ - ...text(colorScheme.highest, "sans", "variant"), - cornerRadius: 6, - padding: { - left: 6, - right: 6, + base: { + ...text(colorScheme.highest, "sans", "variant"), + cornerRadius: 6, + padding: { + left: 6, + right: 6, + } + }, state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background(colorScheme.highest, "on", "hovered"), + }, } - }, { - hover: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background(colorScheme.highest, "on", "hovered"), - }, }), disconnectedOverlay: { ...text(layer, "sans"), From 4bd89c4c8c8b6860050c09d8457fac1baebfee65 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 15 Jun 2023 22:39:51 +0200 Subject: [PATCH 049/215] further style adjustments; cargo-run works --- styles/src/styleTree/assistant.ts | 167 +++++++------- styles/src/styleTree/contactList.ts | 41 ++-- styles/src/styleTree/feedback.ts | 78 ++++--- styles/src/styleTree/search.ts | 210 +++++++++--------- .../styleTree/simpleMessageNotification.ts | 71 +++--- styles/src/styleTree/toolbarDropdownMenu.ts | 92 ++++---- styles/src/styleTree/updateNotification.ts | 54 +++-- 7 files changed, 382 insertions(+), 331 deletions(-) diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index bbb4aae5e1..d501237721 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -1,85 +1,94 @@ import { ColorScheme } from "../theme/colorScheme" import { text, border, background, foreground } from "./components" import editor from "./editor" +import { interactive } from "./interactive" export default function assistant(colorScheme: ColorScheme) { - const layer = colorScheme.highest - return { - container: { - background: editor(colorScheme).background, - padding: { left: 12 }, - }, - header: { - border: border(layer, "default", { bottom: true, top: true }), - margin: { bottom: 6, top: 6 }, - background: editor(colorScheme).background, - }, - userSender: { - ...text(layer, "sans", "default", { size: "sm", weight: "bold" }), - }, - assistantSender: { - ...text(layer, "sans", "accent", { size: "sm", weight: "bold" }), - }, - systemSender: { - ...text(layer, "sans", "variant", { size: "sm", weight: "bold" }), - }, - sentAt: { - margin: { top: 2, left: 8 }, - ...text(layer, "sans", "default", { size: "2xs" }), - }, - modelInfoContainer: { - margin: { right: 16, top: 4 }, - }, - model: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - cornerRadius: 4, - ...text(layer, "sans", "default", { size: "xs" }), - hover: { - background: background(layer, "on", "hovered"), - }, - }, - remainingTokens: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - margin: { left: 4 }, - cornerRadius: 4, - ...text(layer, "sans", "positive", { size: "xs" }), - }, - noRemainingTokens: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - margin: { left: 4 }, - cornerRadius: 4, - ...text(layer, "sans", "negative", { size: "xs" }), - }, - errorIcon: { - margin: { left: 8 }, - color: foreground(layer, "negative"), - width: 12, - }, - apiKeyEditor: { - background: background(layer, "on"), - cornerRadius: 6, - text: text(layer, "mono", "on"), - placeholderText: text(layer, "mono", "on", "disabled", { - size: "xs", - }), - selection: colorScheme.players[0], - border: border(layer, "on"), - padding: { - bottom: 4, - left: 8, - right: 8, - top: 4, - }, - }, - apiKeyPrompt: { - padding: 10, - ...text(layer, "sans", "default", { size: "xs" }), - }, - } + const layer = colorScheme.highest + return { + container: { + background: editor(colorScheme).background, + padding: { left: 12 }, + }, + header: { + border: border(layer, "default", { bottom: true, top: true }), + margin: { bottom: 6, top: 6 }, + background: editor(colorScheme).background, + }, + userSender: { + default: + { ...text(layer, "sans", "default", { size: "sm", weight: "bold" }) }, + }, + assistantSender: { + default: { + ...text(layer, "sans", "accent", { size: "sm", weight: "bold" }) + }, + }, + systemSender: { + default: { + ...text(layer, "sans", "variant", { size: "sm", weight: "bold" }) + }, + }, + sentAt: { + margin: { top: 2, left: 8 }, + ...text(layer, "sans", "default", { size: "2xs" }), + }, + modelInfoContainer: { + margin: { right: 16, top: 4 }, + }, + model: interactive({ + base: { + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + padding: 4, + cornerRadius: 4, + ...text(layer, "sans", "default", { size: "xs" }), + }, state: { + hovered: { + background: background(layer, "on", "hovered"), + } + } + }), + remainingTokens: { + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + padding: 4, + margin: { left: 4 }, + cornerRadius: 4, + ...text(layer, "sans", "positive", { size: "xs" }), + }, + noRemainingTokens: { + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + padding: 4, + margin: { left: 4 }, + cornerRadius: 4, + ...text(layer, "sans", "negative", { size: "xs" }), + }, + errorIcon: { + margin: { left: 8 }, + color: foreground(layer, "negative"), + width: 12, + }, + apiKeyEditor: { + background: background(layer, "on"), + cornerRadius: 6, + text: text(layer, "mono", "on"), + placeholderText: text(layer, "mono", "on", "disabled", { + size: "xs", + }), + selection: colorScheme.players[0], + border: border(layer, "on"), + padding: { + bottom: 4, + left: 8, + right: 8, + top: 4, + }, + }, + apiKeyPrompt: { + padding: 10, + ...text(layer, "sans", "default", { size: "xs" }), + }, + } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 5837720401..4309343ed2 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -192,24 +192,27 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, } ), - projectRow: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, - }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), - }, - hover: { - background: background(layer, "hovered"), - }, - active: { - background: background(layer, "active"), - }, - }, + projectRow: toggleable(interactive({ + base: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, + }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), + }, + }, state: { + hovered: { + background: background(layer, "hovered"), + }, + } + }), + { + default: { background: background(layer, "active") } + }) } } diff --git a/styles/src/styleTree/feedback.ts b/styles/src/styleTree/feedback.ts index 5eef4b4279..4b5a4de89f 100644 --- a/styles/src/styleTree/feedback.ts +++ b/styles/src/styleTree/feedback.ts @@ -1,44 +1,48 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" +import { interactive } from "./interactive" export default function feedback(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - return { - submit_button: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, - }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, - }, - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, - hover: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), - }, + return { + submit_button: interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, }, - button_margin: 8, - info_text_default: text(layer, "sans", "default", { size: "xs" }), - link_text_default: text(layer, "sans", "default", { - size: "xs", - underline: true, - }), - link_text_hover: text(layer, "sans", "hovered", { - size: "xs", - underline: true, - }), - } + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, + } + }, state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, + } + }), + button_margin: 8, + info_text_default: text(layer, "sans", "default", { size: "xs" }), + link_text_default: text(layer, "sans", "default", { + size: "xs", + underline: true, + }), + link_text_hover: text(layer, "sans", "hovered", { + size: "xs", + underline: true, + }), + } } diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index d69c4bb2d9..e278f69ff0 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -1,113 +1,123 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" +import { interactive } from "./interactive" +import { toggleable } from "./toggle" export default function search(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - // Search input - const editor = { - background: background(layer), - cornerRadius: 8, - minWidth: 200, - maxWidth: 500, - placeholderText: text(layer, "mono", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "default"), - border: border(layer), + // Search input + const editor = { + background: background(layer), + cornerRadius: 8, + minWidth: 200, + maxWidth: 500, + placeholderText: text(layer, "mono", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "default"), + border: border(layer), + margin: { + right: 12, + }, + padding: { + top: 3, + bottom: 3, + left: 12, + right: 8, + }, + } + + const includeExcludeEditor = { + ...editor, + minWidth: 100, + maxWidth: 250, + } + + return { + // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive + matchBackground: withOpacity(foreground(layer, "accent"), 0.4), + optionButton: toggleable(interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), margin: { - right: 12, + right: 4, }, padding: { - top: 3, - bottom: 3, - left: 12, - right: 8, + bottom: 2, + left: 10, + right: 10, + top: 2, }, - } + }, state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, + } + }), { + default: { + ...text(layer, "mono", "on", "inverted"), + background: background(layer, "on", "inverted"), + border: border(layer, "on", "inverted"), + }, - const includeExcludeEditor = { - ...editor, - minWidth: 100, - maxWidth: 250, - } - - return { - // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive - matchBackground: withOpacity(foreground(layer, "accent"), 0.4), - optionButton: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, - }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, - }, - active: { - ...text(layer, "mono", "on", "inverted"), - background: background(layer, "on", "inverted"), - border: border(layer, "on", "inverted"), - }, - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, - hover: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), - }, + }), + editor, + invalidEditor: { + ...editor, + border: border(layer, "negative"), + }, + includeExcludeEditor, + invalidIncludeExcludeEditor: { + ...includeExcludeEditor, + border: border(layer, "negative"), + }, + matchIndex: { + ...text(layer, "mono", "variant"), + padding: { + left: 6, + }, + }, + optionButtonGroup: { + padding: { + left: 12, + right: 12, + }, + }, + includeExcludeInputs: { + ...text(layer, "mono", "variant"), + padding: { + right: 6, + }, + }, + resultsStatus: { + ...text(layer, "mono", "on"), + size: 18, + }, + dismissButton: interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 14, + padding: { + left: 10, + right: 10, }, - editor, - invalidEditor: { - ...editor, - border: border(layer, "negative"), - }, - includeExcludeEditor, - invalidIncludeExcludeEditor: { - ...includeExcludeEditor, - border: border(layer, "negative"), - }, - matchIndex: { - ...text(layer, "mono", "variant"), - padding: { - left: 6, - }, - }, - optionButtonGroup: { - padding: { - left: 12, - right: 12, - }, - }, - includeExcludeInputs: { - ...text(layer, "mono", "variant"), - padding: { - right: 6, - }, - }, - resultsStatus: { - ...text(layer, "mono", "on"), - size: 18, - }, - dismissButton: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 14, - padding: { - left: 10, - right: 10, - }, - hover: { - color: foreground(layer, "hovered"), - }, - }, - } + }, state: { + hovered: { + color: foreground(layer, "hovered"), + } + } + }), + } } diff --git a/styles/src/styleTree/simpleMessageNotification.ts b/styles/src/styleTree/simpleMessageNotification.ts index 8d88f05c53..70219d7a10 100644 --- a/styles/src/styleTree/simpleMessageNotification.ts +++ b/styles/src/styleTree/simpleMessageNotification.ts @@ -1,44 +1,51 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" +import { interactive } from "./interactive" const headerPadding = 8 export default function simpleMessageNotification( - colorScheme: ColorScheme + colorScheme: ColorScheme ): Object { - let layer = colorScheme.middle - return { - message: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, right: headerPadding }, + let layer = colorScheme.middle + return { + message: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, right: headerPadding }, + }, + actionMessage: interactive({ + base: { + ...text(layer, "sans", { size: "xs" }), + border: border(layer, "active"), + cornerRadius: 4, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, }, - actionMessage: { - ...text(layer, "sans", { size: "xs" }), - border: border(layer, "active"), - cornerRadius: 4, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - margin: { left: headerPadding, top: 6, bottom: 6 }, - hover: { - ...text(layer, "sans", "default", { size: "xs" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, + margin: { left: headerPadding, top: 6, bottom: 6 }, + }, state: { + hovered: { + ...text(layer, "sans", "default", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "active"), }, - dismissButton: { - color: foreground(layer), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - hover: { - color: foreground(layer, "hovered"), - }, + } + }), + dismissButton: interactive({ + base: { + color: foreground(layer), + iconWidth: 8, + iconHeight: 8, + buttonWidth: 8, + buttonHeight: 8, + }, state: { + hovered: { + color: foreground(layer, "hovered"), }, - } + } + }) + } } diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 92616eb022..0cfcb921ef 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -1,46 +1,56 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" - +import { interactive } from "./interactive" +import { toggleable } from "./toggle" export default function dropdownMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle + let layer = colorScheme.middle - return { - rowHeight: 30, - background: background(layer), - border: border(layer), - shadow: colorScheme.popoverShadow, - header: { - ...text(layer, "sans", { size: "sm" }), - secondaryText: text(layer, "sans", { size: "sm", color: "#aaaaaa" }), - secondaryTextSpacing: 10, - padding: { left: 8, right: 8, top: 2, bottom: 2 }, - cornerRadius: 6, - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - hover: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - } - }, - sectionHeader: { - ...text(layer, "sans", { size: "sm" }), - padding: { left: 8, right: 8, top: 8, bottom: 8 }, - }, - item: { - ...text(layer, "sans", { size: "sm" }), - secondaryTextSpacing: 10, - secondaryText: text(layer, "sans", { size: "sm" }), - padding: { left: 18, right: 18, top: 2, bottom: 2 }, - hover: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - }, - active: { - background: background(layer, "active"), - }, - activeHover: { - background: background(layer, "active"), - }, - }, - } + return { + rowHeight: 30, + background: background(layer), + border: border(layer), + shadow: colorScheme.popoverShadow, + header: interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryText: text(layer, "sans", { size: "sm", color: "#aaaaaa" }), + secondaryTextSpacing: 10, + padding: { left: 8, right: 8, top: 2, bottom: 2 }, + cornerRadius: 6, + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }) + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + } + } + }) + , + sectionHeader: { + ...text(layer, "sans", { size: "sm" }), + padding: { left: 8, right: 8, top: 8, bottom: 8 }, + }, + item: toggleable(interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryTextSpacing: 10, + secondaryText: text(layer, "sans", { size: "sm" }), + padding: { left: 18, right: 18, top: 2, bottom: 2 } + }, state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + } + } + }), { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + }) + } } diff --git a/styles/src/styleTree/updateNotification.ts b/styles/src/styleTree/updateNotification.ts index 281012e62f..aa8db916ea 100644 --- a/styles/src/styleTree/updateNotification.ts +++ b/styles/src/styleTree/updateNotification.ts @@ -1,31 +1,39 @@ import { ColorScheme } from "../theme/colorScheme" import { foreground, text } from "./components" +import { interactive } from "./interactive" const headerPadding = 8 export default function updateNotification(colorScheme: ColorScheme): Object { - let layer = colorScheme.middle - return { - message: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, right: headerPadding }, + let layer = colorScheme.middle + return { + message: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, right: headerPadding }, + }, + actionMessage: interactive({ + base: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, top: 6, bottom: 6 } + }, state: { + hovered: { + color: foreground(layer, "hovered"), + } + } + }), + dismissButton: interactive({ + base: { + color: foreground(layer), + iconWidth: 8, + iconHeight: 8, + buttonWidth: 8, + buttonHeight: 8 + }, state: { + hovered: { + color: foreground(layer, "hovered"), }, - actionMessage: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, top: 6, bottom: 6 }, - hover: { - color: foreground(layer, "hovered"), - }, - }, - dismissButton: { - color: foreground(layer), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - hover: { - color: foreground(layer, "hovered"), - }, - }, - } + }, + }) + + } } From 5369f2c25a98217bd8a6d35f67687a84147af7c2 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 15 Jun 2023 18:42:48 -0400 Subject: [PATCH 050/215] Set up vitest and add tests for `interactive` --- styles/.gitignore | 1 + styles/package-lock.json | 2306 ++++++++++++++++- styles/package.json | 9 +- styles/src/element/interactive/index.ts | 3 + .../element/interactive/interactive.test.ts | 59 + .../interactive}/interactive.ts | 23 +- styles/src/styleTree/assistant.ts | 176 +- styles/src/styleTree/commandPalette.ts | 60 +- styles/src/styleTree/contactList.ts | 412 +-- styles/src/styleTree/contactNotification.ts | 90 +- styles/src/styleTree/contextMenu.ts | 98 +- styles/src/styleTree/copilot.ts | 540 ++-- styles/src/styleTree/editor.ts | 556 ++-- styles/src/styleTree/feedback.ts | 84 +- styles/src/styleTree/picker.ts | 152 +- styles/src/styleTree/projectPanel.ts | 226 +- styles/src/styleTree/search.ts | 218 +- .../styleTree/simpleMessageNotification.ts | 82 +- styles/src/styleTree/statusBar.ts | 268 +- styles/src/styleTree/tabBar.ts | 200 +- styles/src/styleTree/toolbarDropdownMenu.ts | 100 +- styles/src/styleTree/updateNotification.ts | 60 +- styles/src/styleTree/welcome.ts | 242 +- styles/src/styleTree/workspace.ts | 736 +++--- styles/vitest.config.ts | 8 + 25 files changed, 4546 insertions(+), 2163 deletions(-) create mode 100644 styles/src/element/interactive/index.ts create mode 100644 styles/src/element/interactive/interactive.test.ts rename styles/src/{styleTree => element/interactive}/interactive.ts (58%) create mode 100644 styles/vitest.config.ts diff --git a/styles/.gitignore b/styles/.gitignore index c2658d7d1b..25fbf5a1c4 100644 --- a/styles/.gitignore +++ b/styles/.gitignore @@ -1 +1,2 @@ node_modules/ +coverage/ diff --git a/styles/package-lock.json b/styles/package-lock.json index b4bdd52c66..faa64043b6 100644 --- a/styles/package-lock.json +++ b/styles/package-lock.json @@ -20,9 +20,32 @@ "toml": "^3.0.0", "ts-deepmerge": "^6.0.3", "ts-node": "^10.9.1", - "utility-types": "^3.10.0" + "utility-types": "^3.10.0", + "vitest": "^0.32.0" + }, + "devDependencies": { + "@vitest/coverage-v8": "^0.32.0" } }, + "node_modules/@ampproject/remapping": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", + "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -34,6 +57,359 @@ "node": ">=12" } }, + "node_modules/@esbuild/android-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", + "integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz", + "integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz", + "integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", + "integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz", + "integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz", + "integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz", + "integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz", + "integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", + "integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz", + "integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz", + "integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==", + "cpu": [ + "loong64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz", + "integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz", + "integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz", + "integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz", + "integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", + "integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz", + "integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", + "integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz", + "integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", + "integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz", + "integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", + "integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", @@ -42,6 +418,15 @@ "node": ">=6.0.0" } }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.14", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", @@ -81,16 +466,124 @@ "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==" }, + "node_modules/@types/chai": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.5.tgz", + "integrity": "sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==" + }, + "node_modules/@types/chai-subset": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@types/chai-subset/-/chai-subset-1.3.3.tgz", + "integrity": "sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==", + "dependencies": { + "@types/chai": "*" + } + }, "node_modules/@types/chroma-js": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/@types/chroma-js/-/chroma-js-2.4.0.tgz", "integrity": "sha512-JklMxityrwjBTjGY2anH8JaTx3yjRU3/sEHSblLH1ba5lqcSh1LnImXJZO5peJfXyqKYWjHTGy4s5Wz++hARrw==" }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", + "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", + "dev": true + }, "node_modules/@types/node": { "version": "18.14.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.1.tgz", "integrity": "sha512-QH+37Qds3E0eDlReeboBxfHbX9omAcBCXEzswCu6jySP642jiM3cYSIkU/REqwhCUqXdonHFuBfJDiAJxMNhaQ==" }, + "node_modules/@vitest/coverage-v8": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-0.32.0.tgz", + "integrity": "sha512-VXXlWq9X/NbsoP/l/CHLBjutsFFww1UY1qEhzGjn/DY7Tqe+z0Nu8XKc8im/XUAmjiWsh2XV7sy/F0IKAl4eaw==", + "dev": true, + "dependencies": { + "@ampproject/remapping": "^2.2.1", + "@bcoe/v8-coverage": "^0.2.3", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.1", + "istanbul-reports": "^3.1.5", + "magic-string": "^0.30.0", + "picocolors": "^1.0.0", + "std-env": "^3.3.2", + "test-exclude": "^6.0.0", + "v8-to-istanbul": "^9.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "vitest": ">=0.32.0 <1" + } + }, + "node_modules/@vitest/expect": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.32.0.tgz", + "integrity": "sha512-VxVHhIxKw9Lux+O9bwLEEk2gzOUe93xuFHy9SzYWnnoYZFYg1NfBtnfnYWiJN7yooJ7KNElCK5YtA7DTZvtXtg==", + "dependencies": { + "@vitest/spy": "0.32.0", + "@vitest/utils": "0.32.0", + "chai": "^4.3.7" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.32.0.tgz", + "integrity": "sha512-QpCmRxftHkr72xt5A08xTEs9I4iWEXIOCHWhQQguWOKE4QH7DXSKZSOFibuwEIMAD7G0ERvtUyQn7iPWIqSwmw==", + "dependencies": { + "@vitest/utils": "0.32.0", + "concordance": "^5.0.4", + "p-limit": "^4.0.0", + "pathe": "^1.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-0.32.0.tgz", + "integrity": "sha512-yCKorPWjEnzpUxQpGlxulujTcSPgkblwGzAUEL+z01FTUg/YuCDZ8dxr9sHA08oO2EwxzHXNLjQKWJ2zc2a19Q==", + "dependencies": { + "magic-string": "^0.30.0", + "pathe": "^1.1.0", + "pretty-format": "^27.5.1" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.32.0.tgz", + "integrity": "sha512-MruAPlM0uyiq3d53BkwTeShXY0rYEfhNGQzVO5GHBmmX3clsxcWp79mMnkOVcV244sNTeDcHbcPFWIjOI4tZvw==", + "dependencies": { + "tinyspy": "^2.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.32.0.tgz", + "integrity": "sha512-53yXunzx47MmbuvcOPpLaVljHaeSu1G2dHdmy7+9ngMnQIkBQcvwOcoclWFnxDMxFbnq8exAfh3aKSZaK71J5A==", + "dependencies": { + "concordance": "^5.0.4", + "loupe": "^2.3.6", + "pretty-format": "^27.5.1" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "node_modules/acorn": { "version": "8.8.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", @@ -110,11 +603,38 @@ "node": ">=0.4.0" } }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "engines": { + "node": "*" + } + }, "node_modules/ayu": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/ayu/-/ayu-8.0.1.tgz", @@ -125,11 +645,40 @@ "nonenumerable": "^1.1.1" } }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, "node_modules/bezier-easing": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/bezier-easing/-/bezier-easing-2.1.0.tgz", "integrity": "sha512-gbIqZ/eslnUFC1tjEvtz0sgx+xTK20wDnYMIA27VA04R7w6xxXQPZDbibjA9DTWZRA2CXtwHykkVzlCaAJAZig==" }, + "node_modules/blueimp-md5": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz", + "integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "engines": { + "node": ">=8" + } + }, "node_modules/case-anything": { "version": "2.1.10", "resolved": "https://registry.npmjs.org/case-anything/-/case-anything-2.1.10.tgz", @@ -141,16 +690,109 @@ "url": "https://github.com/sponsors/mesqueeb" } }, + "node_modules/chai": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", + "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==", + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^4.1.2", + "get-func-name": "^2.0.0", + "loupe": "^2.3.1", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", + "engines": { + "node": "*" + } + }, "node_modules/chroma-js": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chroma-js/-/chroma-js-2.4.2.tgz", "integrity": "sha512-U9eDw6+wt7V8z5NncY2jJfZa+hUH8XEj8FQHgFJTrUFnJfXYf4Ml4adI2vXZOjqRDpFWtYVWypDfZwnJ+HIR4A==" }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/concordance": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/concordance/-/concordance-5.0.4.tgz", + "integrity": "sha512-OAcsnTEYu1ARJqWVGwf4zh4JDfHZEaSNlNccFmt8YjB2l/n19/PF2viLINHc57vO4FKIAFl2FWASIGZZWZ2Kxw==", + "dependencies": { + "date-time": "^3.1.0", + "esutils": "^2.0.3", + "fast-diff": "^1.2.0", + "js-string-escape": "^1.0.1", + "lodash": "^4.17.15", + "md5-hex": "^3.0.1", + "semver": "^7.3.2", + "well-known-symbols": "^2.0.0" + }, + "engines": { + "node": ">=10.18.0 <11 || >=12.14.0 <13 || >=14" + } + }, + "node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" }, + "node_modules/date-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/date-time/-/date-time-3.1.0.tgz", + "integrity": "sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg==", + "dependencies": { + "time-zone": "^1.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-eql": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/deepmerge": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.0.tgz", @@ -167,16 +809,564 @@ "node": ">=0.3.1" } }, + "node_modules/esbuild": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz", + "integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==", + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.17.19", + "@esbuild/android-arm64": "0.17.19", + "@esbuild/android-x64": "0.17.19", + "@esbuild/darwin-arm64": "0.17.19", + "@esbuild/darwin-x64": "0.17.19", + "@esbuild/freebsd-arm64": "0.17.19", + "@esbuild/freebsd-x64": "0.17.19", + "@esbuild/linux-arm": "0.17.19", + "@esbuild/linux-arm64": "0.17.19", + "@esbuild/linux-ia32": "0.17.19", + "@esbuild/linux-loong64": "0.17.19", + "@esbuild/linux-mips64el": "0.17.19", + "@esbuild/linux-ppc64": "0.17.19", + "@esbuild/linux-riscv64": "0.17.19", + "@esbuild/linux-s390x": "0.17.19", + "@esbuild/linux-x64": "0.17.19", + "@esbuild/netbsd-x64": "0.17.19", + "@esbuild/openbsd-x64": "0.17.19", + "@esbuild/sunos-x64": "0.17.19", + "@esbuild/win32-arm64": "0.17.19", + "@esbuild/win32-ia32": "0.17.19", + "@esbuild/win32-x64": "0.17.19" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==" + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", + "engines": { + "node": "*" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", + "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/js-string-escape": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", + "integrity": "sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==" + }, + "node_modules/local-pkg": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.3.tgz", + "integrity": "sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/loupe": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", + "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "dependencies": { + "get-func-name": "^2.0.0" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/magic-string": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.0.tgz", + "integrity": "sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.13" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" }, + "node_modules/md5-hex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/md5-hex/-/md5-hex-3.0.1.tgz", + "integrity": "sha512-BUiRtTtV39LIJwinWBjqVsU9xhdnz7/i889V859IBFpuqGAj6LuOvHv5XLbgZ2R7ptJoJaEcxkv88/h25T7Ciw==", + "dependencies": { + "blueimp-md5": "^2.10.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mlly": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.3.0.tgz", + "integrity": "sha512-HT5mcgIQKkOrZecOjOX3DJorTikWXwsBfpcr/MGBkhfWcjiqvnaL/9ppxvIUXfjT6xt4DVIAsN9fMUz1ev4bIw==", + "dependencies": { + "acorn": "^8.8.2", + "pathe": "^1.1.0", + "pkg-types": "^1.0.3", + "ufo": "^1.1.2" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/nonenumerable": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/nonenumerable/-/nonenumerable-1.1.1.tgz", "integrity": "sha512-ptUD9w9D8WqW6fuJJkZNCImkf+0vdbgUTbRK3i7jsy3olqtH96hYE6Q/S3Tx9NWbcB/ocAjYshXCAUP0lZ9B4Q==" }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", + "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", + "dependencies": { + "yocto-queue": "^1.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pathe": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.1.tgz", + "integrity": "sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==" + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "engines": { + "node": "*" + } + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "node_modules/pkg-types": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.3.tgz", + "integrity": "sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==", + "dependencies": { + "jsonc-parser": "^3.2.0", + "mlly": "^1.2.0", + "pathe": "^1.1.0" + } + }, + "node_modules/postcss": { + "version": "8.4.24", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.24.tgz", + "integrity": "sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" + }, + "node_modules/rollup": { + "version": "3.25.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.1.tgz", + "integrity": "sha512-tywOR+rwIt5m2ZAWSe5AIJcTat8vGlnPFAv15ycCrw33t6iFsXZ6mzHVFh2psSjxQPmI+xgzMZZizUAukBI4aQ==", + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=14.18.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/semver": { + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.2.tgz", + "integrity": "sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==" + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==" + }, + "node_modules/std-env": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.3.3.tgz", + "integrity": "sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==" + }, + "node_modules/strip-literal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.1.tgz", + "integrity": "sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==", + "dependencies": { + "acorn": "^8.8.2" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/time-zone": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz", + "integrity": "sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/tinybench": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.5.0.tgz", + "integrity": "sha512-kRwSG8Zx4tjF9ZiyH4bhaebu+EDz1BOx9hOigYHlUW4xxI/wKIUQUqo018UlU4ar6ATPBsaMrdbKZ+tmPdohFA==" + }, + "node_modules/tinypool": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.5.0.tgz", + "integrity": "sha512-paHQtnrlS1QZYKF/GnLoOM/DN9fqaGOFbCbxzAhwniySnzl9Ebk8w73/dd34DAhe/obUbPAOldTyYXQZxnPBPQ==", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-2.1.1.tgz", + "integrity": "sha512-XPJL2uSzcOyBMky6OFrusqWlzfFrXtE0hPuMgW8A2HmaqrPo4ZQHRN/V0QXN3FSjKxpsbRrFc5LI7KOwBsT1/w==", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/toml": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", @@ -232,6 +1422,14 @@ } } }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "engines": { + "node": ">=4" + } + }, "node_modules/typescript": { "version": "4.9.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", @@ -245,6 +1443,11 @@ "node": ">=4.2.0" } }, + "node_modules/ufo": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.1.2.tgz", + "integrity": "sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==" + }, "node_modules/utility-types": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", @@ -258,6 +1461,210 @@ "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" }, + "node_modules/v8-to-istanbul": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", + "integrity": "sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^1.6.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/v8-to-istanbul/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.18", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", + "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" + } + }, + "node_modules/vite": { + "version": "4.3.9", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.3.9.tgz", + "integrity": "sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==", + "dependencies": { + "esbuild": "^0.17.5", + "postcss": "^8.4.23", + "rollup": "^3.21.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "@types/node": ">= 14", + "less": "*", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.32.0.tgz", + "integrity": "sha512-220P/y8YacYAU+daOAqiGEFXx2A8AwjadDzQqos6wSukjvvTWNqleJSwoUn0ckyNdjHIKoxn93Nh1vWBqEKr3Q==", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.4", + "mlly": "^1.2.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "vite": "^3.0.0 || ^4.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": ">=v14.18.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vitest": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.32.0.tgz", + "integrity": "sha512-SW83o629gCqnV3BqBnTxhB10DAwzwEx3z+rqYZESehUB+eWsJxwcBQx7CKy0otuGMJTYh7qCVuUX23HkftGl/Q==", + "dependencies": { + "@types/chai": "^4.3.5", + "@types/chai-subset": "^1.3.3", + "@types/node": "*", + "@vitest/expect": "0.32.0", + "@vitest/runner": "0.32.0", + "@vitest/snapshot": "0.32.0", + "@vitest/spy": "0.32.0", + "@vitest/utils": "0.32.0", + "acorn": "^8.8.2", + "acorn-walk": "^8.2.0", + "cac": "^6.7.14", + "chai": "^4.3.7", + "concordance": "^5.0.4", + "debug": "^4.3.4", + "local-pkg": "^0.4.3", + "magic-string": "^0.30.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "std-env": "^3.3.2", + "strip-literal": "^1.0.1", + "tinybench": "^2.5.0", + "tinypool": "^0.5.0", + "vite": "^3.0.0 || ^4.0.0", + "vite-node": "0.32.0", + "why-is-node-running": "^2.2.2" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": ">=v14.18.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@vitest/browser": "*", + "@vitest/ui": "*", + "happy-dom": "*", + "jsdom": "*", + "playwright": "*", + "safaridriver": "*", + "webdriverio": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "playwright": { + "optional": true + }, + "safaridriver": { + "optional": true + }, + "webdriverio": { + "optional": true + } + } + }, + "node_modules/well-known-symbols": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz", + "integrity": "sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q==", + "engines": { + "node": ">=6" + } + }, + "node_modules/why-is-node-running": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz", + "integrity": "sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, "node_modules/yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", @@ -265,9 +1672,36 @@ "engines": { "node": ">=6" } + }, + "node_modules/yocto-queue": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", + "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } }, "dependencies": { + "@ampproject/remapping": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", + "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", + "dev": true, + "requires": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, "@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -276,11 +1710,166 @@ "@jridgewell/trace-mapping": "0.3.9" } }, + "@esbuild/android-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", + "integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==", + "optional": true + }, + "@esbuild/android-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz", + "integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==", + "optional": true + }, + "@esbuild/android-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz", + "integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==", + "optional": true + }, + "@esbuild/darwin-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", + "integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==", + "optional": true + }, + "@esbuild/darwin-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz", + "integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==", + "optional": true + }, + "@esbuild/freebsd-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz", + "integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==", + "optional": true + }, + "@esbuild/freebsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz", + "integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==", + "optional": true + }, + "@esbuild/linux-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz", + "integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==", + "optional": true + }, + "@esbuild/linux-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", + "integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==", + "optional": true + }, + "@esbuild/linux-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz", + "integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==", + "optional": true + }, + "@esbuild/linux-loong64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz", + "integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==", + "optional": true + }, + "@esbuild/linux-mips64el": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz", + "integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==", + "optional": true + }, + "@esbuild/linux-ppc64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz", + "integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==", + "optional": true + }, + "@esbuild/linux-riscv64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz", + "integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==", + "optional": true + }, + "@esbuild/linux-s390x": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz", + "integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==", + "optional": true + }, + "@esbuild/linux-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", + "integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==", + "optional": true + }, + "@esbuild/netbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz", + "integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==", + "optional": true + }, + "@esbuild/openbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", + "integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==", + "optional": true + }, + "@esbuild/sunos-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz", + "integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==", + "optional": true + }, + "@esbuild/win32-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", + "integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==", + "optional": true + }, + "@esbuild/win32-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz", + "integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==", + "optional": true + }, + "@esbuild/win32-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", + "integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==", + "optional": true + }, + "@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true + }, + "@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "requires": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, "@jridgewell/resolve-uri": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==" }, + "@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true + }, "@jridgewell/sourcemap-codec": { "version": "1.4.14", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", @@ -320,16 +1909,103 @@ "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==" }, + "@types/chai": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.5.tgz", + "integrity": "sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==" + }, + "@types/chai-subset": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@types/chai-subset/-/chai-subset-1.3.3.tgz", + "integrity": "sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==", + "requires": { + "@types/chai": "*" + } + }, "@types/chroma-js": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/@types/chroma-js/-/chroma-js-2.4.0.tgz", "integrity": "sha512-JklMxityrwjBTjGY2anH8JaTx3yjRU3/sEHSblLH1ba5lqcSh1LnImXJZO5peJfXyqKYWjHTGy4s5Wz++hARrw==" }, + "@types/istanbul-lib-coverage": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", + "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", + "dev": true + }, "@types/node": { "version": "18.14.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.1.tgz", "integrity": "sha512-QH+37Qds3E0eDlReeboBxfHbX9omAcBCXEzswCu6jySP642jiM3cYSIkU/REqwhCUqXdonHFuBfJDiAJxMNhaQ==" }, + "@vitest/coverage-v8": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-0.32.0.tgz", + "integrity": "sha512-VXXlWq9X/NbsoP/l/CHLBjutsFFww1UY1qEhzGjn/DY7Tqe+z0Nu8XKc8im/XUAmjiWsh2XV7sy/F0IKAl4eaw==", + "dev": true, + "requires": { + "@ampproject/remapping": "^2.2.1", + "@bcoe/v8-coverage": "^0.2.3", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.1", + "istanbul-reports": "^3.1.5", + "magic-string": "^0.30.0", + "picocolors": "^1.0.0", + "std-env": "^3.3.2", + "test-exclude": "^6.0.0", + "v8-to-istanbul": "^9.1.0" + } + }, + "@vitest/expect": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.32.0.tgz", + "integrity": "sha512-VxVHhIxKw9Lux+O9bwLEEk2gzOUe93xuFHy9SzYWnnoYZFYg1NfBtnfnYWiJN7yooJ7KNElCK5YtA7DTZvtXtg==", + "requires": { + "@vitest/spy": "0.32.0", + "@vitest/utils": "0.32.0", + "chai": "^4.3.7" + } + }, + "@vitest/runner": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.32.0.tgz", + "integrity": "sha512-QpCmRxftHkr72xt5A08xTEs9I4iWEXIOCHWhQQguWOKE4QH7DXSKZSOFibuwEIMAD7G0ERvtUyQn7iPWIqSwmw==", + "requires": { + "@vitest/utils": "0.32.0", + "concordance": "^5.0.4", + "p-limit": "^4.0.0", + "pathe": "^1.1.0" + } + }, + "@vitest/snapshot": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-0.32.0.tgz", + "integrity": "sha512-yCKorPWjEnzpUxQpGlxulujTcSPgkblwGzAUEL+z01FTUg/YuCDZ8dxr9sHA08oO2EwxzHXNLjQKWJ2zc2a19Q==", + "requires": { + "magic-string": "^0.30.0", + "pathe": "^1.1.0", + "pretty-format": "^27.5.1" + } + }, + "@vitest/spy": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.32.0.tgz", + "integrity": "sha512-MruAPlM0uyiq3d53BkwTeShXY0rYEfhNGQzVO5GHBmmX3clsxcWp79mMnkOVcV244sNTeDcHbcPFWIjOI4tZvw==", + "requires": { + "tinyspy": "^2.1.0" + } + }, + "@vitest/utils": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.32.0.tgz", + "integrity": "sha512-53yXunzx47MmbuvcOPpLaVljHaeSu1G2dHdmy7+9ngMnQIkBQcvwOcoclWFnxDMxFbnq8exAfh3aKSZaK71J5A==", + "requires": { + "concordance": "^5.0.4", + "loupe": "^2.3.6", + "pretty-format": "^27.5.1" + } + }, "acorn": { "version": "8.8.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", @@ -340,11 +2016,26 @@ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==" }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, + "ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==" + }, "arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" + }, "ayu": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/ayu/-/ayu-8.0.1.tgz", @@ -355,26 +2046,122 @@ "nonenumerable": "^1.1.1" } }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, "bezier-easing": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/bezier-easing/-/bezier-easing-2.1.0.tgz", "integrity": "sha512-gbIqZ/eslnUFC1tjEvtz0sgx+xTK20wDnYMIA27VA04R7w6xxXQPZDbibjA9DTWZRA2CXtwHykkVzlCaAJAZig==" }, + "blueimp-md5": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz", + "integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==" + }, "case-anything": { "version": "2.1.10", "resolved": "https://registry.npmjs.org/case-anything/-/case-anything-2.1.10.tgz", "integrity": "sha512-JczJwVrCP0jPKh05McyVsuOg6AYosrB9XWZKbQzXeDAm2ClE/PJE/BcrrQrVyGYH7Jg8V/LDupmyL4kFlVsVFQ==" }, + "chai": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", + "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==", + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^4.1.2", + "get-func-name": "^2.0.0", + "loupe": "^2.3.1", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==" + }, "chroma-js": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chroma-js/-/chroma-js-2.4.2.tgz", "integrity": "sha512-U9eDw6+wt7V8z5NncY2jJfZa+hUH8XEj8FQHgFJTrUFnJfXYf4Ml4adI2vXZOjqRDpFWtYVWypDfZwnJ+HIR4A==" }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "concordance": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/concordance/-/concordance-5.0.4.tgz", + "integrity": "sha512-OAcsnTEYu1ARJqWVGwf4zh4JDfHZEaSNlNccFmt8YjB2l/n19/PF2viLINHc57vO4FKIAFl2FWASIGZZWZ2Kxw==", + "requires": { + "date-time": "^3.1.0", + "esutils": "^2.0.3", + "fast-diff": "^1.2.0", + "js-string-escape": "^1.0.1", + "lodash": "^4.17.15", + "md5-hex": "^3.0.1", + "semver": "^7.3.2", + "well-known-symbols": "^2.0.0" + } + }, + "convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, "create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" }, + "date-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/date-time/-/date-time-3.1.0.tgz", + "integrity": "sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg==", + "requires": { + "time-zone": "^1.0.0" + } + }, + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "deep-eql": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "requires": { + "type-detect": "^4.0.0" + } + }, "deepmerge": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.0.tgz", @@ -385,16 +2172,414 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" }, + "esbuild": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz", + "integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==", + "requires": { + "@esbuild/android-arm": "0.17.19", + "@esbuild/android-arm64": "0.17.19", + "@esbuild/android-x64": "0.17.19", + "@esbuild/darwin-arm64": "0.17.19", + "@esbuild/darwin-x64": "0.17.19", + "@esbuild/freebsd-arm64": "0.17.19", + "@esbuild/freebsd-x64": "0.17.19", + "@esbuild/linux-arm": "0.17.19", + "@esbuild/linux-arm64": "0.17.19", + "@esbuild/linux-ia32": "0.17.19", + "@esbuild/linux-loong64": "0.17.19", + "@esbuild/linux-mips64el": "0.17.19", + "@esbuild/linux-ppc64": "0.17.19", + "@esbuild/linux-riscv64": "0.17.19", + "@esbuild/linux-s390x": "0.17.19", + "@esbuild/linux-x64": "0.17.19", + "@esbuild/netbsd-x64": "0.17.19", + "@esbuild/openbsd-x64": "0.17.19", + "@esbuild/sunos-x64": "0.17.19", + "@esbuild/win32-arm64": "0.17.19", + "@esbuild/win32-ia32": "0.17.19", + "@esbuild/win32-x64": "0.17.19" + } + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, + "fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==" + }, + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "istanbul-lib-coverage": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", + "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", + "dev": true + }, + "istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "requires": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + } + }, + "istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + } + }, + "istanbul-reports": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "dev": true, + "requires": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + } + }, + "js-string-escape": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", + "integrity": "sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg==" + }, + "jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==" + }, + "local-pkg": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.3.tgz", + "integrity": "sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==" + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "loupe": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", + "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "requires": { + "get-func-name": "^2.0.0" + } + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + }, + "magic-string": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.0.tgz", + "integrity": "sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==", + "requires": { + "@jridgewell/sourcemap-codec": "^1.4.13" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" }, + "md5-hex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/md5-hex/-/md5-hex-3.0.1.tgz", + "integrity": "sha512-BUiRtTtV39LIJwinWBjqVsU9xhdnz7/i889V859IBFpuqGAj6LuOvHv5XLbgZ2R7ptJoJaEcxkv88/h25T7Ciw==", + "requires": { + "blueimp-md5": "^2.10.0" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "mlly": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.3.0.tgz", + "integrity": "sha512-HT5mcgIQKkOrZecOjOX3DJorTikWXwsBfpcr/MGBkhfWcjiqvnaL/9ppxvIUXfjT6xt4DVIAsN9fMUz1ev4bIw==", + "requires": { + "acorn": "^8.8.2", + "pathe": "^1.1.0", + "pkg-types": "^1.0.3", + "ufo": "^1.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==" + }, "nonenumerable": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/nonenumerable/-/nonenumerable-1.1.1.tgz", "integrity": "sha512-ptUD9w9D8WqW6fuJJkZNCImkf+0vdbgUTbRK3i7jsy3olqtH96hYE6Q/S3Tx9NWbcB/ocAjYshXCAUP0lZ9B4Q==" }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "p-limit": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", + "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", + "requires": { + "yocto-queue": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true + }, + "pathe": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.1.tgz", + "integrity": "sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==" + }, + "pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==" + }, + "picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "pkg-types": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.3.tgz", + "integrity": "sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==", + "requires": { + "jsonc-parser": "^3.2.0", + "mlly": "^1.2.0", + "pathe": "^1.1.0" + } + }, + "postcss": { + "version": "8.4.24", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.24.tgz", + "integrity": "sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==", + "requires": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + } + }, + "pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "requires": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + } + }, + "react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" + }, + "rollup": { + "version": "3.25.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.1.tgz", + "integrity": "sha512-tywOR+rwIt5m2ZAWSe5AIJcTat8vGlnPFAv15ycCrw33t6iFsXZ6mzHVFh2psSjxQPmI+xgzMZZizUAukBI4aQ==", + "requires": { + "fsevents": "~2.3.2" + } + }, + "semver": { + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.2.tgz", + "integrity": "sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ==", + "requires": { + "lru-cache": "^6.0.0" + } + }, + "siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==" + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==" + }, + "stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==" + }, + "std-env": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.3.3.tgz", + "integrity": "sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==" + }, + "strip-literal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.1.tgz", + "integrity": "sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==", + "requires": { + "acorn": "^8.8.2" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + } + }, + "time-zone": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz", + "integrity": "sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA==" + }, + "tinybench": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.5.0.tgz", + "integrity": "sha512-kRwSG8Zx4tjF9ZiyH4bhaebu+EDz1BOx9hOigYHlUW4xxI/wKIUQUqo018UlU4ar6ATPBsaMrdbKZ+tmPdohFA==" + }, + "tinypool": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.5.0.tgz", + "integrity": "sha512-paHQtnrlS1QZYKF/GnLoOM/DN9fqaGOFbCbxzAhwniySnzl9Ebk8w73/dd34DAhe/obUbPAOldTyYXQZxnPBPQ==" + }, + "tinyspy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-2.1.1.tgz", + "integrity": "sha512-XPJL2uSzcOyBMky6OFrusqWlzfFrXtE0hPuMgW8A2HmaqrPo4ZQHRN/V0QXN3FSjKxpsbRrFc5LI7KOwBsT1/w==" + }, "toml": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", @@ -425,12 +2610,22 @@ "yn": "3.1.1" } }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" + }, "typescript": { "version": "4.9.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "peer": true }, + "ufo": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.1.2.tgz", + "integrity": "sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==" + }, "utility-types": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", @@ -441,10 +2636,119 @@ "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" }, + "v8-to-istanbul": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", + "integrity": "sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^1.6.0" + }, + "dependencies": { + "@jridgewell/trace-mapping": { + "version": "0.3.18", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", + "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" + } + } + } + }, + "vite": { + "version": "4.3.9", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.3.9.tgz", + "integrity": "sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==", + "requires": { + "esbuild": "^0.17.5", + "fsevents": "~2.3.2", + "postcss": "^8.4.23", + "rollup": "^3.21.0" + } + }, + "vite-node": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.32.0.tgz", + "integrity": "sha512-220P/y8YacYAU+daOAqiGEFXx2A8AwjadDzQqos6wSukjvvTWNqleJSwoUn0ckyNdjHIKoxn93Nh1vWBqEKr3Q==", + "requires": { + "cac": "^6.7.14", + "debug": "^4.3.4", + "mlly": "^1.2.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "vite": "^3.0.0 || ^4.0.0" + } + }, + "vitest": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.32.0.tgz", + "integrity": "sha512-SW83o629gCqnV3BqBnTxhB10DAwzwEx3z+rqYZESehUB+eWsJxwcBQx7CKy0otuGMJTYh7qCVuUX23HkftGl/Q==", + "requires": { + "@types/chai": "^4.3.5", + "@types/chai-subset": "^1.3.3", + "@types/node": "*", + "@vitest/expect": "0.32.0", + "@vitest/runner": "0.32.0", + "@vitest/snapshot": "0.32.0", + "@vitest/spy": "0.32.0", + "@vitest/utils": "0.32.0", + "acorn": "^8.8.2", + "acorn-walk": "^8.2.0", + "cac": "^6.7.14", + "chai": "^4.3.7", + "concordance": "^5.0.4", + "debug": "^4.3.4", + "local-pkg": "^0.4.3", + "magic-string": "^0.30.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "std-env": "^3.3.2", + "strip-literal": "^1.0.1", + "tinybench": "^2.5.0", + "tinypool": "^0.5.0", + "vite": "^3.0.0 || ^4.0.0", + "vite-node": "0.32.0", + "why-is-node-running": "^2.2.2" + } + }, + "well-known-symbols": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz", + "integrity": "sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q==" + }, + "why-is-node-running": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz", + "integrity": "sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==", + "requires": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, "yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==" + }, + "yocto-queue": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", + "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==" } } } diff --git a/styles/package.json b/styles/package.json index 30336d5c51..9907b0cbff 100644 --- a/styles/package.json +++ b/styles/package.json @@ -6,7 +6,8 @@ "scripts": { "build": "ts-node ./src/buildThemes.ts", "build-licenses": "ts-node ./src/buildLicenses.ts", - "build-tokens": "ts-node ./src/buildTokens.ts" + "build-tokens": "ts-node ./src/buildTokens.ts", + "test": "vitest" }, "author": "", "license": "ISC", @@ -22,12 +23,16 @@ "toml": "^3.0.0", "ts-deepmerge": "^6.0.3", "ts-node": "^10.9.1", - "utility-types": "^3.10.0" + "utility-types": "^3.10.0", + "vitest": "^0.32.0" }, "prettier": { "semi": false, "printWidth": 80, "htmlWhitespaceSensitivity": "strict", "tabWidth": 4 + }, + "devDependencies": { + "@vitest/coverage-v8": "^0.32.0" } } diff --git a/styles/src/element/interactive/index.ts b/styles/src/element/interactive/index.ts new file mode 100644 index 0000000000..0ead902eb9 --- /dev/null +++ b/styles/src/element/interactive/index.ts @@ -0,0 +1,3 @@ +import { interactive } from "./interactive"; + +export { interactive } diff --git a/styles/src/element/interactive/interactive.test.ts b/styles/src/element/interactive/interactive.test.ts new file mode 100644 index 0000000000..aa716e998e --- /dev/null +++ b/styles/src/element/interactive/interactive.test.ts @@ -0,0 +1,59 @@ +import { NOT_ENOUGH_STATES_ERROR, NO_DEFAULT_OR_BASE_ERROR, interactive } from './interactive' +import { describe, it, expect } from 'vitest' + +describe('interactive', () => { + + it('creates an Interactive with base properties and states', () => { + + const result = interactive({ + base: { fontSize: 10, color: '#FFFFFF' }, + state: { + hovered: { color: '#EEEEEE' }, + clicked: { color: '#CCCCCC' }, + } + }) + + expect(result).toEqual({ + default: { color: '#FFFFFF', fontSize: 10 }, + hovered: { color: '#EEEEEE', fontSize: 10 }, + clicked: { color: '#CCCCCC', fontSize: 10 }, + }) + }) + + it('creates an Interactive with no base properties', () => { + + const result = interactive({ + state: { + default: { color: '#FFFFFF', fontSize: 10 }, + hovered: { color: '#EEEEEE' }, + clicked: { color: '#CCCCCC' }, + } + }) + + expect(result).toEqual({ + default: { color: '#FFFFFF', fontSize: 10 }, + hovered: { color: '#EEEEEE', fontSize: 10 }, + clicked: { color: '#CCCCCC', fontSize: 10 }, + }) + }) + + it('throws error when both default and base are missing', () => { + const state = { + hovered: { color: 'blue' }, + } + + expect(() => interactive({ state })).toThrow( + NO_DEFAULT_OR_BASE_ERROR + ) + }) + + it('throws error when no other state besides default is present', () => { + const state = { + default: { fontSize: 10 }, + } + + expect(() => interactive({ state })).toThrow( + NOT_ENOUGH_STATES_ERROR + ) + }) +}) diff --git a/styles/src/styleTree/interactive.ts b/styles/src/element/interactive/interactive.ts similarity index 58% rename from styles/src/styleTree/interactive.ts rename to styles/src/element/interactive/interactive.ts index 6bc6ca048b..23cd2a8c15 100644 --- a/styles/src/styleTree/interactive.ts +++ b/styles/src/element/interactive/interactive.ts @@ -10,24 +10,27 @@ type Interactive = { disabled?: T, }; +export const NO_DEFAULT_OR_BASE_ERROR = "An interactive object must have a default state, or a base property." +export const NOT_ENOUGH_STATES_ERROR = "An interactive object must have a default and at least one other state." + interface InteractiveProps { base?: T, state: Partial> } /** - * Helper function for creating Interactive objects that works pretty much like Toggle. - * It takes a object to be used as a value for `default` field and then fills out other fields - * with fields from either `base` or `modifications`. - * Notably, it does not touch `hover`, `clicked` and `disabled` if there are no modifications for it. + * Helper function for creating Interactive objects that works with Toggle-like behavior. + * It takes a default object to be used as the value for `default` field and fills out other fields + * with fields from either `base` or from the `state` object which contains values for specific states. + * Notably, it does not touch `hover`, `clicked`, `selected` and `disabled` states if there are no modifications for them. * - * @param defaultObj Object to be used as the value for `default` field. - * @param base Object containing base fields to be included in the resulting object. - * @param modifications Object containing modified fields to be included in the resulting object. - * @returns Interactive object with fields from `base` and `modifications`. + * @param defaultObj Object to be used as the value for the `default` field. + * @param base Optional object containing base fields to be included in the resulting object. + * @param state Object containing optional modified fields to be included in the resulting object for each state. + * @returns Interactive object with fields from `base` and `state`. */ export function interactive({ base, state }: InteractiveProps): Interactive { - if (!base && !state.default) throw new Error("An interactive object must have a default state, or a base property."); + if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR); let defaultState: T; @@ -64,7 +67,7 @@ export function interactive({ base, state }: InteractiveProps< } if (stateCount < 1) { - throw new Error("An interactive object must have a default and at least one other state."); + throw new Error(NOT_ENOUGH_STATES_ERROR); } return interactiveObj; diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index d501237721..b31fe8169e 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -1,94 +1,94 @@ import { ColorScheme } from "../theme/colorScheme" import { text, border, background, foreground } from "./components" import editor from "./editor" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function assistant(colorScheme: ColorScheme) { - const layer = colorScheme.highest - return { - container: { - background: editor(colorScheme).background, - padding: { left: 12 }, - }, - header: { - border: border(layer, "default", { bottom: true, top: true }), - margin: { bottom: 6, top: 6 }, - background: editor(colorScheme).background, - }, - userSender: { - default: - { ...text(layer, "sans", "default", { size: "sm", weight: "bold" }) }, - }, - assistantSender: { - default: { - ...text(layer, "sans", "accent", { size: "sm", weight: "bold" }) - }, - }, - systemSender: { - default: { - ...text(layer, "sans", "variant", { size: "sm", weight: "bold" }) - }, - }, - sentAt: { - margin: { top: 2, left: 8 }, - ...text(layer, "sans", "default", { size: "2xs" }), - }, - modelInfoContainer: { - margin: { right: 16, top: 4 }, - }, - model: interactive({ - base: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - cornerRadius: 4, - ...text(layer, "sans", "default", { size: "xs" }), - }, state: { - hovered: { - background: background(layer, "on", "hovered"), - } - } - }), - remainingTokens: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - margin: { left: 4 }, - cornerRadius: 4, - ...text(layer, "sans", "positive", { size: "xs" }), - }, - noRemainingTokens: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - margin: { left: 4 }, - cornerRadius: 4, - ...text(layer, "sans", "negative", { size: "xs" }), - }, - errorIcon: { - margin: { left: 8 }, - color: foreground(layer, "negative"), - width: 12, - }, - apiKeyEditor: { - background: background(layer, "on"), - cornerRadius: 6, - text: text(layer, "mono", "on"), - placeholderText: text(layer, "mono", "on", "disabled", { - size: "xs", - }), - selection: colorScheme.players[0], - border: border(layer, "on"), - padding: { - bottom: 4, - left: 8, - right: 8, - top: 4, - }, - }, - apiKeyPrompt: { - padding: 10, - ...text(layer, "sans", "default", { size: "xs" }), - }, - } + const layer = colorScheme.highest + return { + container: { + background: editor(colorScheme).background, + padding: { left: 12 }, + }, + header: { + border: border(layer, "default", { bottom: true, top: true }), + margin: { bottom: 6, top: 6 }, + background: editor(colorScheme).background, + }, + userSender: { + default: + { ...text(layer, "sans", "default", { size: "sm", weight: "bold" }) }, + }, + assistantSender: { + default: { + ...text(layer, "sans", "accent", { size: "sm", weight: "bold" }) + }, + }, + systemSender: { + default: { + ...text(layer, "sans", "variant", { size: "sm", weight: "bold" }) + }, + }, + sentAt: { + margin: { top: 2, left: 8 }, + ...text(layer, "sans", "default", { size: "2xs" }), + }, + modelInfoContainer: { + margin: { right: 16, top: 4 }, + }, + model: interactive({ + base: { + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + padding: 4, + cornerRadius: 4, + ...text(layer, "sans", "default", { size: "xs" }), + }, state: { + hovered: { + background: background(layer, "on", "hovered"), + } + } + }), + remainingTokens: { + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + padding: 4, + margin: { left: 4 }, + cornerRadius: 4, + ...text(layer, "sans", "positive", { size: "xs" }), + }, + noRemainingTokens: { + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + padding: 4, + margin: { left: 4 }, + cornerRadius: 4, + ...text(layer, "sans", "negative", { size: "xs" }), + }, + errorIcon: { + margin: { left: 8 }, + color: foreground(layer, "negative"), + width: 12, + }, + apiKeyEditor: { + background: background(layer, "on"), + cornerRadius: 6, + text: text(layer, "mono", "on"), + placeholderText: text(layer, "mono", "on", "disabled", { + size: "xs", + }), + selection: colorScheme.players[0], + border: border(layer, "on"), + padding: { + bottom: 4, + left: 8, + right: 8, + top: 4, + }, + }, + apiKeyPrompt: { + padding: 10, + ...text(layer, "sans", "default", { size: "xs" }), + }, + } } diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index d6cb196770..081a0ba68c 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -2,38 +2,38 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, background } from "./components" import { toggleable } from "./toggle" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function commandPalette(colorScheme: ColorScheme) { - let layer = colorScheme.highest - return { - keystrokeSpacing: 8, - key: - toggleable(interactive({ - base: { - text: text(layer, "mono", "variant", "default", { size: "xs" }), - cornerRadius: 2, - background: background(layer, "on"), - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - margin: { - top: 1, - bottom: 1, - left: 2, - }, - }, state: { hovered: { cornerRadius: 4, padding: { top: 17 } } } - }), { - default: { - text: text(layer, "mono", "on", "default", { size: "xs" }), - background: withOpacity(background(layer, "on"), 0.2), - } + let layer = colorScheme.highest + return { + keystrokeSpacing: 8, + key: + toggleable(interactive({ + base: { + text: text(layer, "mono", "variant", "default", { size: "xs" }), + cornerRadius: 2, + background: background(layer, "on"), + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + margin: { + top: 1, + bottom: 1, + left: 2, + }, + }, state: { hovered: { cornerRadius: 4, padding: { top: 17 } } } + }), { + default: { + text: text(layer, "mono", "on", "default", { size: "xs" }), + background: withOpacity(background(layer, "on"), 0.2), + } - }) - , + }) + , - } + } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 4309343ed2..3b95a3c885 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -1,218 +1,218 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, foreground, text } from "./components" import { toggleable } from "./toggle" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function contactsPanel(colorScheme: ColorScheme) { - const nameMargin = 8 - const sidePadding = 12 + const nameMargin = 8 + const sidePadding = 12 - let layer = colorScheme.middle + let layer = colorScheme.middle - const contactButton = { - background: background(layer, "on"), - color: foreground(layer, "on"), - iconWidth: 8, - buttonWidth: 16, - cornerRadius: 8, - } - const projectRow = { - guestAvatarSpacing: 4, - height: 24, - guestAvatar: { - cornerRadius: 8, - width: 14, - }, - name: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - right: 6, - }, - }, - guests: { - margin: { - left: nameMargin, - right: nameMargin, - }, - }, - padding: { - left: sidePadding, - right: sidePadding, - }, - } - - return { - background: background(layer), - padding: { top: 12 }, - userQueryEditor: { - background: background(layer, "on"), - cornerRadius: 6, - text: text(layer, "mono", "on"), - placeholderText: text(layer, "mono", "on", "disabled", { - size: "xs", - }), - selection: colorScheme.players[0], - border: border(layer, "on"), - padding: { - bottom: 4, - left: 8, - right: 8, - top: 4, - }, - margin: { - left: 6, - }, - }, - userQueryEditorHeight: 33, - addContactButton: { - margin: { left: 6, right: 12 }, - color: foreground(layer, "on"), - buttonWidth: 28, - iconWidth: 16, - }, - rowHeight: 28, - sectionIconSize: 8, - headerRow: toggleable(interactive({ - base: { - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, - }, - background: background(layer, "default"),// posiewic: breaking change - } - , state: { hovered: { background: background(layer, "default") } } // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. - }), - { - default: { - ...text(layer, "mono", "active", { size: "sm" }), - background: background(layer, "active"), - }, - }), - leaveCall: interactive({ - base: { - background: background(layer), - border: border(layer), - cornerRadius: 6, - margin: { - top: 1, - }, - padding: { - top: 1, - bottom: 1, - left: 7, - right: 7, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - } - , - state: { - hovered: { - ...text(layer, "sans", "hovered", { size: "xs" }), - background: background(layer, "hovered"), - border: border(layer, "hovered"), - } - } + const contactButton = { + background: background(layer, "on"), + color: foreground(layer, "on"), + iconWidth: 8, + buttonWidth: 16, + cornerRadius: 8, } - ), - contactRow: { - inactive: { - default: { - padding: { - left: sidePadding, - right: sidePadding, - } - }, - }, - active: { - default: { - background: background(layer, "active"), - padding: { - left: sidePadding, - right: sidePadding, - } - } - }, - }, - - contactAvatar: { - cornerRadius: 10, - width: 18, - }, - contactStatusFree: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "positive"), - }, - contactStatusBusy: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "negative"), - }, - contactUsername: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - }, - }, - contactButtonSpacing: nameMargin, - contactButton: interactive({ - base: { ...contactButton }, - state: { - hovered: { - background: background(layer, "hovered"), - }, - } - }), - disabledButton: { - ...contactButton, - background: background(layer, "on"), - color: foreground(layer, "on"), - }, - callingIndicator: { - ...text(layer, "mono", "variant", { size: "xs" }), - }, - treeBranch: toggleable(interactive({ - base: { - color: borderColor(layer), - width: 1, - }, - state: { - hovered: { - color: borderColor(layer), - }, - } - }), - { - default: { - color: borderColor(layer), - }, - } - ), - projectRow: toggleable(interactive({ - base: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, + const projectRow = { + guestAvatarSpacing: 4, + height: 24, + guestAvatar: { + cornerRadius: 8, + width: 14, }, name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + right: 6, + }, }, - }, state: { - hovered: { - background: background(layer, "hovered"), + guests: { + margin: { + left: nameMargin, + right: nameMargin, + }, }, - } - }), - { - default: { background: background(layer, "active") } - }) - } + padding: { + left: sidePadding, + right: sidePadding, + }, + } + + return { + background: background(layer), + padding: { top: 12 }, + userQueryEditor: { + background: background(layer, "on"), + cornerRadius: 6, + text: text(layer, "mono", "on"), + placeholderText: text(layer, "mono", "on", "disabled", { + size: "xs", + }), + selection: colorScheme.players[0], + border: border(layer, "on"), + padding: { + bottom: 4, + left: 8, + right: 8, + top: 4, + }, + margin: { + left: 6, + }, + }, + userQueryEditorHeight: 33, + addContactButton: { + margin: { left: 6, right: 12 }, + color: foreground(layer, "on"), + buttonWidth: 28, + iconWidth: 16, + }, + rowHeight: 28, + sectionIconSize: 8, + headerRow: toggleable(interactive({ + base: { + ...text(layer, "mono", { size: "sm" }), + margin: { top: 14 }, + padding: { + left: sidePadding, + right: sidePadding, + }, + background: background(layer, "default"),// posiewic: breaking change + } + , state: { hovered: { background: background(layer, "default") } } // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. + }), + { + default: { + ...text(layer, "mono", "active", { size: "sm" }), + background: background(layer, "active"), + }, + }), + leaveCall: interactive({ + base: { + background: background(layer), + border: border(layer), + cornerRadius: 6, + margin: { + top: 1, + }, + padding: { + top: 1, + bottom: 1, + left: 7, + right: 7, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + } + , + state: { + hovered: { + ...text(layer, "sans", "hovered", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "hovered"), + } + } + } + ), + contactRow: { + inactive: { + default: { + padding: { + left: sidePadding, + right: sidePadding, + } + }, + }, + active: { + default: { + background: background(layer, "active"), + padding: { + left: sidePadding, + right: sidePadding, + } + } + }, + }, + + contactAvatar: { + cornerRadius: 10, + width: 18, + }, + contactStatusFree: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "positive"), + }, + contactStatusBusy: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "negative"), + }, + contactUsername: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + }, + }, + contactButtonSpacing: nameMargin, + contactButton: interactive({ + base: { ...contactButton }, + state: { + hovered: { + background: background(layer, "hovered"), + }, + } + }), + disabledButton: { + ...contactButton, + background: background(layer, "on"), + color: foreground(layer, "on"), + }, + callingIndicator: { + ...text(layer, "mono", "variant", { size: "xs" }), + }, + treeBranch: toggleable(interactive({ + base: { + color: borderColor(layer), + width: 1, + }, + state: { + hovered: { + color: borderColor(layer), + }, + } + }), + { + default: { + color: borderColor(layer), + }, + } + ), + projectRow: toggleable(interactive({ + base: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, + }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), + }, + }, state: { + hovered: { + background: background(layer, "hovered"), + }, + } + }), + { + default: { background: background(layer, "active") } + }) + } } diff --git a/styles/src/styleTree/contactNotification.ts b/styles/src/styleTree/contactNotification.ts index 5b29e15e6b..4d57239005 100644 --- a/styles/src/styleTree/contactNotification.ts +++ b/styles/src/styleTree/contactNotification.ts @@ -1,54 +1,54 @@ import { ColorScheme } from "../theme/colorScheme" import { background, foreground, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" const avatarSize = 12 const headerPadding = 8 export default function contactNotification(colorScheme: ColorScheme): Object { - let layer = colorScheme.lowest - return { - headerAvatar: { - height: avatarSize, - width: avatarSize, - cornerRadius: 6, - }, - headerMessage: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, right: headerPadding }, - }, - headerHeight: 18, - bodyMessage: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: avatarSize + headerPadding, top: 6, bottom: 6 }, - }, - button: - interactive({ - base: { - ...text(layer, "sans", "on", { size: "xs" }), - background: background(layer, "on"), - padding: 4, - cornerRadius: 6, - margin: { left: 6 } + let layer = colorScheme.lowest + return { + headerAvatar: { + height: avatarSize, + width: avatarSize, + cornerRadius: 6, }, - - state: { - hovered: { - background: background(layer, "on", "hovered"), - } - } - }), - - dismissButton: { - default: { - color: foreground(layer, "variant"), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - hover: { - color: foreground(layer, "hovered"), + headerMessage: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, right: headerPadding }, }, - } - }, - } + headerHeight: 18, + bodyMessage: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: avatarSize + headerPadding, top: 6, bottom: 6 }, + }, + button: + interactive({ + base: { + ...text(layer, "sans", "on", { size: "xs" }), + background: background(layer, "on"), + padding: 4, + cornerRadius: 6, + margin: { left: 6 } + }, + + state: { + hovered: { + background: background(layer, "on", "hovered"), + } + } + }), + + dismissButton: { + default: { + color: foreground(layer, "variant"), + iconWidth: 8, + iconHeight: 8, + buttonWidth: 8, + buttonHeight: 8, + hover: { + color: foreground(layer, "hovered"), + }, + } + }, + } } diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 2d5e84dcf0..51bff9de7f 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -1,56 +1,56 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import { toggleable } from "./toggle" export default function contextMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle - return { - background: background(layer), - cornerRadius: 10, - padding: 4, - shadow: colorScheme.popoverShadow, - border: border(layer), - keystrokeMargin: 30, - item: toggleable(interactive({ - base: { - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "variant", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - } - }, state: { - hovered: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "hovered", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - } - } - }), { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, - }), + let layer = colorScheme.middle + return { + background: background(layer), + cornerRadius: 10, + padding: 4, + shadow: colorScheme.popoverShadow, + border: border(layer), + keystrokeMargin: 30, + item: toggleable(interactive({ + base: { + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + } + }, state: { + hovered: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "hovered", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + } + } + }), { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + }), - separator: { - background: borderColor(layer), - margin: { top: 2, bottom: 2 }, - }, - } + separator: { + background: borderColor(layer), + margin: { top: 2, bottom: 2 }, + }, + } } diff --git a/styles/src/styleTree/copilot.ts b/styles/src/styleTree/copilot.ts index 6440941e64..27ef5ec11c 100644 --- a/styles/src/styleTree/copilot.ts +++ b/styles/src/styleTree/copilot.ts @@ -1,286 +1,286 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, svg, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function copilot(colorScheme: ColorScheme) { - let layer = colorScheme.middle + let layer = colorScheme.middle - let content_width = 264 + let content_width = 264 - let ctaButton = - // Copied from welcome screen. FIXME: Move this into a ZDS component - interactive({ - base: { - background: background(layer), - border: border(layer, "default"), - cornerRadius: 4, - margin: { - top: 4, - bottom: 4, - left: 8, - right: 8, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }) - }, - state: { - hovered: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - } - }); - - return { - outLinkIcon: - interactive({ - base: { - icon: svg( - foreground(layer, "variant"), - "icons/link_out_12.svg", - 12, - 12 - ), - container: { - cornerRadius: 6, - padding: { left: 6 }, - }, - }, - state: { - hovered: { - icon: { - color: - foreground(layer, "hovered") - } - }, - } - }), - - modal: { - titleText: { - default: { - ...text(layer, "sans", { size: "xs", weight: "bold" }) - } - }, - titlebar: { - background: background(colorScheme.lowest), - border: border(layer, "active"), - padding: { - top: 4, - bottom: 4, - left: 8, - right: 8, - }, - }, - container: { - background: background(colorScheme.lowest), - padding: { - top: 0, - left: 0, - right: 0, - bottom: 8, - }, - }, - closeIcon: interactive({ - base: - { - icon: svg( - foreground(layer, "variant"), - "icons/x_mark_8.svg", - 8, - 8 - ), - container: { - cornerRadius: 2, - padding: { - top: 4, - bottom: 4, - left: 4, - right: 4, - }, - margin: { - right: 0, - }, - } - }, - state: { - hovered: { - icon: svg( - foreground(layer, "on"), - "icons/x_mark_8.svg", - 8, - 8 - ), - }, - clicked: { - icon: svg( - foreground(layer, "base"), - "icons/x_mark_8.svg", - 8, - 8 - ), - }, - } - }), - dimensions: { - width: 280, - height: 280, - }, - }, - - auth: { - content_width, - - ctaButton, - - header: { - icon: svg( - foreground(layer, "default"), - "icons/zed_plus_copilot_32.svg", - 92, - 32 - ), - container: { - margin: { - top: 35, - bottom: 5, - left: 0, - right: 0, - }, - }, - }, - - prompting: { - subheading: { - ...text(layer, "sans", { size: "xs" }), - margin: { - top: 6, - bottom: 12, - left: 0, - right: 0, - }, - }, - - hint: { - ...text(layer, "sans", { size: "xs", color: "#838994" }), - margin: { - top: 6, - bottom: 2, - }, - }, - - deviceCode: { - text: text(layer, "mono", { size: "sm" }), - cta: { - ...ctaButton, - background: background(colorScheme.lowest), - border: border(colorScheme.lowest, "inverted"), - padding: { - top: 0, - bottom: 0, - left: 16, - right: 16, - }, - margin: { - left: 16, - right: 16, - }, - }, - left: content_width / 2, - leftContainer: { - padding: { - top: 3, - bottom: 3, - left: 0, - right: 6, - }, - }, - right: (content_width * 1) / 3, - rightContainer: interactive({ + let ctaButton = + // Copied from welcome screen. FIXME: Move this into a ZDS component + interactive({ base: { - border: border(colorScheme.lowest, "inverted", { - bottom: false, - right: false, - top: false, - left: true, - }), - padding: { - top: 3, - bottom: 5, - left: 8, - right: 0, - } - }, state: { - hovered: { - border: border(layer, "active", { - bottom: false, - right: false, - top: false, - left: true, - }), - }, + background: background(layer), + border: border(layer, "default"), + cornerRadius: 4, + margin: { + top: 4, + bottom: 4, + left: 8, + right: 8, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }) + }, + state: { + hovered: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, } - }) - }, - }, + }); - notAuthorized: { - subheading: { - ...text(layer, "sans", { size: "xs" }), + return { + outLinkIcon: + interactive({ + base: { + icon: svg( + foreground(layer, "variant"), + "icons/link_out_12.svg", + 12, + 12 + ), + container: { + cornerRadius: 6, + padding: { left: 6 }, + }, + }, + state: { + hovered: { + icon: { + color: + foreground(layer, "hovered") + } + }, + } + }), - margin: { - top: 16, - bottom: 16, - left: 0, - right: 0, - }, + modal: { + titleText: { + default: { + ...text(layer, "sans", { size: "xs", weight: "bold" }) + } + }, + titlebar: { + background: background(colorScheme.lowest), + border: border(layer, "active"), + padding: { + top: 4, + bottom: 4, + left: 8, + right: 8, + }, + }, + container: { + background: background(colorScheme.lowest), + padding: { + top: 0, + left: 0, + right: 0, + bottom: 8, + }, + }, + closeIcon: interactive({ + base: + { + icon: svg( + foreground(layer, "variant"), + "icons/x_mark_8.svg", + 8, + 8 + ), + container: { + cornerRadius: 2, + padding: { + top: 4, + bottom: 4, + left: 4, + right: 4, + }, + margin: { + right: 0, + }, + } + }, + state: { + hovered: { + icon: svg( + foreground(layer, "on"), + "icons/x_mark_8.svg", + 8, + 8 + ), + }, + clicked: { + icon: svg( + foreground(layer, "base"), + "icons/x_mark_8.svg", + 8, + 8 + ), + }, + } + }), + dimensions: { + width: 280, + height: 280, + }, }, - warning: { - ...text(layer, "sans", { - size: "xs", - color: foreground(layer, "warning"), - }), - border: border(layer, "warning"), - background: background(layer, "warning"), - cornerRadius: 2, - padding: { - top: 4, - left: 4, - bottom: 4, - right: 4, - }, - margin: { - bottom: 16, - left: 8, - right: 8, - }, - }, - }, + auth: { + content_width, - authorized: { - subheading: { - ...text(layer, "sans", { size: "xs" }), + ctaButton, - margin: { - top: 16, - bottom: 16, - }, - }, + header: { + icon: svg( + foreground(layer, "default"), + "icons/zed_plus_copilot_32.svg", + 92, + 32 + ), + container: { + margin: { + top: 35, + bottom: 5, + left: 0, + right: 0, + }, + }, + }, - hint: { - ...text(layer, "sans", { size: "xs", color: "#838994" }), - margin: { - top: 24, - bottom: 4, - }, + prompting: { + subheading: { + ...text(layer, "sans", { size: "xs" }), + margin: { + top: 6, + bottom: 12, + left: 0, + right: 0, + }, + }, + + hint: { + ...text(layer, "sans", { size: "xs", color: "#838994" }), + margin: { + top: 6, + bottom: 2, + }, + }, + + deviceCode: { + text: text(layer, "mono", { size: "sm" }), + cta: { + ...ctaButton, + background: background(colorScheme.lowest), + border: border(colorScheme.lowest, "inverted"), + padding: { + top: 0, + bottom: 0, + left: 16, + right: 16, + }, + margin: { + left: 16, + right: 16, + }, + }, + left: content_width / 2, + leftContainer: { + padding: { + top: 3, + bottom: 3, + left: 0, + right: 6, + }, + }, + right: (content_width * 1) / 3, + rightContainer: interactive({ + base: { + border: border(colorScheme.lowest, "inverted", { + bottom: false, + right: false, + top: false, + left: true, + }), + padding: { + top: 3, + bottom: 5, + left: 8, + right: 0, + } + }, state: { + hovered: { + border: border(layer, "active", { + bottom: false, + right: false, + top: false, + left: true, + }), + }, + } + }) + }, + }, + + notAuthorized: { + subheading: { + ...text(layer, "sans", { size: "xs" }), + + margin: { + top: 16, + bottom: 16, + left: 0, + right: 0, + }, + }, + + warning: { + ...text(layer, "sans", { + size: "xs", + color: foreground(layer, "warning"), + }), + border: border(layer, "warning"), + background: background(layer, "warning"), + cornerRadius: 2, + padding: { + top: 4, + left: 4, + bottom: 4, + right: 4, + }, + margin: { + bottom: 16, + left: 8, + right: 8, + }, + }, + }, + + authorized: { + subheading: { + ...text(layer, "sans", { size: "xs" }), + + margin: { + top: 16, + bottom: 16, + }, + }, + + hint: { + ...text(layer, "sans", { size: "xs", color: "#838994" }), + margin: { + top: 24, + bottom: 4, + }, + }, + }, }, - }, - }, - } + } } diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index b3b22f3c8b..3612a0acd1 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -4,290 +4,290 @@ import { background, border, borderColor, foreground, text } from "./components" import hoverPopover from "./hoverPopover" import { buildSyntax } from "../theme/syntax" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import { toggleable } from "./toggle" export default function editor(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.highest + let layer = colorScheme.highest - const autocompleteItem = { - cornerRadius: 6, - padding: { - bottom: 2, - left: 6, - right: 6, - top: 2, - }, - } - - function diagnostic(layer: Layer, styleSet: StyleSets) { - return { - textScaleFactor: 0.857, - header: { - border: border(layer, { - top: true, - }), - }, - message: { - text: text(layer, "sans", styleSet, "default", { size: "sm" }), - highlightText: text(layer, "sans", styleSet, "default", { - size: "sm", - weight: "bold", - }), - }, - } - } - - const syntax = buildSyntax(colorScheme) - - return { - textColor: syntax.primary.color, - background: background(layer), - activeLineBackground: withOpacity(background(layer, "on"), 0.75), - highlightedLineBackground: background(layer, "on"), - // Inline autocomplete suggestions, Co-pilot suggestions, etc. - suggestion: syntax.predictive, - codeActions: { - indicator: toggleable(interactive({ - base: { - color: foreground(layer, "variant"), - }, state: { - clicked: { - color: foreground(layer, "base"), - }, - hovered: { - color: foreground(layer, "on"), - }, - } - }), - { - default: { - color: foreground(layer, "on"), - } - }), - - verticalScale: 0.55, - }, - folds: { - iconMarginScale: 2.5, - foldedIcon: "icons/chevron_right_8.svg", - foldableIcon: "icons/chevron_down_8.svg", - indicator: toggleable(interactive({ - base: { - color: foreground(layer, "variant"), - }, state: { - clicked: { - color: foreground(layer, "base"), - }, - hovered: { - color: foreground(layer, "on"), - }, - } - }), - { - default: { - color: foreground(layer, "on"), - } - }), - ellipses: { - textColor: colorScheme.ramps.neutral(0.71).hex(), - cornerRadiusFactor: 0.15, - background: { - // Copied from hover_popover highlight - default: { color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex() }, - - hover: { - color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), - }, - - clicked: { - color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), - }, - }, - }, - foldBackground: foreground(layer, "variant"), - }, - diff: { - deleted: isLight - ? colorScheme.ramps.red(0.5).hex() - : colorScheme.ramps.red(0.4).hex(), - modified: isLight - ? colorScheme.ramps.yellow(0.5).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.4).hex() - : colorScheme.ramps.green(0.5).hex(), - removedWidthEm: 0.275, - widthEm: 0.15, - cornerRadius: 0.05, - }, - /** Highlights matching occurrences of what is under the cursor - * as well as matched brackets - */ - documentHighlightReadBackground: withOpacity( - foreground(layer, "accent"), - 0.1 - ), - documentHighlightWriteBackground: colorScheme.ramps - .neutral(0.5) - .alpha(0.4) - .hex(), // TODO: This was blend * 2 - errorColor: background(layer, "negative"), - gutterBackground: background(layer), - gutterPaddingFactor: 3.5, - lineNumber: withOpacity(foreground(layer), 0.35), - lineNumberActive: foreground(layer), - renameFade: 0.6, - unnecessaryCodeFade: 0.5, - selection: colorScheme.players[0], - whitespace: colorScheme.ramps.neutral(0.5).hex(), - guestSelections: [ - colorScheme.players[1], - colorScheme.players[2], - colorScheme.players[3], - colorScheme.players[4], - colorScheme.players[5], - colorScheme.players[6], - colorScheme.players[7], - ], - autocomplete: { - background: background(colorScheme.middle), - cornerRadius: 8, - padding: 4, - margin: { - left: -14, - }, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - matchHighlight: foreground(colorScheme.middle, "accent"), - item: autocompleteItem, - hoveredItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "hovered" - ), - background: background(colorScheme.middle, "hovered"), - }, - selectedItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "active" - ), - background: background(colorScheme.middle, "active"), - }, - }, - diagnosticHeader: { - background: background(colorScheme.middle), - iconWidthFactor: 1.5, - textScaleFactor: 0.857, - border: border(colorScheme.middle, { - bottom: true, - top: true, - }), - code: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 10, - }, - }, - source: { - text: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - }, - message: { - highlightText: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - text: text(colorScheme.middle, "sans", { size: "sm" }), - }, - }, - diagnosticPathHeader: { - background: background(colorScheme.middle), - textScaleFactor: 0.857, - filename: text(colorScheme.middle, "mono", { size: "sm" }), - path: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 12, - }, - }, - }, - errorDiagnostic: diagnostic(colorScheme.middle, "negative"), - warningDiagnostic: diagnostic(colorScheme.middle, "warning"), - informationDiagnostic: diagnostic(colorScheme.middle, "accent"), - hintDiagnostic: diagnostic(colorScheme.middle, "warning"), - invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), - hoverPopover: hoverPopover(colorScheme), - linkDefinition: { - color: syntax.linkUri.color, - underline: syntax.linkUri.underline, - }, - jumpIcon: interactive({ - base: { - color: foreground(layer, "on"), - iconWidth: 20, - buttonWidth: 20, + const autocompleteItem = { cornerRadius: 6, padding: { - top: 6, - bottom: 6, - left: 6, - right: 6, - } - }, state: { - hovered: { - background: background(layer, "on", "hovered"), - } - } - }), - - scrollbar: { - width: 12, - minHeightFactor: 1.0, - track: { - border: border(layer, "variant", { left: true }), - }, - thumb: { - background: withOpacity(background(layer, "inverted"), 0.3), - border: { - width: 1, - color: borderColor(layer, "variant"), - top: false, - right: true, - left: true, - bottom: false, + bottom: 2, + left: 6, + right: 6, + top: 2, }, - }, - git: { - deleted: isLight - ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), - modified: isLight - ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), - inserted: isLight - ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), - }, - }, - compositionMark: { - underline: { - thickness: 1.0, - color: borderColor(layer), - }, - }, - syntax, - } + } + + function diagnostic(layer: Layer, styleSet: StyleSets) { + return { + textScaleFactor: 0.857, + header: { + border: border(layer, { + top: true, + }), + }, + message: { + text: text(layer, "sans", styleSet, "default", { size: "sm" }), + highlightText: text(layer, "sans", styleSet, "default", { + size: "sm", + weight: "bold", + }), + }, + } + } + + const syntax = buildSyntax(colorScheme) + + return { + textColor: syntax.primary.color, + background: background(layer), + activeLineBackground: withOpacity(background(layer, "on"), 0.75), + highlightedLineBackground: background(layer, "on"), + // Inline autocomplete suggestions, Co-pilot suggestions, etc. + suggestion: syntax.predictive, + codeActions: { + indicator: toggleable(interactive({ + base: { + color: foreground(layer, "variant"), + }, state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + } + }), + { + default: { + color: foreground(layer, "on"), + } + }), + + verticalScale: 0.55, + }, + folds: { + iconMarginScale: 2.5, + foldedIcon: "icons/chevron_right_8.svg", + foldableIcon: "icons/chevron_down_8.svg", + indicator: toggleable(interactive({ + base: { + color: foreground(layer, "variant"), + }, state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + } + }), + { + default: { + color: foreground(layer, "on"), + } + }), + ellipses: { + textColor: colorScheme.ramps.neutral(0.71).hex(), + cornerRadiusFactor: 0.15, + background: { + // Copied from hover_popover highlight + default: { color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex() }, + + hover: { + color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), + }, + + clicked: { + color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), + }, + }, + }, + foldBackground: foreground(layer, "variant"), + }, + diff: { + deleted: isLight + ? colorScheme.ramps.red(0.5).hex() + : colorScheme.ramps.red(0.4).hex(), + modified: isLight + ? colorScheme.ramps.yellow(0.5).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.4).hex() + : colorScheme.ramps.green(0.5).hex(), + removedWidthEm: 0.275, + widthEm: 0.15, + cornerRadius: 0.05, + }, + /** Highlights matching occurrences of what is under the cursor + * as well as matched brackets + */ + documentHighlightReadBackground: withOpacity( + foreground(layer, "accent"), + 0.1 + ), + documentHighlightWriteBackground: colorScheme.ramps + .neutral(0.5) + .alpha(0.4) + .hex(), // TODO: This was blend * 2 + errorColor: background(layer, "negative"), + gutterBackground: background(layer), + gutterPaddingFactor: 3.5, + lineNumber: withOpacity(foreground(layer), 0.35), + lineNumberActive: foreground(layer), + renameFade: 0.6, + unnecessaryCodeFade: 0.5, + selection: colorScheme.players[0], + whitespace: colorScheme.ramps.neutral(0.5).hex(), + guestSelections: [ + colorScheme.players[1], + colorScheme.players[2], + colorScheme.players[3], + colorScheme.players[4], + colorScheme.players[5], + colorScheme.players[6], + colorScheme.players[7], + ], + autocomplete: { + background: background(colorScheme.middle), + cornerRadius: 8, + padding: 4, + margin: { + left: -14, + }, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + matchHighlight: foreground(colorScheme.middle, "accent"), + item: autocompleteItem, + hoveredItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "hovered" + ), + background: background(colorScheme.middle, "hovered"), + }, + selectedItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "active" + ), + background: background(colorScheme.middle, "active"), + }, + }, + diagnosticHeader: { + background: background(colorScheme.middle), + iconWidthFactor: 1.5, + textScaleFactor: 0.857, + border: border(colorScheme.middle, { + bottom: true, + top: true, + }), + code: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 10, + }, + }, + source: { + text: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + }, + message: { + highlightText: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + text: text(colorScheme.middle, "sans", { size: "sm" }), + }, + }, + diagnosticPathHeader: { + background: background(colorScheme.middle), + textScaleFactor: 0.857, + filename: text(colorScheme.middle, "mono", { size: "sm" }), + path: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 12, + }, + }, + }, + errorDiagnostic: diagnostic(colorScheme.middle, "negative"), + warningDiagnostic: diagnostic(colorScheme.middle, "warning"), + informationDiagnostic: diagnostic(colorScheme.middle, "accent"), + hintDiagnostic: diagnostic(colorScheme.middle, "warning"), + invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), + hoverPopover: hoverPopover(colorScheme), + linkDefinition: { + color: syntax.linkUri.color, + underline: syntax.linkUri.underline, + }, + jumpIcon: interactive({ + base: { + color: foreground(layer, "on"), + iconWidth: 20, + buttonWidth: 20, + cornerRadius: 6, + padding: { + top: 6, + bottom: 6, + left: 6, + right: 6, + } + }, state: { + hovered: { + background: background(layer, "on", "hovered"), + } + } + }), + + scrollbar: { + width: 12, + minHeightFactor: 1.0, + track: { + border: border(layer, "variant", { left: true }), + }, + thumb: { + background: withOpacity(background(layer, "inverted"), 0.3), + border: { + width: 1, + color: borderColor(layer, "variant"), + top: false, + right: true, + left: true, + bottom: false, + }, + }, + git: { + deleted: isLight + ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), + modified: isLight + ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), + inserted: isLight + ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), + }, + }, + compositionMark: { + underline: { + thickness: 1.0, + color: borderColor(layer), + }, + }, + syntax, + } } diff --git a/styles/src/styleTree/feedback.ts b/styles/src/styleTree/feedback.ts index 4b5a4de89f..19a8f1e4c7 100644 --- a/styles/src/styleTree/feedback.ts +++ b/styles/src/styleTree/feedback.ts @@ -1,48 +1,48 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function feedback(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - return { - submit_button: interactive({ - base: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, - }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, - } - }, state: { - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, - hovered: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), - }, - } - }), - button_margin: 8, - info_text_default: text(layer, "sans", "default", { size: "xs" }), - link_text_default: text(layer, "sans", "default", { - size: "xs", - underline: true, - }), - link_text_hover: text(layer, "sans", "hovered", { - size: "xs", - underline: true, - }), - } + return { + submit_button: interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, + }, + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, + } + }, state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, + } + }), + button_margin: 8, + info_text_default: text(layer, "sans", "default", { size: "xs" }), + link_text_default: text(layer, "sans", "default", { + size: "xs", + underline: true, + }), + link_text_hover: text(layer, "sans", "hovered", { + size: "xs", + underline: true, + }), + } } diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 89b6cd0614..3bcdae584f 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -2,88 +2,88 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, text } from "./components" import { toggleable } from "./toggle" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function picker(colorScheme: ColorScheme): any { - let layer = colorScheme.lowest - const container = { - background: background(layer), - border: border(layer), - shadow: colorScheme.modalShadow, - cornerRadius: 12, - padding: { - bottom: 4, - }, - } - const inputEditor = { - placeholderText: text(layer, "sans", "on", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "on"), - border: border(layer, { bottom: true }), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - margin: { - bottom: 4, - }, - } - const emptyInputEditor: any = { ...inputEditor } - delete emptyInputEditor.border - delete emptyInputEditor.margin - - return { - ...container, - emptyContainer: { - ...container, - padding: {}, - }, - item: toggleable(interactive({ - base: { + let layer = colorScheme.lowest + const container = { + background: background(layer), + border: border(layer), + shadow: colorScheme.modalShadow, + cornerRadius: 12, padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, + bottom: 4, + }, + } + const inputEditor = { + placeholderText: text(layer, "sans", "on", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "on"), + border: border(layer, { bottom: true }), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, }, margin: { - top: 1, - left: 4, - right: 4, + bottom: 4, }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { weight: "bold" }), - } - , state: { - hovered: { - background: withOpacity(background(layer, "hovered"), 0.5), - } - } - }), - { - default: { - background: withOpacity( - background(layer, "base", "active"), - 0.5 - ), - //text: text(layer, "sans", "base", "active"), - } - }), + } + const emptyInputEditor: any = { ...inputEditor } + delete emptyInputEditor.border + delete emptyInputEditor.margin + + return { + ...container, + emptyContainer: { + ...container, + padding: {}, + }, + item: toggleable(interactive({ + base: { + padding: { + bottom: 4, + left: 12, + right: 12, + top: 4, + }, + margin: { + top: 1, + left: 4, + right: 4, + }, + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { weight: "bold" }), + } + , state: { + hovered: { + background: withOpacity(background(layer, "hovered"), 0.5), + } + } + }), + { + default: { + background: withOpacity( + background(layer, "base", "active"), + 0.5 + ), + //text: text(layer, "sans", "base", "active"), + } + }), - inputEditor, - emptyInputEditor, - noMatches: { - text: text(layer, "sans", "variant"), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - }, - } + inputEditor, + emptyInputEditor, + noMatches: { + text: text(layer, "sans", "variant"), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + }, + } } diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 782c781156..132dfe102c 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -1,123 +1,123 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import { toggleable } from "./toggle" export default function projectPanel(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.middle + let layer = colorScheme.middle - let baseEntry = { - height: 22, - iconColor: foreground(layer, "variant"), - iconSize: 7, - iconSpacing: 5, - } - - let status = { - git: { - modified: isLight - ? colorScheme.ramps.yellow(0.6).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.45).hex() - : colorScheme.ramps.green(0.5).hex(), - conflict: isLight - ? colorScheme.ramps.red(0.6).hex() - : colorScheme.ramps.red(0.5).hex(), - }, - } - - let entry = toggleable(interactive({ - base: { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - status, - }, state: - { - hovered: { - background: background(layer, "variant", "hovered"), - } - } - }), - { - default: { - /*background: colorScheme.isLight - ? withOpacity(background(layer, "active"), 0.5) - : background(layer, "active") ,*/ // todo posiewic - text: text(layer, "mono", "active", { size: "sm" }), - }, - hovered: { - //background: background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), - }, - - }); - - return { - openProjectButton: interactive({ - base: { - background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 16, - left: 16, - right: 16, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }) - }, state: { - hovered: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - } - }), - background: background(layer), - padding: { left: 6, right: 6, top: 0, bottom: 6 }, - indentWidth: 12, - entry, - draggedEntry: { - ...baseEntry, - text: text(layer, "mono", "on", { size: "sm" }), - background: withOpacity(background(layer, "on"), 0.9), - border: border(layer), - status, - }, - ignoredEntry: { - ...entry, - iconColor: foreground(layer, "disabled"), - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, + let baseEntry = { + height: 22, iconColor: foreground(layer, "variant"), - }, - }, - cutEntry: { - ...entry, - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - default: { - ...entry.active.default, - background: background(layer, "active"), - text: text(layer, "mono", "disabled", { size: "sm" }), - }, + iconSize: 7, + iconSpacing: 5, + } - }, - }, - filenameEditor: { - background: background(layer, "on"), - text: text(layer, "mono", "on", { size: "sm" }), - selection: colorScheme.players[0], - }, - } + let status = { + git: { + modified: isLight + ? colorScheme.ramps.yellow(0.6).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.45).hex() + : colorScheme.ramps.green(0.5).hex(), + conflict: isLight + ? colorScheme.ramps.red(0.6).hex() + : colorScheme.ramps.red(0.5).hex(), + }, + } + + let entry = toggleable(interactive({ + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, state: + { + hovered: { + background: background(layer, "variant", "hovered"), + } + } + }), + { + default: { + /*background: colorScheme.isLight + ? withOpacity(background(layer, "active"), 0.5) + : background(layer, "active") ,*/ // todo posiewic + text: text(layer, "mono", "active", { size: "sm" }), + }, + hovered: { + //background: background(layer, "active"), + text: text(layer, "mono", "active", { size: "sm" }), + }, + + }); + + return { + openProjectButton: interactive({ + base: { + background: background(layer), + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 16, + left: 16, + right: 16, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }) + }, state: { + hovered: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + } + }), + background: background(layer), + padding: { left: 6, right: 6, top: 0, bottom: 6 }, + indentWidth: 12, + entry, + draggedEntry: { + ...baseEntry, + text: text(layer, "mono", "on", { size: "sm" }), + background: withOpacity(background(layer, "on"), 0.9), + border: border(layer), + status, + }, + ignoredEntry: { + ...entry, + iconColor: foreground(layer, "disabled"), + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + iconColor: foreground(layer, "variant"), + }, + }, + cutEntry: { + ...entry, + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + default: { + ...entry.active.default, + background: background(layer, "active"), + text: text(layer, "mono", "disabled", { size: "sm" }), + }, + + }, + }, + filenameEditor: { + background: background(layer, "on"), + text: text(layer, "mono", "on", { size: "sm" }), + selection: colorScheme.players[0], + }, + } } diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index e278f69ff0..1f63d2740b 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -1,123 +1,123 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import { toggleable } from "./toggle" export default function search(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - // Search input - const editor = { - background: background(layer), - cornerRadius: 8, - minWidth: 200, - maxWidth: 500, - placeholderText: text(layer, "mono", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "default"), - border: border(layer), - margin: { - right: 12, - }, - padding: { - top: 3, - bottom: 3, - left: 12, - right: 8, - }, - } - - const includeExcludeEditor = { - ...editor, - minWidth: 100, - maxWidth: 250, - } - - return { - // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive - matchBackground: withOpacity(foreground(layer, "accent"), 0.4), - optionButton: toggleable(interactive({ - base: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), + // Search input + const editor = { + background: background(layer), + cornerRadius: 8, + minWidth: 200, + maxWidth: 500, + placeholderText: text(layer, "mono", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "default"), + border: border(layer), margin: { - right: 4, + right: 12, }, padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, + top: 3, + bottom: 3, + left: 12, + right: 8, }, - }, state: { - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, - hovered: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), - }, - } - }), { - default: { - ...text(layer, "mono", "on", "inverted"), - background: background(layer, "on", "inverted"), - border: border(layer, "on", "inverted"), - }, + } - }), - editor, - invalidEditor: { - ...editor, - border: border(layer, "negative"), - }, - includeExcludeEditor, - invalidIncludeExcludeEditor: { - ...includeExcludeEditor, - border: border(layer, "negative"), - }, - matchIndex: { - ...text(layer, "mono", "variant"), - padding: { - left: 6, - }, - }, - optionButtonGroup: { - padding: { - left: 12, - right: 12, - }, - }, - includeExcludeInputs: { - ...text(layer, "mono", "variant"), - padding: { - right: 6, - }, - }, - resultsStatus: { - ...text(layer, "mono", "on"), - size: 18, - }, - dismissButton: interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 14, - padding: { - left: 10, - right: 10, + const includeExcludeEditor = { + ...editor, + minWidth: 100, + maxWidth: 250, + } + + return { + // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive + matchBackground: withOpacity(foreground(layer, "accent"), 0.4), + optionButton: toggleable(interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, + }, + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, + }, + }, state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, + } + }), { + default: { + ...text(layer, "mono", "on", "inverted"), + background: background(layer, "on", "inverted"), + border: border(layer, "on", "inverted"), + }, + + }), + editor, + invalidEditor: { + ...editor, + border: border(layer, "negative"), }, - }, state: { - hovered: { - color: foreground(layer, "hovered"), - } - } - }), - } + includeExcludeEditor, + invalidIncludeExcludeEditor: { + ...includeExcludeEditor, + border: border(layer, "negative"), + }, + matchIndex: { + ...text(layer, "mono", "variant"), + padding: { + left: 6, + }, + }, + optionButtonGroup: { + padding: { + left: 12, + right: 12, + }, + }, + includeExcludeInputs: { + ...text(layer, "mono", "variant"), + padding: { + right: 6, + }, + }, + resultsStatus: { + ...text(layer, "mono", "on"), + size: 18, + }, + dismissButton: interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 14, + padding: { + left: 10, + right: 10, + }, + }, state: { + hovered: { + color: foreground(layer, "hovered"), + } + } + }), + } } diff --git a/styles/src/styleTree/simpleMessageNotification.ts b/styles/src/styleTree/simpleMessageNotification.ts index 70219d7a10..4c2abfcf9d 100644 --- a/styles/src/styleTree/simpleMessageNotification.ts +++ b/styles/src/styleTree/simpleMessageNotification.ts @@ -1,51 +1,51 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" const headerPadding = 8 export default function simpleMessageNotification( - colorScheme: ColorScheme + colorScheme: ColorScheme ): Object { - let layer = colorScheme.middle - return { - message: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, right: headerPadding }, - }, - actionMessage: interactive({ - base: { - ...text(layer, "sans", { size: "xs" }), - border: border(layer, "active"), - cornerRadius: 4, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, + let layer = colorScheme.middle + return { + message: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, right: headerPadding }, }, + actionMessage: interactive({ + base: { + ...text(layer, "sans", { size: "xs" }), + border: border(layer, "active"), + cornerRadius: 4, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, - margin: { left: headerPadding, top: 6, bottom: 6 }, - }, state: { - hovered: { - ...text(layer, "sans", "default", { size: "xs" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - } - }), - dismissButton: interactive({ - base: { - color: foreground(layer), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - }, state: { - hovered: { - color: foreground(layer, "hovered"), - }, - } - }) - } + margin: { left: headerPadding, top: 6, bottom: 6 }, + }, state: { + hovered: { + ...text(layer, "sans", "default", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + } + }), + dismissButton: interactive({ + base: { + color: foreground(layer), + iconWidth: 8, + iconHeight: 8, + buttonWidth: 8, + buttonHeight: 8, + }, state: { + hovered: { + color: foreground(layer, "hovered"), + }, + } + }) + } } diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 754703c2b9..ee78f5e6b3 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -1,145 +1,145 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import { toggleable } from "./toggle" export default function statusBar(colorScheme: ColorScheme) { - let layer = colorScheme.lowest + let layer = colorScheme.lowest - const statusContainer = { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 6, right: 6 }, - } + const statusContainer = { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 6, right: 6 }, + } - const diagnosticStatusContainer = { - cornerRadius: 6, - padding: { top: 1, bottom: 1, left: 6, right: 6 }, - } + const diagnosticStatusContainer = { + cornerRadius: 6, + padding: { top: 1, bottom: 1, left: 6, right: 6 }, + } - return { - height: 30, - itemSpacing: 8, - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - border: border(layer, { top: true, overlay: true }), - cursorPosition: text(layer, "sans", "variant"), - activeLanguage: interactive({ - base: { - padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant") - }, - state: { - hovered: { - ...text(layer, "sans", "on"), - } - } - }, - ), - autoUpdateProgressMessage: text(layer, "sans", "variant"), - autoUpdateDoneMessage: text(layer, "sans", "variant"), - lspStatus: interactive({ - base: { - ...diagnosticStatusContainer, - iconSpacing: 4, - iconWidth: 14, - height: 18, - message: text(layer, "sans"), - iconColor: foreground(layer) - }, - state: { - hovered: { - message: text(layer, "sans"), - iconColor: foreground(layer), - background: background(layer, "hovered"), - } - } - }), - diagnosticMessage: interactive({ - base: { - ...text(layer, "sans") - }, - state: { hovered: text(layer, "sans", "hovered") } - }, - ), - diagnosticSummary: - interactive({ - base: { - height: 20, - iconWidth: 16, - iconSpacing: 2, - summarySpacing: 6, - text: text(layer, "sans", { size: "sm" }), - iconColorOk: foreground(layer, "variant"), - iconColorWarning: foreground(layer, "warning"), - iconColorError: foreground(layer, "negative"), - containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, - }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), - }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - } - }, state: { - hovered: { - iconColorOk: foreground(layer, "on"), - containerOk: { - background: background(layer, "on", "hovered"), + return { + height: 30, + itemSpacing: 8, + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + border: border(layer, { top: true, overlay: true }), + cursorPosition: text(layer, "sans", "variant"), + activeLanguage: interactive({ + base: { + padding: { left: 6, right: 6 }, + ...text(layer, "sans", "variant") }, - containerWarning: { - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), - }, - containerError: { - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), + state: { + hovered: { + ...text(layer, "sans", "on"), + } + } + }, + ), + autoUpdateProgressMessage: text(layer, "sans", "variant"), + autoUpdateDoneMessage: text(layer, "sans", "variant"), + lspStatus: interactive({ + base: { + ...diagnosticStatusContainer, + iconSpacing: 4, + iconWidth: 14, + height: 18, + message: text(layer, "sans"), + iconColor: foreground(layer) + }, + state: { + hovered: { + message: text(layer, "sans"), + iconColor: foreground(layer), + background: background(layer, "hovered"), + } } - } - } - } - ), - panelButtons: { - groupLeft: {}, - groupBottom: {}, - groupRight: {}, - button: toggleable(interactive({ - base: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), - }, - }, state: { - hovered: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - } - } - }), - { - default: { - iconColor: foreground(layer, "active"), - background: background(layer, "active"), - } }), - badge: { - cornerRadius: 3, - padding: 2, - margin: { bottom: -1, right: -1 }, - border: border(layer), - background: background(layer, "accent"), - }, - }, - } + diagnosticMessage: interactive({ + base: { + ...text(layer, "sans") + }, + state: { hovered: text(layer, "sans", "hovered") } + }, + ), + diagnosticSummary: + interactive({ + base: { + height: 20, + iconWidth: 16, + iconSpacing: 2, + summarySpacing: 6, + text: text(layer, "sans", { size: "sm" }), + iconColorOk: foreground(layer, "variant"), + iconColorWarning: foreground(layer, "warning"), + iconColorError: foreground(layer, "negative"), + containerOk: { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 7, right: 7 }, + }, + containerWarning: { + ...diagnosticStatusContainer, + background: background(layer, "warning"), + border: border(layer, "warning"), + }, + containerError: { + ...diagnosticStatusContainer, + background: background(layer, "negative"), + border: border(layer, "negative"), + } + }, state: { + hovered: { + iconColorOk: foreground(layer, "on"), + containerOk: { + background: background(layer, "on", "hovered"), + }, + containerWarning: { + background: background(layer, "warning", "hovered"), + border: border(layer, "warning", "hovered"), + }, + containerError: { + background: background(layer, "negative", "hovered"), + border: border(layer, "negative", "hovered"), + } + } + } + } + ), + panelButtons: { + groupLeft: {}, + groupBottom: {}, + groupRight: {}, + button: toggleable(interactive({ + base: { + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), + }, + }, state: { + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), + } + } + }), + { + default: { + iconColor: foreground(layer, "active"), + background: background(layer, "active"), + } + }), + badge: { + cornerRadius: 3, + padding: 2, + margin: { bottom: -1, right: -1 }, + border: border(layer), + background: background(layer, "accent"), + }, + }, + } } diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index 9da63b9518..8011a70772 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -2,117 +2,117 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, border, background, foreground } from "./components" import { toggleable } from "./toggle" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function tabBar(colorScheme: ColorScheme) { - const height = 32 + const height = 32 - let activeLayer = colorScheme.highest - let layer = colorScheme.middle + let activeLayer = colorScheme.highest + let layer = colorScheme.middle - const tab = { - height, - text: text(layer, "sans", "variant", { size: "sm" }), - background: background(layer), - border: border(layer, { - right: true, - bottom: true, - overlay: true, - }), - padding: { - left: 8, - right: 12, - }, - spacing: 8, + const tab = { + height, + text: text(layer, "sans", "variant", { size: "sm" }), + background: background(layer), + border: border(layer, { + right: true, + bottom: true, + overlay: true, + }), + padding: { + left: 8, + right: 12, + }, + spacing: 8, - // Tab type icons (e.g. Project Search) - typeIconWidth: 14, + // Tab type icons (e.g. Project Search) + typeIconWidth: 14, - // Close icons - closeIconWidth: 8, - iconClose: foreground(layer, "variant"), - iconCloseActive: foreground(layer, "hovered"), + // Close icons + closeIconWidth: 8, + iconClose: foreground(layer, "variant"), + iconCloseActive: foreground(layer, "hovered"), - // Indicators - iconConflict: foreground(layer, "warning"), - iconDirty: foreground(layer, "accent"), + // Indicators + iconConflict: foreground(layer, "warning"), + iconDirty: foreground(layer, "accent"), - // When two tabs of the same name are open, a label appears next to them - description: { - margin: { left: 8 }, - ...text(layer, "sans", "disabled", { size: "2xs" }), - }, - } + // When two tabs of the same name are open, a label appears next to them + description: { + margin: { left: 8 }, + ...text(layer, "sans", "disabled", { size: "2xs" }), + }, + } - const activePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(activeLayer, "sans", "active", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const activePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(activeLayer, "sans", "active", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const inactivePaneInactiveTab = { - ...tab, - background: background(layer), - text: text(layer, "sans", "variant", { size: "sm" }), - } + const inactivePaneInactiveTab = { + ...tab, + background: background(layer), + text: text(layer, "sans", "variant", { size: "sm" }), + } - const inactivePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(layer, "sans", "variant", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const inactivePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(layer, "sans", "variant", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const draggedTab = { - ...activePaneActiveTab, - background: withOpacity(tab.background, 0.9), - border: undefined as any, - shadow: colorScheme.popoverShadow, - } + const draggedTab = { + ...activePaneActiveTab, + background: withOpacity(tab.background, 0.9), + border: undefined as any, + shadow: colorScheme.popoverShadow, + } - return { - height, - background: background(layer), - activePane: { - activeTab: activePaneActiveTab, - inactiveTab: tab, - }, - inactivePane: { - activeTab: inactivePaneActiveTab, - inactiveTab: inactivePaneInactiveTab, - }, - draggedTab, - paneButton: toggleable(interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - }, - state: { - hovered: { - color: foreground(layer, "hovered"), - } - } - }), - { - default: { - color: foreground(layer, "accent"), - } - }, - ), - paneButtonContainer: { - background: tab.background, - border: { - ...tab.border, - right: false, - }, - }, - } + return { + height, + background: background(layer), + activePane: { + activeTab: activePaneActiveTab, + inactiveTab: tab, + }, + inactivePane: { + activeTab: inactivePaneActiveTab, + inactiveTab: inactivePaneInactiveTab, + }, + draggedTab, + paneButton: toggleable(interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), + } + } + }), + { + default: { + color: foreground(layer, "accent"), + } + }, + ), + paneButtonContainer: { + background: tab.background, + border: { + ...tab.border, + right: false, + }, + }, + } } diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 0cfcb921ef..0bb3958dc8 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -1,56 +1,56 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import { toggleable } from "./toggle" export default function dropdownMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle + let layer = colorScheme.middle - return { - rowHeight: 30, - background: background(layer), - border: border(layer), - shadow: colorScheme.popoverShadow, - header: interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryText: text(layer, "sans", { size: "sm", color: "#aaaaaa" }), - secondaryTextSpacing: 10, - padding: { left: 8, right: 8, top: 2, bottom: 2 }, - cornerRadius: 6, - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }) - }, - state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - } - } - }) - , - sectionHeader: { - ...text(layer, "sans", { size: "sm" }), - padding: { left: 8, right: 8, top: 8, bottom: 8 }, - }, - item: toggleable(interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryTextSpacing: 10, - secondaryText: text(layer, "sans", { size: "sm" }), - padding: { left: 18, right: 18, top: 2, bottom: 2 } - }, state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - } - } - }), { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, - }) - } + return { + rowHeight: 30, + background: background(layer), + border: border(layer), + shadow: colorScheme.popoverShadow, + header: interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryText: text(layer, "sans", { size: "sm", color: "#aaaaaa" }), + secondaryTextSpacing: 10, + padding: { left: 8, right: 8, top: 2, bottom: 2 }, + cornerRadius: 6, + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }) + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + } + } + }) + , + sectionHeader: { + ...text(layer, "sans", { size: "sm" }), + padding: { left: 8, right: 8, top: 8, bottom: 8 }, + }, + item: toggleable(interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryTextSpacing: 10, + secondaryText: text(layer, "sans", { size: "sm" }), + padding: { left: 18, right: 18, top: 2, bottom: 2 } + }, state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + } + } + }), { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + }) + } } diff --git a/styles/src/styleTree/updateNotification.ts b/styles/src/styleTree/updateNotification.ts index aa8db916ea..a7a5aaabaa 100644 --- a/styles/src/styleTree/updateNotification.ts +++ b/styles/src/styleTree/updateNotification.ts @@ -1,39 +1,39 @@ import { ColorScheme } from "../theme/colorScheme" import { foreground, text } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" const headerPadding = 8 export default function updateNotification(colorScheme: ColorScheme): Object { - let layer = colorScheme.middle - return { - message: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, right: headerPadding }, - }, - actionMessage: interactive({ - base: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, top: 6, bottom: 6 } - }, state: { - hovered: { - color: foreground(layer, "hovered"), - } - } - }), - dismissButton: interactive({ - base: { - color: foreground(layer), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8 - }, state: { - hovered: { - color: foreground(layer, "hovered"), + let layer = colorScheme.middle + return { + message: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, right: headerPadding }, }, - }, - }) + actionMessage: interactive({ + base: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, top: 6, bottom: 6 } + }, state: { + hovered: { + color: foreground(layer, "hovered"), + } + } + }), + dismissButton: interactive({ + base: { + color: foreground(layer), + iconWidth: 8, + iconHeight: 8, + buttonWidth: 8, + buttonHeight: 8 + }, state: { + hovered: { + color: foreground(layer, "hovered"), + }, + }, + }) - } + } } diff --git a/styles/src/styleTree/welcome.ts b/styles/src/styleTree/welcome.ts index 7ba7b30430..f0e4badf3f 100644 --- a/styles/src/styleTree/welcome.ts +++ b/styles/src/styleTree/welcome.ts @@ -1,133 +1,133 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { - border, - background, - foreground, - text, - TextProperties, - svg, + border, + background, + foreground, + text, + TextProperties, + svg, } from "./components" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" export default function welcome(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - let checkboxBase = { - cornerRadius: 4, - padding: { - left: 3, - right: 3, - top: 3, - bottom: 3, - }, - // shadow: colorScheme.popoverShadow, - border: border(layer), - margin: { - right: 8, - top: 5, - bottom: 5, - }, - } - - let interactive_text_size: TextProperties = { size: "sm" } - - return { - pageWidth: 320, - logo: svg(foreground(layer, "default"), "icons/logo_96.svg", 64, 64), - logoSubheading: { - ...text(layer, "sans", "variant", { size: "md" }), - margin: { - top: 10, - bottom: 7, - }, - }, - buttonGroup: { - margin: { - top: 8, - bottom: 16, - }, - }, - headingGroup: { - margin: { - top: 8, - bottom: 12, - }, - }, - checkboxGroup: { - border: border(layer, "variant"), - background: withOpacity(background(layer, "hovered"), 0.25), - cornerRadius: 4, - padding: { - left: 12, - top: 2, - bottom: 2, - }, - }, - button: interactive({ - base: { - background: background(layer), - border: border(layer, "active"), + let checkboxBase = { cornerRadius: 4, - margin: { - top: 4, - bottom: 4, - }, padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, + left: 3, + right: 3, + top: 3, + bottom: 3, }, - ...text(layer, "sans", "default", interactive_text_size) - }, state: { - hovered: { - ...text(layer, "sans", "default", interactive_text_size), - background: background(layer, "hovered"), - } - } - }), + // shadow: colorScheme.popoverShadow, + border: border(layer), + margin: { + right: 8, + top: 5, + bottom: 5, + }, + } - usageNote: { - ...text(layer, "sans", "variant", { size: "2xs" }), - padding: { - top: -4, - }, - }, - checkboxContainer: { - margin: { - top: 4, - }, - padding: { - bottom: 8, - }, - }, - checkbox: { - label: { - ...text(layer, "sans", interactive_text_size), - // Also supports margin, container, border, etc. - }, - icon: svg(foreground(layer, "on"), "icons/check_12.svg", 12, 12), - default: { - ...checkboxBase, - background: background(layer, "default"), - border: border(layer, "active"), - }, - checked: { - ...checkboxBase, - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - hovered: { - ...checkboxBase, - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - hoveredAndChecked: { - ...checkboxBase, - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - }, - } + let interactive_text_size: TextProperties = { size: "sm" } + + return { + pageWidth: 320, + logo: svg(foreground(layer, "default"), "icons/logo_96.svg", 64, 64), + logoSubheading: { + ...text(layer, "sans", "variant", { size: "md" }), + margin: { + top: 10, + bottom: 7, + }, + }, + buttonGroup: { + margin: { + top: 8, + bottom: 16, + }, + }, + headingGroup: { + margin: { + top: 8, + bottom: 12, + }, + }, + checkboxGroup: { + border: border(layer, "variant"), + background: withOpacity(background(layer, "hovered"), 0.25), + cornerRadius: 4, + padding: { + left: 12, + top: 2, + bottom: 2, + }, + }, + button: interactive({ + base: { + background: background(layer), + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 4, + bottom: 4, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", interactive_text_size) + }, state: { + hovered: { + ...text(layer, "sans", "default", interactive_text_size), + background: background(layer, "hovered"), + } + } + }), + + usageNote: { + ...text(layer, "sans", "variant", { size: "2xs" }), + padding: { + top: -4, + }, + }, + checkboxContainer: { + margin: { + top: 4, + }, + padding: { + bottom: 8, + }, + }, + checkbox: { + label: { + ...text(layer, "sans", interactive_text_size), + // Also supports margin, container, border, etc. + }, + icon: svg(foreground(layer, "on"), "icons/check_12.svg", 12, 12), + default: { + ...checkboxBase, + background: background(layer, "default"), + border: border(layer, "active"), + }, + checked: { + ...checkboxBase, + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + hovered: { + ...checkboxBase, + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + hoveredAndChecked: { + ...checkboxBase, + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + }, + } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index fcada68a28..fa2d337592 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -2,383 +2,383 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { toggleable } from "./toggle" import { - background, - border, - borderColor, - foreground, - svg, - text, + background, + border, + borderColor, + foreground, + svg, + text, } from "./components" import statusBar from "./statusBar" import tabBar from "./tabBar" -import { interactive } from "./interactive" +import { interactive } from "../element/interactive" import merge from 'ts-deepmerge'; export default function workspace(colorScheme: ColorScheme) { - const layer = colorScheme.lowest - const isLight = colorScheme.isLight - const itemSpacing = 8 - const titlebarButton = toggleable(interactive({ - base: { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), - }, state: { - hovered: { - ...text(layer, "sans", "variant", "hovered", { size: "xs" }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { size: "xs" }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - } - } - }), - { - default: { - ...text(layer, "sans", "variant", "active", { size: "xs" }), - background: background(layer, "variant", "active"), - border: border(layer, "variant", "active"), - } - }, - ); - const avatarWidth = 18 - const avatarOuterWidth = avatarWidth + 4 - const followerAvatarWidth = 14 - const followerAvatarOuterWidth = followerAvatarWidth + 4 - - return { - background: background(colorScheme.lowest), - blankPane: { - logoContainer: { - width: 256, - height: 256, - }, - logo: svg( - withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), - "icons/logo_96.svg", - 256, - 256 - ), - - logoShadow: svg( - withOpacity( - colorScheme.isLight - ? "#FFFFFF" - : colorScheme.lowest.base.default.background, - colorScheme.isLight ? 1 : 0.6 - ), - "icons/logo_96.svg", - 256, - 256 - ), - keyboardHints: { - margin: { - top: 96, - }, - cornerRadius: 4, - }, - keyboardHint: - interactive({ - base: { - ...text(layer, "sans", "variant", { size: "sm" }), - padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, - }, - cornerRadius: 8 - }, state: { - hovered: { - ...text(layer, "sans", "active", { size: "sm" }), - } - } - }), - - keyboardHintWidth: 320, - }, - joiningProjectAvatar: { - cornerRadius: 40, - width: 80, - }, - joiningProjectMessage: { - padding: 12, - ...text(layer, "sans", { size: "lg" }), - }, - externalLocationMessage: { - background: background(colorScheme.middle, "accent"), - border: border(colorScheme.middle, "accent"), - cornerRadius: 6, - padding: 12, - margin: { bottom: 8, right: 8 }, - ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), - }, - leaderBorderOpacity: 0.7, - leaderBorderWidth: 2.0, - tabBar: tabBar(colorScheme), - modal: { - margin: { - bottom: 52, - top: 52, - }, - cursor: "Arrow", - }, - zoomedBackground: { - cursor: "Arrow", - background: isLight - ? withOpacity(background(colorScheme.lowest), 0.8) - : withOpacity(background(colorScheme.highest), 0.6), - }, - zoomedPaneForeground: { - margin: 16, - shadow: colorScheme.modalShadow, - border: border(colorScheme.lowest, { overlay: true }), - }, - zoomedPanelForeground: { - margin: 16, - border: border(colorScheme.lowest, { overlay: true }), - }, - dock: { - left: { - border: border(layer, { right: true }), - }, - bottom: { - border: border(layer, { top: true }), - }, - right: { - border: border(layer, { left: true }), - }, - }, - paneDivider: { - color: borderColor(layer), - width: 1, - }, - statusBar: statusBar(colorScheme), - titlebar: { - itemSpacing, - facePileSpacing: 2, - height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. - background: background(layer), - border: border(layer, { bottom: true }), - padding: { - left: 80, - right: itemSpacing, - }, - - // Project - title: text(layer, "sans", "variant"), - highlight_color: text(layer, "sans", "active").color, - - // Collaborators - leaderAvatar: { - width: avatarWidth, - outerWidth: avatarOuterWidth, - cornerRadius: avatarWidth / 2, - outerCornerRadius: avatarOuterWidth / 2, - }, - followerAvatar: { - width: followerAvatarWidth, - outerWidth: followerAvatarOuterWidth, - cornerRadius: followerAvatarWidth / 2, - outerCornerRadius: followerAvatarOuterWidth / 2, - }, - inactiveAvatarGrayscale: true, - followerAvatarOverlap: 8, - leaderSelection: { - margin: { - top: 4, - bottom: 4, - }, - padding: { - left: 2, - right: 2, - top: 2, - bottom: 2, - }, - cornerRadius: 6, - }, - avatarRibbon: { - height: 3, - width: 12, - // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. - }, - - // Sign in buttom - // FlatButton, Variant - signInPrompt: - merge(titlebarButton, - { - inactive: { - default: { - margin: { - left: itemSpacing, - }, - } - } - }), - - - // Offline Indicator - offlineIcon: { - color: foreground(layer, "variant"), - width: 16, - margin: { - left: itemSpacing, - }, - padding: { - right: 4, - }, - }, - - // Notice that the collaboration server is out of date - outdatedWarning: { - ...text(layer, "sans", "warning", { size: "xs" }), - background: withOpacity(background(layer, "warning"), 0.3), - border: border(layer, "warning"), - margin: { - left: itemSpacing, - }, - padding: { - left: 8, - right: 8, - }, - cornerRadius: 6, - }, - callControl: interactive({ + const layer = colorScheme.lowest + const isLight = colorScheme.isLight + const itemSpacing = 8 + const titlebarButton = toggleable(interactive({ base: { - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 20, - }, state: { - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - } - }), - toggleContactsButton: toggleable(interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, - }, - state: { - clicked: { - background: background(layer, "variant", "pressed"), - color: foreground(layer, "variant", "pressed"), - }, - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - } - } - }), - { - default: { - background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active") - } - }, - ), - userMenuButton: merge(titlebarButton, { - inactive: { - default: { - buttonWidth: 20, - iconWidth: 12 - } - }, active: { // posiewic: these properties are not currently set on main - default: { - iconWidth: 12, - button_width: 20, - } - } - }), - - - toggleContactsBadge: { - cornerRadius: 3, - padding: 2, - margin: { top: 3, left: 3 }, - border: border(layer), - background: foreground(layer, "accent"), - }, - shareButton: { - ...titlebarButton, - }, - }, - - toolbar: { - height: 34, - background: background(colorScheme.highest), - border: border(colorScheme.highest, { bottom: true }), - itemSpacing: 8, - navButton: interactive( - { - base: { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, cornerRadius: 6, - }, state: { + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), + }, state: { hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), + ...text(layer, "sans", "variant", "hovered", { size: "xs" }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), }, - disabled: { - color: foreground(colorScheme.highest, "on", "disabled"), - }, - } - }), - padding: { left: 8, right: 8, top: 4, bottom: 4 }, - }, - breadcrumbHeight: 24, - breadcrumbs: interactive({ - base: { - ...text(colorScheme.highest, "sans", "variant"), - cornerRadius: 6, - padding: { - left: 6, - right: 6, + clicked: { + ...text(layer, "sans", "variant", "pressed", { size: "xs" }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + } } - }, state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background(colorScheme.highest, "on", "hovered"), - }, - } }), - disconnectedOverlay: { - ...text(layer, "sans"), - background: withOpacity(background(layer), 0.8), - }, - notification: { - margin: { top: 10 }, - background: background(colorScheme.middle), - cornerRadius: 6, - padding: 12, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - }, - notifications: { - width: 400, - margin: { right: 10, bottom: 10 }, - }, - dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), - } + { + default: { + ...text(layer, "sans", "variant", "active", { size: "xs" }), + background: background(layer, "variant", "active"), + border: border(layer, "variant", "active"), + } + }, + ); + const avatarWidth = 18 + const avatarOuterWidth = avatarWidth + 4 + const followerAvatarWidth = 14 + const followerAvatarOuterWidth = followerAvatarWidth + 4 + + return { + background: background(colorScheme.lowest), + blankPane: { + logoContainer: { + width: 256, + height: 256, + }, + logo: svg( + withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), + "icons/logo_96.svg", + 256, + 256 + ), + + logoShadow: svg( + withOpacity( + colorScheme.isLight + ? "#FFFFFF" + : colorScheme.lowest.base.default.background, + colorScheme.isLight ? 1 : 0.6 + ), + "icons/logo_96.svg", + 256, + 256 + ), + keyboardHints: { + margin: { + top: 96, + }, + cornerRadius: 4, + }, + keyboardHint: + interactive({ + base: { + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, + left: 8, + right: 8, + bottom: 3, + }, + cornerRadius: 8 + }, state: { + hovered: { + ...text(layer, "sans", "active", { size: "sm" }), + } + } + }), + + keyboardHintWidth: 320, + }, + joiningProjectAvatar: { + cornerRadius: 40, + width: 80, + }, + joiningProjectMessage: { + padding: 12, + ...text(layer, "sans", { size: "lg" }), + }, + externalLocationMessage: { + background: background(colorScheme.middle, "accent"), + border: border(colorScheme.middle, "accent"), + cornerRadius: 6, + padding: 12, + margin: { bottom: 8, right: 8 }, + ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), + }, + leaderBorderOpacity: 0.7, + leaderBorderWidth: 2.0, + tabBar: tabBar(colorScheme), + modal: { + margin: { + bottom: 52, + top: 52, + }, + cursor: "Arrow", + }, + zoomedBackground: { + cursor: "Arrow", + background: isLight + ? withOpacity(background(colorScheme.lowest), 0.8) + : withOpacity(background(colorScheme.highest), 0.6), + }, + zoomedPaneForeground: { + margin: 16, + shadow: colorScheme.modalShadow, + border: border(colorScheme.lowest, { overlay: true }), + }, + zoomedPanelForeground: { + margin: 16, + border: border(colorScheme.lowest, { overlay: true }), + }, + dock: { + left: { + border: border(layer, { right: true }), + }, + bottom: { + border: border(layer, { top: true }), + }, + right: { + border: border(layer, { left: true }), + }, + }, + paneDivider: { + color: borderColor(layer), + width: 1, + }, + statusBar: statusBar(colorScheme), + titlebar: { + itemSpacing, + facePileSpacing: 2, + height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. + background: background(layer), + border: border(layer, { bottom: true }), + padding: { + left: 80, + right: itemSpacing, + }, + + // Project + title: text(layer, "sans", "variant"), + highlight_color: text(layer, "sans", "active").color, + + // Collaborators + leaderAvatar: { + width: avatarWidth, + outerWidth: avatarOuterWidth, + cornerRadius: avatarWidth / 2, + outerCornerRadius: avatarOuterWidth / 2, + }, + followerAvatar: { + width: followerAvatarWidth, + outerWidth: followerAvatarOuterWidth, + cornerRadius: followerAvatarWidth / 2, + outerCornerRadius: followerAvatarOuterWidth / 2, + }, + inactiveAvatarGrayscale: true, + followerAvatarOverlap: 8, + leaderSelection: { + margin: { + top: 4, + bottom: 4, + }, + padding: { + left: 2, + right: 2, + top: 2, + bottom: 2, + }, + cornerRadius: 6, + }, + avatarRibbon: { + height: 3, + width: 12, + // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. + }, + + // Sign in buttom + // FlatButton, Variant + signInPrompt: + merge(titlebarButton, + { + inactive: { + default: { + margin: { + left: itemSpacing, + }, + } + } + }), + + + // Offline Indicator + offlineIcon: { + color: foreground(layer, "variant"), + width: 16, + margin: { + left: itemSpacing, + }, + padding: { + right: 4, + }, + }, + + // Notice that the collaboration server is out of date + outdatedWarning: { + ...text(layer, "sans", "warning", { size: "xs" }), + background: withOpacity(background(layer, "warning"), 0.3), + border: border(layer, "warning"), + margin: { + left: itemSpacing, + }, + padding: { + left: 8, + right: 8, + }, + cornerRadius: 6, + }, + callControl: interactive({ + base: { + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 20, + }, state: { + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + } + }), + toggleContactsButton: toggleable(interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { + clicked: { + background: background(layer, "variant", "pressed"), + color: foreground(layer, "variant", "pressed"), + }, + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + } + } + }), + { + default: { + background: background(layer, "variant", "active"), + color: foreground(layer, "variant", "active") + } + }, + ), + userMenuButton: merge(titlebarButton, { + inactive: { + default: { + buttonWidth: 20, + iconWidth: 12 + } + }, active: { // posiewic: these properties are not currently set on main + default: { + iconWidth: 12, + button_width: 20, + } + } + }), + + + toggleContactsBadge: { + cornerRadius: 3, + padding: 2, + margin: { top: 3, left: 3 }, + border: border(layer), + background: foreground(layer, "accent"), + }, + shareButton: { + ...titlebarButton, + }, + }, + + toolbar: { + height: 34, + background: background(colorScheme.highest), + border: border(colorScheme.highest, { bottom: true }), + itemSpacing: 8, + navButton: interactive( + { + base: { + color: foreground(colorScheme.highest, "on"), + iconWidth: 12, + buttonWidth: 24, + cornerRadius: 6, + }, state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, + disabled: { + color: foreground(colorScheme.highest, "on", "disabled"), + }, + } + }), + padding: { left: 8, right: 8, top: 4, bottom: 4 }, + }, + breadcrumbHeight: 24, + breadcrumbs: interactive({ + base: { + ...text(colorScheme.highest, "sans", "variant"), + cornerRadius: 6, + padding: { + left: 6, + right: 6, + } + }, state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background(colorScheme.highest, "on", "hovered"), + }, + } + }), + disconnectedOverlay: { + ...text(layer, "sans"), + background: withOpacity(background(layer), 0.8), + }, + notification: { + margin: { top: 10 }, + background: background(colorScheme.middle), + cornerRadius: 6, + padding: 12, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + }, + notifications: { + width: 400, + margin: { right: 10, bottom: 10 }, + }, + dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), + } } diff --git a/styles/vitest.config.ts b/styles/vitest.config.ts new file mode 100644 index 0000000000..83bd50b9c6 --- /dev/null +++ b/styles/vitest.config.ts @@ -0,0 +1,8 @@ +import { configDefaults, defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + exclude: [...configDefaults.exclude, 'target/*'], + include: ['src/**/*.{spec,test}.ts'], + }, +}) From 1f3feacb2162db3a35699060727c43b062c882fb Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 16 Jun 2023 00:37:08 -0400 Subject: [PATCH 051/215] Add path aliases --- styles/src/element/{interactive => }/index.ts | 0 .../{interactive => }/interactive.test.ts | 0 .../element/{interactive => }/interactive.ts | 0 styles/src/styleTree/assistant.ts | 2 +- styles/src/styleTree/commandPalette.ts | 2 +- styles/src/styleTree/contactList.ts | 2 +- styles/src/styleTree/contactNotification.ts | 2 +- styles/src/styleTree/contextMenu.ts | 2 +- styles/src/styleTree/copilot.ts | 2 +- styles/src/styleTree/editor.ts | 2 +- styles/src/styleTree/feedback.ts | 2 +- styles/src/styleTree/picker.ts | 2 +- styles/src/styleTree/projectPanel.ts | 2 +- styles/src/styleTree/search.ts | 2 +- .../styleTree/simpleMessageNotification.ts | 2 +- styles/src/styleTree/statusBar.ts | 2 +- styles/src/styleTree/tabBar.ts | 2 +- styles/src/styleTree/toolbarDropdownMenu.ts | 2 +- styles/src/styleTree/updateNotification.ts | 2 +- styles/src/styleTree/welcome.ts | 2 +- styles/src/styleTree/workspace.ts | 2 +- styles/tsconfig.json | 30 +++++++++++++++++-- 22 files changed, 46 insertions(+), 20 deletions(-) rename styles/src/element/{interactive => }/index.ts (100%) rename styles/src/element/{interactive => }/interactive.test.ts (100%) rename styles/src/element/{interactive => }/interactive.ts (100%) diff --git a/styles/src/element/interactive/index.ts b/styles/src/element/index.ts similarity index 100% rename from styles/src/element/interactive/index.ts rename to styles/src/element/index.ts diff --git a/styles/src/element/interactive/interactive.test.ts b/styles/src/element/interactive.test.ts similarity index 100% rename from styles/src/element/interactive/interactive.test.ts rename to styles/src/element/interactive.test.ts diff --git a/styles/src/element/interactive/interactive.ts b/styles/src/element/interactive.ts similarity index 100% rename from styles/src/element/interactive/interactive.ts rename to styles/src/element/interactive.ts diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index b31fe8169e..6ebf648481 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -1,7 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { text, border, background, foreground } from "./components" import editor from "./editor" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function assistant(colorScheme: ColorScheme) { const layer = colorScheme.highest diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index 081a0ba68c..8634d08a90 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -2,7 +2,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, background } from "./components" import { toggleable } from "./toggle" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function commandPalette(colorScheme: ColorScheme) { let layer = colorScheme.highest diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 3b95a3c885..f038d79716 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -1,7 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, foreground, text } from "./components" import { toggleable } from "./toggle" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function contactsPanel(colorScheme: ColorScheme) { const nameMargin = 8 const sidePadding = 12 diff --git a/styles/src/styleTree/contactNotification.ts b/styles/src/styleTree/contactNotification.ts index 4d57239005..7de3f2fe0c 100644 --- a/styles/src/styleTree/contactNotification.ts +++ b/styles/src/styleTree/contactNotification.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, foreground, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" const avatarSize = 12 const headerPadding = 8 diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 51bff9de7f..21231ccac9 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import { toggleable } from "./toggle" export default function contextMenu(colorScheme: ColorScheme) { diff --git a/styles/src/styleTree/copilot.ts b/styles/src/styleTree/copilot.ts index 27ef5ec11c..9229761414 100644 --- a/styles/src/styleTree/copilot.ts +++ b/styles/src/styleTree/copilot.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, svg, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function copilot(colorScheme: ColorScheme) { let layer = colorScheme.middle diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 3612a0acd1..5a55341933 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -4,7 +4,7 @@ import { background, border, borderColor, foreground, text } from "./components" import hoverPopover from "./hoverPopover" import { buildSyntax } from "../theme/syntax" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import { toggleable } from "./toggle" export default function editor(colorScheme: ColorScheme) { diff --git a/styles/src/styleTree/feedback.ts b/styles/src/styleTree/feedback.ts index 19a8f1e4c7..4f0e99844d 100644 --- a/styles/src/styleTree/feedback.ts +++ b/styles/src/styleTree/feedback.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function feedback(colorScheme: ColorScheme) { let layer = colorScheme.highest diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 3bcdae584f..940059eb43 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -2,7 +2,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, text } from "./components" import { toggleable } from "./toggle" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function picker(colorScheme: ColorScheme): any { let layer = colorScheme.lowest diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 132dfe102c..5df3988be6 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -1,7 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import { toggleable } from "./toggle" export default function projectPanel(colorScheme: ColorScheme) { const { isLight } = colorScheme diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index 1f63d2740b..64f17e7d74 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -1,7 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import { toggleable } from "./toggle" export default function search(colorScheme: ColorScheme) { diff --git a/styles/src/styleTree/simpleMessageNotification.ts b/styles/src/styleTree/simpleMessageNotification.ts index 4c2abfcf9d..404be2da7e 100644 --- a/styles/src/styleTree/simpleMessageNotification.ts +++ b/styles/src/styleTree/simpleMessageNotification.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" const headerPadding = 8 diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index ee78f5e6b3..30f933de8c 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import { toggleable } from "./toggle" export default function statusBar(colorScheme: ColorScheme) { let layer = colorScheme.lowest diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index 8011a70772..ae2d14bfd6 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -2,7 +2,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, border, background, foreground } from "./components" import { toggleable } from "./toggle" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function tabBar(colorScheme: ColorScheme) { const height = 32 diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 0bb3958dc8..bb3e8eda0c 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import { toggleable } from "./toggle" export default function dropdownMenu(colorScheme: ColorScheme) { let layer = colorScheme.middle diff --git a/styles/src/styleTree/updateNotification.ts b/styles/src/styleTree/updateNotification.ts index a7a5aaabaa..0cef7fa805 100644 --- a/styles/src/styleTree/updateNotification.ts +++ b/styles/src/styleTree/updateNotification.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { foreground, text } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" const headerPadding = 8 diff --git a/styles/src/styleTree/welcome.ts b/styles/src/styleTree/welcome.ts index f0e4badf3f..a0d599b747 100644 --- a/styles/src/styleTree/welcome.ts +++ b/styles/src/styleTree/welcome.ts @@ -8,7 +8,7 @@ import { TextProperties, svg, } from "./components" -import { interactive } from "../element/interactive" +import { interactive } from "../element" export default function welcome(colorScheme: ColorScheme) { let layer = colorScheme.highest diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index fa2d337592..1045be1a9a 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -11,7 +11,7 @@ import { } from "./components" import statusBar from "./statusBar" import tabBar from "./tabBar" -import { interactive } from "../element/interactive" +import { interactive } from "../element" import merge from 'ts-deepmerge'; export default function workspace(colorScheme: ColorScheme) { const layer = colorScheme.lowest diff --git a/styles/tsconfig.json b/styles/tsconfig.json index 6d24728a0a..051626adbc 100644 --- a/styles/tsconfig.json +++ b/styles/tsconfig.json @@ -20,7 +20,33 @@ "noFallthroughCasesInSwitch": false, "experimentalDecorators": true, "strictPropertyInitialization": false, - "skipLibCheck": true + "skipLibCheck": true, + "baseUrl": ".", + "paths": { + "@/*": [ + "./*" + ], + "@element/*": [ + "./src/element/*" + ], + "@component/*": [ + "./src/component/*" + ], + "@styleTree/*": [ + "./src/styleTree/*" + ], + "@theme/*": [ + "./src/theme/*" + ], + "@themes/*": [ + "./src/themes/*" + ], + "@util/*": [ + "./src/util/*" + ] + } }, - "exclude": ["node_modules"] + "exclude": [ + "node_modules" + ] } From 5c034ab63c2520e8fe0a6c27f9602dc0851662c6 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 16 Jun 2023 01:01:51 -0400 Subject: [PATCH 052/215] Format --- styles/src/element/index.ts | 2 +- styles/src/element/interactive.test.ts | 59 ++- styles/src/element/interactive.ts | 76 +-- styles/src/styleTree/app.ts | 1 - styles/src/styleTree/assistant.ts | 25 +- styles/src/styleTree/commandPalette.ts | 22 +- styles/src/styleTree/components.ts | 434 +++++++++--------- styles/src/styleTree/contactList.ts | 106 +++-- styles/src/styleTree/contactNotification.ts | 31 +- styles/src/styleTree/contextMenu.ts | 60 +-- styles/src/styleTree/copilot.ts | 66 ++- styles/src/styleTree/editor.ts | 67 +-- styles/src/styleTree/feedback.ts | 7 +- styles/src/styleTree/picker.ts | 54 ++- styles/src/styleTree/projectPanel.ts | 37 +- styles/src/styleTree/search.ts | 72 +-- .../styleTree/simpleMessageNotification.ts | 12 +- styles/src/styleTree/statusBar.ts | 134 +++--- styles/src/styleTree/tabBar.ts | 29 +- styles/src/styleTree/toggle.ts | 64 +-- styles/src/styleTree/toolbarDropdownMenu.ts | 54 ++- styles/src/styleTree/updateNotification.ts | 17 +- styles/src/styleTree/welcome.ts | 9 +- styles/src/styleTree/workspace.ts | 235 +++++----- styles/src/theme/tokens/colorScheme.ts | 56 ++- styles/src/theme/tokens/layer.ts | 33 +- styles/src/theme/tokens/players.ts | 18 +- styles/src/theme/tokens/token.ts | 9 +- styles/src/utils/slugify.ts | 11 +- styles/tsconfig.json | 32 +- styles/vitest.config.ts | 6 +- 31 files changed, 978 insertions(+), 860 deletions(-) diff --git a/styles/src/element/index.ts b/styles/src/element/index.ts index 0ead902eb9..ad58b89e0e 100644 --- a/styles/src/element/index.ts +++ b/styles/src/element/index.ts @@ -1,3 +1,3 @@ -import { interactive } from "./interactive"; +import { interactive } from "./interactive" export { interactive } diff --git a/styles/src/element/interactive.test.ts b/styles/src/element/interactive.test.ts index aa716e998e..b0cc57875f 100644 --- a/styles/src/element/interactive.test.ts +++ b/styles/src/element/interactive.test.ts @@ -1,59 +1,56 @@ -import { NOT_ENOUGH_STATES_ERROR, NO_DEFAULT_OR_BASE_ERROR, interactive } from './interactive' -import { describe, it, expect } from 'vitest' - -describe('interactive', () => { - - it('creates an Interactive with base properties and states', () => { +import { + NOT_ENOUGH_STATES_ERROR, + NO_DEFAULT_OR_BASE_ERROR, + interactive, +} from "./interactive" +import { describe, it, expect } from "vitest" +describe("interactive", () => { + it("creates an Interactive with base properties and states", () => { const result = interactive({ - base: { fontSize: 10, color: '#FFFFFF' }, + base: { fontSize: 10, color: "#FFFFFF" }, state: { - hovered: { color: '#EEEEEE' }, - clicked: { color: '#CCCCCC' }, - } + hovered: { color: "#EEEEEE" }, + clicked: { color: "#CCCCCC" }, + }, }) expect(result).toEqual({ - default: { color: '#FFFFFF', fontSize: 10 }, - hovered: { color: '#EEEEEE', fontSize: 10 }, - clicked: { color: '#CCCCCC', fontSize: 10 }, + default: { color: "#FFFFFF", fontSize: 10 }, + hovered: { color: "#EEEEEE", fontSize: 10 }, + clicked: { color: "#CCCCCC", fontSize: 10 }, }) }) - it('creates an Interactive with no base properties', () => { - + it("creates an Interactive with no base properties", () => { const result = interactive({ state: { - default: { color: '#FFFFFF', fontSize: 10 }, - hovered: { color: '#EEEEEE' }, - clicked: { color: '#CCCCCC' }, - } + default: { color: "#FFFFFF", fontSize: 10 }, + hovered: { color: "#EEEEEE" }, + clicked: { color: "#CCCCCC" }, + }, }) expect(result).toEqual({ - default: { color: '#FFFFFF', fontSize: 10 }, - hovered: { color: '#EEEEEE', fontSize: 10 }, - clicked: { color: '#CCCCCC', fontSize: 10 }, + default: { color: "#FFFFFF", fontSize: 10 }, + hovered: { color: "#EEEEEE", fontSize: 10 }, + clicked: { color: "#CCCCCC", fontSize: 10 }, }) }) - it('throws error when both default and base are missing', () => { + it("throws error when both default and base are missing", () => { const state = { - hovered: { color: 'blue' }, + hovered: { color: "blue" }, } - expect(() => interactive({ state })).toThrow( - NO_DEFAULT_OR_BASE_ERROR - ) + expect(() => interactive({ state })).toThrow(NO_DEFAULT_OR_BASE_ERROR) }) - it('throws error when no other state besides default is present', () => { + it("throws error when no other state besides default is present", () => { const state = { default: { fontSize: 10 }, } - expect(() => interactive({ state })).toThrow( - NOT_ENOUGH_STATES_ERROR - ) + expect(() => interactive({ state })).toThrow(NOT_ENOUGH_STATES_ERROR) }) }) diff --git a/styles/src/element/interactive.ts b/styles/src/element/interactive.ts index 23cd2a8c15..5d9772d313 100644 --- a/styles/src/element/interactive.ts +++ b/styles/src/element/interactive.ts @@ -1,20 +1,27 @@ import merge from "ts-deepmerge" -type InteractiveState = "default" | "hovered" | "clicked" | "selected" | "disabled"; +type InteractiveState = + | "default" + | "hovered" + | "clicked" + | "selected" + | "disabled" type Interactive = { - default: T, - hovered?: T, - clicked?: T, - selected?: T, - disabled?: T, -}; + default: T + hovered?: T + clicked?: T + selected?: T + disabled?: T +} -export const NO_DEFAULT_OR_BASE_ERROR = "An interactive object must have a default state, or a base property." -export const NOT_ENOUGH_STATES_ERROR = "An interactive object must have a default and at least one other state." +export const NO_DEFAULT_OR_BASE_ERROR = + "An interactive object must have a default state, or a base property." +export const NOT_ENOUGH_STATES_ERROR = + "An interactive object must have a default and at least one other state." interface InteractiveProps { - base?: T, + base?: T state: Partial> } @@ -29,46 +36,61 @@ interface InteractiveProps { * @param state Object containing optional modified fields to be included in the resulting object for each state. * @returns Interactive object with fields from `base` and `state`. */ -export function interactive({ base, state }: InteractiveProps): Interactive { - if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR); +export function interactive({ + base, + state, +}: InteractiveProps): Interactive { + if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR) - let defaultState: T; + let defaultState: T if (state.default && base) { - defaultState = merge(base, state.default) as T; + defaultState = merge(base, state.default) as T } else { - defaultState = base ? base : state.default as T; + defaultState = base ? base : (state.default as T) } let interactiveObj: Interactive = { default: defaultState, - }; + } - let stateCount = 0; + let stateCount = 0 if (state.hovered !== undefined) { - interactiveObj.hovered = merge(interactiveObj.default, state.hovered) as T; - stateCount++; + interactiveObj.hovered = merge( + interactiveObj.default, + state.hovered + ) as T + stateCount++ } if (state.clicked !== undefined) { - interactiveObj.clicked = merge(interactiveObj.default, state.clicked) as T; - stateCount++; + interactiveObj.clicked = merge( + interactiveObj.default, + state.clicked + ) as T + stateCount++ } if (state.selected !== undefined) { - interactiveObj.selected = merge(interactiveObj.default, state.selected) as T; - stateCount++; + interactiveObj.selected = merge( + interactiveObj.default, + state.selected + ) as T + stateCount++ } if (state.disabled !== undefined) { - interactiveObj.disabled = merge(interactiveObj.default, state.disabled) as T; - stateCount++; + interactiveObj.disabled = merge( + interactiveObj.default, + state.disabled + ) as T + stateCount++ } if (stateCount < 1) { - throw new Error(NOT_ENOUGH_STATES_ERROR); + throw new Error(NOT_ENOUGH_STATES_ERROR) } - return interactiveObj; + return interactiveObj } diff --git a/styles/src/styleTree/app.ts b/styles/src/styleTree/app.ts index 6244cbae10..754443cc5f 100644 --- a/styles/src/styleTree/app.ts +++ b/styles/src/styleTree/app.ts @@ -1,4 +1,3 @@ -import { text } from "./components" import contactFinder from "./contactFinder" import contactsPopover from "./contactsPopover" import commandPalette from "./commandPalette" diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index 6ebf648481..163584cd6d 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -16,17 +16,27 @@ export default function assistant(colorScheme: ColorScheme) { background: editor(colorScheme).background, }, userSender: { - default: - { ...text(layer, "sans", "default", { size: "sm", weight: "bold" }) }, + default: { + ...text(layer, "sans", "default", { + size: "sm", + weight: "bold", + }), + }, }, assistantSender: { default: { - ...text(layer, "sans", "accent", { size: "sm", weight: "bold" }) + ...text(layer, "sans", "accent", { + size: "sm", + weight: "bold", + }), }, }, systemSender: { default: { - ...text(layer, "sans", "variant", { size: "sm", weight: "bold" }) + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), }, }, sentAt: { @@ -43,11 +53,12 @@ export default function assistant(colorScheme: ColorScheme) { padding: 4, cornerRadius: 4, ...text(layer, "sans", "default", { size: "xs" }), - }, state: { + }, + state: { hovered: { background: background(layer, "on", "hovered"), - } - } + }, + }, }), remainingTokens: { background: background(layer, "on"), diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index 8634d08a90..ae0aae2f81 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -8,10 +8,12 @@ export default function commandPalette(colorScheme: ColorScheme) { let layer = colorScheme.highest return { keystrokeSpacing: 8, - key: - toggleable(interactive({ + key: toggleable( + interactive({ base: { - text: text(layer, "mono", "variant", "default", { size: "xs" }), + text: text(layer, "mono", "variant", "default", { + size: "xs", + }), cornerRadius: 2, background: background(layer, "on"), padding: { @@ -25,15 +27,15 @@ export default function commandPalette(colorScheme: ColorScheme) { bottom: 1, left: 2, }, - }, state: { hovered: { cornerRadius: 4, padding: { top: 17 } } } - }), { + }, + state: { hovered: { cornerRadius: 4, padding: { top: 17 } } }, + }), + { default: { text: text(layer, "mono", "on", "default", { size: "xs" }), background: withOpacity(background(layer, "on"), 0.2), - } - - }) - , - + }, + } + ), } } diff --git a/styles/src/styleTree/components.ts b/styles/src/styleTree/components.ts index 3aa5d9176e..bfd1f75cb0 100644 --- a/styles/src/styleTree/components.ts +++ b/styles/src/styleTree/components.ts @@ -2,297 +2,297 @@ import { fontFamilies, fontSizes, FontWeight } from "../common" import { Layer, Styles, StyleSets, Style } from "../theme/colorScheme" function isStyleSet(key: any): key is StyleSets { - return [ - "base", - "variant", - "on", - "accent", - "positive", - "warning", - "negative", - ].includes(key) + return [ + "base", + "variant", + "on", + "accent", + "positive", + "warning", + "negative", + ].includes(key) } function isStyle(key: any): key is Styles { - return [ - "default", - "active", - "disabled", - "hovered", - "pressed", - "inverted", - ].includes(key) + return [ + "default", + "active", + "disabled", + "hovered", + "pressed", + "inverted", + ].includes(key) } function getStyle( - layer: Layer, - possibleStyleSetOrStyle?: any, - possibleStyle?: any + layer: Layer, + possibleStyleSetOrStyle?: any, + possibleStyle?: any ): Style { - let styleSet: StyleSets = "base" - let style: Styles = "default" - if (isStyleSet(possibleStyleSetOrStyle)) { - styleSet = possibleStyleSetOrStyle - } else if (isStyle(possibleStyleSetOrStyle)) { - style = possibleStyleSetOrStyle - } + let styleSet: StyleSets = "base" + let style: Styles = "default" + if (isStyleSet(possibleStyleSetOrStyle)) { + styleSet = possibleStyleSetOrStyle + } else if (isStyle(possibleStyleSetOrStyle)) { + style = possibleStyleSetOrStyle + } - if (isStyle(possibleStyle)) { - style = possibleStyle - } + if (isStyle(possibleStyle)) { + style = possibleStyle + } - return layer[styleSet][style] + return layer[styleSet][style] } export function background(layer: Layer, style?: Styles): string export function background( - layer: Layer, - styleSet?: StyleSets, - style?: Styles + layer: Layer, + styleSet?: StyleSets, + style?: Styles ): string export function background( - layer: Layer, - styleSetOrStyles?: StyleSets | Styles, - style?: Styles + layer: Layer, + styleSetOrStyles?: StyleSets | Styles, + style?: Styles ): string { - return getStyle(layer, styleSetOrStyles, style).background + return getStyle(layer, styleSetOrStyles, style).background } export function borderColor(layer: Layer, style?: Styles): string export function borderColor( - layer: Layer, - styleSet?: StyleSets, - style?: Styles + layer: Layer, + styleSet?: StyleSets, + style?: Styles ): string export function borderColor( - layer: Layer, - styleSetOrStyles?: StyleSets | Styles, - style?: Styles + layer: Layer, + styleSetOrStyles?: StyleSets | Styles, + style?: Styles ): string { - return getStyle(layer, styleSetOrStyles, style).border + return getStyle(layer, styleSetOrStyles, style).border } export function foreground(layer: Layer, style?: Styles): string export function foreground( - layer: Layer, - styleSet?: StyleSets, - style?: Styles + layer: Layer, + styleSet?: StyleSets, + style?: Styles ): string export function foreground( - layer: Layer, - styleSetOrStyles?: StyleSets | Styles, - style?: Styles + layer: Layer, + styleSetOrStyles?: StyleSets | Styles, + style?: Styles ): string { - return getStyle(layer, styleSetOrStyles, style).foreground + return getStyle(layer, styleSetOrStyles, style).foreground } interface Text extends Object { - family: keyof typeof fontFamilies - color: string - size: number - weight?: FontWeight - underline?: boolean + family: keyof typeof fontFamilies + color: string + size: number + weight?: FontWeight + underline?: boolean } export interface TextProperties { - size?: keyof typeof fontSizes - weight?: FontWeight - underline?: boolean - color?: string - features?: FontFeatures + size?: keyof typeof fontSizes + weight?: FontWeight + underline?: boolean + color?: string + features?: FontFeatures } interface FontFeatures { - /** Contextual Alternates: Applies a second substitution feature based on a match of a character pattern within a context of surrounding patterns */ - calt?: boolean - /** Case-Sensitive Forms: Shifts various punctuation marks up to a position that works better with all-capital sequences */ - case?: boolean - /** Capital Spacing: Adjusts inter-glyph spacing for all-capital text */ - cpsp?: boolean - /** Fractions: Replaces figures separated by a slash with diagonal fractions */ - frac?: boolean - /** Standard Ligatures: Replaces a sequence of glyphs with a single glyph which is preferred for typographic purposes */ - liga?: boolean - /** Oldstyle Figures: Changes selected figures from the default or lining style to oldstyle form. */ - onum?: boolean - /** Ordinals: Replaces default alphabetic glyphs with the corresponding ordinal forms for use after figures */ - ordn?: boolean - /** Proportional Figures: Replaces figure glyphs set on uniform (tabular) widths with corresponding glyphs set on proportional widths */ - pnum?: boolean - /** Stylistic set 01 */ - ss01?: boolean - /** Stylistic set 02 */ - ss02?: boolean - /** Stylistic set 03 */ - ss03?: boolean - /** Stylistic set 04 */ - ss04?: boolean - /** Stylistic set 05 */ - ss05?: boolean - /** Stylistic set 06 */ - ss06?: boolean - /** Stylistic set 07 */ - ss07?: boolean - /** Stylistic set 08 */ - ss08?: boolean - /** Stylistic set 09 */ - ss09?: boolean - /** Stylistic set 10 */ - ss10?: boolean - /** Stylistic set 11 */ - ss11?: boolean - /** Stylistic set 12 */ - ss12?: boolean - /** Stylistic set 13 */ - ss13?: boolean - /** Stylistic set 14 */ - ss14?: boolean - /** Stylistic set 15 */ - ss15?: boolean - /** Stylistic set 16 */ - ss16?: boolean - /** Stylistic set 17 */ - ss17?: boolean - /** Stylistic set 18 */ - ss18?: boolean - /** Stylistic set 19 */ - ss19?: boolean - /** Stylistic set 20 */ - ss20?: boolean - /** Subscript: Replaces default glyphs with subscript glyphs */ - subs?: boolean - /** Superscript: Replaces default glyphs with superscript glyphs */ - sups?: boolean - /** Swash: Replaces default glyphs with swash glyphs for stylistic purposes */ - swsh?: boolean - /** Titling: Replaces default glyphs with titling glyphs for use in large-size settings */ - titl?: boolean - /** Tabular Figures: Replaces figure glyphs set on proportional widths with corresponding glyphs set on uniform (tabular) widths */ - tnum?: boolean - /** Slashed Zero: Replaces default zero with a slashed zero for better distinction between "0" and "O" */ - zero?: boolean + /** Contextual Alternates: Applies a second substitution feature based on a match of a character pattern within a context of surrounding patterns */ + calt?: boolean + /** Case-Sensitive Forms: Shifts various punctuation marks up to a position that works better with all-capital sequences */ + case?: boolean + /** Capital Spacing: Adjusts inter-glyph spacing for all-capital text */ + cpsp?: boolean + /** Fractions: Replaces figures separated by a slash with diagonal fractions */ + frac?: boolean + /** Standard Ligatures: Replaces a sequence of glyphs with a single glyph which is preferred for typographic purposes */ + liga?: boolean + /** Oldstyle Figures: Changes selected figures from the default or lining style to oldstyle form. */ + onum?: boolean + /** Ordinals: Replaces default alphabetic glyphs with the corresponding ordinal forms for use after figures */ + ordn?: boolean + /** Proportional Figures: Replaces figure glyphs set on uniform (tabular) widths with corresponding glyphs set on proportional widths */ + pnum?: boolean + /** Stylistic set 01 */ + ss01?: boolean + /** Stylistic set 02 */ + ss02?: boolean + /** Stylistic set 03 */ + ss03?: boolean + /** Stylistic set 04 */ + ss04?: boolean + /** Stylistic set 05 */ + ss05?: boolean + /** Stylistic set 06 */ + ss06?: boolean + /** Stylistic set 07 */ + ss07?: boolean + /** Stylistic set 08 */ + ss08?: boolean + /** Stylistic set 09 */ + ss09?: boolean + /** Stylistic set 10 */ + ss10?: boolean + /** Stylistic set 11 */ + ss11?: boolean + /** Stylistic set 12 */ + ss12?: boolean + /** Stylistic set 13 */ + ss13?: boolean + /** Stylistic set 14 */ + ss14?: boolean + /** Stylistic set 15 */ + ss15?: boolean + /** Stylistic set 16 */ + ss16?: boolean + /** Stylistic set 17 */ + ss17?: boolean + /** Stylistic set 18 */ + ss18?: boolean + /** Stylistic set 19 */ + ss19?: boolean + /** Stylistic set 20 */ + ss20?: boolean + /** Subscript: Replaces default glyphs with subscript glyphs */ + subs?: boolean + /** Superscript: Replaces default glyphs with superscript glyphs */ + sups?: boolean + /** Swash: Replaces default glyphs with swash glyphs for stylistic purposes */ + swsh?: boolean + /** Titling: Replaces default glyphs with titling glyphs for use in large-size settings */ + titl?: boolean + /** Tabular Figures: Replaces figure glyphs set on proportional widths with corresponding glyphs set on uniform (tabular) widths */ + tnum?: boolean + /** Slashed Zero: Replaces default zero with a slashed zero for better distinction between "0" and "O" */ + zero?: boolean } export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - styleSet: StyleSets, - style: Styles, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + styleSet: StyleSets, + style: Styles, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - styleSet: StyleSets, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + styleSet: StyleSets, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - style: Styles, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + style: Styles, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + properties?: TextProperties ): Text export function text( - layer: Layer, - fontFamily: keyof typeof fontFamilies, - styleSetStyleOrProperties?: StyleSets | Styles | TextProperties, - styleOrProperties?: Styles | TextProperties, - properties?: TextProperties + layer: Layer, + fontFamily: keyof typeof fontFamilies, + styleSetStyleOrProperties?: StyleSets | Styles | TextProperties, + styleOrProperties?: Styles | TextProperties, + properties?: TextProperties ) { - let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) + let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) - if (typeof styleSetStyleOrProperties === "object") { - properties = styleSetStyleOrProperties - } - if (typeof styleOrProperties === "object") { - properties = styleOrProperties - } + if (typeof styleSetStyleOrProperties === "object") { + properties = styleSetStyleOrProperties + } + if (typeof styleOrProperties === "object") { + properties = styleOrProperties + } - let size = fontSizes[properties?.size || "sm"] - let color = properties?.color || style.foreground + let size = fontSizes[properties?.size || "sm"] + let color = properties?.color || style.foreground - return { - family: fontFamilies[fontFamily], - ...properties, - color, - size, - } + return { + family: fontFamilies[fontFamily], + ...properties, + color, + size, + } } export interface Border { - color: string - width: number - top?: boolean - bottom?: boolean - left?: boolean - right?: boolean - overlay?: boolean + color: string + width: number + top?: boolean + bottom?: boolean + left?: boolean + right?: boolean + overlay?: boolean } export interface BorderProperties { - width?: number - top?: boolean - bottom?: boolean - left?: boolean - right?: boolean - overlay?: boolean + width?: number + top?: boolean + bottom?: boolean + left?: boolean + right?: boolean + overlay?: boolean } export function border( - layer: Layer, - styleSet: StyleSets, - style: Styles, - properties?: BorderProperties + layer: Layer, + styleSet: StyleSets, + style: Styles, + properties?: BorderProperties ): Border export function border( - layer: Layer, - styleSet: StyleSets, - properties?: BorderProperties + layer: Layer, + styleSet: StyleSets, + properties?: BorderProperties ): Border export function border( - layer: Layer, - style: Styles, - properties?: BorderProperties + layer: Layer, + style: Styles, + properties?: BorderProperties ): Border export function border(layer: Layer, properties?: BorderProperties): Border export function border( - layer: Layer, - styleSetStyleOrProperties?: StyleSets | Styles | BorderProperties, - styleOrProperties?: Styles | BorderProperties, - properties?: BorderProperties + layer: Layer, + styleSetStyleOrProperties?: StyleSets | Styles | BorderProperties, + styleOrProperties?: Styles | BorderProperties, + properties?: BorderProperties ): Border { - let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) + let style = getStyle(layer, styleSetStyleOrProperties, styleOrProperties) - if (typeof styleSetStyleOrProperties === "object") { - properties = styleSetStyleOrProperties - } - if (typeof styleOrProperties === "object") { - properties = styleOrProperties - } + if (typeof styleSetStyleOrProperties === "object") { + properties = styleSetStyleOrProperties + } + if (typeof styleOrProperties === "object") { + properties = styleOrProperties + } - return { - color: style.border, - width: 1, - ...properties, - } + return { + color: style.border, + width: 1, + ...properties, + } } export function svg( - color: string, - asset: String, - width: Number, - height: Number + color: string, + asset: String, + width: Number, + height: Number ) { - return { - color, - asset, - dimensions: { - width, - height, - }, - } + return { + color, + asset, + dimensions: { + width, + height, + }, + } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index f038d79716..5c6068408e 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -72,24 +72,28 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, rowHeight: 28, sectionIconSize: 8, - headerRow: toggleable(interactive({ - base: { - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, + headerRow: toggleable( + interactive({ + base: { + ...text(layer, "mono", { size: "sm" }), + margin: { top: 14 }, + padding: { + left: sidePadding, + right: sidePadding, + }, + background: background(layer, "default"), // posiewic: breaking change }, - background: background(layer, "default"),// posiewic: breaking change - } - , state: { hovered: { background: background(layer, "default") } } // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. - }), + state: { + hovered: { background: background(layer, "default") }, + }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. + }), { default: { ...text(layer, "mono", "active", { size: "sm" }), background: background(layer, "active"), }, - }), + } + ), leaveCall: interactive({ base: { background: background(layer), @@ -105,24 +109,22 @@ export default function contactsPanel(colorScheme: ColorScheme) { right: 7, }, ...text(layer, "sans", "variant", { size: "xs" }), - } - , + }, state: { hovered: { ...text(layer, "sans", "hovered", { size: "xs" }), background: background(layer, "hovered"), border: border(layer, "hovered"), - } - } - } - ), + }, + }, + }), contactRow: { inactive: { default: { padding: { left: sidePadding, right: sidePadding, - } + }, }, }, active: { @@ -131,8 +133,8 @@ export default function contactsPanel(colorScheme: ColorScheme) { padding: { left: sidePadding, right: sidePadding, - } - } + }, + }, }, }, @@ -165,7 +167,7 @@ export default function contactsPanel(colorScheme: ColorScheme) { hovered: { background: background(layer, "hovered"), }, - } + }, }), disabledButton: { ...contactButton, @@ -175,44 +177,48 @@ export default function contactsPanel(colorScheme: ColorScheme) { callingIndicator: { ...text(layer, "mono", "variant", { size: "xs" }), }, - treeBranch: toggleable(interactive({ - base: { - color: borderColor(layer), - width: 1, - }, - state: { - hovered: { + treeBranch: toggleable( + interactive({ + base: { color: borderColor(layer), + width: 1, }, - } - }), + state: { + hovered: { + color: borderColor(layer), + }, + }, + }), { default: { color: borderColor(layer), }, } ), - projectRow: toggleable(interactive({ - base: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, + projectRow: toggleable( + interactive({ + base: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, + }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), + }, }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), + state: { + hovered: { + background: background(layer, "hovered"), + }, }, - }, state: { - hovered: { - background: background(layer, "hovered"), - }, - } - }), + }), { - default: { background: background(layer, "active") } - }) + default: { background: background(layer, "active") }, + } + ), } } diff --git a/styles/src/styleTree/contactNotification.ts b/styles/src/styleTree/contactNotification.ts index 7de3f2fe0c..825c5a389a 100644 --- a/styles/src/styleTree/contactNotification.ts +++ b/styles/src/styleTree/contactNotification.ts @@ -21,22 +21,21 @@ export default function contactNotification(colorScheme: ColorScheme): Object { ...text(layer, "sans", { size: "xs" }), margin: { left: avatarSize + headerPadding, top: 6, bottom: 6 }, }, - button: - interactive({ - base: { - ...text(layer, "sans", "on", { size: "xs" }), - background: background(layer, "on"), - padding: 4, - cornerRadius: 6, - margin: { left: 6 } - }, + button: interactive({ + base: { + ...text(layer, "sans", "on", { size: "xs" }), + background: background(layer, "on"), + padding: 4, + cornerRadius: 6, + margin: { left: 6 }, + }, - state: { - hovered: { - background: background(layer, "on", "hovered"), - } - } - }), + state: { + hovered: { + background: background(layer, "on", "hovered"), + }, + }, + }), dismissButton: { default: { @@ -48,7 +47,7 @@ export default function contactNotification(colorScheme: ColorScheme): Object { hover: { color: foreground(layer, "hovered"), }, - } + }, }, } } diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 21231ccac9..6f5eb53640 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -12,41 +12,45 @@ export default function contextMenu(colorScheme: ColorScheme) { shadow: colorScheme.popoverShadow, border: border(layer), keystrokeMargin: 30, - item: toggleable(interactive({ - base: { - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "variant", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - } - }, state: { - hovered: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), + item: toggleable( + interactive({ + base: { + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), keystroke: { - ...text(layer, "sans", "hovered", { + ...text(layer, "sans", "variant", { size: "sm", weight: "bold", }), padding: { left: 3, right: 3 }, }, - } + }, + state: { + hovered: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "hovered", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + }, + }, + }), + { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, } - }), { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, - }), + ), separator: { background: borderColor(layer), diff --git a/styles/src/styleTree/copilot.ts b/styles/src/styleTree/copilot.ts index 9229761414..1e09f4ff6b 100644 --- a/styles/src/styleTree/copilot.ts +++ b/styles/src/styleTree/copilot.ts @@ -25,7 +25,7 @@ export default function copilot(colorScheme: ColorScheme) { left: 7, right: 7, }, - ...text(layer, "sans", "default", { size: "sm" }) + ...text(layer, "sans", "default", { size: "sm" }), }, state: { hovered: { @@ -33,39 +33,37 @@ export default function copilot(colorScheme: ColorScheme) { background: background(layer, "hovered"), border: border(layer, "active"), }, - } - }); + }, + }) return { - outLinkIcon: - interactive({ - base: { - icon: svg( - foreground(layer, "variant"), - "icons/link_out_12.svg", - 12, - 12 - ), - container: { - cornerRadius: 6, - padding: { left: 6 }, + outLinkIcon: interactive({ + base: { + icon: svg( + foreground(layer, "variant"), + "icons/link_out_12.svg", + 12, + 12 + ), + container: { + cornerRadius: 6, + padding: { left: 6 }, + }, + }, + state: { + hovered: { + icon: { + color: foreground(layer, "hovered"), }, }, - state: { - hovered: { - icon: { - color: - foreground(layer, "hovered") - } - }, - } - }), + }, + }), modal: { titleText: { default: { - ...text(layer, "sans", { size: "xs", weight: "bold" }) - } + ...text(layer, "sans", { size: "xs", weight: "bold" }), + }, }, titlebar: { background: background(colorScheme.lowest), @@ -87,8 +85,7 @@ export default function copilot(colorScheme: ColorScheme) { }, }, closeIcon: interactive({ - base: - { + base: { icon: svg( foreground(layer, "variant"), "icons/x_mark_8.svg", @@ -106,7 +103,7 @@ export default function copilot(colorScheme: ColorScheme) { margin: { right: 0, }, - } + }, }, state: { hovered: { @@ -125,7 +122,7 @@ export default function copilot(colorScheme: ColorScheme) { 8 ), }, - } + }, }), dimensions: { width: 280, @@ -214,8 +211,9 @@ export default function copilot(colorScheme: ColorScheme) { bottom: 5, left: 8, right: 0, - } - }, state: { + }, + }, + state: { hovered: { border: border(layer, "active", { bottom: false, @@ -224,8 +222,8 @@ export default function copilot(colorScheme: ColorScheme) { left: true, }), }, - } - }) + }, + }), }, }, diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 5a55341933..9dec64b0ce 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -50,23 +50,26 @@ export default function editor(colorScheme: ColorScheme) { // Inline autocomplete suggestions, Co-pilot suggestions, etc. suggestion: syntax.predictive, codeActions: { - indicator: toggleable(interactive({ - base: { - color: foreground(layer, "variant"), - }, state: { - clicked: { - color: foreground(layer, "base"), + indicator: toggleable( + interactive({ + base: { + color: foreground(layer, "variant"), }, - hovered: { - color: foreground(layer, "on"), + state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, }, - } - }), + }), { default: { color: foreground(layer, "on"), - } - }), + }, + } + ), verticalScale: 0.55, }, @@ -74,29 +77,34 @@ export default function editor(colorScheme: ColorScheme) { iconMarginScale: 2.5, foldedIcon: "icons/chevron_right_8.svg", foldableIcon: "icons/chevron_down_8.svg", - indicator: toggleable(interactive({ - base: { - color: foreground(layer, "variant"), - }, state: { - clicked: { - color: foreground(layer, "base"), + indicator: toggleable( + interactive({ + base: { + color: foreground(layer, "variant"), }, - hovered: { - color: foreground(layer, "on"), + state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, }, - } - }), + }), { default: { color: foreground(layer, "on"), - } - }), + }, + } + ), ellipses: { textColor: colorScheme.ramps.neutral(0.71).hex(), cornerRadiusFactor: 0.15, background: { // Copied from hover_popover highlight - default: { color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex() }, + default: { + color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), + }, hover: { color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), @@ -245,12 +253,13 @@ export default function editor(colorScheme: ColorScheme) { bottom: 6, left: 6, right: 6, - } - }, state: { + }, + }, + state: { hovered: { background: background(layer, "on", "hovered"), - } - } + }, + }, }), scrollbar: { diff --git a/styles/src/styleTree/feedback.ts b/styles/src/styleTree/feedback.ts index 4f0e99844d..c98cbe768f 100644 --- a/styles/src/styleTree/feedback.ts +++ b/styles/src/styleTree/feedback.ts @@ -20,8 +20,9 @@ export default function feedback(colorScheme: ColorScheme) { left: 10, right: 10, top: 2, - } - }, state: { + }, + }, + state: { clicked: { ...text(layer, "mono", "on", "pressed"), background: background(layer, "on", "pressed"), @@ -32,7 +33,7 @@ export default function feedback(colorScheme: ColorScheme) { background: background(layer, "on", "hovered"), border: border(layer, "on", "hovered"), }, - } + }, }), button_margin: 8, info_text_default: text(layer, "sans", "default", { size: "xs" }), diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 940059eb43..7730395ec9 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -40,29 +40,35 @@ export default function picker(colorScheme: ColorScheme): any { ...container, padding: {}, }, - item: toggleable(interactive({ - base: { - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, + item: toggleable( + interactive({ + base: { + padding: { + bottom: 4, + left: 12, + right: 12, + top: 4, + }, + margin: { + top: 1, + left: 4, + right: 4, + }, + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { + weight: "bold", + }), }, - margin: { - top: 1, - left: 4, - right: 4, + state: { + hovered: { + background: withOpacity( + background(layer, "hovered"), + 0.5 + ), + }, }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { weight: "bold" }), - } - , state: { - hovered: { - background: withOpacity(background(layer, "hovered"), 0.5), - } - } - }), + }), { default: { background: withOpacity( @@ -70,9 +76,9 @@ export default function picker(colorScheme: ColorScheme): any { 0.5 ), //text: text(layer, "sans", "base", "active"), - } - }), - + }, + } + ), inputEditor, emptyInputEditor, diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 5df3988be6..23df2fbf58 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -29,18 +29,19 @@ export default function projectPanel(colorScheme: ColorScheme) { }, } - let entry = toggleable(interactive({ - base: { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - status, - }, state: - { - hovered: { - background: background(layer, "variant", "hovered"), - } - } - }), + let entry = toggleable( + interactive({ + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, + state: { + hovered: { + background: background(layer, "variant", "hovered"), + }, + }, + }), { default: { /*background: colorScheme.isLight @@ -52,8 +53,8 @@ export default function projectPanel(colorScheme: ColorScheme) { //background: background(layer, "active"), text: text(layer, "mono", "active", { size: "sm" }), }, - - }); + } + ) return { openProjectButton: interactive({ @@ -72,14 +73,15 @@ export default function projectPanel(colorScheme: ColorScheme) { left: 7, right: 7, }, - ...text(layer, "sans", "default", { size: "sm" }) - }, state: { + ...text(layer, "sans", "default", { size: "sm" }), + }, + state: { hovered: { ...text(layer, "sans", "default", { size: "sm" }), background: background(layer, "hovered"), border: border(layer, "active"), }, - } + }, }), background: background(layer), padding: { left: 6, right: 6, top: 0, bottom: 6 }, @@ -111,7 +113,6 @@ export default function projectPanel(colorScheme: ColorScheme) { background: background(layer, "active"), text: text(layer, "mono", "disabled", { size: "sm" }), }, - }, }, filenameEditor: { diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index 64f17e7d74..a95296971c 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -37,41 +37,44 @@ export default function search(colorScheme: ColorScheme) { return { // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive matchBackground: withOpacity(foreground(layer, "accent"), 0.4), - optionButton: toggleable(interactive({ - base: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, + optionButton: toggleable( + interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, + }, + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, + }, }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, + state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, }, - }, state: { - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, - hovered: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), + }), + { + default: { + ...text(layer, "mono", "on", "inverted"), + background: background(layer, "on", "inverted"), + border: border(layer, "on", "inverted"), }, } - }), { - default: { - ...text(layer, "mono", "on", "inverted"), - background: background(layer, "on", "inverted"), - border: border(layer, "on", "inverted"), - }, - - }), + ), editor, invalidEditor: { ...editor, @@ -113,11 +116,12 @@ export default function search(colorScheme: ColorScheme) { left: 10, right: 10, }, - }, state: { + }, + state: { hovered: { color: foreground(layer, "hovered"), - } - } + }, + }, }), } } diff --git a/styles/src/styleTree/simpleMessageNotification.ts b/styles/src/styleTree/simpleMessageNotification.ts index 404be2da7e..e894db3514 100644 --- a/styles/src/styleTree/simpleMessageNotification.ts +++ b/styles/src/styleTree/simpleMessageNotification.ts @@ -26,13 +26,14 @@ export default function simpleMessageNotification( }, margin: { left: headerPadding, top: 6, bottom: 6 }, - }, state: { + }, + state: { hovered: { ...text(layer, "sans", "default", { size: "xs" }), background: background(layer, "hovered"), border: border(layer, "active"), }, - } + }, }), dismissButton: interactive({ base: { @@ -41,11 +42,12 @@ export default function simpleMessageNotification( iconHeight: 8, buttonWidth: 8, buttonHeight: 8, - }, state: { + }, + state: { hovered: { color: foreground(layer, "hovered"), }, - } - }) + }, + }), } } diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 30f933de8c..8a91b7eaac 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -29,15 +29,14 @@ export default function statusBar(colorScheme: ColorScheme) { activeLanguage: interactive({ base: { padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant") + ...text(layer, "sans", "variant"), }, state: { hovered: { ...text(layer, "sans", "on"), - } - } - }, - ), + }, + }, + }), autoUpdateProgressMessage: text(layer, "sans", "variant"), autoUpdateDoneMessage: text(layer, "sans", "variant"), lspStatus: interactive({ @@ -47,92 +46,93 @@ export default function statusBar(colorScheme: ColorScheme) { iconWidth: 14, height: 18, message: text(layer, "sans"), - iconColor: foreground(layer) + iconColor: foreground(layer), }, state: { hovered: { message: text(layer, "sans"), iconColor: foreground(layer), background: background(layer, "hovered"), - } - } + }, + }, }), diagnosticMessage: interactive({ base: { - ...text(layer, "sans") + ...text(layer, "sans"), }, - state: { hovered: text(layer, "sans", "hovered") } - }, - ), - diagnosticSummary: - interactive({ - base: { - height: 20, - iconWidth: 16, - iconSpacing: 2, - summarySpacing: 6, - text: text(layer, "sans", { size: "sm" }), - iconColorOk: foreground(layer, "variant"), - iconColorWarning: foreground(layer, "warning"), - iconColorError: foreground(layer, "negative"), + state: { hovered: text(layer, "sans", "hovered") }, + }), + diagnosticSummary: interactive({ + base: { + height: 20, + iconWidth: 16, + iconSpacing: 2, + summarySpacing: 6, + text: text(layer, "sans", { size: "sm" }), + iconColorOk: foreground(layer, "variant"), + iconColorWarning: foreground(layer, "warning"), + iconColorError: foreground(layer, "negative"), + containerOk: { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 7, right: 7 }, + }, + containerWarning: { + ...diagnosticStatusContainer, + background: background(layer, "warning"), + border: border(layer, "warning"), + }, + containerError: { + ...diagnosticStatusContainer, + background: background(layer, "negative"), + border: border(layer, "negative"), + }, + }, + state: { + hovered: { + iconColorOk: foreground(layer, "on"), containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, + background: background(layer, "on", "hovered"), }, containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), + background: background(layer, "warning", "hovered"), + border: border(layer, "warning", "hovered"), }, containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - } - }, state: { - hovered: { - iconColorOk: foreground(layer, "on"), - containerOk: { - background: background(layer, "on", "hovered"), - }, - containerWarning: { - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), - }, - containerError: { - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), - } - } - } - } - ), + background: background(layer, "negative", "hovered"), + border: border(layer, "negative", "hovered"), + }, + }, + }, + }), panelButtons: { groupLeft: {}, groupBottom: {}, groupRight: {}, - button: toggleable(interactive({ - base: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), + button: toggleable( + interactive({ + base: { + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), + }, }, - }, state: { - hovered: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - } - } - }), + state: { + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), + }, + }, + }), { default: { iconColor: foreground(layer, "active"), background: background(layer, "active"), - } - }), + }, + } + ), badge: { cornerRadius: 3, padding: 2, diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index ae2d14bfd6..c2b5de0215 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -89,23 +89,24 @@ export default function tabBar(colorScheme: ColorScheme) { inactiveTab: inactivePaneInactiveTab, }, draggedTab, - paneButton: toggleable(interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - }, - state: { - hovered: { - color: foreground(layer, "hovered"), - } - } - }), + paneButton: toggleable( + interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), + }, + }, + }), { default: { color: foreground(layer, "accent"), - } - }, + }, + } ), paneButtonContainer: { background: tab.background, diff --git a/styles/src/styleTree/toggle.ts b/styles/src/styleTree/toggle.ts index d6b37dde9e..2b6858e15b 100644 --- a/styles/src/styleTree/toggle.ts +++ b/styles/src/styleTree/toggle.ts @@ -1,41 +1,47 @@ -import { DeepPartial } from 'utility-types'; -import merge from 'ts-deepmerge'; +import merge from "ts-deepmerge" -interface Toggleable { - inactive: T - active: T, +type ToggleState = "inactive" | "active" + +type Toggleable = Record + +const NO_INACTIVE_OR_BASE_ERROR = + "A toggleable object must have an inactive state, or a base property." +const NO_ACTIVE_ERROR = "A toggleable object must have an active state." + +interface ToggleableProps { + base?: T + state: Partial> } /** * Helper function for creating Toggleable objects. * @template T The type of the object being toggled. - * @param inactive The initial state of the toggleable object. - * @param modifications The modifications to be applied to the initial state to create the active state. + * @param props Object containing the base (inactive) state and state modifications to create the active state. * @returns A Toggleable object containing both the inactive and active states. * @example * ``` - * toggleable({day: 1, month: "January"}, {day: 3}) - * ``` - * This returns the following object: - * ``` - * Toggleable<_>{ - * inactive: { day: 1, month: "January" }, - * active: { day: 3, month: "January" } - * } - * ``` - * The function also works for nested structures: - * ``` - * toggleable({first_level: "foo", second_level: {nested_member: "nested"}}, {second_level: {nested_member: "another nested thing"}}) - * ``` - * Which returns: - * ``` - * Toggleable<_> { - * inactive: {first_level: "foo", second_level: {nested_member: "nested"}}, - * active: { first_level: "foo", second_level: {nested_member: "another nested thing"}} - * } + * toggleable({ + * base: { background: "#000000", text: "#CCCCCC" }, + * state: { active: { text: "#CCCCCC" } }, + * }) * ``` */ -export function toggleable(inactive: T, modifications: DeepPartial): Toggleable { - let active: T = merge(inactive, modifications) as T; - return { active: active, inactive: inactive }; +export function toggleable( + props: ToggleableProps +): Toggleable { + const { base, state } = props + + if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR) + if (!state.active) throw new Error(NO_ACTIVE_ERROR) + + const inactiveState = base + ? ((state.inactive ? merge(base, state.inactive) : base) as T) + : (state.inactive as T) + + const toggleObj: Toggleable = { + inactive: inactiveState, + active: merge(base ?? {}, state.active) as T, + } + + return toggleObj } diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index bb3e8eda0c..1f47c85f4e 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -13,44 +13,50 @@ export default function dropdownMenu(colorScheme: ColorScheme) { header: interactive({ base: { ...text(layer, "sans", { size: "sm" }), - secondaryText: text(layer, "sans", { size: "sm", color: "#aaaaaa" }), + secondaryText: text(layer, "sans", { + size: "sm", + color: "#aaaaaa", + }), secondaryTextSpacing: 10, padding: { left: 8, right: 8, top: 2, bottom: 2 }, cornerRadius: 6, background: background(layer, "on"), - border: border(layer, "on", { overlay: true }) + border: border(layer, "on", { overlay: true }), }, state: { hovered: { background: background(layer, "hovered"), ...text(layer, "sans", "hovered", { size: "sm" }), - } - } - }) - , + }, + }, + }), sectionHeader: { ...text(layer, "sans", { size: "sm" }), padding: { left: 8, right: 8, top: 8, bottom: 8 }, }, - item: toggleable(interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryTextSpacing: 10, - secondaryText: text(layer, "sans", { size: "sm" }), - padding: { left: 18, right: 18, top: 2, bottom: 2 } - }, state: { + item: toggleable( + interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryTextSpacing: 10, + secondaryText: text(layer, "sans", { size: "sm" }), + padding: { left: 18, right: 18, top: 2, bottom: 2 }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + }, + }, + }), + { + default: { + background: background(layer, "active"), + }, hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - } + background: background(layer, "active"), + }, } - }), { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, - }) + ), } } diff --git a/styles/src/styleTree/updateNotification.ts b/styles/src/styleTree/updateNotification.ts index 0cef7fa805..c6ef81c667 100644 --- a/styles/src/styleTree/updateNotification.ts +++ b/styles/src/styleTree/updateNotification.ts @@ -14,12 +14,13 @@ export default function updateNotification(colorScheme: ColorScheme): Object { actionMessage: interactive({ base: { ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, top: 6, bottom: 6 } - }, state: { + margin: { left: headerPadding, top: 6, bottom: 6 }, + }, + state: { hovered: { color: foreground(layer, "hovered"), - } - } + }, + }, }), dismissButton: interactive({ base: { @@ -27,13 +28,13 @@ export default function updateNotification(colorScheme: ColorScheme): Object { iconWidth: 8, iconHeight: 8, buttonWidth: 8, - buttonHeight: 8 - }, state: { + buttonHeight: 8, + }, + state: { hovered: { color: foreground(layer, "hovered"), }, }, - }) - + }), } } diff --git a/styles/src/styleTree/welcome.ts b/styles/src/styleTree/welcome.ts index a0d599b747..311ff6daff 100644 --- a/styles/src/styleTree/welcome.ts +++ b/styles/src/styleTree/welcome.ts @@ -79,13 +79,14 @@ export default function welcome(colorScheme: ColorScheme) { left: 7, right: 7, }, - ...text(layer, "sans", "default", interactive_text_size) - }, state: { + ...text(layer, "sans", "default", interactive_text_size), + }, + state: { hovered: { ...text(layer, "sans", "default", interactive_text_size), background: background(layer, "hovered"), - } - } + }, + }, }), usageNote: { diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index 1045be1a9a..79e7830aec 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -12,44 +12,50 @@ import { import statusBar from "./statusBar" import tabBar from "./tabBar" import { interactive } from "../element" -import merge from 'ts-deepmerge'; +import merge from "ts-deepmerge" export default function workspace(colorScheme: ColorScheme) { const layer = colorScheme.lowest const isLight = colorScheme.isLight const itemSpacing = 8 - const titlebarButton = toggleable(interactive({ - base: { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, + const titlebarButton = toggleable( + interactive({ + base: { + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), - }, state: { - hovered: { - ...text(layer, "sans", "variant", "hovered", { size: "xs" }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), + state: { + hovered: { + ...text(layer, "sans", "variant", "hovered", { + size: "xs", + }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), + }, + clicked: { + ...text(layer, "sans", "variant", "pressed", { + size: "xs", + }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + }, }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { size: "xs" }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - } - } - }), + }), { default: { ...text(layer, "sans", "variant", "active", { size: "xs" }), background: background(layer, "variant", "active"), border: border(layer, "variant", "active"), - } - }, - ); + }, + } + ) const avatarWidth = 18 const avatarOuterWidth = avatarWidth + 4 const followerAvatarWidth = 14 @@ -86,23 +92,23 @@ export default function workspace(colorScheme: ColorScheme) { }, cornerRadius: 4, }, - keyboardHint: - interactive({ - base: { - ...text(layer, "sans", "variant", { size: "sm" }), - padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, - }, - cornerRadius: 8 - }, state: { - hovered: { - ...text(layer, "sans", "active", { size: "sm" }), - } - } - }), + keyboardHint: interactive({ + base: { + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, + left: 8, + right: 8, + bottom: 3, + }, + cornerRadius: 8, + }, + state: { + hovered: { + ...text(layer, "sans", "active", { size: "sm" }), + }, + }, + }), keyboardHintWidth: 320, }, @@ -214,18 +220,15 @@ export default function workspace(colorScheme: ColorScheme) { // Sign in buttom // FlatButton, Variant - signInPrompt: - merge(titlebarButton, - { - inactive: { - default: { - margin: { - left: itemSpacing, - }, - } - } - }), - + signInPrompt: merge(titlebarButton, { + inactive: { + default: { + margin: { + left: itemSpacing, + }, + }, + }, + }), // Offline Indicator offlineIcon: { @@ -259,54 +262,57 @@ export default function workspace(colorScheme: ColorScheme) { color: foreground(layer, "variant"), iconWidth: 12, buttonWidth: 20, - }, state: { - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - } - }), - toggleContactsButton: toggleable(interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, }, state: { - clicked: { - background: background(layer, "variant", "pressed"), - color: foreground(layer, "variant", "pressed"), - }, hovered: { background: background(layer, "variant", "hovered"), color: foreground(layer, "variant", "hovered"), - } - } + }, + }, }), + toggleContactsButton: toggleable( + interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { + clicked: { + background: background(layer, "variant", "pressed"), + color: foreground(layer, "variant", "pressed"), + }, + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + }, + }), { default: { background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active") - } - }, + color: foreground(layer, "variant", "active"), + }, + } ), userMenuButton: merge(titlebarButton, { inactive: { default: { buttonWidth: 20, - iconWidth: 12 - } - }, active: { // posiewic: these properties are not currently set on main + iconWidth: 12, + }, + }, + active: { + // posiewic: these properties are not currently set on main default: { iconWidth: 12, button_width: 20, - } - } + }, + }, }), - toggleContactsBadge: { cornerRadius: 3, padding: 2, @@ -324,27 +330,31 @@ export default function workspace(colorScheme: ColorScheme) { background: background(colorScheme.highest), border: border(colorScheme.highest, { bottom: true }), itemSpacing: 8, - navButton: interactive( - { - base: { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, - cornerRadius: 6, - }, state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - disabled: { - color: foreground(colorScheme.highest, "on", "disabled"), - }, - } - }), + navButton: interactive({ + base: { + color: foreground(colorScheme.highest, "on"), + iconWidth: 12, + buttonWidth: 24, + cornerRadius: 6, + }, + state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, + disabled: { + color: foreground( + colorScheme.highest, + "on", + "disabled" + ), + }, + }, + }), padding: { left: 8, right: 8, top: 4, bottom: 4 }, }, breadcrumbHeight: 24, @@ -355,13 +365,18 @@ export default function workspace(colorScheme: ColorScheme) { padding: { left: 6, right: 6, - } - }, state: { + }, + }, + state: { hovered: { color: foreground(colorScheme.highest, "on", "hovered"), - background: background(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), }, - } + }, }), disconnectedOverlay: { ...text(layer, "sans"), diff --git a/styles/src/theme/tokens/colorScheme.ts b/styles/src/theme/tokens/colorScheme.ts index 84b8db5ce0..bc53ca802a 100644 --- a/styles/src/theme/tokens/colorScheme.ts +++ b/styles/src/theme/tokens/colorScheme.ts @@ -1,9 +1,19 @@ -import { SingleBoxShadowToken, SingleColorToken, SingleOtherToken, TokenTypes } from "@tokens-studio/types" -import { ColorScheme, Shadow, SyntaxHighlightStyle, ThemeSyntax } from "../colorScheme" +import { + SingleBoxShadowToken, + SingleColorToken, + SingleOtherToken, + TokenTypes, +} from "@tokens-studio/types" +import { + ColorScheme, + Shadow, + SyntaxHighlightStyle, + ThemeSyntax, +} from "../colorScheme" import { LayerToken, layerToken } from "./layer" import { PlayersToken, playersToken } from "./players" import { colorToken } from "./token" -import { Syntax } from "../syntax"; +import { Syntax } from "../syntax" import editor from "../../styleTree/editor" interface ColorSchemeTokens { @@ -18,27 +28,32 @@ interface ColorSchemeTokens { syntax?: Partial } -const createShadowToken = (shadow: Shadow, tokenName: string): SingleBoxShadowToken => { +const createShadowToken = ( + shadow: Shadow, + tokenName: string +): SingleBoxShadowToken => { return { name: tokenName, type: TokenTypes.BOX_SHADOW, - value: `${shadow.offset[0]}px ${shadow.offset[1]}px ${shadow.blur}px 0px ${shadow.color}` - }; -}; + value: `${shadow.offset[0]}px ${shadow.offset[1]}px ${shadow.blur}px 0px ${shadow.color}`, + } +} const popoverShadowToken = (colorScheme: ColorScheme): SingleBoxShadowToken => { - const shadow = colorScheme.popoverShadow; - return createShadowToken(shadow, "popoverShadow"); -}; + const shadow = colorScheme.popoverShadow + return createShadowToken(shadow, "popoverShadow") +} const modalShadowToken = (colorScheme: ColorScheme): SingleBoxShadowToken => { - const shadow = colorScheme.modalShadow; - return createShadowToken(shadow, "modalShadow"); -}; + const shadow = colorScheme.modalShadow + return createShadowToken(shadow, "modalShadow") +} type ThemeSyntaxColorTokens = Record -function syntaxHighlightStyleColorTokens(syntax: Syntax): ThemeSyntaxColorTokens { +function syntaxHighlightStyleColorTokens( + syntax: Syntax +): ThemeSyntaxColorTokens { const styleKeys = Object.keys(syntax) as (keyof Syntax)[] return styleKeys.reduce((acc, styleKey) => { @@ -46,13 +61,16 @@ function syntaxHighlightStyleColorTokens(syntax: Syntax): ThemeSyntaxColorTokens // This can happen because we have a "constructor" property on the syntax object // and a "constructor" property on the prototype of the syntax object // To work around this just assert that the type of the style is not a function - if (!syntax[styleKey] || typeof syntax[styleKey] === 'function') return acc; - const { color } = syntax[styleKey] as Required; - return { ...acc, [styleKey]: colorToken(styleKey, color) }; - }, {} as ThemeSyntaxColorTokens); + if (!syntax[styleKey] || typeof syntax[styleKey] === "function") + return acc + const { color } = syntax[styleKey] as Required + return { ...acc, [styleKey]: colorToken(styleKey, color) } + }, {} as ThemeSyntaxColorTokens) } -const syntaxTokens = (colorScheme: ColorScheme): ColorSchemeTokens['syntax'] => { +const syntaxTokens = ( + colorScheme: ColorScheme +): ColorSchemeTokens["syntax"] => { const syntax = editor(colorScheme).syntax return syntaxHighlightStyleColorTokens(syntax) diff --git a/styles/src/theme/tokens/layer.ts b/styles/src/theme/tokens/layer.ts index 3ee813b8c4..42a69b5a52 100644 --- a/styles/src/theme/tokens/layer.ts +++ b/styles/src/theme/tokens/layer.ts @@ -1,11 +1,11 @@ -import { SingleColorToken } from "@tokens-studio/types"; -import { Layer, Style, StyleSet } from "../colorScheme"; -import { colorToken } from "./token"; +import { SingleColorToken } from "@tokens-studio/types" +import { Layer, Style, StyleSet } from "../colorScheme" +import { colorToken } from "./token" interface StyleToken { - background: SingleColorToken, - border: SingleColorToken, - foreground: SingleColorToken, + background: SingleColorToken + border: SingleColorToken + foreground: SingleColorToken } interface StyleSetToken { @@ -37,24 +37,27 @@ export const styleToken = (style: Style, name: string): StyleToken => { return token } -export const styleSetToken = (styleSet: StyleSet, name: string): StyleSetToken => { - const token: StyleSetToken = {} as StyleSetToken; +export const styleSetToken = ( + styleSet: StyleSet, + name: string +): StyleSetToken => { + const token: StyleSetToken = {} as StyleSetToken for (const style in styleSet) { - const s = style as keyof StyleSet; - token[s] = styleToken(styleSet[s], `${name}${style}`); + const s = style as keyof StyleSet + token[s] = styleToken(styleSet[s], `${name}${style}`) } - return token; + return token } export const layerToken = (layer: Layer, name: string): LayerToken => { - const token: LayerToken = {} as LayerToken; + const token: LayerToken = {} as LayerToken for (const styleSet in layer) { - const s = styleSet as keyof Layer; - token[s] = styleSetToken(layer[s], `${name}${styleSet}`); + const s = styleSet as keyof Layer + token[s] = styleSetToken(layer[s], `${name}${styleSet}`) } - return token; + return token } diff --git a/styles/src/theme/tokens/players.ts b/styles/src/theme/tokens/players.ts index b5f5538b2e..94d05cd827 100644 --- a/styles/src/theme/tokens/players.ts +++ b/styles/src/theme/tokens/players.ts @@ -6,13 +6,21 @@ export type PlayerToken = Record<"selection" | "cursor", SingleColorToken> export type PlayersToken = Record -function buildPlayerToken(colorScheme: ColorScheme, index: number): PlayerToken { - +function buildPlayerToken( + colorScheme: ColorScheme, + index: number +): PlayerToken { const playerNumber = index.toString() as keyof Players return { - selection: colorToken(`player${index}Selection`, colorScheme.players[playerNumber].selection), - cursor: colorToken(`player${index}Cursor`, colorScheme.players[playerNumber].cursor), + selection: colorToken( + `player${index}Selection`, + colorScheme.players[playerNumber].selection + ), + cursor: colorToken( + `player${index}Cursor`, + colorScheme.players[playerNumber].cursor + ), } } @@ -24,5 +32,5 @@ export const playersToken = (colorScheme: ColorScheme): PlayersToken => ({ "4": buildPlayerToken(colorScheme, 4), "5": buildPlayerToken(colorScheme, 5), "6": buildPlayerToken(colorScheme, 6), - "7": buildPlayerToken(colorScheme, 7) + "7": buildPlayerToken(colorScheme, 7), }) diff --git a/styles/src/theme/tokens/token.ts b/styles/src/theme/tokens/token.ts index 3e5187dd64..2f1760778e 100644 --- a/styles/src/theme/tokens/token.ts +++ b/styles/src/theme/tokens/token.ts @@ -1,6 +1,10 @@ import { SingleColorToken, TokenTypes } from "@tokens-studio/types" -export function colorToken(name: string, value: string, description?: string): SingleColorToken { +export function colorToken( + name: string, + value: string, + description?: string +): SingleColorToken { const token: SingleColorToken = { name, type: TokenTypes.COLOR, @@ -8,7 +12,8 @@ export function colorToken(name: string, value: string, description?: string): S description, } - if (!token.value || token.value === '') throw new Error("Color token must have a value") + if (!token.value || token.value === "") + throw new Error("Color token must have a value") return token } diff --git a/styles/src/utils/slugify.ts b/styles/src/utils/slugify.ts index 62b226cd10..b5c3b3c519 100644 --- a/styles/src/utils/slugify.ts +++ b/styles/src/utils/slugify.ts @@ -1 +1,10 @@ -export function slugify(t: string): string { return t.toString().toLowerCase().replace(/\s+/g, '-').replace(/[^\w\-]+/g, '').replace(/\-\-+/g, '-').replace(/^-+/, '').replace(/-+$/, '') } +export function slugify(t: string): string { + return t + .toString() + .toLowerCase() + .replace(/\s+/g, "-") + .replace(/[^\w\-]+/g, "") + .replace(/\-\-+/g, "-") + .replace(/^-+/, "") + .replace(/-+$/, "") +} diff --git a/styles/tsconfig.json b/styles/tsconfig.json index 051626adbc..7a8ec69927 100644 --- a/styles/tsconfig.json +++ b/styles/tsconfig.json @@ -23,30 +23,14 @@ "skipLibCheck": true, "baseUrl": ".", "paths": { - "@/*": [ - "./*" - ], - "@element/*": [ - "./src/element/*" - ], - "@component/*": [ - "./src/component/*" - ], - "@styleTree/*": [ - "./src/styleTree/*" - ], - "@theme/*": [ - "./src/theme/*" - ], - "@themes/*": [ - "./src/themes/*" - ], - "@util/*": [ - "./src/util/*" - ] + "@/*": ["./*"], + "@element/*": ["./src/element/*"], + "@component/*": ["./src/component/*"], + "@styleTree/*": ["./src/styleTree/*"], + "@theme/*": ["./src/theme/*"], + "@themes/*": ["./src/themes/*"], + "@util/*": ["./src/util/*"] } }, - "exclude": [ - "node_modules" - ] + "exclude": ["node_modules"] } diff --git a/styles/vitest.config.ts b/styles/vitest.config.ts index 83bd50b9c6..00f3a9852d 100644 --- a/styles/vitest.config.ts +++ b/styles/vitest.config.ts @@ -1,8 +1,8 @@ -import { configDefaults, defineConfig } from 'vitest/config' +import { configDefaults, defineConfig } from "vitest/config" export default defineConfig({ test: { - exclude: [...configDefaults.exclude, 'target/*'], - include: ['src/**/*.{spec,test}.ts'], + exclude: [...configDefaults.exclude, "target/*"], + include: ["src/**/*.{spec,test}.ts"], }, }) From 040881df3f584036570f7e07ee3fee7002e5e81f Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 16 Jun 2023 01:02:00 -0400 Subject: [PATCH 053/215] Update toggle --- styles/src/element/toggle.ts | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 styles/src/element/toggle.ts diff --git a/styles/src/element/toggle.ts b/styles/src/element/toggle.ts new file mode 100644 index 0000000000..2b6858e15b --- /dev/null +++ b/styles/src/element/toggle.ts @@ -0,0 +1,47 @@ +import merge from "ts-deepmerge" + +type ToggleState = "inactive" | "active" + +type Toggleable = Record + +const NO_INACTIVE_OR_BASE_ERROR = + "A toggleable object must have an inactive state, or a base property." +const NO_ACTIVE_ERROR = "A toggleable object must have an active state." + +interface ToggleableProps { + base?: T + state: Partial> +} + +/** + * Helper function for creating Toggleable objects. + * @template T The type of the object being toggled. + * @param props Object containing the base (inactive) state and state modifications to create the active state. + * @returns A Toggleable object containing both the inactive and active states. + * @example + * ``` + * toggleable({ + * base: { background: "#000000", text: "#CCCCCC" }, + * state: { active: { text: "#CCCCCC" } }, + * }) + * ``` + */ +export function toggleable( + props: ToggleableProps +): Toggleable { + const { base, state } = props + + if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR) + if (!state.active) throw new Error(NO_ACTIVE_ERROR) + + const inactiveState = base + ? ((state.inactive ? merge(base, state.inactive) : base) as T) + : (state.inactive as T) + + const toggleObj: Toggleable = { + inactive: inactiveState, + active: merge(base ?? {}, state.active) as T, + } + + return toggleObj +} From 61535ed41f62653efbd966fbf3d15d0632e0eb44 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 16 Jun 2023 01:11:02 -0400 Subject: [PATCH 054/215] Update toggle, add tests --- styles/src/element/index.ts | 3 +- styles/src/element/toggle.test.ts | 52 +++++++++++++++++++++ styles/src/element/toggle.ts | 4 +- styles/src/styleTree/commandPalette.ts | 3 +- styles/src/styleTree/contactList.ts | 3 +- styles/src/styleTree/contextMenu.ts | 3 +- styles/src/styleTree/editor.ts | 3 +- styles/src/styleTree/picker.ts | 3 +- styles/src/styleTree/projectPanel.ts | 3 +- styles/src/styleTree/search.ts | 3 +- styles/src/styleTree/statusBar.ts | 3 +- styles/src/styleTree/tabBar.ts | 3 +- styles/src/styleTree/toolbarDropdownMenu.ts | 3 +- styles/src/styleTree/workspace.ts | 2 +- 14 files changed, 67 insertions(+), 24 deletions(-) create mode 100644 styles/src/element/toggle.test.ts diff --git a/styles/src/element/index.ts b/styles/src/element/index.ts index ad58b89e0e..b1e3cfe415 100644 --- a/styles/src/element/index.ts +++ b/styles/src/element/index.ts @@ -1,3 +1,4 @@ import { interactive } from "./interactive" +import { toggleable } from "./toggle" -export { interactive } +export { interactive, toggleable } diff --git a/styles/src/element/toggle.test.ts b/styles/src/element/toggle.test.ts new file mode 100644 index 0000000000..8018ce1039 --- /dev/null +++ b/styles/src/element/toggle.test.ts @@ -0,0 +1,52 @@ +import { + NO_ACTIVE_ERROR, + NO_INACTIVE_OR_BASE_ERROR, + toggleable, +} from "./toggle" +import { describe, it, expect } from "vitest" + +describe("toggleable", () => { + it("creates a Toggleable with base properties and states", () => { + const result = toggleable({ + base: { background: "#000000", color: "#CCCCCC" }, + state: { + active: { color: "#FFFFFF" }, + }, + }) + + expect(result).toEqual({ + inactive: { background: "#000000", color: "#CCCCCC" }, + active: { background: "#000000", color: "#FFFFFF" }, + }) + }) + + it("creates a Toggleable with no base properties", () => { + const result = toggleable({ + state: { + inactive: { background: "#000000", color: "#CCCCCC" }, + active: { background: "#000000", color: "#FFFFFF" }, + }, + }) + + expect(result).toEqual({ + inactive: { background: "#000000", color: "#CCCCCC" }, + active: { background: "#000000", color: "#FFFFFF" }, + }) + }) + + it("throws error when both inactive and base are missing", () => { + const state = { + active: { background: "#000000", color: "#FFFFFF" }, + } + + expect(() => toggleable({ state })).toThrow(NO_INACTIVE_OR_BASE_ERROR) + }) + + it("throws error when no active state is present", () => { + const state = { + inactive: { background: "#000000", color: "#CCCCCC" }, + } + + expect(() => toggleable({ state })).toThrow(NO_ACTIVE_ERROR) + }) +}) diff --git a/styles/src/element/toggle.ts b/styles/src/element/toggle.ts index 2b6858e15b..84390810c0 100644 --- a/styles/src/element/toggle.ts +++ b/styles/src/element/toggle.ts @@ -4,9 +4,9 @@ type ToggleState = "inactive" | "active" type Toggleable = Record -const NO_INACTIVE_OR_BASE_ERROR = +export const NO_INACTIVE_OR_BASE_ERROR = "A toggleable object must have an inactive state, or a base property." -const NO_ACTIVE_ERROR = "A toggleable object must have an active state." +export const NO_ACTIVE_ERROR = "A toggleable object must have an active state." interface ToggleableProps { base?: T diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index ae0aae2f81..59e12945db 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -1,8 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, background } from "./components" -import { toggleable } from "./toggle" -import { interactive } from "../element" +import { interactive, toggleable } from "../element" export default function commandPalette(colorScheme: ColorScheme) { let layer = colorScheme.highest diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 5c6068408e..2ac17a4584 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -1,7 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, foreground, text } from "./components" -import { toggleable } from "./toggle" -import { interactive } from "../element" +import { interactive, toggleable } from "../element" export default function contactsPanel(colorScheme: ColorScheme) { const nameMargin = 8 const sidePadding = 12 diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 6f5eb53640..90ba0ce5b5 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -1,7 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, text } from "./components" -import { interactive } from "../element" -import { toggleable } from "./toggle" +import { interactive, toggleable } from "../element" export default function contextMenu(colorScheme: ColorScheme) { let layer = colorScheme.middle diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 9dec64b0ce..e029a724a3 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -4,8 +4,7 @@ import { background, border, borderColor, foreground, text } from "./components" import hoverPopover from "./hoverPopover" import { buildSyntax } from "../theme/syntax" -import { interactive } from "../element" -import { toggleable } from "./toggle" +import { interactive, toggleable } from "../element" export default function editor(colorScheme: ColorScheme) { const { isLight } = colorScheme diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 7730395ec9..12fecfa6f8 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -1,8 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, text } from "./components" -import { toggleable } from "./toggle" -import { interactive } from "../element" +import { interactive, toggleable } from "../element" export default function picker(colorScheme: ColorScheme): any { let layer = colorScheme.lowest diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 23df2fbf58..5f283e551d 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -1,8 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" -import { interactive } from "../element" -import { toggleable } from "./toggle" +import { interactive, toggleable } from "../element" export default function projectPanel(colorScheme: ColorScheme) { const { isLight } = colorScheme diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index a95296971c..4b0869f10e 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -1,8 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" -import { interactive } from "../element" -import { toggleable } from "./toggle" +import { interactive, toggleable } from "../element" export default function search(colorScheme: ColorScheme) { let layer = colorScheme.highest diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 8a91b7eaac..d6d7eda732 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -1,7 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" -import { interactive } from "../element" -import { toggleable } from "./toggle" +import { interactive, toggleable } from "../element" export default function statusBar(colorScheme: ColorScheme) { let layer = colorScheme.lowest diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index c2b5de0215..e00f0b8b83 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -1,8 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, border, background, foreground } from "./components" -import { toggleable } from "./toggle" -import { interactive } from "../element" +import { interactive, toggleable } from "../element" export default function tabBar(colorScheme: ColorScheme) { const height = 32 diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 1f47c85f4e..3ce7ca7d7c 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -1,7 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" -import { interactive } from "../element" -import { toggleable } from "./toggle" +import { interactive, toggleable } from "../element" export default function dropdownMenu(colorScheme: ColorScheme) { let layer = colorScheme.middle diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index 79e7830aec..a2a21eaff4 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -1,6 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" -import { toggleable } from "./toggle" +import { toggleable } from "../element" import { background, border, From ae53c3e6232e30d37fb33fbe4162c07a472b1a67 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 16 Jun 2023 01:41:10 -0400 Subject: [PATCH 055/215] WIP: Start updating style trees to new `toggle()` format. --- styles/src/styleTree/commandPalette.ts | 62 +++++++++++++------------- styles/src/styleTree/contactList.ts | 18 ++++---- 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index 59e12945db..cb6bb0503a 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -1,40 +1,42 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, background } from "./components" -import { interactive, toggleable } from "../element" +import { toggleable } from "../element" export default function commandPalette(colorScheme: ColorScheme) { let layer = colorScheme.highest + + const key = toggleable({ + base: { + text: text(layer, "mono", "variant", "default", { size: "xs" }), + cornerRadius: 2, + background: background(layer, "on"), + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + margin: { + top: 1, + bottom: 1, + left: 2, + }, + }, + state: { + active: { + text: text(layer, "mono", "on", "default", { size: "xs" }), + background: withOpacity(background(layer, "on"), 0.2), + } + } + }) + return { keystrokeSpacing: 8, - key: toggleable( - interactive({ - base: { - text: text(layer, "mono", "variant", "default", { - size: "xs", - }), - cornerRadius: 2, - background: background(layer, "on"), - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - margin: { - top: 1, - bottom: 1, - left: 2, - }, - }, - state: { hovered: { cornerRadius: 4, padding: { top: 17 } } }, - }), - { - default: { - text: text(layer, "mono", "on", "default", { size: "xs" }), - background: withOpacity(background(layer, "on"), 0.2), - }, - } - ), + // TODO: This should be a Toggle on the rust side so we don't have to do this + key: { + ...key.inactive, + active: key.active, + } } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 2ac17a4584..1f38b9b376 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -71,8 +71,8 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, rowHeight: 28, sectionIconSize: 8, - headerRow: toggleable( - interactive({ + headerRow: toggleable({ + base: interactive({ base: { ...text(layer, "mono", { size: "sm" }), margin: { top: 14 }, @@ -86,13 +86,15 @@ export default function contactsPanel(colorScheme: ColorScheme) { hovered: { background: background(layer, "default") }, }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. }), - { - default: { - ...text(layer, "mono", "active", { size: "sm" }), - background: background(layer, "active"), - }, + state: { + active: { + default: { + ...text(layer, "mono", "active", { size: "sm" }), + background: background(layer, "active"), + }, + } } - ), + }), leaveCall: interactive({ base: { background: background(layer), From 60b4054b0a28580e1ebd99205433317fe58577b1 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 16 Jun 2023 14:30:16 +0200 Subject: [PATCH 056/215] Fix up toggles --- .../src/activity_indicator.rs | 2 +- crates/command_palette/src/command_palette.rs | 6 +- crates/theme/src/theme.rs | 12 +- styles/src/element/interactive.ts | 119 +-- styles/src/element/toggle.ts | 32 +- styles/src/styleTree/commandPalette.ts | 66 +- styles/src/styleTree/contactList.ts | 420 +++++----- styles/src/styleTree/contextMenu.ts | 108 +-- styles/src/styleTree/editor.ts | 558 ++++++------- styles/src/styleTree/picker.ts | 170 ++-- styles/src/styleTree/projectPanel.ts | 216 ++--- styles/src/styleTree/search.ts | 226 ++--- styles/src/styleTree/statusBar.ts | 272 +++--- styles/src/styleTree/tabBar.ts | 201 ++--- styles/src/styleTree/toolbarDropdownMenu.ts | 108 +-- styles/src/styleTree/workspace.ts | 774 +++++++++--------- 16 files changed, 1670 insertions(+), 1620 deletions(-) diff --git a/crates/activity_indicator/src/activity_indicator.rs b/crates/activity_indicator/src/activity_indicator.rs index 801c8f7172..f795d7321c 100644 --- a/crates/activity_indicator/src/activity_indicator.rs +++ b/crates/activity_indicator/src/activity_indicator.rs @@ -326,7 +326,7 @@ impl View for ActivityIndicator { let mut element = MouseEventHandler::::new(0, cx, |state, cx| { let theme = &theme::current(cx).workspace.status_bar.lsp_status; let style = if state.hovered() && on_click.is_some() { - theme.hover.as_ref().unwrap_or(&theme.default) + theme.hovered.as_ref().unwrap_or(&theme.default) } else { &theme.default }; diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rs index e7e7462fd9..aec876bd78 100644 --- a/crates/command_palette/src/command_palette.rs +++ b/crates/command_palette/src/command_palette.rs @@ -186,11 +186,7 @@ impl PickerDelegate for CommandPaletteDelegate { let command = &self.actions[mat.candidate_id]; let theme = theme::current(cx); let style = theme.picker.item.in_state(selected).style_for(mouse_state); - let key_style = &theme - .command_palette - .key - .in_state(selected) - .style_for(mouse_state); + let key_style = &theme.command_palette.key.in_state(selected); let keystroke_spacing = theme.command_palette.keystroke_spacing; Flex::row() diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index fd30387ad8..8f9f228129 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -498,7 +498,7 @@ pub struct ContextMenuItem { #[derive(Debug, Deserialize, Default)] pub struct CommandPalette { - pub key: Toggleable>, + pub key: Toggleable, pub keystroke_spacing: f32, } @@ -805,7 +805,7 @@ pub struct DiffStyle { #[derive(Debug, Default, Clone, Copy)] pub struct Interactive { pub default: T, - pub hover: Option, + pub hovered: Option, pub clicked: Option, pub disabled: Option, } @@ -855,7 +855,7 @@ impl Interactive { if state.clicked() == Some(platform::MouseButton::Left) && self.clicked.is_some() { self.clicked.as_ref().unwrap() } else if state.hovered() { - self.hover.as_ref().unwrap_or(&self.default) + self.hovered.as_ref().unwrap_or(&self.default) } else { &self.default } @@ -873,7 +873,7 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive { #[derive(Deserialize)] struct Helper { default: Value, - hover: Option, + hovered: Option, clicked: Option, disabled: Option, } @@ -899,14 +899,14 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive { } }; - let hover = deserialize_state(json.hover)?; + let hovered = deserialize_state(json.hovered)?; let clicked = deserialize_state(json.clicked)?; let disabled = deserialize_state(json.disabled)?; let default = serde_json::from_value(json.default).map_err(serde::de::Error::custom)?; Ok(Interactive { default, - hover, + hovered, clicked, disabled, }) diff --git a/styles/src/element/interactive.ts b/styles/src/element/interactive.ts index 5d9772d313..bd90e28aad 100644 --- a/styles/src/element/interactive.ts +++ b/styles/src/element/interactive.ts @@ -1,28 +1,29 @@ import merge from "ts-deepmerge" +import { DeepPartial } from "utility-types" type InteractiveState = - | "default" - | "hovered" - | "clicked" - | "selected" - | "disabled" + | "default" + | "hovered" + | "clicked" + | "selected" + | "disabled" type Interactive = { - default: T - hovered?: T - clicked?: T - selected?: T - disabled?: T + default: T + hovered?: T + clicked?: T + selected?: T + disabled?: T } export const NO_DEFAULT_OR_BASE_ERROR = - "An interactive object must have a default state, or a base property." + "An interactive object must have a default state, or a base property." export const NOT_ENOUGH_STATES_ERROR = - "An interactive object must have a default and at least one other state." + "An interactive object must have a default and at least one other state." interface InteractiveProps { - base?: T - state: Partial> + base?: T + state: Partial>> } /** @@ -37,60 +38,60 @@ interface InteractiveProps { * @returns Interactive object with fields from `base` and `state`. */ export function interactive({ - base, - state, + base, + state, }: InteractiveProps): Interactive { - if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR) + if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR) - let defaultState: T + let defaultState: T - if (state.default && base) { - defaultState = merge(base, state.default) as T - } else { - defaultState = base ? base : (state.default as T) - } + if (state.default && base) { + defaultState = merge(base, state.default) as T + } else { + defaultState = base ? base : (state.default as T) + } - let interactiveObj: Interactive = { - default: defaultState, - } + let interactiveObj: Interactive = { + default: defaultState, + } - let stateCount = 0 + let stateCount = 0 - if (state.hovered !== undefined) { - interactiveObj.hovered = merge( - interactiveObj.default, - state.hovered - ) as T - stateCount++ - } + if (state.hovered !== undefined) { + interactiveObj.hovered = merge( + interactiveObj.default, + state.hovered + ) as T + stateCount++ + } - if (state.clicked !== undefined) { - interactiveObj.clicked = merge( - interactiveObj.default, - state.clicked - ) as T - stateCount++ - } + if (state.clicked !== undefined) { + interactiveObj.clicked = merge( + interactiveObj.default, + state.clicked + ) as T + stateCount++ + } - if (state.selected !== undefined) { - interactiveObj.selected = merge( - interactiveObj.default, - state.selected - ) as T - stateCount++ - } + if (state.selected !== undefined) { + interactiveObj.selected = merge( + interactiveObj.default, + state.selected + ) as T + stateCount++ + } - if (state.disabled !== undefined) { - interactiveObj.disabled = merge( - interactiveObj.default, - state.disabled - ) as T - stateCount++ - } + if (state.disabled !== undefined) { + interactiveObj.disabled = merge( + interactiveObj.default, + state.disabled + ) as T + stateCount++ + } - if (stateCount < 1) { - throw new Error(NOT_ENOUGH_STATES_ERROR) - } + if (stateCount < 1) { + throw new Error(NOT_ENOUGH_STATES_ERROR) + } - return interactiveObj + return interactiveObj } diff --git a/styles/src/element/toggle.ts b/styles/src/element/toggle.ts index 84390810c0..cbf28b71e7 100644 --- a/styles/src/element/toggle.ts +++ b/styles/src/element/toggle.ts @@ -1,16 +1,17 @@ import merge from "ts-deepmerge" +import { DeepPartial } from "utility-types" type ToggleState = "inactive" | "active" type Toggleable = Record export const NO_INACTIVE_OR_BASE_ERROR = - "A toggleable object must have an inactive state, or a base property." + "A toggleable object must have an inactive state, or a base property." export const NO_ACTIVE_ERROR = "A toggleable object must have an active state." interface ToggleableProps { - base?: T - state: Partial> + base?: T + state: Partial>> } /** @@ -27,21 +28,20 @@ interface ToggleableProps { * ``` */ export function toggleable( - props: ToggleableProps + props: ToggleableProps ): Toggleable { - const { base, state } = props + const { base, state } = props - if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR) - if (!state.active) throw new Error(NO_ACTIVE_ERROR) + if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR) + if (!state.active) throw new Error(NO_ACTIVE_ERROR) - const inactiveState = base - ? ((state.inactive ? merge(base, state.inactive) : base) as T) - : (state.inactive as T) + const inactiveState = base + ? ((state.inactive ? merge(base, state.inactive) : base) as T) + : (state.inactive as T) - const toggleObj: Toggleable = { - inactive: inactiveState, - active: merge(base ?? {}, state.active) as T, - } - - return toggleObj + const toggleObj: Toggleable = { + inactive: inactiveState, + active: merge(base ?? {}, state.active) as T, + } + return toggleObj } diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index cb6bb0503a..947e730f55 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -4,39 +4,39 @@ import { text, background } from "./components" import { toggleable } from "../element" export default function commandPalette(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - const key = toggleable({ - base: { - text: text(layer, "mono", "variant", "default", { size: "xs" }), - cornerRadius: 2, - background: background(layer, "on"), - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - margin: { - top: 1, - bottom: 1, - left: 2, - }, - }, - state: { - active: { - text: text(layer, "mono", "on", "default", { size: "xs" }), - background: withOpacity(background(layer, "on"), 0.2), - } - } - }) - - return { - keystrokeSpacing: 8, - // TODO: This should be a Toggle on the rust side so we don't have to do this - key: { - ...key.inactive, - active: key.active, - } + const key = toggleable({ + base: { + text: text(layer, "mono", "variant", "default", { size: "xs" }), + cornerRadius: 2, + background: background(layer, "on"), + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + margin: { + top: 1, + bottom: 1, + left: 2, + }, + }, + state: { + active: { + text: text(layer, "mono", "on", "default", { size: "xs" }), + background: withOpacity(background(layer, "on"), 0.2), + } } + }) + + return { + keystrokeSpacing: 8, + // TODO: This should be a Toggle on the rust side so we don't have to do this + key: { + inactive: { ...key.inactive }, + active: key.active, + } + } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 1f38b9b376..d5ecb1c224 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -2,224 +2,232 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function contactsPanel(colorScheme: ColorScheme) { - const nameMargin = 8 - const sidePadding = 12 + const nameMargin = 8 + const sidePadding = 12 - let layer = colorScheme.middle + let layer = colorScheme.middle - const contactButton = { - background: background(layer, "on"), - color: foreground(layer, "on"), - iconWidth: 8, - buttonWidth: 16, - cornerRadius: 8, - } - const projectRow = { - guestAvatarSpacing: 4, - height: 24, - guestAvatar: { - cornerRadius: 8, - width: 14, - }, - name: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - right: 6, - }, - }, - guests: { - margin: { - left: nameMargin, - right: nameMargin, - }, - }, - padding: { + const contactButton = { + background: background(layer, "on"), + color: foreground(layer, "on"), + iconWidth: 8, + buttonWidth: 16, + cornerRadius: 8, + } + const projectRow = { + guestAvatarSpacing: 4, + height: 24, + guestAvatar: { + cornerRadius: 8, + width: 14, + }, + name: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + right: 6, + }, + }, + guests: { + margin: { + left: nameMargin, + right: nameMargin, + }, + }, + padding: { + left: sidePadding, + right: sidePadding, + }, + } + + return { + background: background(layer), + padding: { top: 12 }, + userQueryEditor: { + background: background(layer, "on"), + cornerRadius: 6, + text: text(layer, "mono", "on"), + placeholderText: text(layer, "mono", "on", "disabled", { + size: "xs", + }), + selection: colorScheme.players[0], + border: border(layer, "on"), + padding: { + bottom: 4, + left: 8, + right: 8, + top: 4, + }, + margin: { + left: 6, + }, + }, + userQueryEditorHeight: 33, + addContactButton: { + margin: { left: 6, right: 12 }, + color: foreground(layer, "on"), + buttonWidth: 28, + iconWidth: 16, + }, + rowHeight: 28, + sectionIconSize: 8, + headerRow: toggleable({ + base: interactive({ + base: { + ...text(layer, "mono", { size: "sm" }), + margin: { top: 14 }, + padding: { left: sidePadding, right: sidePadding, + }, + background: background(layer, "default"), // posiewic: breaking change }, - } - - return { + state: { + hovered: { background: background(layer, "default") }, + }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. + }), + state: { + active: { + default: { + ...text(layer, "mono", "active", { size: "sm" }), + background: background(layer, "active"), + }, + } + } + }), + leaveCall: interactive({ + base: { background: background(layer), - padding: { top: 12 }, - userQueryEditor: { - background: background(layer, "on"), - cornerRadius: 6, - text: text(layer, "mono", "on"), - placeholderText: text(layer, "mono", "on", "disabled", { - size: "xs", - }), - selection: colorScheme.players[0], - border: border(layer, "on"), - padding: { - bottom: 4, - left: 8, - right: 8, - top: 4, - }, - margin: { - left: 6, - }, + border: border(layer), + cornerRadius: 6, + margin: { + top: 1, }, - userQueryEditorHeight: 33, - addContactButton: { - margin: { left: 6, right: 12 }, - color: foreground(layer, "on"), - buttonWidth: 28, - iconWidth: 16, + padding: { + top: 1, + bottom: 1, + left: 7, + right: 7, }, - rowHeight: 28, - sectionIconSize: 8, - headerRow: toggleable({ - base: interactive({ - base: { - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, - }, - background: background(layer, "default"), // posiewic: breaking change - }, - state: { - hovered: { background: background(layer, "default") }, - }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. - }), - state: { - active: { - default: { - ...text(layer, "mono", "active", { size: "sm" }), - background: background(layer, "active"), - }, - } - } - }), - leaveCall: interactive({ - base: { - background: background(layer), - border: border(layer), - cornerRadius: 6, - margin: { - top: 1, - }, - padding: { - top: 1, - bottom: 1, - left: 7, - right: 7, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - }, - state: { - hovered: { - ...text(layer, "sans", "hovered", { size: "xs" }), - background: background(layer, "hovered"), - border: border(layer, "hovered"), - }, - }, - }), - contactRow: { - inactive: { - default: { - padding: { - left: sidePadding, - right: sidePadding, - }, - }, - }, - active: { - default: { - background: background(layer, "active"), - padding: { - left: sidePadding, - right: sidePadding, - }, - }, - }, + ...text(layer, "sans", "variant", { size: "xs" }), + }, + state: { + hovered: { + ...text(layer, "sans", "hovered", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "hovered"), }, + }, + }), + contactRow: { + inactive: { + default: { + padding: { + left: sidePadding, + right: sidePadding, + }, + }, + }, + active: { + default: { + background: background(layer, "active"), + padding: { + left: sidePadding, + right: sidePadding, + }, + }, + }, + }, - contactAvatar: { - cornerRadius: 10, - width: 18, + contactAvatar: { + cornerRadius: 10, + width: 18, + }, + contactStatusFree: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "positive"), + }, + contactStatusBusy: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "negative"), + }, + contactUsername: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + }, + }, + contactButtonSpacing: nameMargin, + contactButton: interactive({ + base: { ...contactButton }, + state: { + hovered: { + background: background(layer, "hovered"), }, - contactStatusFree: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "positive"), - }, - contactStatusBusy: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "negative"), - }, - contactUsername: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - }, - }, - contactButtonSpacing: nameMargin, - contactButton: interactive({ - base: { ...contactButton }, - state: { - hovered: { - background: background(layer, "hovered"), - }, + }, + }), + disabledButton: { + ...contactButton, + background: background(layer, "on"), + color: foreground(layer, "on"), + }, + callingIndicator: { + ...text(layer, "mono", "variant", { size: "xs" }), + }, + treeBranch: toggleable({ + base: + interactive({ + base: { + color: borderColor(layer), + width: 1, + }, + state: { + hovered: { + color: borderColor(layer), }, + }, }), - disabledButton: { - ...contactButton, - background: background(layer, "on"), - color: foreground(layer, "on"), - }, - callingIndicator: { - ...text(layer, "mono", "variant", { size: "xs" }), - }, - treeBranch: toggleable( - interactive({ - base: { - color: borderColor(layer), - width: 1, - }, - state: { - hovered: { - color: borderColor(layer), - }, - }, - }), - { - default: { - color: borderColor(layer), - }, - } - ), - projectRow: toggleable( - interactive({ - base: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, - }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), - }, - }, - state: { - hovered: { - background: background(layer, "hovered"), - }, - }, - }), - { - default: { background: background(layer, "active") }, - } - ), + state: { + active: { + default: { + color: borderColor(layer), + }, + } + } } + ), + projectRow: toggleable({ + base: + interactive({ + base: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, + }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), + }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + }, + }, + }), + state: { + active: { + default: { background: background(layer, "active") }, + } + } + } + ), + } } diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 90ba0ce5b5..661742f800 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -3,57 +3,61 @@ import { background, border, borderColor, text } from "./components" import { interactive, toggleable } from "../element" export default function contextMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle - return { - background: background(layer), - cornerRadius: 10, - padding: 4, - shadow: colorScheme.popoverShadow, - border: border(layer), - keystrokeMargin: 30, - item: toggleable( - interactive({ - base: { - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "variant", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - }, - state: { - hovered: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "hovered", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - }, - }, - }), - { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, - } - ), - - separator: { - background: borderColor(layer), - margin: { top: 2, bottom: 2 }, - }, + let layer = colorScheme.middle + return { + background: background(layer), + cornerRadius: 10, + padding: 4, + shadow: colorScheme.popoverShadow, + border: border(layer), + keystrokeMargin: 30, + item: toggleable({ + base: + interactive({ + base: { + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "hovered", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + }, + }, + }), + state: { + active: { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + } + } } + ), + + separator: { + background: borderColor(layer), + margin: { top: 2, bottom: 2 }, + }, + } } diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index e029a724a3..2437257875 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -7,295 +7,303 @@ import { buildSyntax } from "../theme/syntax" import { interactive, toggleable } from "../element" export default function editor(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.highest + let layer = colorScheme.highest - const autocompleteItem = { - cornerRadius: 6, - padding: { - bottom: 2, - left: 6, - right: 6, - top: 2, - }, - } - - function diagnostic(layer: Layer, styleSet: StyleSets) { - return { - textScaleFactor: 0.857, - header: { - border: border(layer, { - top: true, - }), - }, - message: { - text: text(layer, "sans", styleSet, "default", { size: "sm" }), - highlightText: text(layer, "sans", styleSet, "default", { - size: "sm", - weight: "bold", - }), - }, - } - } - - const syntax = buildSyntax(colorScheme) + const autocompleteItem = { + cornerRadius: 6, + padding: { + bottom: 2, + left: 6, + right: 6, + top: 2, + }, + } + function diagnostic(layer: Layer, styleSet: StyleSets) { return { - textColor: syntax.primary.color, - background: background(layer), - activeLineBackground: withOpacity(background(layer, "on"), 0.75), - highlightedLineBackground: background(layer, "on"), - // Inline autocomplete suggestions, Co-pilot suggestions, etc. - suggestion: syntax.predictive, - codeActions: { - indicator: toggleable( - interactive({ - base: { - color: foreground(layer, "variant"), - }, - state: { - clicked: { - color: foreground(layer, "base"), - }, - hovered: { - color: foreground(layer, "on"), - }, - }, - }), - { - default: { - color: foreground(layer, "on"), - }, - } - ), + textScaleFactor: 0.857, + header: { + border: border(layer, { + top: true, + }), + }, + message: { + text: text(layer, "sans", styleSet, "default", { size: "sm" }), + highlightText: text(layer, "sans", styleSet, "default", { + size: "sm", + weight: "bold", + }), + }, + } + } - verticalScale: 0.55, - }, - folds: { - iconMarginScale: 2.5, - foldedIcon: "icons/chevron_right_8.svg", - foldableIcon: "icons/chevron_down_8.svg", - indicator: toggleable( - interactive({ - base: { - color: foreground(layer, "variant"), - }, - state: { - clicked: { - color: foreground(layer, "base"), - }, - hovered: { - color: foreground(layer, "on"), - }, - }, - }), - { - default: { - color: foreground(layer, "on"), - }, - } - ), - ellipses: { - textColor: colorScheme.ramps.neutral(0.71).hex(), - cornerRadiusFactor: 0.15, - background: { - // Copied from hover_popover highlight - default: { - color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), - }, + const syntax = buildSyntax(colorScheme) - hover: { - color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), - }, - - clicked: { - color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), - }, - }, - }, - foldBackground: foreground(layer, "variant"), - }, - diff: { - deleted: isLight - ? colorScheme.ramps.red(0.5).hex() - : colorScheme.ramps.red(0.4).hex(), - modified: isLight - ? colorScheme.ramps.yellow(0.5).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.4).hex() - : colorScheme.ramps.green(0.5).hex(), - removedWidthEm: 0.275, - widthEm: 0.15, - cornerRadius: 0.05, - }, - /** Highlights matching occurrences of what is under the cursor - * as well as matched brackets - */ - documentHighlightReadBackground: withOpacity( - foreground(layer, "accent"), - 0.1 - ), - documentHighlightWriteBackground: colorScheme.ramps - .neutral(0.5) - .alpha(0.4) - .hex(), // TODO: This was blend * 2 - errorColor: background(layer, "negative"), - gutterBackground: background(layer), - gutterPaddingFactor: 3.5, - lineNumber: withOpacity(foreground(layer), 0.35), - lineNumberActive: foreground(layer), - renameFade: 0.6, - unnecessaryCodeFade: 0.5, - selection: colorScheme.players[0], - whitespace: colorScheme.ramps.neutral(0.5).hex(), - guestSelections: [ - colorScheme.players[1], - colorScheme.players[2], - colorScheme.players[3], - colorScheme.players[4], - colorScheme.players[5], - colorScheme.players[6], - colorScheme.players[7], - ], - autocomplete: { - background: background(colorScheme.middle), - cornerRadius: 8, - padding: 4, - margin: { - left: -14, - }, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - matchHighlight: foreground(colorScheme.middle, "accent"), - item: autocompleteItem, - hoveredItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "hovered" - ), - background: background(colorScheme.middle, "hovered"), - }, - selectedItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "active" - ), - background: background(colorScheme.middle, "active"), - }, - }, - diagnosticHeader: { - background: background(colorScheme.middle), - iconWidthFactor: 1.5, - textScaleFactor: 0.857, - border: border(colorScheme.middle, { - bottom: true, - top: true, - }), - code: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 10, - }, - }, - source: { - text: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - }, - message: { - highlightText: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - text: text(colorScheme.middle, "sans", { size: "sm" }), - }, - }, - diagnosticPathHeader: { - background: background(colorScheme.middle), - textScaleFactor: 0.857, - filename: text(colorScheme.middle, "mono", { size: "sm" }), - path: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 12, - }, - }, - }, - errorDiagnostic: diagnostic(colorScheme.middle, "negative"), - warningDiagnostic: diagnostic(colorScheme.middle, "warning"), - informationDiagnostic: diagnostic(colorScheme.middle, "accent"), - hintDiagnostic: diagnostic(colorScheme.middle, "warning"), - invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), - hoverPopover: hoverPopover(colorScheme), - linkDefinition: { - color: syntax.linkUri.color, - underline: syntax.linkUri.underline, - }, - jumpIcon: interactive({ + return { + textColor: syntax.primary.color, + background: background(layer), + activeLineBackground: withOpacity(background(layer, "on"), 0.75), + highlightedLineBackground: background(layer, "on"), + // Inline autocomplete suggestions, Co-pilot suggestions, etc. + suggestion: syntax.predictive, + codeActions: { + indicator: toggleable({ + base: + interactive({ base: { - color: foreground(layer, "on"), - iconWidth: 20, - buttonWidth: 20, - cornerRadius: 6, - padding: { - top: 6, - bottom: 6, - left: 6, - right: 6, - }, + color: foreground(layer, "variant"), }, state: { - hovered: { - background: background(layer, "on", "hovered"), - }, + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, }, - }), + }), + state: { + active: { + default: { + color: foreground(layer, "on"), + }, + } + } + } + ), - scrollbar: { - width: 12, - minHeightFactor: 1.0, - track: { - border: border(layer, "variant", { left: true }), + verticalScale: 0.55, + }, + folds: { + iconMarginScale: 2.5, + foldedIcon: "icons/chevron_right_8.svg", + foldableIcon: "icons/chevron_down_8.svg", + indicator: toggleable({ + base: + interactive({ + base: { + color: foreground(layer, "variant"), }, - thumb: { - background: withOpacity(background(layer, "inverted"), 0.3), - border: { - width: 1, - color: borderColor(layer, "variant"), - top: false, - right: true, - left: true, - bottom: false, - }, + state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, }, - git: { - deleted: isLight - ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), - modified: isLight - ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), - inserted: isLight - ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), + }), + state: { + active: { + default: { + color: foreground(layer, "on"), }, + } + } + } + ), + ellipses: { + textColor: colorScheme.ramps.neutral(0.71).hex(), + cornerRadiusFactor: 0.15, + background: { + // Copied from hover_popover highlight + default: { + color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), + }, + + hovered: { + color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), + }, + + clicked: { + color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), + }, }, - compositionMark: { - underline: { - thickness: 1.0, - color: borderColor(layer), - }, + }, + foldBackground: foreground(layer, "variant"), + }, + diff: { + deleted: isLight + ? colorScheme.ramps.red(0.5).hex() + : colorScheme.ramps.red(0.4).hex(), + modified: isLight + ? colorScheme.ramps.yellow(0.5).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.4).hex() + : colorScheme.ramps.green(0.5).hex(), + removedWidthEm: 0.275, + widthEm: 0.15, + cornerRadius: 0.05, + }, + /** Highlights matching occurrences of what is under the cursor + * as well as matched brackets + */ + documentHighlightReadBackground: withOpacity( + foreground(layer, "accent"), + 0.1 + ), + documentHighlightWriteBackground: colorScheme.ramps + .neutral(0.5) + .alpha(0.4) + .hex(), // TODO: This was blend * 2 + errorColor: background(layer, "negative"), + gutterBackground: background(layer), + gutterPaddingFactor: 3.5, + lineNumber: withOpacity(foreground(layer), 0.35), + lineNumberActive: foreground(layer), + renameFade: 0.6, + unnecessaryCodeFade: 0.5, + selection: colorScheme.players[0], + whitespace: colorScheme.ramps.neutral(0.5).hex(), + guestSelections: [ + colorScheme.players[1], + colorScheme.players[2], + colorScheme.players[3], + colorScheme.players[4], + colorScheme.players[5], + colorScheme.players[6], + colorScheme.players[7], + ], + autocomplete: { + background: background(colorScheme.middle), + cornerRadius: 8, + padding: 4, + margin: { + left: -14, + }, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + matchHighlight: foreground(colorScheme.middle, "accent"), + item: autocompleteItem, + hoveredItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "hovered" + ), + background: background(colorScheme.middle, "hovered"), + }, + selectedItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "active" + ), + background: background(colorScheme.middle, "active"), + }, + }, + diagnosticHeader: { + background: background(colorScheme.middle), + iconWidthFactor: 1.5, + textScaleFactor: 0.857, + border: border(colorScheme.middle, { + bottom: true, + top: true, + }), + code: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 10, }, - syntax, - } + }, + source: { + text: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + }, + message: { + highlightText: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + text: text(colorScheme.middle, "sans", { size: "sm" }), + }, + }, + diagnosticPathHeader: { + background: background(colorScheme.middle), + textScaleFactor: 0.857, + filename: text(colorScheme.middle, "mono", { size: "sm" }), + path: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 12, + }, + }, + }, + errorDiagnostic: diagnostic(colorScheme.middle, "negative"), + warningDiagnostic: diagnostic(colorScheme.middle, "warning"), + informationDiagnostic: diagnostic(colorScheme.middle, "accent"), + hintDiagnostic: diagnostic(colorScheme.middle, "warning"), + invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), + hoverPopover: hoverPopover(colorScheme), + linkDefinition: { + color: syntax.linkUri.color, + underline: syntax.linkUri.underline, + }, + jumpIcon: interactive({ + base: { + color: foreground(layer, "on"), + iconWidth: 20, + buttonWidth: 20, + cornerRadius: 6, + padding: { + top: 6, + bottom: 6, + left: 6, + right: 6, + }, + }, + state: { + hovered: { + background: background(layer, "on", "hovered"), + }, + }, + }), + + scrollbar: { + width: 12, + minHeightFactor: 1.0, + track: { + border: border(layer, "variant", { left: true }), + }, + thumb: { + background: withOpacity(background(layer, "inverted"), 0.3), + border: { + width: 1, + color: borderColor(layer, "variant"), + top: false, + right: true, + left: true, + bottom: false, + }, + }, + git: { + deleted: isLight + ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), + modified: isLight + ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), + inserted: isLight + ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), + }, + }, + compositionMark: { + underline: { + thickness: 1.0, + color: borderColor(layer), + }, + }, + syntax, + } } diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 12fecfa6f8..f7cec1bd41 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -4,91 +4,95 @@ import { background, border, text } from "./components" import { interactive, toggleable } from "../element" export default function picker(colorScheme: ColorScheme): any { - let layer = colorScheme.lowest - const container = { - background: background(layer), - border: border(layer), - shadow: colorScheme.modalShadow, - cornerRadius: 12, - padding: { - bottom: 4, - }, - } - const inputEditor = { - placeholderText: text(layer, "sans", "on", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "on"), - border: border(layer, { bottom: true }), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - margin: { - bottom: 4, - }, - } - const emptyInputEditor: any = { ...inputEditor } - delete emptyInputEditor.border - delete emptyInputEditor.margin + let layer = colorScheme.lowest + const container = { + background: background(layer), + border: border(layer), + shadow: colorScheme.modalShadow, + cornerRadius: 12, + padding: { + bottom: 4, + }, + } + const inputEditor = { + placeholderText: text(layer, "sans", "on", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "on"), + border: border(layer, { bottom: true }), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + margin: { + bottom: 4, + }, + } + const emptyInputEditor: any = { ...inputEditor } + delete emptyInputEditor.border + delete emptyInputEditor.margin - return { - ...container, - emptyContainer: { - ...container, - padding: {}, - }, - item: toggleable( - interactive({ - base: { - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, - }, - margin: { - top: 1, - left: 4, - right: 4, - }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { - weight: "bold", - }), - }, - state: { - hovered: { - background: withOpacity( - background(layer, "hovered"), - 0.5 - ), - }, - }, - }), - { - default: { - background: withOpacity( - background(layer, "base", "active"), - 0.5 - ), - //text: text(layer, "sans", "base", "active"), - }, - } - ), - - inputEditor, - emptyInputEditor, - noMatches: { - text: text(layer, "sans", "variant"), + return { + ...container, + emptyContainer: { + ...container, + padding: {}, + }, + item: toggleable({ + base: + interactive({ + base: { padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, + bottom: 4, + left: 12, + right: 12, + top: 4, }, - }, + margin: { + top: 1, + left: 4, + right: 4, + }, + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { + weight: "bold", + }), + }, + state: { + hovered: { + background: withOpacity( + background(layer, "hovered"), + 0.5 + ), + }, + }, + }), + state: { + active: { + default: { + background: withOpacity( + background(layer, "base", "active"), + 0.5 + ), + //text: text(layer, "sans", "base", "active"), + }, + } + } } + ), + + inputEditor, + emptyInputEditor, + noMatches: { + text: text(layer, "sans", "variant"), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + }, + } } diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 5f283e551d..babd1431fb 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -3,121 +3,125 @@ import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function projectPanel(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.middle + let layer = colorScheme.middle - let baseEntry = { - height: 22, - iconColor: foreground(layer, "variant"), - iconSize: 7, - iconSpacing: 5, - } + let baseEntry = { + height: 22, + iconColor: foreground(layer, "variant"), + iconSize: 7, + iconSpacing: 5, + } - let status = { - git: { - modified: isLight - ? colorScheme.ramps.yellow(0.6).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.45).hex() - : colorScheme.ramps.green(0.5).hex(), - conflict: isLight - ? colorScheme.ramps.red(0.6).hex() - : colorScheme.ramps.red(0.5).hex(), + let status = { + git: { + modified: isLight + ? colorScheme.ramps.yellow(0.6).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.45).hex() + : colorScheme.ramps.green(0.5).hex(), + conflict: isLight + ? colorScheme.ramps.red(0.6).hex() + : colorScheme.ramps.red(0.5).hex(), + }, + } + + let entry = toggleable({ + base: + interactive({ + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, }, + state: { + hovered: { + background: background(layer, "variant", "hovered"), + }, + }, + }), + state: { + active: { + default: { + /*background: colorScheme.isLight + ? withOpacity(background(layer, "active"), 0.5) + : background(layer, "active") ,*/ // todo posiewic + text: text(layer, "mono", "active", { size: "sm" }), + }, + hovered: { + //background: background(layer, "active"), + text: text(layer, "mono", "active", { size: "sm" }), + }, + } } + } + ) - let entry = toggleable( - interactive({ - base: { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - status, - }, - state: { - hovered: { - background: background(layer, "variant", "hovered"), - }, - }, - }), - { - default: { - /*background: colorScheme.isLight - ? withOpacity(background(layer, "active"), 0.5) - : background(layer, "active") ,*/ // todo posiewic - text: text(layer, "mono", "active", { size: "sm" }), - }, - hovered: { - //background: background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), - }, - } - ) - - return { - openProjectButton: interactive({ - base: { - background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 16, - left: 16, - right: 16, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }), - }, - state: { - hovered: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - }, - }), + return { + openProjectButton: interactive({ + base: { background: background(layer), - padding: { left: 6, right: 6, top: 0, bottom: 6 }, - indentWidth: 12, - entry, - draggedEntry: { - ...baseEntry, - text: text(layer, "mono", "on", { size: "sm" }), - background: withOpacity(background(layer, "on"), 0.9), - border: border(layer), - status, + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 16, + left: 16, + right: 16, }, - ignoredEntry: { - ...entry, - iconColor: foreground(layer, "disabled"), - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - iconColor: foreground(layer, "variant"), - }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, }, - cutEntry: { - ...entry, - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - default: { - ...entry.active.default, - background: background(layer, "active"), - text: text(layer, "mono", "disabled", { size: "sm" }), - }, - }, + ...text(layer, "sans", "default", { size: "sm" }), + }, + state: { + hovered: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), }, - filenameEditor: { - background: background(layer, "on"), - text: text(layer, "mono", "on", { size: "sm" }), - selection: colorScheme.players[0], + }, + }), + background: background(layer), + padding: { left: 6, right: 6, top: 0, bottom: 6 }, + indentWidth: 12, + entry, + draggedEntry: { + ...baseEntry, + text: text(layer, "mono", "on", { size: "sm" }), + background: withOpacity(background(layer, "on"), 0.9), + border: border(layer), + status, + }, + ignoredEntry: { + ...entry, + iconColor: foreground(layer, "disabled"), + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + iconColor: foreground(layer, "variant"), + }, + }, + cutEntry: { + ...entry, + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + default: { + ...entry.active.default, + background: background(layer, "active"), + text: text(layer, "mono", "disabled", { size: "sm" }), }, - } + }, + }, + filenameEditor: { + background: background(layer, "on"), + text: text(layer, "mono", "on", { size: "sm" }), + selection: colorScheme.players[0], + }, + } } diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index 4b0869f10e..aa015d5cde 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -4,123 +4,127 @@ import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function search(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - // Search input - const editor = { - background: background(layer), - cornerRadius: 8, - minWidth: 200, - maxWidth: 500, - placeholderText: text(layer, "mono", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "default"), - border: border(layer), - margin: { - right: 12, - }, - padding: { - top: 3, - bottom: 3, - left: 12, - right: 8, - }, - } + // Search input + const editor = { + background: background(layer), + cornerRadius: 8, + minWidth: 200, + maxWidth: 500, + placeholderText: text(layer, "mono", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "default"), + border: border(layer), + margin: { + right: 12, + }, + padding: { + top: 3, + bottom: 3, + left: 12, + right: 8, + }, + } - const includeExcludeEditor = { - ...editor, - minWidth: 100, - maxWidth: 250, - } + const includeExcludeEditor = { + ...editor, + minWidth: 100, + maxWidth: 250, + } - return { - // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive - matchBackground: withOpacity(foreground(layer, "accent"), 0.4), - optionButton: toggleable( - interactive({ - base: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, - }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, - }, - }, - state: { - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, - hovered: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), - }, - }, - }), - { - default: { - ...text(layer, "mono", "on", "inverted"), - background: background(layer, "on", "inverted"), - border: border(layer, "on", "inverted"), - }, - } - ), - editor, - invalidEditor: { - ...editor, - border: border(layer, "negative"), - }, - includeExcludeEditor, - invalidIncludeExcludeEditor: { - ...includeExcludeEditor, - border: border(layer, "negative"), - }, - matchIndex: { - ...text(layer, "mono", "variant"), - padding: { - left: 6, - }, - }, - optionButtonGroup: { - padding: { - left: 12, - right: 12, - }, - }, - includeExcludeInputs: { - ...text(layer, "mono", "variant"), - padding: { - right: 6, - }, - }, - resultsStatus: { + return { + // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive + matchBackground: withOpacity(foreground(layer, "accent"), 0.4), + optionButton: toggleable({ + base: + interactive({ + base: { ...text(layer, "mono", "on"), - size: 18, - }, - dismissButton: interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 14, - padding: { - left: 10, - right: 10, - }, + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, }, - state: { - hovered: { - color: foreground(layer, "hovered"), - }, + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, }, + }, + state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, + }, }), + state: { + active: { + default: { + ...text(layer, "mono", "on", "inverted"), + background: background(layer, "on", "inverted"), + border: border(layer, "on", "inverted"), + }, + } + } } + ), + editor, + invalidEditor: { + ...editor, + border: border(layer, "negative"), + }, + includeExcludeEditor, + invalidIncludeExcludeEditor: { + ...includeExcludeEditor, + border: border(layer, "negative"), + }, + matchIndex: { + ...text(layer, "mono", "variant"), + padding: { + left: 6, + }, + }, + optionButtonGroup: { + padding: { + left: 12, + right: 12, + }, + }, + includeExcludeInputs: { + ...text(layer, "mono", "variant"), + padding: { + right: 6, + }, + }, + resultsStatus: { + ...text(layer, "mono", "on"), + size: 18, + }, + dismissButton: interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 14, + padding: { + left: 10, + right: 10, + }, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), + }, + }, + }), + } } diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index d6d7eda732..4c566a5c3a 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -2,143 +2,147 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function statusBar(colorScheme: ColorScheme) { - let layer = colorScheme.lowest + let layer = colorScheme.lowest - const statusContainer = { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 6, right: 6 }, - } + const statusContainer = { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 6, right: 6 }, + } - const diagnosticStatusContainer = { - cornerRadius: 6, - padding: { top: 1, bottom: 1, left: 6, right: 6 }, - } + const diagnosticStatusContainer = { + cornerRadius: 6, + padding: { top: 1, bottom: 1, left: 6, right: 6 }, + } - return { - height: 30, - itemSpacing: 8, - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, + return { + height: 30, + itemSpacing: 8, + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + border: border(layer, { top: true, overlay: true }), + cursorPosition: text(layer, "sans", "variant"), + activeLanguage: interactive({ + base: { + padding: { left: 6, right: 6 }, + ...text(layer, "sans", "variant"), + }, + state: { + hovered: { + ...text(layer, "sans", "on"), }, - border: border(layer, { top: true, overlay: true }), - cursorPosition: text(layer, "sans", "variant"), - activeLanguage: interactive({ - base: { - padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant"), - }, - state: { - hovered: { - ...text(layer, "sans", "on"), - }, - }, - }), - autoUpdateProgressMessage: text(layer, "sans", "variant"), - autoUpdateDoneMessage: text(layer, "sans", "variant"), - lspStatus: interactive({ - base: { - ...diagnosticStatusContainer, - iconSpacing: 4, - iconWidth: 14, - height: 18, - message: text(layer, "sans"), - iconColor: foreground(layer), - }, - state: { - hovered: { - message: text(layer, "sans"), - iconColor: foreground(layer), - background: background(layer, "hovered"), - }, - }, - }), - diagnosticMessage: interactive({ - base: { - ...text(layer, "sans"), - }, - state: { hovered: text(layer, "sans", "hovered") }, - }), - diagnosticSummary: interactive({ - base: { - height: 20, - iconWidth: 16, - iconSpacing: 2, - summarySpacing: 6, - text: text(layer, "sans", { size: "sm" }), - iconColorOk: foreground(layer, "variant"), - iconColorWarning: foreground(layer, "warning"), - iconColorError: foreground(layer, "negative"), - containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, - }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), - }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - }, - }, - state: { - hovered: { - iconColorOk: foreground(layer, "on"), - containerOk: { - background: background(layer, "on", "hovered"), - }, - containerWarning: { - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), - }, - containerError: { - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), - }, - }, - }, - }), - panelButtons: { - groupLeft: {}, - groupBottom: {}, - groupRight: {}, - button: toggleable( - interactive({ - base: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), - }, - }, - state: { - hovered: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - }, - }, - }), - { - default: { - iconColor: foreground(layer, "active"), - background: background(layer, "active"), - }, - } - ), - badge: { - cornerRadius: 3, - padding: 2, - margin: { bottom: -1, right: -1 }, - border: border(layer), - background: background(layer, "accent"), - }, + }, + }), + autoUpdateProgressMessage: text(layer, "sans", "variant"), + autoUpdateDoneMessage: text(layer, "sans", "variant"), + lspStatus: interactive({ + base: { + ...diagnosticStatusContainer, + iconSpacing: 4, + iconWidth: 14, + height: 18, + message: text(layer, "sans"), + iconColor: foreground(layer), + }, + state: { + hovered: { + message: text(layer, "sans"), + iconColor: foreground(layer), + background: background(layer, "hovered"), }, - } + }, + }), + diagnosticMessage: interactive({ + base: { + ...text(layer, "sans"), + }, + state: { hovered: text(layer, "sans", "hovered") }, + }), + diagnosticSummary: interactive({ + base: { + height: 20, + iconWidth: 16, + iconSpacing: 2, + summarySpacing: 6, + text: text(layer, "sans", { size: "sm" }), + iconColorOk: foreground(layer, "variant"), + iconColorWarning: foreground(layer, "warning"), + iconColorError: foreground(layer, "negative"), + containerOk: { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 7, right: 7 }, + }, + containerWarning: { + ...diagnosticStatusContainer, + background: background(layer, "warning"), + border: border(layer, "warning"), + }, + containerError: { + ...diagnosticStatusContainer, + background: background(layer, "negative"), + border: border(layer, "negative"), + }, + }, + state: { + hovered: { + iconColorOk: foreground(layer, "on"), + containerOk: { + background: background(layer, "on", "hovered"), + }, + containerWarning: { + background: background(layer, "warning", "hovered"), + border: border(layer, "warning", "hovered"), + }, + containerError: { + background: background(layer, "negative", "hovered"), + border: border(layer, "negative", "hovered"), + }, + }, + }, + }), + panelButtons: { + groupLeft: {}, + groupBottom: {}, + groupRight: {}, + button: toggleable({ + base: + interactive({ + base: { + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), + }, + }, + state: { + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), + }, + }, + }), state: + { + active: { + default: { + iconColor: foreground(layer, "active"), + background: background(layer, "active"), + }, + } + } + } + ), + badge: { + cornerRadius: 3, + padding: 2, + margin: { bottom: -1, right: -1 }, + border: border(layer), + background: background(layer, "accent"), + }, + }, + } } diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index e00f0b8b83..d7b3b58055 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -4,115 +4,120 @@ import { text, border, background, foreground } from "./components" import { interactive, toggleable } from "../element" export default function tabBar(colorScheme: ColorScheme) { - const height = 32 + const height = 32 - let activeLayer = colorScheme.highest - let layer = colorScheme.middle + let activeLayer = colorScheme.highest + let layer = colorScheme.middle - const tab = { - height, - text: text(layer, "sans", "variant", { size: "sm" }), - background: background(layer), - border: border(layer, { - right: true, - bottom: true, - overlay: true, - }), - padding: { - left: 8, - right: 12, - }, - spacing: 8, + const tab = { + height, + text: text(layer, "sans", "variant", { size: "sm" }), + background: background(layer), + border: border(layer, { + right: true, + bottom: true, + overlay: true, + }), + padding: { + left: 8, + right: 12, + }, + spacing: 8, - // Tab type icons (e.g. Project Search) - typeIconWidth: 14, + // Tab type icons (e.g. Project Search) + typeIconWidth: 14, - // Close icons - closeIconWidth: 8, - iconClose: foreground(layer, "variant"), - iconCloseActive: foreground(layer, "hovered"), + // Close icons + closeIconWidth: 8, + iconClose: foreground(layer, "variant"), + iconCloseActive: foreground(layer, "hovered"), - // Indicators - iconConflict: foreground(layer, "warning"), - iconDirty: foreground(layer, "accent"), + // Indicators + iconConflict: foreground(layer, "warning"), + iconDirty: foreground(layer, "accent"), - // When two tabs of the same name are open, a label appears next to them - description: { - margin: { left: 8 }, - ...text(layer, "sans", "disabled", { size: "2xs" }), - }, - } + // When two tabs of the same name are open, a label appears next to them + description: { + margin: { left: 8 }, + ...text(layer, "sans", "disabled", { size: "2xs" }), + }, + } - const activePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(activeLayer, "sans", "active", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const activePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(activeLayer, "sans", "active", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const inactivePaneInactiveTab = { - ...tab, - background: background(layer), - text: text(layer, "sans", "variant", { size: "sm" }), - } + const inactivePaneInactiveTab = { + ...tab, + background: background(layer), + text: text(layer, "sans", "variant", { size: "sm" }), + } - const inactivePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(layer, "sans", "variant", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } + const inactivePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(layer, "sans", "variant", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } - const draggedTab = { - ...activePaneActiveTab, - background: withOpacity(tab.background, 0.9), - border: undefined as any, - shadow: colorScheme.popoverShadow, - } + const draggedTab = { + ...activePaneActiveTab, + background: withOpacity(tab.background, 0.9), + border: undefined as any, + shadow: colorScheme.popoverShadow, + } - return { - height, - background: background(layer), - activePane: { - activeTab: activePaneActiveTab, - inactiveTab: tab, - }, - inactivePane: { - activeTab: inactivePaneActiveTab, - inactiveTab: inactivePaneInactiveTab, - }, - draggedTab, - paneButton: toggleable( - interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - }, - state: { - hovered: { - color: foreground(layer, "hovered"), - }, - }, - }), - { - default: { - color: foreground(layer, "accent"), - }, - } - ), - paneButtonContainer: { - background: tab.background, - border: { - ...tab.border, - right: false, + return { + height, + background: background(layer), + activePane: { + activeTab: activePaneActiveTab, + inactiveTab: tab, + }, + inactivePane: { + activeTab: inactivePaneActiveTab, + inactiveTab: inactivePaneInactiveTab, + }, + draggedTab, + paneButton: toggleable({ + base: + interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), }, - }, + }, + }), + state: + { + active: { + default: { + color: foreground(layer, "accent"), + }, + } + } } + ), + paneButtonContainer: { + background: tab.background, + border: { + ...tab.border, + right: false, + }, + }, + } } diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 3ce7ca7d7c..3a870b008f 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -2,60 +2,64 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" import { interactive, toggleable } from "../element" export default function dropdownMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle + let layer = colorScheme.middle - return { - rowHeight: 30, - background: background(layer), - border: border(layer), - shadow: colorScheme.popoverShadow, - header: interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryText: text(layer, "sans", { - size: "sm", - color: "#aaaaaa", - }), - secondaryTextSpacing: 10, - padding: { left: 8, right: 8, top: 2, bottom: 2 }, - cornerRadius: 6, - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - }, - state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - }, - }, + return { + rowHeight: 30, + background: background(layer), + border: border(layer), + shadow: colorScheme.popoverShadow, + header: interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryText: text(layer, "sans", { + size: "sm", + color: "#aaaaaa", }), - sectionHeader: { - ...text(layer, "sans", { size: "sm" }), - padding: { left: 8, right: 8, top: 8, bottom: 8 }, + secondaryTextSpacing: 10, + padding: { left: 8, right: 8, top: 2, bottom: 2 }, + cornerRadius: 6, + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), }, - item: toggleable( - interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryTextSpacing: 10, - secondaryText: text(layer, "sans", { size: "sm" }), - padding: { left: 18, right: 18, top: 2, bottom: 2 }, - }, - state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - }, - }, - }), - { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, - } - ), + }, + }), + sectionHeader: { + ...text(layer, "sans", { size: "sm" }), + padding: { left: 8, right: 8, top: 8, bottom: 8 }, + }, + item: toggleable({ + base: + interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryTextSpacing: 10, + secondaryText: text(layer, "sans", { size: "sm" }), + padding: { left: 18, right: 18, top: 2, bottom: 2 }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + }, + }, + }), + state: { + active: { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + } + } } + ), + } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index a2a21eaff4..96f4b8bdbd 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -2,398 +2,406 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { toggleable } from "../element" import { - background, - border, - borderColor, - foreground, - svg, - text, + background, + border, + borderColor, + foreground, + svg, + text, } from "./components" import statusBar from "./statusBar" import tabBar from "./tabBar" import { interactive } from "../element" import merge from "ts-deepmerge" export default function workspace(colorScheme: ColorScheme) { - const layer = colorScheme.lowest - const isLight = colorScheme.isLight - const itemSpacing = 8 - const titlebarButton = toggleable( - interactive({ - base: { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), - }, - state: { - hovered: { - ...text(layer, "sans", "variant", "hovered", { - size: "xs", - }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { - size: "xs", - }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - }, - }, - }), - { - default: { - ...text(layer, "sans", "variant", "active", { size: "xs" }), - background: background(layer, "variant", "active"), - border: border(layer, "variant", "active"), - }, - } - ) - const avatarWidth = 18 - const avatarOuterWidth = avatarWidth + 4 - const followerAvatarWidth = 14 - const followerAvatarOuterWidth = followerAvatarWidth + 4 - - return { - background: background(colorScheme.lowest), - blankPane: { - logoContainer: { - width: 256, - height: 256, - }, - logo: svg( - withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), - "icons/logo_96.svg", - 256, - 256 - ), - - logoShadow: svg( - withOpacity( - colorScheme.isLight - ? "#FFFFFF" - : colorScheme.lowest.base.default.background, - colorScheme.isLight ? 1 : 0.6 - ), - "icons/logo_96.svg", - 256, - 256 - ), - keyboardHints: { - margin: { - top: 96, - }, - cornerRadius: 4, - }, - keyboardHint: interactive({ - base: { - ...text(layer, "sans", "variant", { size: "sm" }), - padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, - }, - cornerRadius: 8, - }, - state: { - hovered: { - ...text(layer, "sans", "active", { size: "sm" }), - }, - }, + const layer = colorScheme.lowest + const isLight = colorScheme.isLight + const itemSpacing = 8 + const titlebarButton = toggleable({ + base: + interactive({ + base: { + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), + }, + state: { + hovered: { + ...text(layer, "sans", "variant", "hovered", { + size: "xs", }), - - keyboardHintWidth: 320, - }, - joiningProjectAvatar: { - cornerRadius: 40, - width: 80, - }, - joiningProjectMessage: { - padding: 12, - ...text(layer, "sans", { size: "lg" }), - }, - externalLocationMessage: { - background: background(colorScheme.middle, "accent"), - border: border(colorScheme.middle, "accent"), - cornerRadius: 6, - padding: 12, - margin: { bottom: 8, right: 8 }, - ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), - }, - leaderBorderOpacity: 0.7, - leaderBorderWidth: 2.0, - tabBar: tabBar(colorScheme), - modal: { - margin: { - bottom: 52, - top: 52, - }, - cursor: "Arrow", - }, - zoomedBackground: { - cursor: "Arrow", - background: isLight - ? withOpacity(background(colorScheme.lowest), 0.8) - : withOpacity(background(colorScheme.highest), 0.6), - }, - zoomedPaneForeground: { - margin: 16, - shadow: colorScheme.modalShadow, - border: border(colorScheme.lowest, { overlay: true }), - }, - zoomedPanelForeground: { - margin: 16, - border: border(colorScheme.lowest, { overlay: true }), - }, - dock: { - left: { - border: border(layer, { right: true }), - }, - bottom: { - border: border(layer, { top: true }), - }, - right: { - border: border(layer, { left: true }), - }, - }, - paneDivider: { - color: borderColor(layer), - width: 1, - }, - statusBar: statusBar(colorScheme), - titlebar: { - itemSpacing, - facePileSpacing: 2, - height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. - background: background(layer), - border: border(layer, { bottom: true }), - padding: { - left: 80, - right: itemSpacing, - }, - - // Project - title: text(layer, "sans", "variant"), - highlight_color: text(layer, "sans", "active").color, - - // Collaborators - leaderAvatar: { - width: avatarWidth, - outerWidth: avatarOuterWidth, - cornerRadius: avatarWidth / 2, - outerCornerRadius: avatarOuterWidth / 2, - }, - followerAvatar: { - width: followerAvatarWidth, - outerWidth: followerAvatarOuterWidth, - cornerRadius: followerAvatarWidth / 2, - outerCornerRadius: followerAvatarOuterWidth / 2, - }, - inactiveAvatarGrayscale: true, - followerAvatarOverlap: 8, - leaderSelection: { - margin: { - top: 4, - bottom: 4, - }, - padding: { - left: 2, - right: 2, - top: 2, - bottom: 2, - }, - cornerRadius: 6, - }, - avatarRibbon: { - height: 3, - width: 12, - // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. - }, - - // Sign in buttom - // FlatButton, Variant - signInPrompt: merge(titlebarButton, { - inactive: { - default: { - margin: { - left: itemSpacing, - }, - }, - }, + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), + }, + clicked: { + ...text(layer, "sans", "variant", "pressed", { + size: "xs", }), - - // Offline Indicator - offlineIcon: { - color: foreground(layer, "variant"), - width: 16, - margin: { - left: itemSpacing, - }, - padding: { - right: 4, - }, - }, - - // Notice that the collaboration server is out of date - outdatedWarning: { - ...text(layer, "sans", "warning", { size: "xs" }), - background: withOpacity(background(layer, "warning"), 0.3), - border: border(layer, "warning"), - margin: { - left: itemSpacing, - }, - padding: { - left: 8, - right: 8, - }, - cornerRadius: 6, - }, - callControl: interactive({ - base: { - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 20, - }, - state: { - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - }, - }), - toggleContactsButton: toggleable( - interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, - }, - state: { - clicked: { - background: background(layer, "variant", "pressed"), - color: foreground(layer, "variant", "pressed"), - }, - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - }, - }), - { - default: { - background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active"), - }, - } - ), - userMenuButton: merge(titlebarButton, { - inactive: { - default: { - buttonWidth: 20, - iconWidth: 12, - }, - }, - active: { - // posiewic: these properties are not currently set on main - default: { - iconWidth: 12, - button_width: 20, - }, - }, - }), - - toggleContactsBadge: { - cornerRadius: 3, - padding: 2, - margin: { top: 3, left: 3 }, - border: border(layer), - background: foreground(layer, "accent"), - }, - shareButton: { - ...titlebarButton, - }, + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + }, }, - - toolbar: { - height: 34, - background: background(colorScheme.highest), - border: border(colorScheme.highest, { bottom: true }), - itemSpacing: 8, - navButton: interactive({ - base: { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, - cornerRadius: 6, - }, - state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - disabled: { - color: foreground( - colorScheme.highest, - "on", - "disabled" - ), - }, - }, - }), - padding: { left: 8, right: 8, top: 4, bottom: 4 }, + }), + state: { + active: { + default: { + ...text(layer, "sans", "variant", "active", { size: "xs" }), + background: background(layer, "variant", "active"), + border: border(layer, "variant", "active"), }, - breadcrumbHeight: 24, - breadcrumbs: interactive({ - base: { - ...text(colorScheme.highest, "sans", "variant"), - cornerRadius: 6, - padding: { - left: 6, - right: 6, - }, - }, - state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - }, - }), - disconnectedOverlay: { - ...text(layer, "sans"), - background: withOpacity(background(layer), 0.8), - }, - notification: { - margin: { top: 10 }, - background: background(colorScheme.middle), - cornerRadius: 6, - padding: 12, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - }, - notifications: { - width: 400, - margin: { right: 10, bottom: 10 }, - }, - dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), + } } + } + ) + const avatarWidth = 18 + const avatarOuterWidth = avatarWidth + 4 + const followerAvatarWidth = 14 + const followerAvatarOuterWidth = followerAvatarWidth + 4 + + return { + background: background(colorScheme.lowest), + blankPane: { + logoContainer: { + width: 256, + height: 256, + }, + logo: svg( + withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), + "icons/logo_96.svg", + 256, + 256 + ), + + logoShadow: svg( + withOpacity( + colorScheme.isLight + ? "#FFFFFF" + : colorScheme.lowest.base.default.background, + colorScheme.isLight ? 1 : 0.6 + ), + "icons/logo_96.svg", + 256, + 256 + ), + keyboardHints: { + margin: { + top: 96, + }, + cornerRadius: 4, + }, + keyboardHint: interactive({ + base: { + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, + left: 8, + right: 8, + bottom: 3, + }, + cornerRadius: 8, + }, + state: { + hovered: { + ...text(layer, "sans", "active", { size: "sm" }), + }, + }, + }), + + keyboardHintWidth: 320, + }, + joiningProjectAvatar: { + cornerRadius: 40, + width: 80, + }, + joiningProjectMessage: { + padding: 12, + ...text(layer, "sans", { size: "lg" }), + }, + externalLocationMessage: { + background: background(colorScheme.middle, "accent"), + border: border(colorScheme.middle, "accent"), + cornerRadius: 6, + padding: 12, + margin: { bottom: 8, right: 8 }, + ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), + }, + leaderBorderOpacity: 0.7, + leaderBorderWidth: 2.0, + tabBar: tabBar(colorScheme), + modal: { + margin: { + bottom: 52, + top: 52, + }, + cursor: "Arrow", + }, + zoomedBackground: { + cursor: "Arrow", + background: isLight + ? withOpacity(background(colorScheme.lowest), 0.8) + : withOpacity(background(colorScheme.highest), 0.6), + }, + zoomedPaneForeground: { + margin: 16, + shadow: colorScheme.modalShadow, + border: border(colorScheme.lowest, { overlay: true }), + }, + zoomedPanelForeground: { + margin: 16, + border: border(colorScheme.lowest, { overlay: true }), + }, + dock: { + left: { + border: border(layer, { right: true }), + }, + bottom: { + border: border(layer, { top: true }), + }, + right: { + border: border(layer, { left: true }), + }, + }, + paneDivider: { + color: borderColor(layer), + width: 1, + }, + statusBar: statusBar(colorScheme), + titlebar: { + itemSpacing, + facePileSpacing: 2, + height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. + background: background(layer), + border: border(layer, { bottom: true }), + padding: { + left: 80, + right: itemSpacing, + }, + + // Project + title: text(layer, "sans", "variant"), + highlight_color: text(layer, "sans", "active").color, + + // Collaborators + leaderAvatar: { + width: avatarWidth, + outerWidth: avatarOuterWidth, + cornerRadius: avatarWidth / 2, + outerCornerRadius: avatarOuterWidth / 2, + }, + followerAvatar: { + width: followerAvatarWidth, + outerWidth: followerAvatarOuterWidth, + cornerRadius: followerAvatarWidth / 2, + outerCornerRadius: followerAvatarOuterWidth / 2, + }, + inactiveAvatarGrayscale: true, + followerAvatarOverlap: 8, + leaderSelection: { + margin: { + top: 4, + bottom: 4, + }, + padding: { + left: 2, + right: 2, + top: 2, + bottom: 2, + }, + cornerRadius: 6, + }, + avatarRibbon: { + height: 3, + width: 12, + // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. + }, + + // Sign in buttom + // FlatButton, Variant + signInPrompt: merge(titlebarButton, { + inactive: { + default: { + margin: { + left: itemSpacing, + }, + }, + }, + }), + + // Offline Indicator + offlineIcon: { + color: foreground(layer, "variant"), + width: 16, + margin: { + left: itemSpacing, + }, + padding: { + right: 4, + }, + }, + + // Notice that the collaboration server is out of date + outdatedWarning: { + ...text(layer, "sans", "warning", { size: "xs" }), + background: withOpacity(background(layer, "warning"), 0.3), + border: border(layer, "warning"), + margin: { + left: itemSpacing, + }, + padding: { + left: 8, + right: 8, + }, + cornerRadius: 6, + }, + callControl: interactive({ + base: { + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 20, + }, + state: { + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + }, + }), + toggleContactsButton: toggleable({ + base: + interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { + clicked: { + background: background(layer, "variant", "pressed"), + color: foreground(layer, "variant", "pressed"), + }, + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + }, + }), state: + { + active: { + default: { + background: background(layer, "variant", "active"), + color: foreground(layer, "variant", "active"), + }, + } + } + } + ), + userMenuButton: merge(titlebarButton, { + inactive: { + default: { + buttonWidth: 20, + iconWidth: 12, + }, + }, + active: { + // posiewic: these properties are not currently set on main + default: { + iconWidth: 12, + button_width: 20, + }, + }, + }), + + toggleContactsBadge: { + cornerRadius: 3, + padding: 2, + margin: { top: 3, left: 3 }, + border: border(layer), + background: foreground(layer, "accent"), + }, + shareButton: { + ...titlebarButton, + }, + }, + + toolbar: { + height: 34, + background: background(colorScheme.highest), + border: border(colorScheme.highest, { bottom: true }), + itemSpacing: 8, + navButton: interactive({ + base: { + color: foreground(colorScheme.highest, "on"), + iconWidth: 12, + buttonWidth: 24, + cornerRadius: 6, + }, + state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, + disabled: { + color: foreground( + colorScheme.highest, + "on", + "disabled" + ), + }, + }, + }), + padding: { left: 8, right: 8, top: 4, bottom: 4 }, + }, + breadcrumbHeight: 24, + breadcrumbs: interactive({ + base: { + ...text(colorScheme.highest, "sans", "variant"), + cornerRadius: 6, + padding: { + left: 6, + right: 6, + }, + }, + state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, + }, + }), + disconnectedOverlay: { + ...text(layer, "sans"), + background: withOpacity(background(layer), 0.8), + }, + notification: { + margin: { top: 10 }, + background: background(colorScheme.middle), + cornerRadius: 6, + padding: 12, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + }, + notifications: { + width: 400, + margin: { right: 10, bottom: 10 }, + }, + dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), + } } From dacfd70fb4390b52b04dd66dcb562db4e13e49e8 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 15:46:30 -0700 Subject: [PATCH 057/215] Remove unescessary enum --- crates/context_menu/src/context_menu.rs | 22 +++---------------- crates/theme/src/theme.rs | 29 ++++++------------------- crates/workspace/src/dock.rs | 9 ++------ 3 files changed, 12 insertions(+), 48 deletions(-) diff --git a/crates/context_menu/src/context_menu.rs b/crates/context_menu/src/context_menu.rs index e140177c5c..de78b51e9c 100644 --- a/crates/context_menu/src/context_menu.rs +++ b/crates/context_menu/src/context_menu.rs @@ -9,7 +9,6 @@ use gpui::{ }; use menu::*; use std::{any::TypeId, borrow::Cow, sync::Arc, time::Duration}; -use theme::ToggleState; pub fn init(cx: &mut AppContext) { cx.add_action(ContextMenu::select_first); @@ -329,12 +328,7 @@ impl ContextMenu { Flex::column().with_children(self.items.iter().enumerate().map(|(ix, item)| { match item { ContextMenuItem::Item { label, .. } => { - let toggle_state = if Some(ix) == self.selected_index { - ToggleState::Active - } else { - ToggleState::Inactive - }; - let style = style.item.in_state(toggle_state); + let style = style.item.in_state(self.selected_index == Some(ix)); let style = style.style_for(&mut Default::default()); match label { @@ -367,12 +361,7 @@ impl ContextMenu { .with_children(self.items.iter().enumerate().map(|(ix, item)| { match item { ContextMenuItem::Item { action, .. } => { - let toggle_state = if Some(ix) == self.selected_index { - ToggleState::Active - } else { - ToggleState::Inactive - }; - let style = style.item.in_state(toggle_state); + let style = style.item.in_state(self.selected_index == Some(ix)); let style = style.style_for(&mut Default::default()); match action { @@ -419,12 +408,7 @@ impl ContextMenu { let action = action.clone(); let view_id = self.parent_view_id; MouseEventHandler::::new(ix, cx, |state, _| { - let toggle_state = if Some(ix) == self.selected_index { - ToggleState::Active - } else { - ToggleState::Inactive - }; - let style = style.item.in_state(toggle_state); + let style = style.item.in_state(self.selected_index == Some(ix)); let style = style.style_for(state); let keystroke = match &action { ContextMenuItemAction::Action(action) => Some( diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 8f9f228129..586f444ebb 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -816,37 +816,22 @@ pub struct Toggleable { inactive: T, } -#[derive(Copy, Clone, Debug, Default, Hash, PartialEq, Eq)] -pub enum ToggleState { - #[default] - Inactive, - Active, -} - -impl> From for ToggleState { - fn from(item: T) -> Self { - match *item.borrow() { - true => Self::Active, - false => Self::Inactive, - } - } -} - impl Toggleable { pub fn new(active: T, inactive: T) -> Self { Self { active, inactive } } - pub fn in_state(&self, state: impl Into) -> &T { - match state.into() { - ToggleState::Inactive => &self.inactive, - ToggleState::Active => &self.active, + pub fn in_state(&self, active: bool) -> &T { + if active { + &self.inactive + } else { + &self.active } } pub fn active_state(&self) -> &T { - self.in_state(ToggleState::Active) + self.in_state(true) } pub fn inactive_state(&self) -> &T { - self.in_state(ToggleState::Inactive) + self.in_state(false) } } diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index ec00ddece8..9d23c6aca4 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -6,7 +6,7 @@ use gpui::{ }; use serde::Deserialize; use std::rc::Rc; -use theme::{ThemeSettings, ToggleState}; +use theme::ThemeSettings; pub trait Panel: View { fn position(&self, cx: &WindowContext) -> DockPosition; @@ -498,12 +498,7 @@ impl View for PanelButtons { Stack::new() .with_child( MouseEventHandler::::new(panel_ix, cx, |state, cx| { - let toggle_state = if is_active { - ToggleState::Active - } else { - ToggleState::Inactive - }; - let style = button_style.in_state(toggle_state); + let style = button_style.in_state(is_active); let style = style.style_for(state); Flex::row() From da9401414160445725f2f855f5ba3310ced97e65 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 15:54:58 -0700 Subject: [PATCH 058/215] Fix flipped boolean --- crates/theme/src/theme.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 586f444ebb..69c06c85ad 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -822,9 +822,9 @@ impl Toggleable { } pub fn in_state(&self, active: bool) -> &T { if active { - &self.inactive - } else { &self.active + } else { + &self.inactive } } pub fn active_state(&self) -> &T { From b1b4b563c2b1adc377cf52cc4477f287f93ececd Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 15:58:59 -0700 Subject: [PATCH 059/215] Add zed typescript settings Remove 2 space indent --- styles/.zed/settings.json | 11 + styles/src/styleTree/commandPalette.ts | 64 +- styles/src/styleTree/contactList.ts | 424 +++++------ styles/src/styleTree/contextMenu.ts | 108 +-- styles/src/styleTree/editor.ts | 584 +++++++-------- styles/src/styleTree/picker.ts | 178 ++--- styles/src/styleTree/projectPanel.ts | 234 +++--- styles/src/styleTree/search.ts | 238 +++--- styles/src/styleTree/statusBar.ts | 268 +++---- styles/src/styleTree/tabBar.ts | 224 +++--- styles/src/styleTree/toolbarDropdownMenu.ts | 110 +-- styles/src/styleTree/workspace.ts | 776 ++++++++++---------- 12 files changed, 1615 insertions(+), 1604 deletions(-) create mode 100644 styles/.zed/settings.json diff --git a/styles/.zed/settings.json b/styles/.zed/settings.json new file mode 100644 index 0000000000..0a3c761b8e --- /dev/null +++ b/styles/.zed/settings.json @@ -0,0 +1,11 @@ +// Folder-specific settings +// +// For a full list of overridable settings, and general information on folder-specific settings, +// see the documentation: https://docs.zed.dev/configuration/configuring-zed#folder-specific-settings +{ + "languages": { + "TypeScript": { + "tab_size": 4 + } + } +} diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index 947e730f55..5389a775ed 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -4,39 +4,39 @@ import { text, background } from "./components" import { toggleable } from "../element" export default function commandPalette(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - const key = toggleable({ - base: { - text: text(layer, "mono", "variant", "default", { size: "xs" }), - cornerRadius: 2, - background: background(layer, "on"), - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - margin: { - top: 1, - bottom: 1, - left: 2, - }, - }, - state: { - active: { - text: text(layer, "mono", "on", "default", { size: "xs" }), - background: withOpacity(background(layer, "on"), 0.2), - } - } - }) + const key = toggleable({ + base: { + text: text(layer, "mono", "variant", "default", { size: "xs" }), + cornerRadius: 2, + background: background(layer, "on"), + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + margin: { + top: 1, + bottom: 1, + left: 2, + }, + }, + state: { + active: { + text: text(layer, "mono", "on", "default", { size: "xs" }), + background: withOpacity(background(layer, "on"), 0.2), + } + } + }) - return { - keystrokeSpacing: 8, - // TODO: This should be a Toggle on the rust side so we don't have to do this - key: { - inactive: { ...key.inactive }, - active: key.active, + return { + keystrokeSpacing: 8, + // TODO: This should be a Toggle on the rust side so we don't have to do this + key: { + inactive: { ...key.inactive }, + active: key.active, + } } - } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index d5ecb1c224..57034109f1 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -2,232 +2,232 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function contactsPanel(colorScheme: ColorScheme) { - const nameMargin = 8 - const sidePadding = 12 + const nameMargin = 8 + const sidePadding = 12 - let layer = colorScheme.middle + let layer = colorScheme.middle - const contactButton = { - background: background(layer, "on"), - color: foreground(layer, "on"), - iconWidth: 8, - buttonWidth: 16, - cornerRadius: 8, - } - const projectRow = { - guestAvatarSpacing: 4, - height: 24, - guestAvatar: { - cornerRadius: 8, - width: 14, - }, - name: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - right: 6, - }, - }, - guests: { - margin: { - left: nameMargin, - right: nameMargin, - }, - }, - padding: { - left: sidePadding, - right: sidePadding, - }, - } - - return { - background: background(layer), - padding: { top: 12 }, - userQueryEditor: { - background: background(layer, "on"), - cornerRadius: 6, - text: text(layer, "mono", "on"), - placeholderText: text(layer, "mono", "on", "disabled", { - size: "xs", - }), - selection: colorScheme.players[0], - border: border(layer, "on"), - padding: { - bottom: 4, - left: 8, - right: 8, - top: 4, - }, - margin: { - left: 6, - }, - }, - userQueryEditorHeight: 33, - addContactButton: { - margin: { left: 6, right: 12 }, - color: foreground(layer, "on"), - buttonWidth: 28, - iconWidth: 16, - }, - rowHeight: 28, - sectionIconSize: 8, - headerRow: toggleable({ - base: interactive({ - base: { - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, - }, - background: background(layer, "default"), // posiewic: breaking change + const contactButton = { + background: background(layer, "on"), + color: foreground(layer, "on"), + iconWidth: 8, + buttonWidth: 16, + cornerRadius: 8, + } + const projectRow = { + guestAvatarSpacing: 4, + height: 24, + guestAvatar: { + cornerRadius: 8, + width: 14, }, - state: { - hovered: { background: background(layer, "default") }, - }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. - }), - state: { - active: { - default: { - ...text(layer, "mono", "active", { size: "sm" }), - background: background(layer, "active"), - }, - } - } - }), - leaveCall: interactive({ - base: { - background: background(layer), - border: border(layer), - cornerRadius: 6, - margin: { - top: 1, + name: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + right: 6, + }, + }, + guests: { + margin: { + left: nameMargin, + right: nameMargin, + }, }, padding: { - top: 1, - bottom: 1, - left: 7, - right: 7, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - }, - state: { - hovered: { - ...text(layer, "sans", "hovered", { size: "xs" }), - background: background(layer, "hovered"), - border: border(layer, "hovered"), - }, - }, - }), - contactRow: { - inactive: { - default: { - padding: { left: sidePadding, right: sidePadding, - }, }, - }, - active: { - default: { - background: background(layer, "active"), - padding: { - left: sidePadding, - right: sidePadding, - }, - }, - }, - }, + } - contactAvatar: { - cornerRadius: 10, - width: 18, - }, - contactStatusFree: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "positive"), - }, - contactStatusBusy: { - cornerRadius: 4, - padding: 4, - margin: { top: 12, left: 12 }, - background: foreground(layer, "negative"), - }, - contactUsername: { - ...text(layer, "mono", { size: "sm" }), - margin: { - left: nameMargin, - }, - }, - contactButtonSpacing: nameMargin, - contactButton: interactive({ - base: { ...contactButton }, - state: { - hovered: { - background: background(layer, "hovered"), + return { + background: background(layer), + padding: { top: 12 }, + userQueryEditor: { + background: background(layer, "on"), + cornerRadius: 6, + text: text(layer, "mono", "on"), + placeholderText: text(layer, "mono", "on", "disabled", { + size: "xs", + }), + selection: colorScheme.players[0], + border: border(layer, "on"), + padding: { + bottom: 4, + left: 8, + right: 8, + top: 4, + }, + margin: { + left: 6, + }, }, - }, - }), - disabledButton: { - ...contactButton, - background: background(layer, "on"), - color: foreground(layer, "on"), - }, - callingIndicator: { - ...text(layer, "mono", "variant", { size: "xs" }), - }, - treeBranch: toggleable({ - base: - interactive({ - base: { - color: borderColor(layer), - width: 1, - }, - state: { - hovered: { - color: borderColor(layer), - }, - }, + userQueryEditorHeight: 33, + addContactButton: { + margin: { left: 6, right: 12 }, + color: foreground(layer, "on"), + buttonWidth: 28, + iconWidth: 16, + }, + rowHeight: 28, + sectionIconSize: 8, + headerRow: toggleable({ + base: interactive({ + base: { + ...text(layer, "mono", { size: "sm" }), + margin: { top: 14 }, + padding: { + left: sidePadding, + right: sidePadding, + }, + background: background(layer, "default"), // posiewic: breaking change + }, + state: { + hovered: { background: background(layer, "default") }, + }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. + }), + state: { + active: { + default: { + ...text(layer, "mono", "active", { size: "sm" }), + background: background(layer, "active"), + }, + } + } }), - state: { - active: { - default: { - color: borderColor(layer), - }, - } - } - } - ), - projectRow: toggleable({ - base: - interactive({ - base: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, + leaveCall: interactive({ + base: { + background: background(layer), + border: border(layer), + cornerRadius: 6, + margin: { + top: 1, + }, + padding: { + top: 1, + bottom: 1, + left: 7, + right: 7, + }, + ...text(layer, "sans", "variant", { size: "xs" }), }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), + state: { + hovered: { + ...text(layer, "sans", "hovered", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "hovered"), + }, }, - }, - state: { - hovered: { - background: background(layer, "hovered"), - }, - }, }), - state: { - active: { - default: { background: background(layer, "active") }, + contactRow: { + inactive: { + default: { + padding: { + left: sidePadding, + right: sidePadding, + }, + }, + }, + active: { + default: { + background: background(layer, "active"), + padding: { + left: sidePadding, + right: sidePadding, + }, + }, + }, + }, + + contactAvatar: { + cornerRadius: 10, + width: 18, + }, + contactStatusFree: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "positive"), + }, + contactStatusBusy: { + cornerRadius: 4, + padding: 4, + margin: { top: 12, left: 12 }, + background: foreground(layer, "negative"), + }, + contactUsername: { + ...text(layer, "mono", { size: "sm" }), + margin: { + left: nameMargin, + }, + }, + contactButtonSpacing: nameMargin, + contactButton: interactive({ + base: { ...contactButton }, + state: { + hovered: { + background: background(layer, "hovered"), + }, + }, + }), + disabledButton: { + ...contactButton, + background: background(layer, "on"), + color: foreground(layer, "on"), + }, + callingIndicator: { + ...text(layer, "mono", "variant", { size: "xs" }), + }, + treeBranch: toggleable({ + base: + interactive({ + base: { + color: borderColor(layer), + width: 1, + }, + state: { + hovered: { + color: borderColor(layer), + }, + }, + }), + state: { + active: { + default: { + color: borderColor(layer), + }, + } + } } - } + ), + projectRow: toggleable({ + base: + interactive({ + base: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, + }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), + }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + }, + }, + }), + state: { + active: { + default: { background: background(layer, "active") }, + } + } + } + ), } - ), - } } diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 661742f800..7b2b9be6c2 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -3,61 +3,61 @@ import { background, border, borderColor, text } from "./components" import { interactive, toggleable } from "../element" export default function contextMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle - return { - background: background(layer), - cornerRadius: 10, - padding: 4, - shadow: colorScheme.popoverShadow, - border: border(layer), - keystrokeMargin: 30, - item: toggleable({ - base: - interactive({ - base: { - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "variant", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - }, - state: { - hovered: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "hovered", { - size: "sm", - weight: "bold", + let layer = colorScheme.middle + return { + background: background(layer), + cornerRadius: 10, + padding: 4, + shadow: colorScheme.popoverShadow, + border: border(layer), + keystrokeMargin: 30, + item: toggleable({ + base: + interactive({ + base: { + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "hovered", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + }, + }, }), - padding: { left: 3, right: 3 }, - }, - }, - }, - }), - state: { - active: { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, + state: { + active: { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + } + } } - } - } - ), + ), - separator: { - background: borderColor(layer), - margin: { top: 2, bottom: 2 }, - }, - } + separator: { + background: borderColor(layer), + margin: { top: 2, bottom: 2 }, + }, + } } diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 2437257875..b02366192a 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -7,303 +7,303 @@ import { buildSyntax } from "../theme/syntax" import { interactive, toggleable } from "../element" export default function editor(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.highest + let layer = colorScheme.highest - const autocompleteItem = { - cornerRadius: 6, - padding: { - bottom: 2, - left: 6, - right: 6, - top: 2, - }, - } - - function diagnostic(layer: Layer, styleSet: StyleSets) { - return { - textScaleFactor: 0.857, - header: { - border: border(layer, { - top: true, - }), - }, - message: { - text: text(layer, "sans", styleSet, "default", { size: "sm" }), - highlightText: text(layer, "sans", styleSet, "default", { - size: "sm", - weight: "bold", - }), - }, - } - } - - const syntax = buildSyntax(colorScheme) - - return { - textColor: syntax.primary.color, - background: background(layer), - activeLineBackground: withOpacity(background(layer, "on"), 0.75), - highlightedLineBackground: background(layer, "on"), - // Inline autocomplete suggestions, Co-pilot suggestions, etc. - suggestion: syntax.predictive, - codeActions: { - indicator: toggleable({ - base: - interactive({ - base: { - color: foreground(layer, "variant"), - }, - state: { - clicked: { - color: foreground(layer, "base"), - }, - hovered: { - color: foreground(layer, "on"), - }, - }, - }), - state: { - active: { - default: { - color: foreground(layer, "on"), - }, - } - } - } - ), - - verticalScale: 0.55, - }, - folds: { - iconMarginScale: 2.5, - foldedIcon: "icons/chevron_right_8.svg", - foldableIcon: "icons/chevron_down_8.svg", - indicator: toggleable({ - base: - interactive({ - base: { - color: foreground(layer, "variant"), - }, - state: { - clicked: { - color: foreground(layer, "base"), - }, - hovered: { - color: foreground(layer, "on"), - }, - }, - }), - state: { - active: { - default: { - color: foreground(layer, "on"), - }, - } - } - } - ), - ellipses: { - textColor: colorScheme.ramps.neutral(0.71).hex(), - cornerRadiusFactor: 0.15, - background: { - // Copied from hover_popover highlight - default: { - color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), - }, - - hovered: { - color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), - }, - - clicked: { - color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), - }, - }, - }, - foldBackground: foreground(layer, "variant"), - }, - diff: { - deleted: isLight - ? colorScheme.ramps.red(0.5).hex() - : colorScheme.ramps.red(0.4).hex(), - modified: isLight - ? colorScheme.ramps.yellow(0.5).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.4).hex() - : colorScheme.ramps.green(0.5).hex(), - removedWidthEm: 0.275, - widthEm: 0.15, - cornerRadius: 0.05, - }, - /** Highlights matching occurrences of what is under the cursor - * as well as matched brackets - */ - documentHighlightReadBackground: withOpacity( - foreground(layer, "accent"), - 0.1 - ), - documentHighlightWriteBackground: colorScheme.ramps - .neutral(0.5) - .alpha(0.4) - .hex(), // TODO: This was blend * 2 - errorColor: background(layer, "negative"), - gutterBackground: background(layer), - gutterPaddingFactor: 3.5, - lineNumber: withOpacity(foreground(layer), 0.35), - lineNumberActive: foreground(layer), - renameFade: 0.6, - unnecessaryCodeFade: 0.5, - selection: colorScheme.players[0], - whitespace: colorScheme.ramps.neutral(0.5).hex(), - guestSelections: [ - colorScheme.players[1], - colorScheme.players[2], - colorScheme.players[3], - colorScheme.players[4], - colorScheme.players[5], - colorScheme.players[6], - colorScheme.players[7], - ], - autocomplete: { - background: background(colorScheme.middle), - cornerRadius: 8, - padding: 4, - margin: { - left: -14, - }, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - matchHighlight: foreground(colorScheme.middle, "accent"), - item: autocompleteItem, - hoveredItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "hovered" - ), - background: background(colorScheme.middle, "hovered"), - }, - selectedItem: { - ...autocompleteItem, - matchHighlight: foreground( - colorScheme.middle, - "accent", - "active" - ), - background: background(colorScheme.middle, "active"), - }, - }, - diagnosticHeader: { - background: background(colorScheme.middle), - iconWidthFactor: 1.5, - textScaleFactor: 0.857, - border: border(colorScheme.middle, { - bottom: true, - top: true, - }), - code: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 10, - }, - }, - source: { - text: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - }, - message: { - highlightText: text(colorScheme.middle, "sans", { - size: "sm", - weight: "bold", - }), - text: text(colorScheme.middle, "sans", { size: "sm" }), - }, - }, - diagnosticPathHeader: { - background: background(colorScheme.middle), - textScaleFactor: 0.857, - filename: text(colorScheme.middle, "mono", { size: "sm" }), - path: { - ...text(colorScheme.middle, "mono", { size: "sm" }), - margin: { - left: 12, - }, - }, - }, - errorDiagnostic: diagnostic(colorScheme.middle, "negative"), - warningDiagnostic: diagnostic(colorScheme.middle, "warning"), - informationDiagnostic: diagnostic(colorScheme.middle, "accent"), - hintDiagnostic: diagnostic(colorScheme.middle, "warning"), - invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), - invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), - hoverPopover: hoverPopover(colorScheme), - linkDefinition: { - color: syntax.linkUri.color, - underline: syntax.linkUri.underline, - }, - jumpIcon: interactive({ - base: { - color: foreground(layer, "on"), - iconWidth: 20, - buttonWidth: 20, + const autocompleteItem = { cornerRadius: 6, padding: { - top: 6, - bottom: 6, - left: 6, - right: 6, + bottom: 2, + left: 6, + right: 6, + top: 2, }, - }, - state: { - hovered: { - background: background(layer, "on", "hovered"), - }, - }, - }), + } - scrollbar: { - width: 12, - minHeightFactor: 1.0, - track: { - border: border(layer, "variant", { left: true }), - }, - thumb: { - background: withOpacity(background(layer, "inverted"), 0.3), - border: { - width: 1, - color: borderColor(layer, "variant"), - top: false, - right: true, - left: true, - bottom: false, + function diagnostic(layer: Layer, styleSet: StyleSets) { + return { + textScaleFactor: 0.857, + header: { + border: border(layer, { + top: true, + }), + }, + message: { + text: text(layer, "sans", styleSet, "default", { size: "sm" }), + highlightText: text(layer, "sans", styleSet, "default", { + size: "sm", + weight: "bold", + }), + }, + } + } + + const syntax = buildSyntax(colorScheme) + + return { + textColor: syntax.primary.color, + background: background(layer), + activeLineBackground: withOpacity(background(layer, "on"), 0.75), + highlightedLineBackground: background(layer, "on"), + // Inline autocomplete suggestions, Co-pilot suggestions, etc. + suggestion: syntax.predictive, + codeActions: { + indicator: toggleable({ + base: + interactive({ + base: { + color: foreground(layer, "variant"), + }, + state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + }, + }), + state: { + active: { + default: { + color: foreground(layer, "on"), + }, + } + } + } + ), + + verticalScale: 0.55, }, - }, - git: { - deleted: isLight - ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), - modified: isLight - ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), - inserted: isLight - ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) - : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), - }, - }, - compositionMark: { - underline: { - thickness: 1.0, - color: borderColor(layer), - }, - }, - syntax, - } + folds: { + iconMarginScale: 2.5, + foldedIcon: "icons/chevron_right_8.svg", + foldableIcon: "icons/chevron_down_8.svg", + indicator: toggleable({ + base: + interactive({ + base: { + color: foreground(layer, "variant"), + }, + state: { + clicked: { + color: foreground(layer, "base"), + }, + hovered: { + color: foreground(layer, "on"), + }, + }, + }), + state: { + active: { + default: { + color: foreground(layer, "on"), + }, + } + } + } + ), + ellipses: { + textColor: colorScheme.ramps.neutral(0.71).hex(), + cornerRadiusFactor: 0.15, + background: { + // Copied from hover_popover highlight + default: { + color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), + }, + + hovered: { + color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), + }, + + clicked: { + color: colorScheme.ramps.neutral(0.5).alpha(0.7).hex(), + }, + }, + }, + foldBackground: foreground(layer, "variant"), + }, + diff: { + deleted: isLight + ? colorScheme.ramps.red(0.5).hex() + : colorScheme.ramps.red(0.4).hex(), + modified: isLight + ? colorScheme.ramps.yellow(0.5).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.4).hex() + : colorScheme.ramps.green(0.5).hex(), + removedWidthEm: 0.275, + widthEm: 0.15, + cornerRadius: 0.05, + }, + /** Highlights matching occurrences of what is under the cursor + * as well as matched brackets + */ + documentHighlightReadBackground: withOpacity( + foreground(layer, "accent"), + 0.1 + ), + documentHighlightWriteBackground: colorScheme.ramps + .neutral(0.5) + .alpha(0.4) + .hex(), // TODO: This was blend * 2 + errorColor: background(layer, "negative"), + gutterBackground: background(layer), + gutterPaddingFactor: 3.5, + lineNumber: withOpacity(foreground(layer), 0.35), + lineNumberActive: foreground(layer), + renameFade: 0.6, + unnecessaryCodeFade: 0.5, + selection: colorScheme.players[0], + whitespace: colorScheme.ramps.neutral(0.5).hex(), + guestSelections: [ + colorScheme.players[1], + colorScheme.players[2], + colorScheme.players[3], + colorScheme.players[4], + colorScheme.players[5], + colorScheme.players[6], + colorScheme.players[7], + ], + autocomplete: { + background: background(colorScheme.middle), + cornerRadius: 8, + padding: 4, + margin: { + left: -14, + }, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, + matchHighlight: foreground(colorScheme.middle, "accent"), + item: autocompleteItem, + hoveredItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "hovered" + ), + background: background(colorScheme.middle, "hovered"), + }, + selectedItem: { + ...autocompleteItem, + matchHighlight: foreground( + colorScheme.middle, + "accent", + "active" + ), + background: background(colorScheme.middle, "active"), + }, + }, + diagnosticHeader: { + background: background(colorScheme.middle), + iconWidthFactor: 1.5, + textScaleFactor: 0.857, + border: border(colorScheme.middle, { + bottom: true, + top: true, + }), + code: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 10, + }, + }, + source: { + text: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + }, + message: { + highlightText: text(colorScheme.middle, "sans", { + size: "sm", + weight: "bold", + }), + text: text(colorScheme.middle, "sans", { size: "sm" }), + }, + }, + diagnosticPathHeader: { + background: background(colorScheme.middle), + textScaleFactor: 0.857, + filename: text(colorScheme.middle, "mono", { size: "sm" }), + path: { + ...text(colorScheme.middle, "mono", { size: "sm" }), + margin: { + left: 12, + }, + }, + }, + errorDiagnostic: diagnostic(colorScheme.middle, "negative"), + warningDiagnostic: diagnostic(colorScheme.middle, "warning"), + informationDiagnostic: diagnostic(colorScheme.middle, "accent"), + hintDiagnostic: diagnostic(colorScheme.middle, "warning"), + invalidErrorDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidHintDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidInformationDiagnostic: diagnostic(colorScheme.middle, "base"), + invalidWarningDiagnostic: diagnostic(colorScheme.middle, "base"), + hoverPopover: hoverPopover(colorScheme), + linkDefinition: { + color: syntax.linkUri.color, + underline: syntax.linkUri.underline, + }, + jumpIcon: interactive({ + base: { + color: foreground(layer, "on"), + iconWidth: 20, + buttonWidth: 20, + cornerRadius: 6, + padding: { + top: 6, + bottom: 6, + left: 6, + right: 6, + }, + }, + state: { + hovered: { + background: background(layer, "on", "hovered"), + }, + }, + }), + + scrollbar: { + width: 12, + minHeightFactor: 1.0, + track: { + border: border(layer, "variant", { left: true }), + }, + thumb: { + background: withOpacity(background(layer, "inverted"), 0.3), + border: { + width: 1, + color: borderColor(layer, "variant"), + top: false, + right: true, + left: true, + bottom: false, + }, + }, + git: { + deleted: isLight + ? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8), + modified: isLight + ? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8), + inserted: isLight + ? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8) + : withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8), + }, + }, + compositionMark: { + underline: { + thickness: 1.0, + color: borderColor(layer), + }, + }, + syntax, + } } diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index f7cec1bd41..809cd1743f 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -4,95 +4,95 @@ import { background, border, text } from "./components" import { interactive, toggleable } from "../element" export default function picker(colorScheme: ColorScheme): any { - let layer = colorScheme.lowest - const container = { - background: background(layer), - border: border(layer), - shadow: colorScheme.modalShadow, - cornerRadius: 12, - padding: { - bottom: 4, - }, - } - const inputEditor = { - placeholderText: text(layer, "sans", "on", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "on"), - border: border(layer, { bottom: true }), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - margin: { - bottom: 4, - }, - } - const emptyInputEditor: any = { ...inputEditor } - delete emptyInputEditor.border - delete emptyInputEditor.margin - - return { - ...container, - emptyContainer: { - ...container, - padding: {}, - }, - item: toggleable({ - base: - interactive({ - base: { - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, - }, - margin: { - top: 1, - left: 4, - right: 4, - }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { - weight: "bold", - }), - }, - state: { - hovered: { - background: withOpacity( - background(layer, "hovered"), - 0.5 - ), - }, - }, - }), - state: { - active: { - default: { - background: withOpacity( - background(layer, "base", "active"), - 0.5 - ), - //text: text(layer, "sans", "base", "active"), - }, - } - } + let layer = colorScheme.lowest + const container = { + background: background(layer), + border: border(layer), + shadow: colorScheme.modalShadow, + cornerRadius: 12, + padding: { + bottom: 4, + }, } - ), + const inputEditor = { + placeholderText: text(layer, "sans", "on", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "on"), + border: border(layer, { bottom: true }), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + margin: { + bottom: 4, + }, + } + const emptyInputEditor: any = { ...inputEditor } + delete emptyInputEditor.border + delete emptyInputEditor.margin - inputEditor, - emptyInputEditor, - noMatches: { - text: text(layer, "sans", "variant"), - padding: { - bottom: 8, - left: 16, - right: 16, - top: 8, - }, - }, - } + return { + ...container, + emptyContainer: { + ...container, + padding: {}, + }, + item: toggleable({ + base: + interactive({ + base: { + padding: { + bottom: 4, + left: 12, + right: 12, + top: 4, + }, + margin: { + top: 1, + left: 4, + right: 4, + }, + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { + weight: "bold", + }), + }, + state: { + hovered: { + background: withOpacity( + background(layer, "hovered"), + 0.5 + ), + }, + }, + }), + state: { + active: { + default: { + background: withOpacity( + background(layer, "base", "active"), + 0.5 + ), + //text: text(layer, "sans", "base", "active"), + }, + } + } + } + ), + + inputEditor, + emptyInputEditor, + noMatches: { + text: text(layer, "sans", "variant"), + padding: { + bottom: 8, + left: 16, + right: 16, + top: 8, + }, + }, + } } diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index babd1431fb..7c37ce6bd3 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -3,125 +3,125 @@ import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function projectPanel(colorScheme: ColorScheme) { - const { isLight } = colorScheme + const { isLight } = colorScheme - let layer = colorScheme.middle + let layer = colorScheme.middle - let baseEntry = { - height: 22, - iconColor: foreground(layer, "variant"), - iconSize: 7, - iconSpacing: 5, - } - - let status = { - git: { - modified: isLight - ? colorScheme.ramps.yellow(0.6).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.45).hex() - : colorScheme.ramps.green(0.5).hex(), - conflict: isLight - ? colorScheme.ramps.red(0.6).hex() - : colorScheme.ramps.red(0.5).hex(), - }, - } - - let entry = toggleable({ - base: - interactive({ - base: { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - status, - }, - state: { - hovered: { - background: background(layer, "variant", "hovered"), - }, - }, - }), - state: { - active: { - default: { - /*background: colorScheme.isLight - ? withOpacity(background(layer, "active"), 0.5) - : background(layer, "active") ,*/ // todo posiewic - text: text(layer, "mono", "active", { size: "sm" }), - }, - hovered: { - //background: background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), - }, - } - } - } - ) - - return { - openProjectButton: interactive({ - base: { - background: background(layer), - border: border(layer, "active"), - cornerRadius: 4, - margin: { - top: 16, - left: 16, - right: 16, - }, - padding: { - top: 3, - bottom: 3, - left: 7, - right: 7, - }, - ...text(layer, "sans", "default", { size: "sm" }), - }, - state: { - hovered: { - ...text(layer, "sans", "default", { size: "sm" }), - background: background(layer, "hovered"), - border: border(layer, "active"), - }, - }, - }), - background: background(layer), - padding: { left: 6, right: 6, top: 0, bottom: 6 }, - indentWidth: 12, - entry, - draggedEntry: { - ...baseEntry, - text: text(layer, "mono", "on", { size: "sm" }), - background: withOpacity(background(layer, "on"), 0.9), - border: border(layer), - status, - }, - ignoredEntry: { - ...entry, - iconColor: foreground(layer, "disabled"), - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, + let baseEntry = { + height: 22, iconColor: foreground(layer, "variant"), - }, - }, - cutEntry: { - ...entry, - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - default: { - ...entry.active.default, - background: background(layer, "active"), - text: text(layer, "mono", "disabled", { size: "sm" }), + iconSize: 7, + iconSpacing: 5, + } + + let status = { + git: { + modified: isLight + ? colorScheme.ramps.yellow(0.6).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.45).hex() + : colorScheme.ramps.green(0.5).hex(), + conflict: isLight + ? colorScheme.ramps.red(0.6).hex() + : colorScheme.ramps.red(0.5).hex(), }, - }, - }, - filenameEditor: { - background: background(layer, "on"), - text: text(layer, "mono", "on", { size: "sm" }), - selection: colorScheme.players[0], - }, - } + } + + let entry = toggleable({ + base: + interactive({ + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, + state: { + hovered: { + background: background(layer, "variant", "hovered"), + }, + }, + }), + state: { + active: { + default: { + /*background: colorScheme.isLight + ? withOpacity(background(layer, "active"), 0.5) + : background(layer, "active") ,*/ // todo posiewic + text: text(layer, "mono", "active", { size: "sm" }), + }, + hovered: { + //background: background(layer, "active"), + text: text(layer, "mono", "active", { size: "sm" }), + }, + } + } + } + ) + + return { + openProjectButton: interactive({ + base: { + background: background(layer), + border: border(layer, "active"), + cornerRadius: 4, + margin: { + top: 16, + left: 16, + right: 16, + }, + padding: { + top: 3, + bottom: 3, + left: 7, + right: 7, + }, + ...text(layer, "sans", "default", { size: "sm" }), + }, + state: { + hovered: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "hovered"), + border: border(layer, "active"), + }, + }, + }), + background: background(layer), + padding: { left: 6, right: 6, top: 0, bottom: 6 }, + indentWidth: 12, + entry, + draggedEntry: { + ...baseEntry, + text: text(layer, "mono", "on", { size: "sm" }), + background: withOpacity(background(layer, "on"), 0.9), + border: border(layer), + status, + }, + ignoredEntry: { + ...entry, + iconColor: foreground(layer, "disabled"), + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + iconColor: foreground(layer, "variant"), + }, + }, + cutEntry: { + ...entry, + text: text(layer, "mono", "disabled"), + active: { + ...entry.active, + default: { + ...entry.active.default, + background: background(layer, "active"), + text: text(layer, "mono", "disabled", { size: "sm" }), + }, + }, + }, + filenameEditor: { + background: background(layer, "on"), + text: text(layer, "mono", "on", { size: "sm" }), + selection: colorScheme.players[0], + }, + } } diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index aa015d5cde..0123ddee22 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -4,127 +4,127 @@ import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function search(colorScheme: ColorScheme) { - let layer = colorScheme.highest + let layer = colorScheme.highest - // Search input - const editor = { - background: background(layer), - cornerRadius: 8, - minWidth: 200, - maxWidth: 500, - placeholderText: text(layer, "mono", "disabled"), - selection: colorScheme.players[0], - text: text(layer, "mono", "default"), - border: border(layer), - margin: { - right: 12, - }, - padding: { - top: 3, - bottom: 3, - left: 12, - right: 8, - }, - } - - const includeExcludeEditor = { - ...editor, - minWidth: 100, - maxWidth: 250, - } - - return { - // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive - matchBackground: withOpacity(foreground(layer, "accent"), 0.4), - optionButton: toggleable({ - base: - interactive({ - base: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, - }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, - }, - }, - state: { - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, - hovered: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), - }, - }, - }), - state: { - active: { - default: { - ...text(layer, "mono", "on", "inverted"), - background: background(layer, "on", "inverted"), - border: border(layer, "on", "inverted"), - }, - } - } - } - ), - editor, - invalidEditor: { - ...editor, - border: border(layer, "negative"), - }, - includeExcludeEditor, - invalidIncludeExcludeEditor: { - ...includeExcludeEditor, - border: border(layer, "negative"), - }, - matchIndex: { - ...text(layer, "mono", "variant"), - padding: { - left: 6, - }, - }, - optionButtonGroup: { - padding: { - left: 12, - right: 12, - }, - }, - includeExcludeInputs: { - ...text(layer, "mono", "variant"), - padding: { - right: 6, - }, - }, - resultsStatus: { - ...text(layer, "mono", "on"), - size: 18, - }, - dismissButton: interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 14, + // Search input + const editor = { + background: background(layer), + cornerRadius: 8, + minWidth: 200, + maxWidth: 500, + placeholderText: text(layer, "mono", "disabled"), + selection: colorScheme.players[0], + text: text(layer, "mono", "default"), + border: border(layer), + margin: { + right: 12, + }, padding: { - left: 10, - right: 10, + top: 3, + bottom: 3, + left: 12, + right: 8, }, - }, - state: { - hovered: { - color: foreground(layer, "hovered"), + } + + const includeExcludeEditor = { + ...editor, + minWidth: 100, + maxWidth: 250, + } + + return { + // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive + matchBackground: withOpacity(foreground(layer, "accent"), 0.4), + optionButton: toggleable({ + base: + interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, + }, + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, + }, + }, + state: { + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, + }, + }), + state: { + active: { + default: { + ...text(layer, "mono", "on", "inverted"), + background: background(layer, "on", "inverted"), + border: border(layer, "on", "inverted"), + }, + } + } + } + ), + editor, + invalidEditor: { + ...editor, + border: border(layer, "negative"), }, - }, - }), - } + includeExcludeEditor, + invalidIncludeExcludeEditor: { + ...includeExcludeEditor, + border: border(layer, "negative"), + }, + matchIndex: { + ...text(layer, "mono", "variant"), + padding: { + left: 6, + }, + }, + optionButtonGroup: { + padding: { + left: 12, + right: 12, + }, + }, + includeExcludeInputs: { + ...text(layer, "mono", "variant"), + padding: { + right: 6, + }, + }, + resultsStatus: { + ...text(layer, "mono", "on"), + size: 18, + }, + dismissButton: interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 14, + padding: { + left: 10, + right: 10, + }, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), + }, + }, + }), + } } diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 4c566a5c3a..e4a48e8215 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -2,147 +2,147 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" export default function statusBar(colorScheme: ColorScheme) { - let layer = colorScheme.lowest + let layer = colorScheme.lowest - const statusContainer = { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 6, right: 6 }, - } + const statusContainer = { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 6, right: 6 }, + } - const diagnosticStatusContainer = { - cornerRadius: 6, - padding: { top: 1, bottom: 1, left: 6, right: 6 }, - } + const diagnosticStatusContainer = { + cornerRadius: 6, + padding: { top: 1, bottom: 1, left: 6, right: 6 }, + } - return { - height: 30, - itemSpacing: 8, - padding: { - top: 1, - bottom: 1, - left: 6, - right: 6, - }, - border: border(layer, { top: true, overlay: true }), - cursorPosition: text(layer, "sans", "variant"), - activeLanguage: interactive({ - base: { - padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant"), - }, - state: { - hovered: { - ...text(layer, "sans", "on"), + return { + height: 30, + itemSpacing: 8, + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, }, - }, - }), - autoUpdateProgressMessage: text(layer, "sans", "variant"), - autoUpdateDoneMessage: text(layer, "sans", "variant"), - lspStatus: interactive({ - base: { - ...diagnosticStatusContainer, - iconSpacing: 4, - iconWidth: 14, - height: 18, - message: text(layer, "sans"), - iconColor: foreground(layer), - }, - state: { - hovered: { - message: text(layer, "sans"), - iconColor: foreground(layer), - background: background(layer, "hovered"), - }, - }, - }), - diagnosticMessage: interactive({ - base: { - ...text(layer, "sans"), - }, - state: { hovered: text(layer, "sans", "hovered") }, - }), - diagnosticSummary: interactive({ - base: { - height: 20, - iconWidth: 16, - iconSpacing: 2, - summarySpacing: 6, - text: text(layer, "sans", { size: "sm" }), - iconColorOk: foreground(layer, "variant"), - iconColorWarning: foreground(layer, "warning"), - iconColorError: foreground(layer, "negative"), - containerOk: { - cornerRadius: 6, - padding: { top: 3, bottom: 3, left: 7, right: 7 }, - }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), - }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - }, - }, - state: { - hovered: { - iconColorOk: foreground(layer, "on"), - containerOk: { - background: background(layer, "on", "hovered"), - }, - containerWarning: { - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), - }, - containerError: { - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), - }, - }, - }, - }), - panelButtons: { - groupLeft: {}, - groupBottom: {}, - groupRight: {}, - button: toggleable({ - base: - interactive({ + border: border(layer, { top: true, overlay: true }), + cursorPosition: text(layer, "sans", "variant"), + activeLanguage: interactive({ base: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), - }, + padding: { left: 6, right: 6 }, + ...text(layer, "sans", "variant"), }, state: { - hovered: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - }, + hovered: { + ...text(layer, "sans", "on"), + }, }, - }), state: - { - active: { - default: { - iconColor: foreground(layer, "active"), - background: background(layer, "active"), + }), + autoUpdateProgressMessage: text(layer, "sans", "variant"), + autoUpdateDoneMessage: text(layer, "sans", "variant"), + lspStatus: interactive({ + base: { + ...diagnosticStatusContainer, + iconSpacing: 4, + iconWidth: 14, + height: 18, + message: text(layer, "sans"), + iconColor: foreground(layer), }, - } - } - } - ), - badge: { - cornerRadius: 3, - padding: 2, - margin: { bottom: -1, right: -1 }, - border: border(layer), - background: background(layer, "accent"), - }, - }, - } + state: { + hovered: { + message: text(layer, "sans"), + iconColor: foreground(layer), + background: background(layer, "hovered"), + }, + }, + }), + diagnosticMessage: interactive({ + base: { + ...text(layer, "sans"), + }, + state: { hovered: text(layer, "sans", "hovered") }, + }), + diagnosticSummary: interactive({ + base: { + height: 20, + iconWidth: 16, + iconSpacing: 2, + summarySpacing: 6, + text: text(layer, "sans", { size: "sm" }), + iconColorOk: foreground(layer, "variant"), + iconColorWarning: foreground(layer, "warning"), + iconColorError: foreground(layer, "negative"), + containerOk: { + cornerRadius: 6, + padding: { top: 3, bottom: 3, left: 7, right: 7 }, + }, + containerWarning: { + ...diagnosticStatusContainer, + background: background(layer, "warning"), + border: border(layer, "warning"), + }, + containerError: { + ...diagnosticStatusContainer, + background: background(layer, "negative"), + border: border(layer, "negative"), + }, + }, + state: { + hovered: { + iconColorOk: foreground(layer, "on"), + containerOk: { + background: background(layer, "on", "hovered"), + }, + containerWarning: { + background: background(layer, "warning", "hovered"), + border: border(layer, "warning", "hovered"), + }, + containerError: { + background: background(layer, "negative", "hovered"), + border: border(layer, "negative", "hovered"), + }, + }, + }, + }), + panelButtons: { + groupLeft: {}, + groupBottom: {}, + groupRight: {}, + button: toggleable({ + base: + interactive({ + base: { + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), + }, + }, + state: { + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), + }, + }, + }), state: + { + active: { + default: { + iconColor: foreground(layer, "active"), + background: background(layer, "active"), + }, + } + } + } + ), + badge: { + cornerRadius: 3, + padding: 2, + margin: { bottom: -1, right: -1 }, + border: border(layer), + background: background(layer, "accent"), + }, + }, + } } diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index d7b3b58055..f2c99ea736 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -4,120 +4,120 @@ import { text, border, background, foreground } from "./components" import { interactive, toggleable } from "../element" export default function tabBar(colorScheme: ColorScheme) { - const height = 32 + const height = 32 - let activeLayer = colorScheme.highest - let layer = colorScheme.middle + let activeLayer = colorScheme.highest + let layer = colorScheme.middle - const tab = { - height, - text: text(layer, "sans", "variant", { size: "sm" }), - background: background(layer), - border: border(layer, { - right: true, - bottom: true, - overlay: true, - }), - padding: { - left: 8, - right: 12, - }, - spacing: 8, - - // Tab type icons (e.g. Project Search) - typeIconWidth: 14, - - // Close icons - closeIconWidth: 8, - iconClose: foreground(layer, "variant"), - iconCloseActive: foreground(layer, "hovered"), - - // Indicators - iconConflict: foreground(layer, "warning"), - iconDirty: foreground(layer, "accent"), - - // When two tabs of the same name are open, a label appears next to them - description: { - margin: { left: 8 }, - ...text(layer, "sans", "disabled", { size: "2xs" }), - }, - } - - const activePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(activeLayer, "sans", "active", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } - - const inactivePaneInactiveTab = { - ...tab, - background: background(layer), - text: text(layer, "sans", "variant", { size: "sm" }), - } - - const inactivePaneActiveTab = { - ...tab, - background: background(activeLayer), - text: text(layer, "sans", "variant", { size: "sm" }), - border: { - ...tab.border, - bottom: false, - }, - } - - const draggedTab = { - ...activePaneActiveTab, - background: withOpacity(tab.background, 0.9), - border: undefined as any, - shadow: colorScheme.popoverShadow, - } - - return { - height, - background: background(layer), - activePane: { - activeTab: activePaneActiveTab, - inactiveTab: tab, - }, - inactivePane: { - activeTab: inactivePaneActiveTab, - inactiveTab: inactivePaneInactiveTab, - }, - draggedTab, - paneButton: toggleable({ - base: - interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - }, - state: { - hovered: { - color: foreground(layer, "hovered"), - }, - }, + const tab = { + height, + text: text(layer, "sans", "variant", { size: "sm" }), + background: background(layer), + border: border(layer, { + right: true, + bottom: true, + overlay: true, }), - state: - { - active: { - default: { - color: foreground(layer, "accent"), - }, - } - } + padding: { + left: 8, + right: 12, + }, + spacing: 8, + + // Tab type icons (e.g. Project Search) + typeIconWidth: 14, + + // Close icons + closeIconWidth: 8, + iconClose: foreground(layer, "variant"), + iconCloseActive: foreground(layer, "hovered"), + + // Indicators + iconConflict: foreground(layer, "warning"), + iconDirty: foreground(layer, "accent"), + + // When two tabs of the same name are open, a label appears next to them + description: { + margin: { left: 8 }, + ...text(layer, "sans", "disabled", { size: "2xs" }), + }, + } + + const activePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(activeLayer, "sans", "active", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } + + const inactivePaneInactiveTab = { + ...tab, + background: background(layer), + text: text(layer, "sans", "variant", { size: "sm" }), + } + + const inactivePaneActiveTab = { + ...tab, + background: background(activeLayer), + text: text(layer, "sans", "variant", { size: "sm" }), + border: { + ...tab.border, + bottom: false, + }, + } + + const draggedTab = { + ...activePaneActiveTab, + background: withOpacity(tab.background, 0.9), + border: undefined as any, + shadow: colorScheme.popoverShadow, + } + + return { + height, + background: background(layer), + activePane: { + activeTab: activePaneActiveTab, + inactiveTab: tab, + }, + inactivePane: { + activeTab: inactivePaneActiveTab, + inactiveTab: inactivePaneInactiveTab, + }, + draggedTab, + paneButton: toggleable({ + base: + interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), + }, + }, + }), + state: + { + active: { + default: { + color: foreground(layer, "accent"), + }, + } + } + } + ), + paneButtonContainer: { + background: tab.background, + border: { + ...tab.border, + right: false, + }, + }, } - ), - paneButtonContainer: { - background: tab.background, - border: { - ...tab.border, - right: false, - }, - }, - } } diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 3a870b008f..b1b28d789e 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -2,64 +2,64 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" import { interactive, toggleable } from "../element" export default function dropdownMenu(colorScheme: ColorScheme) { - let layer = colorScheme.middle + let layer = colorScheme.middle - return { - rowHeight: 30, - background: background(layer), - border: border(layer), - shadow: colorScheme.popoverShadow, - header: interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryText: text(layer, "sans", { - size: "sm", - color: "#aaaaaa", - }), - secondaryTextSpacing: 10, - padding: { left: 8, right: 8, top: 2, bottom: 2 }, - cornerRadius: 6, - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - }, - state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - }, - }, - }), - sectionHeader: { - ...text(layer, "sans", { size: "sm" }), - padding: { left: 8, right: 8, top: 8, bottom: 8 }, - }, - item: toggleable({ - base: - interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryTextSpacing: 10, - secondaryText: text(layer, "sans", { size: "sm" }), - padding: { left: 18, right: 18, top: 2, bottom: 2 }, - }, - state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), + return { + rowHeight: 30, + background: background(layer), + border: border(layer), + shadow: colorScheme.popoverShadow, + header: interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryText: text(layer, "sans", { + size: "sm", + color: "#aaaaaa", + }), + secondaryTextSpacing: 10, + padding: { left: 8, right: 8, top: 2, bottom: 2 }, + cornerRadius: 6, + background: background(layer, "on"), + border: border(layer, "on", { overlay: true }), + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + }, }, - }, }), - state: { - active: { - default: { - background: background(layer, "active"), - }, - hovered: { - background: background(layer, "active"), - }, + sectionHeader: { + ...text(layer, "sans", { size: "sm" }), + padding: { left: 8, right: 8, top: 8, bottom: 8 }, + }, + item: toggleable({ + base: + interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryTextSpacing: 10, + secondaryText: text(layer, "sans", { size: "sm" }), + padding: { left: 18, right: 18, top: 2, bottom: 2 }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), + }, + }, + }), + state: { + active: { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "active"), + }, + } + } } - } + ), } - ), - } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index 96f4b8bdbd..fdc7657481 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -2,406 +2,406 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { toggleable } from "../element" import { - background, - border, - borderColor, - foreground, - svg, - text, + background, + border, + borderColor, + foreground, + svg, + text, } from "./components" import statusBar from "./statusBar" import tabBar from "./tabBar" import { interactive } from "../element" import merge from "ts-deepmerge" export default function workspace(colorScheme: ColorScheme) { - const layer = colorScheme.lowest - const isLight = colorScheme.isLight - const itemSpacing = 8 - const titlebarButton = toggleable({ - base: - interactive({ - base: { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), - }, - state: { - hovered: { - ...text(layer, "sans", "variant", "hovered", { - size: "xs", - }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { - size: "xs", - }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - }, - }, - }), - state: { - active: { - default: { - ...text(layer, "sans", "variant", "active", { size: "xs" }), - background: background(layer, "variant", "active"), - border: border(layer, "variant", "active"), - }, - } - } - } - ) - const avatarWidth = 18 - const avatarOuterWidth = avatarWidth + 4 - const followerAvatarWidth = 14 - const followerAvatarOuterWidth = followerAvatarWidth + 4 - - return { - background: background(colorScheme.lowest), - blankPane: { - logoContainer: { - width: 256, - height: 256, - }, - logo: svg( - withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), - "icons/logo_96.svg", - 256, - 256 - ), - - logoShadow: svg( - withOpacity( - colorScheme.isLight - ? "#FFFFFF" - : colorScheme.lowest.base.default.background, - colorScheme.isLight ? 1 : 0.6 - ), - "icons/logo_96.svg", - 256, - 256 - ), - keyboardHints: { - margin: { - top: 96, - }, - cornerRadius: 4, - }, - keyboardHint: interactive({ - base: { - ...text(layer, "sans", "variant", { size: "sm" }), - padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, - }, - cornerRadius: 8, - }, - state: { - hovered: { - ...text(layer, "sans", "active", { size: "sm" }), - }, - }, - }), - - keyboardHintWidth: 320, - }, - joiningProjectAvatar: { - cornerRadius: 40, - width: 80, - }, - joiningProjectMessage: { - padding: 12, - ...text(layer, "sans", { size: "lg" }), - }, - externalLocationMessage: { - background: background(colorScheme.middle, "accent"), - border: border(colorScheme.middle, "accent"), - cornerRadius: 6, - padding: 12, - margin: { bottom: 8, right: 8 }, - ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), - }, - leaderBorderOpacity: 0.7, - leaderBorderWidth: 2.0, - tabBar: tabBar(colorScheme), - modal: { - margin: { - bottom: 52, - top: 52, - }, - cursor: "Arrow", - }, - zoomedBackground: { - cursor: "Arrow", - background: isLight - ? withOpacity(background(colorScheme.lowest), 0.8) - : withOpacity(background(colorScheme.highest), 0.6), - }, - zoomedPaneForeground: { - margin: 16, - shadow: colorScheme.modalShadow, - border: border(colorScheme.lowest, { overlay: true }), - }, - zoomedPanelForeground: { - margin: 16, - border: border(colorScheme.lowest, { overlay: true }), - }, - dock: { - left: { - border: border(layer, { right: true }), - }, - bottom: { - border: border(layer, { top: true }), - }, - right: { - border: border(layer, { left: true }), - }, - }, - paneDivider: { - color: borderColor(layer), - width: 1, - }, - statusBar: statusBar(colorScheme), - titlebar: { - itemSpacing, - facePileSpacing: 2, - height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. - background: background(layer), - border: border(layer, { bottom: true }), - padding: { - left: 80, - right: itemSpacing, - }, - - // Project - title: text(layer, "sans", "variant"), - highlight_color: text(layer, "sans", "active").color, - - // Collaborators - leaderAvatar: { - width: avatarWidth, - outerWidth: avatarOuterWidth, - cornerRadius: avatarWidth / 2, - outerCornerRadius: avatarOuterWidth / 2, - }, - followerAvatar: { - width: followerAvatarWidth, - outerWidth: followerAvatarOuterWidth, - cornerRadius: followerAvatarWidth / 2, - outerCornerRadius: followerAvatarOuterWidth / 2, - }, - inactiveAvatarGrayscale: true, - followerAvatarOverlap: 8, - leaderSelection: { - margin: { - top: 4, - bottom: 4, - }, - padding: { - left: 2, - right: 2, - top: 2, - bottom: 2, - }, - cornerRadius: 6, - }, - avatarRibbon: { - height: 3, - width: 12, - // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. - }, - - // Sign in buttom - // FlatButton, Variant - signInPrompt: merge(titlebarButton, { - inactive: { - default: { - margin: { - left: itemSpacing, - }, - }, - }, - }), - - // Offline Indicator - offlineIcon: { - color: foreground(layer, "variant"), - width: 16, - margin: { - left: itemSpacing, - }, - padding: { - right: 4, - }, - }, - - // Notice that the collaboration server is out of date - outdatedWarning: { - ...text(layer, "sans", "warning", { size: "xs" }), - background: withOpacity(background(layer, "warning"), 0.3), - border: border(layer, "warning"), - margin: { - left: itemSpacing, - }, - padding: { - left: 8, - right: 8, - }, - cornerRadius: 6, - }, - callControl: interactive({ - base: { - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 20, - }, - state: { - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - }, - }), - toggleContactsButton: toggleable({ + const layer = colorScheme.lowest + const isLight = colorScheme.isLight + const itemSpacing = 8 + const titlebarButton = toggleable({ base: - interactive({ + interactive({ + base: { + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, + }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), + }, + state: { + hovered: { + ...text(layer, "sans", "variant", "hovered", { + size: "xs", + }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), + }, + clicked: { + ...text(layer, "sans", "variant", "pressed", { + size: "xs", + }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + }, + }, + }), + state: { + active: { + default: { + ...text(layer, "sans", "variant", "active", { size: "xs" }), + background: background(layer, "variant", "active"), + border: border(layer, "variant", "active"), + }, + } + } + } + ) + const avatarWidth = 18 + const avatarOuterWidth = avatarWidth + 4 + const followerAvatarWidth = 14 + const followerAvatarOuterWidth = followerAvatarWidth + 4 + + return { + background: background(colorScheme.lowest), + blankPane: { + logoContainer: { + width: 256, + height: 256, + }, + logo: svg( + withOpacity("#000000", colorScheme.isLight ? 0.6 : 0.8), + "icons/logo_96.svg", + 256, + 256 + ), + + logoShadow: svg( + withOpacity( + colorScheme.isLight + ? "#FFFFFF" + : colorScheme.lowest.base.default.background, + colorScheme.isLight ? 1 : 0.6 + ), + "icons/logo_96.svg", + 256, + 256 + ), + keyboardHints: { + margin: { + top: 96, + }, + cornerRadius: 4, + }, + keyboardHint: interactive({ + base: { + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, + left: 8, + right: 8, + bottom: 3, + }, + cornerRadius: 8, + }, + state: { + hovered: { + ...text(layer, "sans", "active", { size: "sm" }), + }, + }, + }), + + keyboardHintWidth: 320, + }, + joiningProjectAvatar: { + cornerRadius: 40, + width: 80, + }, + joiningProjectMessage: { + padding: 12, + ...text(layer, "sans", { size: "lg" }), + }, + externalLocationMessage: { + background: background(colorScheme.middle, "accent"), + border: border(colorScheme.middle, "accent"), + cornerRadius: 6, + padding: 12, + margin: { bottom: 8, right: 8 }, + ...text(colorScheme.middle, "sans", "accent", { size: "xs" }), + }, + leaderBorderOpacity: 0.7, + leaderBorderWidth: 2.0, + tabBar: tabBar(colorScheme), + modal: { + margin: { + bottom: 52, + top: 52, + }, + cursor: "Arrow", + }, + zoomedBackground: { + cursor: "Arrow", + background: isLight + ? withOpacity(background(colorScheme.lowest), 0.8) + : withOpacity(background(colorScheme.highest), 0.6), + }, + zoomedPaneForeground: { + margin: 16, + shadow: colorScheme.modalShadow, + border: border(colorScheme.lowest, { overlay: true }), + }, + zoomedPanelForeground: { + margin: 16, + border: border(colorScheme.lowest, { overlay: true }), + }, + dock: { + left: { + border: border(layer, { right: true }), + }, + bottom: { + border: border(layer, { top: true }), + }, + right: { + border: border(layer, { left: true }), + }, + }, + paneDivider: { + color: borderColor(layer), + width: 1, + }, + statusBar: statusBar(colorScheme), + titlebar: { + itemSpacing, + facePileSpacing: 2, + height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. + background: background(layer), + border: border(layer, { bottom: true }), + padding: { + left: 80, + right: itemSpacing, + }, + + // Project + title: text(layer, "sans", "variant"), + highlight_color: text(layer, "sans", "active").color, + + // Collaborators + leaderAvatar: { + width: avatarWidth, + outerWidth: avatarOuterWidth, + cornerRadius: avatarWidth / 2, + outerCornerRadius: avatarOuterWidth / 2, + }, + followerAvatar: { + width: followerAvatarWidth, + outerWidth: followerAvatarOuterWidth, + cornerRadius: followerAvatarWidth / 2, + outerCornerRadius: followerAvatarOuterWidth / 2, + }, + inactiveAvatarGrayscale: true, + followerAvatarOverlap: 8, + leaderSelection: { + margin: { + top: 4, + bottom: 4, + }, + padding: { + left: 2, + right: 2, + top: 2, + bottom: 2, + }, + cornerRadius: 6, + }, + avatarRibbon: { + height: 3, + width: 12, + // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. + }, + + // Sign in buttom + // FlatButton, Variant + signInPrompt: merge(titlebarButton, { + inactive: { + default: { + margin: { + left: itemSpacing, + }, + }, + }, + }), + + // Offline Indicator + offlineIcon: { + color: foreground(layer, "variant"), + width: 16, + margin: { + left: itemSpacing, + }, + padding: { + right: 4, + }, + }, + + // Notice that the collaboration server is out of date + outdatedWarning: { + ...text(layer, "sans", "warning", { size: "xs" }), + background: withOpacity(background(layer, "warning"), 0.3), + border: border(layer, "warning"), + margin: { + left: itemSpacing, + }, + padding: { + left: 8, + right: 8, + }, + cornerRadius: 6, + }, + callControl: interactive({ + base: { + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 20, + }, + state: { + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + }, + }), + toggleContactsButton: toggleable({ + base: + interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { + clicked: { + background: background(layer, "variant", "pressed"), + color: foreground(layer, "variant", "pressed"), + }, + hovered: { + background: background(layer, "variant", "hovered"), + color: foreground(layer, "variant", "hovered"), + }, + }, + }), state: + { + active: { + default: { + background: background(layer, "variant", "active"), + color: foreground(layer, "variant", "active"), + }, + } + } + } + ), + userMenuButton: merge(titlebarButton, { + inactive: { + default: { + buttonWidth: 20, + iconWidth: 12, + }, + }, + active: { + // posiewic: these properties are not currently set on main + default: { + iconWidth: 12, + button_width: 20, + }, + }, + }), + + toggleContactsBadge: { + cornerRadius: 3, + padding: 2, + margin: { top: 3, left: 3 }, + border: border(layer), + background: foreground(layer, "accent"), + }, + shareButton: { + ...titlebarButton, + }, + }, + + toolbar: { + height: 34, + background: background(colorScheme.highest), + border: border(colorScheme.highest, { bottom: true }), + itemSpacing: 8, + navButton: interactive({ + base: { + color: foreground(colorScheme.highest, "on"), + iconWidth: 12, + buttonWidth: 24, + cornerRadius: 6, + }, + state: { + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, + disabled: { + color: foreground( + colorScheme.highest, + "on", + "disabled" + ), + }, + }, + }), + padding: { left: 8, right: 8, top: 4, bottom: 4 }, + }, + breadcrumbHeight: 24, + breadcrumbs: interactive({ base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, + ...text(colorScheme.highest, "sans", "variant"), + cornerRadius: 6, + padding: { + left: 6, + right: 6, + }, }, state: { - clicked: { - background: background(layer, "variant", "pressed"), - color: foreground(layer, "variant", "pressed"), - }, - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, + hovered: { + color: foreground(colorScheme.highest, "on", "hovered"), + background: background( + colorScheme.highest, + "on", + "hovered" + ), + }, }, - }), state: - { - active: { - default: { - background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active"), - }, - } - } - } - ), - userMenuButton: merge(titlebarButton, { - inactive: { - default: { - buttonWidth: 20, - iconWidth: 12, - }, + }), + disconnectedOverlay: { + ...text(layer, "sans"), + background: withOpacity(background(layer), 0.8), }, - active: { - // posiewic: these properties are not currently set on main - default: { - iconWidth: 12, - button_width: 20, - }, + notification: { + margin: { top: 10 }, + background: background(colorScheme.middle), + cornerRadius: 6, + padding: 12, + border: border(colorScheme.middle), + shadow: colorScheme.popoverShadow, }, - }), - - toggleContactsBadge: { - cornerRadius: 3, - padding: 2, - margin: { top: 3, left: 3 }, - border: border(layer), - background: foreground(layer, "accent"), - }, - shareButton: { - ...titlebarButton, - }, - }, - - toolbar: { - height: 34, - background: background(colorScheme.highest), - border: border(colorScheme.highest, { bottom: true }), - itemSpacing: 8, - navButton: interactive({ - base: { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, - cornerRadius: 6, + notifications: { + width: 400, + margin: { right: 10, bottom: 10 }, }, - state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - disabled: { - color: foreground( - colorScheme.highest, - "on", - "disabled" - ), - }, - }, - }), - padding: { left: 8, right: 8, top: 4, bottom: 4 }, - }, - breadcrumbHeight: 24, - breadcrumbs: interactive({ - base: { - ...text(colorScheme.highest, "sans", "variant"), - cornerRadius: 6, - padding: { - left: 6, - right: 6, - }, - }, - state: { - hovered: { - color: foreground(colorScheme.highest, "on", "hovered"), - background: background( - colorScheme.highest, - "on", - "hovered" - ), - }, - }, - }), - disconnectedOverlay: { - ...text(layer, "sans"), - background: withOpacity(background(layer), 0.8), - }, - notification: { - margin: { top: 10 }, - background: background(colorScheme.middle), - cornerRadius: 6, - padding: 12, - border: border(colorScheme.middle), - shadow: colorScheme.popoverShadow, - }, - notifications: { - width: 400, - margin: { right: 10, bottom: 10 }, - }, - dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), - } + dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), + } } From f1dc6124dd7687cadccee4e4eddcde5bf5caaa60 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 16:09:17 -0700 Subject: [PATCH 060/215] Fix rebase mistake --- crates/editor/src/element.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 835d53bc8c..9cc058133b 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1527,7 +1527,7 @@ impl EditorElement { enum JumpIcon {} MouseEventHandler::::new((*id).into(), cx, |state, _| { - let style = style.jump_icon.style_for(state, false); + let style = style.jump_icon.style_for(state); Svg::new("icons/arrow_up_right_8.svg") .with_color(style.color) .constrained() From 11125a62c711b69c8474515c3e529ca5536902f9 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 20 Jun 2023 16:48:30 -0700 Subject: [PATCH 061/215] Add copy-on-click to diagnostic messages --- crates/diagnostics/src/diagnostics.rs | 4 +- crates/editor/src/display_map/block_map.rs | 1 + crates/editor/src/editor.rs | 48 +++++++++++++++------- crates/editor/src/element.rs | 10 +++-- crates/workspace/src/workspace.rs | 6 ++- 5 files changed, 49 insertions(+), 20 deletions(-) diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 5350e53d6a..d0cd437946 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -1509,7 +1509,8 @@ mod tests { let snapshot = editor.snapshot(cx); snapshot .blocks_in_range(0..snapshot.max_point().row()) - .filter_map(|(row, block)| { + .enumerate() + .filter_map(|(ix, (row, block))| { let name = match block { TransformBlock::Custom(block) => block .render(&mut BlockContext { @@ -1520,6 +1521,7 @@ mod tests { gutter_width: 0., line_height: 0., em_width: 0., + block_id: ix, }) .name()? .to_string(), diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index 0cf5bacc65..b20ecaef1c 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -88,6 +88,7 @@ pub struct BlockContext<'a, 'b, 'c> { pub gutter_padding: f32, pub em_width: f32, pub line_height: f32, + pub block_id: usize, } #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 2e0d444e04..dd9952e870 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -7949,6 +7949,7 @@ impl Deref for EditorStyle { pub fn diagnostic_block_renderer(diagnostic: Diagnostic, is_valid: bool) -> RenderBlock { let mut highlighted_lines = Vec::new(); + for (index, line) in diagnostic.message.lines().enumerate() { let line = match &diagnostic.source { Some(source) if index == 0 => { @@ -7960,25 +7961,44 @@ pub fn diagnostic_block_renderer(diagnostic: Diagnostic, is_valid: bool) -> Rend }; highlighted_lines.push(line); } - + let message = diagnostic.message; Arc::new(move |cx: &mut BlockContext| { + let message = message.clone(); let settings = settings::get::(cx); + let tooltip_style = settings.theme.tooltip.clone(); let theme = &settings.theme.editor; let style = diagnostic_style(diagnostic.severity, is_valid, theme); let font_size = (style.text_scale_factor * settings.buffer_font_size(cx)).round(); - Flex::column() - .with_children(highlighted_lines.iter().map(|(line, highlights)| { - Label::new( - line.clone(), - style.message.clone().with_font_size(font_size), - ) - .with_highlights(highlights.clone()) - .contained() - .with_margin_left(cx.anchor_x) - })) - .aligned() - .left() - .into_any() + let anchor_x = cx.anchor_x; + enum BlockContextToolip {} + MouseEventHandler::::new(cx.block_id, cx, |_, _| { + Flex::column() + .with_children(highlighted_lines.iter().map(|(line, highlights)| { + Label::new( + line.clone(), + style.message.clone().with_font_size(font_size), + ) + .with_highlights(highlights.clone()) + .contained() + .with_margin_left(anchor_x) + })) + .aligned() + .left() + .into_any() + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, move |_, _, cx| { + cx.write_to_clipboard(ClipboardItem::new(message.clone())); + }) + // We really need to rethink this ID system... + .with_tooltip::( + cx.block_id, + "Copy diagnostic message".to_string(), + None, + tooltip_style, + cx, + ) + .into_any() }) } diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index d6f9a2e906..5be745162a 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1467,6 +1467,7 @@ impl EditorElement { editor: &mut Editor, cx: &mut LayoutContext, ) -> (f32, Vec) { + let mut block_id = 0; let scroll_x = snapshot.scroll_anchor.offset.x(); let (fixed_blocks, non_fixed_blocks) = snapshot .blocks_in_range(rows.clone()) @@ -1474,7 +1475,7 @@ impl EditorElement { TransformBlock::ExcerptHeader { .. } => false, TransformBlock::Custom(block) => block.style() == BlockStyle::Fixed, }); - let mut render_block = |block: &TransformBlock, width: f32| { + let mut render_block = |block: &TransformBlock, width: f32, block_id: usize| { let mut element = match block { TransformBlock::Custom(block) => { let align_to = block @@ -1499,6 +1500,7 @@ impl EditorElement { scroll_x, gutter_width, em_width, + block_id, }) } TransformBlock::ExcerptHeader { @@ -1634,7 +1636,8 @@ impl EditorElement { let mut fixed_block_max_width = 0f32; let mut blocks = Vec::new(); for (row, block) in fixed_blocks { - let element = render_block(block, f32::INFINITY); + let element = render_block(block, f32::INFINITY, block_id); + block_id += 1; fixed_block_max_width = fixed_block_max_width.max(element.size().x() + em_width); blocks.push(BlockLayout { row, @@ -1654,7 +1657,8 @@ impl EditorElement { .max(gutter_width + scroll_width), BlockStyle::Fixed => unreachable!(), }; - let element = render_block(block, width); + let element = render_block(block, width, block_id); + block_id += 1; blocks.push(BlockLayout { row, element, diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 43ca41ab1d..a4974fc173 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -140,9 +140,11 @@ pub struct OpenPaths { #[derive(Clone, Deserialize, PartialEq)] pub struct ActivatePane(pub usize); +#[derive(Deserialize)] pub struct Toast { id: usize, msg: Cow<'static, str>, + #[serde(skip)] on_click: Option<(Cow<'static, str>, Arc)>, } @@ -183,9 +185,9 @@ impl Clone for Toast { } } -pub type WorkspaceId = i64; +impl_actions!(workspace, [ActivatePane, Toast]); -impl_actions!(workspace, [ActivatePane]); +pub type WorkspaceId = i64; pub fn init_settings(cx: &mut AppContext) { settings::register::(cx); From 7a051a0dcbafd467203bcaeec773c269abcd02cd Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 20 Jun 2023 18:12:59 -0600 Subject: [PATCH 062/215] Panic in debug if global settings can't be deserialized from defaults Co-Authored-By: Max Brunsfeld Co-Authored-By: Julia Risley --- crates/settings/src/settings_store.rs | 31 +++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/crates/settings/src/settings_store.rs b/crates/settings/src/settings_store.rs index 1188018cd8..5e2be5a881 100644 --- a/crates/settings/src/settings_store.rs +++ b/crates/settings/src/settings_store.rs @@ -147,25 +147,28 @@ impl SettingsStore { local_values: Vec::new(), })); - if let Some(default_settings) = setting_value + let default_settings = setting_value .deserialize_setting(&self.raw_default_settings) + .expect("can't deserialize default settings"); + + let mut user_values_stack = Vec::new(); + if let Some(user_settings) = setting_value + .deserialize_setting(&self.raw_user_settings) .log_err() { - let mut user_values_stack = Vec::new(); + user_values_stack = vec![user_settings]; + } - if let Some(user_settings) = setting_value - .deserialize_setting(&self.raw_user_settings) - .log_err() - { - user_values_stack = vec![user_settings]; - } + #[cfg(debug_assertions)] + setting_value + .load_setting(&default_settings, &[], cx) + .expect("can't deserialize settings from defaults"); - if let Some(setting) = setting_value - .load_setting(&default_settings, &user_values_stack, cx) - .log_err() - { - setting_value.set_global_value(setting); - } + if let Some(setting) = setting_value + .load_setting(&default_settings, &user_values_stack, cx) + .log_err() + { + setting_value.set_global_value(setting); } } From 23bc11f8b3d6c7c7ec1448cf801071258a66e812 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 20 Jun 2023 18:51:37 -0600 Subject: [PATCH 063/215] Remove the nested Pane from the assistant Since we don't want tabs, I think it would be better to render the toolbar for ourselves directly and handle switching between conversations. Co-Authored-By: Julia Risley --- Cargo.lock | 1 + assets/keymaps/default.json | 6 +- assets/settings/default.json | 54 ++-- crates/ai/Cargo.toml | 1 + crates/ai/src/assistant.rs | 289 ++++++++++----------- crates/project_panel/src/project_panel.rs | 1 + crates/terminal_view/src/terminal_panel.rs | 1 + crates/workspace/src/dock.rs | 3 +- crates/workspace/src/workspace.rs | 10 +- 9 files changed, 189 insertions(+), 177 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cdabeb26ec..3ba305b2cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,6 +109,7 @@ dependencies = [ "isahc", "language", "menu", + "project", "regex", "schemars", "search", diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index cce8b07d17..3d51c07856 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -40,7 +40,8 @@ "cmd-o": "workspace::Open", "alt-cmd-o": "projects::OpenRecent", "ctrl-~": "workspace::NewTerminal", - "ctrl-`": "terminal_panel::ToggleFocus" + "ctrl-`": "terminal_panel::ToggleFocus", + "shift-escape": "workspace::ToggleZoom" } }, { @@ -235,8 +236,7 @@ "cmd-shift-g": "search::SelectPrevMatch", "alt-cmd-c": "search::ToggleCaseSensitive", "alt-cmd-w": "search::ToggleWholeWord", - "alt-cmd-r": "search::ToggleRegex", - "shift-escape": "workspace::ToggleZoom" + "alt-cmd-r": "search::ToggleRegex" } }, // Bindings from VS Code diff --git a/assets/settings/default.json b/assets/settings/default.json index bd73bcbf08..c570660f38 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -57,37 +57,37 @@ "show_whitespaces": "selection", // Scrollbar related settings "scrollbar": { - // When to show the scrollbar in the editor. - // This setting can take four values: - // - // 1. Show the scrollbar if there's important information or - // follow the system's configured behavior (default): - // "auto" - // 2. Match the system's configured behavior: - // "system" - // 3. Always show the scrollbar: - // "always" - // 4. Never show the scrollbar: - // "never" - "show": "auto", - // Whether to show git diff indicators in the scrollbar. - "git_diff": true + // When to show the scrollbar in the editor. + // This setting can take four values: + // + // 1. Show the scrollbar if there's important information or + // follow the system's configured behavior (default): + // "auto" + // 2. Match the system's configured behavior: + // "system" + // 3. Always show the scrollbar: + // "always" + // 4. Never show the scrollbar: + // "never" + "show": "auto", + // Whether to show git diff indicators in the scrollbar. + "git_diff": true }, "project_panel": { - // Whether to show the git status in the project panel. - "git_status": true, - // Where to dock project panel. Can be 'left' or 'right'. - "dock": "left", - // Default width of the project panel. - "default_width": 240 + // Whether to show the git status in the project panel. + "git_status": true, + // Where to dock project panel. Can be 'left' or 'right'. + "dock": "left", + // Default width of the project panel. + "default_width": 240 }, "assistant": { - // Where to dock the assistant. Can be 'left', 'right' or 'bottom'. - "dock": "right", - // Default width when the assistant is docked to the left or right. - "default_width": 450, - // Default height when the assistant is docked to the bottom. - "default_height": 320 + // Where to dock the assistant. Can be 'left', 'right' or 'bottom'. + "dock": "right", + // Default width when the assistant is docked to the left or right. + "default_width": 450, + // Default height when the assistant is docked to the bottom. + "default_height": 320 }, // Whether the screen sharing icon is shown in the os status bar. "show_call_status_icon": true, diff --git a/crates/ai/Cargo.toml b/crates/ai/Cargo.toml index 76aaf41017..785bc657cf 100644 --- a/crates/ai/Cargo.toml +++ b/crates/ai/Cargo.toml @@ -34,3 +34,4 @@ tiktoken-rs = "0.4" [dev-dependencies] editor = { path = "../editor", features = ["test-support"] } +project = { path = "../project", features = ["test-support"] } diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index f7929006c6..eff3b7b5b4 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -37,7 +37,7 @@ use util::{ use workspace::{ dock::{DockPosition, Panel}, item::Item, - pane, Pane, Save, Workspace, + Save, Workspace, }; const OPENAI_API_URL: &'static str = "https://api.openai.com/v1"; @@ -66,21 +66,24 @@ pub fn init(cx: &mut AppContext) { cx.add_action( |workspace: &mut Workspace, _: &NewContext, cx: &mut ViewContext| { if let Some(this) = workspace.panel::(cx) { - this.update(cx, |this, cx| this.add_context(cx)) + this.update(cx, |this, cx| { + this.add_conversation(cx); + }) } workspace.focus_panel::(cx); }, ); - cx.add_action(AssistantEditor::assist); - cx.capture_action(AssistantEditor::cancel_last_assist); - cx.capture_action(AssistantEditor::save); - cx.add_action(AssistantEditor::quote_selection); - cx.capture_action(AssistantEditor::copy); - cx.capture_action(AssistantEditor::split); - cx.capture_action(AssistantEditor::cycle_message_role); + cx.add_action(ConversationEditor::assist); + cx.capture_action(ConversationEditor::cancel_last_assist); + cx.capture_action(ConversationEditor::save); + cx.add_action(ConversationEditor::quote_selection); + cx.capture_action(ConversationEditor::copy); + cx.capture_action(ConversationEditor::split); + cx.capture_action(ConversationEditor::cycle_message_role); cx.add_action(AssistantPanel::save_api_key); cx.add_action(AssistantPanel::reset_api_key); + cx.add_action(AssistantPanel::toggle_zoom); cx.add_action( |workspace: &mut Workspace, _: &ToggleFocus, cx: &mut ViewContext| { workspace.toggle_panel_focus::(cx); @@ -88,6 +91,7 @@ pub fn init(cx: &mut AppContext) { ); } +#[derive(Debug)] pub enum AssistantPanelEvent { ZoomIn, ZoomOut, @@ -99,14 +103,17 @@ pub enum AssistantPanelEvent { pub struct AssistantPanel { width: Option, height: Option, - pane: ViewHandle, + active_conversation_index: usize, + conversation_editors: Vec>, + saved_conversations: Vec, + zoomed: bool, + has_focus: bool, api_key: Rc>>, api_key_editor: Option>, has_read_credentials: bool, languages: Arc, fs: Arc, subscriptions: Vec, - saved_conversations: Vec, _watch_saved_conversations: Task>, } @@ -125,61 +132,6 @@ impl AssistantPanel { // TODO: deserialize state. workspace.update(&mut cx, |workspace, cx| { cx.add_view::(|cx| { - let weak_self = cx.weak_handle(); - let pane = cx.add_view(|cx| { - let mut pane = Pane::new( - workspace.weak_handle(), - workspace.project().clone(), - workspace.app_state().background_actions, - Default::default(), - cx, - ); - pane.set_can_split(false, cx); - pane.set_can_navigate(false, cx); - pane.on_can_drop(move |_, _| false); - pane.set_render_tab_bar_buttons(cx, move |pane, cx| { - let weak_self = weak_self.clone(); - Flex::row() - .with_child(Pane::render_tab_bar_button( - 0, - "icons/plus_12.svg", - false, - Some(("New Context".into(), Some(Box::new(NewContext)))), - cx, - move |_, cx| { - let weak_self = weak_self.clone(); - cx.window_context().defer(move |cx| { - if let Some(this) = weak_self.upgrade(cx) { - this.update(cx, |this, cx| this.add_context(cx)); - } - }) - }, - None, - )) - .with_child(Pane::render_tab_bar_button( - 1, - if pane.is_zoomed() { - "icons/minimize_8.svg" - } else { - "icons/maximize_8.svg" - }, - pane.is_zoomed(), - Some(( - "Toggle Zoom".into(), - Some(Box::new(workspace::ToggleZoom)), - )), - cx, - move |pane, cx| pane.toggle_zoom(&Default::default(), cx), - None, - )) - .into_any() - }); - let buffer_search_bar = cx.add_view(search::BufferSearchBar::new); - pane.toolbar() - .update(cx, |toolbar, cx| toolbar.add_item(buffer_search_bar, cx)); - pane - }); - const CONVERSATION_WATCH_DURATION: Duration = Duration::from_millis(100); let _watch_saved_conversations = cx.spawn(move |this, mut cx| async move { let mut events = fs @@ -200,7 +152,11 @@ impl AssistantPanel { }); let mut this = Self { - pane, + active_conversation_index: 0, + conversation_editors: Default::default(), + saved_conversations, + zoomed: false, + has_focus: false, api_key: Rc::new(RefCell::new(None)), api_key_editor: None, has_read_credentials: false, @@ -209,22 +165,18 @@ impl AssistantPanel { width: None, height: None, subscriptions: Default::default(), - saved_conversations, _watch_saved_conversations, }; let mut old_dock_position = this.position(cx); - this.subscriptions = vec![ - cx.observe(&this.pane, |_, _, cx| cx.notify()), - cx.subscribe(&this.pane, Self::handle_pane_event), - cx.observe_global::(move |this, cx| { + this.subscriptions = + vec![cx.observe_global::(move |this, cx| { let new_dock_position = this.position(cx); if new_dock_position != old_dock_position { old_dock_position = new_dock_position; cx.emit(AssistantPanelEvent::DockPositionChanged); } - }), - ]; + })]; this }) @@ -232,25 +184,14 @@ impl AssistantPanel { }) } - fn handle_pane_event( - &mut self, - _pane: ViewHandle, - event: &pane::Event, - cx: &mut ViewContext, - ) { - match event { - pane::Event::ZoomIn => cx.emit(AssistantPanelEvent::ZoomIn), - pane::Event::ZoomOut => cx.emit(AssistantPanelEvent::ZoomOut), - pane::Event::Focus => cx.emit(AssistantPanelEvent::Focus), - pane::Event::Remove => cx.emit(AssistantPanelEvent::Close), - _ => {} - } - } - - fn add_context(&mut self, cx: &mut ViewContext) { + fn add_conversation(&mut self, cx: &mut ViewContext) -> ViewHandle { let focus = self.has_focus(cx); let editor = cx.add_view(|cx| { - AssistantEditor::new( + if focus { + cx.focus_self(); + } + + ConversationEditor::new( self.api_key.clone(), self.languages.clone(), self.fs.clone(), @@ -258,20 +199,23 @@ impl AssistantPanel { ) }); self.subscriptions - .push(cx.subscribe(&editor, Self::handle_assistant_editor_event)); - self.pane.update(cx, |pane, cx| { - pane.add_item(Box::new(editor), true, focus, None, cx) - }); + .push(cx.subscribe(&editor, Self::handle_conversation_editor_event)); + + self.active_conversation_index = self.conversation_editors.len(); + self.conversation_editors.push(editor.clone()); + + cx.notify(); + editor } - fn handle_assistant_editor_event( + fn handle_conversation_editor_event( &mut self, - _: ViewHandle, + _: ViewHandle, event: &AssistantEditorEvent, cx: &mut ViewContext, ) { match event { - AssistantEditorEvent::TabContentChanged => self.pane.update(cx, |_, cx| cx.notify()), + AssistantEditorEvent::TabContentChanged => cx.notify(), } } @@ -302,6 +246,19 @@ impl AssistantPanel { cx.focus_self(); cx.notify(); } + + fn toggle_zoom(&mut self, _: &workspace::ToggleZoom, cx: &mut ViewContext) { + if self.zoomed { + cx.emit(AssistantPanelEvent::ZoomOut) + } else { + cx.emit(AssistantPanelEvent::ZoomIn) + } + } + + fn active_conversation_editor(&self) -> Option<&ViewHandle> { + self.conversation_editors + .get(self.active_conversation_index) + } } fn build_api_key_editor(cx: &mut ViewContext) -> ViewHandle { @@ -345,20 +302,27 @@ impl View for AssistantPanel { .with_style(style.api_key_prompt.container) .aligned() .into_any() + } else if let Some(editor) = self.active_conversation_editor() { + ChildView::new(editor, cx).into_any() } else { - ChildView::new(&self.pane, cx).into_any() + Empty::new().into_any() } } fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext) { + self.has_focus = true; if cx.is_self_focused() { - if let Some(api_key_editor) = self.api_key_editor.as_ref() { + if let Some(editor) = self.active_conversation_editor() { + cx.focus(editor); + } else if let Some(api_key_editor) = self.api_key_editor.as_ref() { cx.focus(api_key_editor); - } else { - cx.focus(&self.pane); } } } + + fn focus_out(&mut self, _: gpui::AnyViewHandle, _: &mut ViewContext) { + self.has_focus = false; + } } impl Panel for AssistantPanel { @@ -411,12 +375,13 @@ impl Panel for AssistantPanel { matches!(event, AssistantPanelEvent::ZoomOut) } - fn is_zoomed(&self, cx: &WindowContext) -> bool { - self.pane.read(cx).is_zoomed() + fn is_zoomed(&self, _: &WindowContext) -> bool { + self.zoomed } fn set_zoomed(&mut self, zoomed: bool, cx: &mut ViewContext) { - self.pane.update(cx, |pane, cx| pane.set_zoomed(zoomed, cx)); + self.zoomed = zoomed; + cx.notify(); } fn set_active(&mut self, active: bool, cx: &mut ViewContext) { @@ -443,8 +408,8 @@ impl Panel for AssistantPanel { } } - if self.pane.read(cx).items_len() == 0 { - self.add_context(cx); + if self.conversation_editors.is_empty() { + self.add_conversation(cx); } } } @@ -469,12 +434,8 @@ impl Panel for AssistantPanel { matches!(event, AssistantPanelEvent::Close) } - fn has_focus(&self, cx: &WindowContext) -> bool { - self.pane.read(cx).has_focus() - || self - .api_key_editor - .as_ref() - .map_or(false, |editor| editor.is_focused(cx)) + fn has_focus(&self, _: &WindowContext) -> bool { + self.has_focus } fn is_focus_event(event: &Self::Event) -> bool { @@ -494,7 +455,7 @@ struct Summary { done: bool, } -struct Assistant { +struct Conversation { buffer: ModelHandle, message_anchors: Vec, messages_metadata: HashMap, @@ -513,11 +474,11 @@ struct Assistant { _subscriptions: Vec, } -impl Entity for Assistant { +impl Entity for Conversation { type Event = AssistantEvent; } -impl Assistant { +impl Conversation { fn new( api_key: Rc>>, language_registry: Arc, @@ -1080,7 +1041,7 @@ impl Assistant { &mut self, debounce: Option, fs: Arc, - cx: &mut ModelContext, + cx: &mut ModelContext, ) { self.pending_save = cx.spawn(|this, mut cx| async move { if let Some(debounce) = debounce { @@ -1158,8 +1119,8 @@ struct ScrollPosition { cursor: Anchor, } -struct AssistantEditor { - assistant: ModelHandle, +struct ConversationEditor { + assistant: ModelHandle, fs: Arc, editor: ViewHandle, blocks: HashSet, @@ -1167,14 +1128,14 @@ struct AssistantEditor { _subscriptions: Vec, } -impl AssistantEditor { +impl ConversationEditor { fn new( api_key: Rc>>, language_registry: Arc, fs: Arc, cx: &mut ViewContext, ) -> Self { - let assistant = cx.add_model(|cx| Assistant::new(api_key, language_registry, cx)); + let assistant = cx.add_model(|cx| Conversation::new(api_key, language_registry, cx)); let editor = cx.add_view(|cx| { let mut editor = Editor::for_buffer(assistant.read(cx).buffer.clone(), None, cx); editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx); @@ -1262,7 +1223,7 @@ impl AssistantEditor { fn handle_assistant_event( &mut self, - _: ModelHandle, + _: ModelHandle, event: &AssistantEvent, cx: &mut ViewContext, ) { @@ -1501,20 +1462,15 @@ impl AssistantEditor { if let Some(text) = text { panel.update(cx, |panel, cx| { - if let Some(assistant) = panel - .pane - .read(cx) - .active_item() - .and_then(|item| item.downcast::()) - .ok_or_else(|| anyhow!("no active context")) - .log_err() - { - assistant.update(cx, |assistant, cx| { - assistant - .editor - .update(cx, |editor, cx| editor.insert(&text, cx)) - }); - } + let editor = panel + .active_conversation_editor() + .cloned() + .unwrap_or_else(|| panel.add_conversation(cx)); + editor.update(cx, |assistant, cx| { + assistant + .editor + .update(cx, |editor, cx| editor.insert(&text, cx)) + }); }); } } @@ -1592,11 +1548,11 @@ impl AssistantEditor { } } -impl Entity for AssistantEditor { +impl Entity for ConversationEditor { type Event = AssistantEditorEvent; } -impl View for AssistantEditor { +impl View for ConversationEditor { fn ui_name() -> &'static str { "AssistantEditor" } @@ -1655,7 +1611,7 @@ impl View for AssistantEditor { } } -impl Item for AssistantEditor { +impl Item for ConversationEditor { fn tab_content( &self, _: Option, @@ -1812,12 +1768,55 @@ async fn stream_completion( #[cfg(test)] mod tests { use super::*; - use gpui::AppContext; + use fs::FakeFs; + use gpui::{AppContext, TestAppContext}; + use project::Project; + + fn init_test(cx: &mut TestAppContext) { + cx.foreground().forbid_parking(); + cx.update(|cx| { + cx.set_global(SettingsStore::test(cx)); + theme::init((), cx); + language::init(cx); + editor::init_settings(cx); + crate::init(cx); + workspace::init_settings(cx); + Project::init_settings(cx); + }); + } + + #[gpui::test] + async fn test_panel(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.background()); + let project = Project::test(fs, [], cx).await; + let (window_id, workspace) = cx.add_window(|cx| Workspace::test_new(project.clone(), cx)); + let weak_workspace = workspace.downgrade(); + + let panel = cx + .spawn(|cx| async move { AssistantPanel::load(weak_workspace, cx).await }) + .await + .unwrap(); + + workspace.update(cx, |workspace, cx| { + workspace.add_panel(panel.clone(), cx); + workspace.toggle_dock(DockPosition::Right, cx); + assert!(workspace.right_dock().read(cx).is_open()); + cx.focus(&panel); + }); + + cx.dispatch_action(window_id, workspace::ToggleZoom); + + workspace.read_with(cx, |workspace, cx| { + assert_eq!(workspace.zoomed_view(cx).unwrap(), panel); + }) + } #[gpui::test] fn test_inserting_and_removing_messages(cx: &mut AppContext) { let registry = Arc::new(LanguageRegistry::test()); - let assistant = cx.add_model(|cx| Assistant::new(Default::default(), registry, cx)); + let assistant = cx.add_model(|cx| Conversation::new(Default::default(), registry, cx)); let buffer = assistant.read(cx).buffer.clone(); let message_1 = assistant.read(cx).message_anchors[0].clone(); @@ -1943,7 +1942,7 @@ mod tests { #[gpui::test] fn test_message_splitting(cx: &mut AppContext) { let registry = Arc::new(LanguageRegistry::test()); - let assistant = cx.add_model(|cx| Assistant::new(Default::default(), registry, cx)); + let assistant = cx.add_model(|cx| Conversation::new(Default::default(), registry, cx)); let buffer = assistant.read(cx).buffer.clone(); let message_1 = assistant.read(cx).message_anchors[0].clone(); @@ -2036,7 +2035,7 @@ mod tests { #[gpui::test] fn test_messages_for_offsets(cx: &mut AppContext) { let registry = Arc::new(LanguageRegistry::test()); - let assistant = cx.add_model(|cx| Assistant::new(Default::default(), registry, cx)); + let assistant = cx.add_model(|cx| Conversation::new(Default::default(), registry, cx)); let buffer = assistant.read(cx).buffer.clone(); let message_1 = assistant.read(cx).message_anchors[0].clone(); @@ -2080,7 +2079,7 @@ mod tests { ); fn message_ids_for_offsets( - assistant: &ModelHandle, + assistant: &ModelHandle, offsets: &[usize], cx: &AppContext, ) -> Vec { @@ -2094,7 +2093,7 @@ mod tests { } fn messages( - assistant: &ModelHandle, + assistant: &ModelHandle, cx: &AppContext, ) -> Vec<(MessageId, Role, Range)> { assistant diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 9563d54be8..c8781c195c 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -153,6 +153,7 @@ pub fn init(cx: &mut AppContext) { ); } +#[derive(Debug)] pub enum Event { OpenedEntry { entry_id: ProjectEntryId, diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index ac3875af9e..6de6527a26 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -25,6 +25,7 @@ pub fn init(cx: &mut AppContext) { cx.add_action(TerminalPanel::new_terminal); } +#[derive(Debug)] pub enum Event { Close, DockPositionChanged, diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index c174b8d3a5..8ced21a809 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -249,7 +249,7 @@ impl Dock { } } - pub fn add_panel(&mut self, panel: ViewHandle, cx: &mut ViewContext) { + pub(crate) fn add_panel(&mut self, panel: ViewHandle, cx: &mut ViewContext) { let subscriptions = [ cx.observe(&panel, |_, _, cx| cx.notify()), cx.subscribe(&panel, |this, panel, event, cx| { @@ -603,6 +603,7 @@ pub mod test { use super::*; use gpui::{ViewContext, WindowContext}; + #[derive(Debug)] pub enum TestPanelEvent { PositionChanged, Activated, diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 43ca41ab1d..d93dae2d13 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -859,7 +859,10 @@ impl Workspace { &self.right_dock } - pub fn add_panel(&mut self, panel: ViewHandle, cx: &mut ViewContext) { + pub fn add_panel(&mut self, panel: ViewHandle, cx: &mut ViewContext) + where + T::Event: std::fmt::Debug, + { let dock = match panel.position(cx) { DockPosition::Left => &self.left_dock, DockPosition::Bottom => &self.bottom_dock, @@ -1700,6 +1703,11 @@ impl Workspace { cx.notify(); } + #[cfg(any(test, feature = "test-support"))] + pub fn zoomed_view(&self, cx: &AppContext) -> Option { + self.zoomed.and_then(|view| view.upgrade(cx)) + } + fn dismiss_zoomed_items_to_reveal( &mut self, dock_to_reveal: Option, From 3a61fd503f2a5c77635b57526270f2212771ce07 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 20 Jun 2023 20:11:32 -0600 Subject: [PATCH 064/215] WIP: Trying to display the toolbar but tired. May be worth discarding this. --- assets/icons/hamburger_15.svg | 3 +++ crates/ai/src/assistant.rs | 28 ++++++++++++++++++++--- crates/gpui/src/elements/svg.rs | 37 ++++++++++++++++++++++++++----- crates/theme/src/theme.rs | 7 +++--- crates/theme/src/ui.rs | 30 +++++-------------------- styles/src/styleTree/assistant.ts | 13 ++++++++++- 6 files changed, 80 insertions(+), 38 deletions(-) create mode 100644 assets/icons/hamburger_15.svg diff --git a/assets/icons/hamburger_15.svg b/assets/icons/hamburger_15.svg new file mode 100644 index 0000000000..060caeecbf --- /dev/null +++ b/assets/icons/hamburger_15.svg @@ -0,0 +1,3 @@ + + + diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index eff3b7b5b4..dac3d8dda0 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -30,6 +30,7 @@ use std::{ borrow::Cow, cell::RefCell, cmp, env, fmt::Write, io, iter, ops::Range, path::PathBuf, rc::Rc, sync::Arc, time::Duration, }; +use theme::{ui::IconStyle, IconButton, Theme}; use util::{ channel::ReleaseChannel, paths::CONVERSATIONS_DIR, post_inc, truncate_and_trailoff, ResultExt, TryFutureExt, @@ -259,6 +260,16 @@ impl AssistantPanel { self.conversation_editors .get(self.active_conversation_index) } + + fn render_hamburger_button( + &self, + style: &IconStyle, + cx: &ViewContext, + ) -> impl Element { + Svg::for_style(style.icon.clone()) + .contained() + .with_style(style.container) + } } fn build_api_key_editor(cx: &mut ViewContext) -> ViewHandle { @@ -282,7 +293,8 @@ impl View for AssistantPanel { } fn render(&mut self, cx: &mut ViewContext) -> AnyElement { - let style = &theme::current(cx).assistant; + let theme = &theme::current(cx); + let style = &theme.assistant; if let Some(api_key_editor) = self.api_key_editor.as_ref() { Flex::column() .with_child( @@ -303,7 +315,17 @@ impl View for AssistantPanel { .aligned() .into_any() } else if let Some(editor) = self.active_conversation_editor() { - ChildView::new(editor, cx).into_any() + Flex::column() + .with_child( + Flex::row() + .with_child(self.render_hamburger_button(&style.hamburger_button, cx)) + .contained() + .with_style(theme.workspace.tab_bar.container) + .constrained() + .with_height(theme.workspace.tab_bar.height), + ) + .with_child(ChildView::new(editor, cx).flex(1., true)) + .into_any() } else { Empty::new().into_any() } @@ -1401,7 +1423,7 @@ impl ConversationEditor { .aligned() .left() .contained() - .with_style(style.header) + .with_style(style.message_header) .into_any() } }), diff --git a/crates/gpui/src/elements/svg.rs b/crates/gpui/src/elements/svg.rs index 5444221322..a6b4fab980 100644 --- a/crates/gpui/src/elements/svg.rs +++ b/crates/gpui/src/elements/svg.rs @@ -1,7 +1,5 @@ -use std::{borrow::Cow, ops::Range}; - -use serde_json::json; - +use super::constrain_size_preserving_aspect_ratio; +use crate::json::ToJson; use crate::{ color::Color, geometry::{ @@ -10,6 +8,9 @@ use crate::{ }, scene, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext, }; +use serde_derive::Deserialize; +use serde_json::json; +use std::{borrow::Cow, ops::Range}; pub struct Svg { path: Cow<'static, str>, @@ -24,6 +25,15 @@ impl Svg { } } + pub fn for_style(style: SvgStyle) -> impl Element { + Self::new(style.asset) + .with_color(style.color) + .constrained() + .constrained() + .with_width(style.dimensions.width) + .with_height(style.dimensions.height) + } + pub fn with_color(mut self, color: Color) -> Self { self.color = color; self @@ -105,9 +115,24 @@ impl Element for Svg { } } -use crate::json::ToJson; +#[derive(Clone, Deserialize, Default)] +pub struct SvgStyle { + pub color: Color, + pub asset: String, + pub dimensions: Dimensions, +} -use super::constrain_size_preserving_aspect_ratio; +#[derive(Clone, Deserialize, Default)] +pub struct Dimensions { + pub width: f32, + pub height: f32, +} + +impl Dimensions { + pub fn to_vec(&self) -> Vector2F { + vec2f(self.width, self.height) + } +} fn from_usvg_rect(rect: usvg::Rect) -> RectF { RectF::new( diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index c7563ec87a..38e66cbb4c 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -4,7 +4,7 @@ pub mod ui; use gpui::{ color::Color, - elements::{ContainerStyle, ImageStyle, LabelStyle, Shadow, TooltipStyle}, + elements::{ContainerStyle, ImageStyle, LabelStyle, Shadow, SvgStyle, TooltipStyle}, fonts::{HighlightStyle, TextStyle}, platform, AppContext, AssetSource, Border, MouseState, }; @@ -12,7 +12,7 @@ use serde::{de::DeserializeOwned, Deserialize}; use serde_json::Value; use settings::SettingsStore; use std::{collections::HashMap, sync::Arc}; -use ui::{ButtonStyle, CheckboxStyle, IconStyle, ModalStyle, SvgStyle}; +use ui::{ButtonStyle, CheckboxStyle, IconStyle, ModalStyle}; pub use theme_registry::*; pub use theme_settings::*; @@ -994,7 +994,8 @@ pub struct TerminalStyle { #[derive(Clone, Deserialize, Default)] pub struct AssistantStyle { pub container: ContainerStyle, - pub header: ContainerStyle, + pub hamburger_button: IconStyle, + pub message_header: ContainerStyle, pub sent_at: ContainedText, pub user_sender: Interactive, pub assistant_sender: Interactive, diff --git a/crates/theme/src/ui.rs b/crates/theme/src/ui.rs index b86bfca8c4..058123e53d 100644 --- a/crates/theme/src/ui.rs +++ b/crates/theme/src/ui.rs @@ -1,13 +1,12 @@ use std::borrow::Cow; use gpui::{ - color::Color, elements::{ - ConstrainedBox, Container, ContainerStyle, Empty, Flex, KeystrokeLabel, Label, - MouseEventHandler, ParentElement, Stack, Svg, + ConstrainedBox, Container, ContainerStyle, Dimensions, Empty, Flex, KeystrokeLabel, Label, + MouseEventHandler, ParentElement, Stack, Svg, SvgStyle, }, fonts::TextStyle, - geometry::vector::{vec2f, Vector2F}, + geometry::vector::Vector2F, platform, platform::MouseButton, scene::MouseClick, @@ -93,25 +92,6 @@ where .with_cursor_style(platform::CursorStyle::PointingHand) } -#[derive(Clone, Deserialize, Default)] -pub struct SvgStyle { - pub color: Color, - pub asset: String, - pub dimensions: Dimensions, -} - -#[derive(Clone, Deserialize, Default)] -pub struct Dimensions { - pub width: f32, - pub height: f32, -} - -impl Dimensions { - pub fn to_vec(&self) -> Vector2F { - vec2f(self.width, self.height) - } -} - pub fn svg(style: &SvgStyle) -> ConstrainedBox { Svg::new(style.asset.clone()) .with_color(style.color) @@ -122,8 +102,8 @@ pub fn svg(style: &SvgStyle) -> ConstrainedBox { #[derive(Clone, Deserialize, Default)] pub struct IconStyle { - icon: SvgStyle, - container: ContainerStyle, + pub icon: SvgStyle, + pub container: ContainerStyle, } pub fn icon(style: &IconStyle) -> Container { diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index bbb4aae5e1..0f294dcc51 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -9,11 +9,22 @@ export default function assistant(colorScheme: ColorScheme) { background: editor(colorScheme).background, padding: { left: 12 }, }, - header: { + messageHeader: { border: border(layer, "default", { bottom: true, top: true }), margin: { bottom: 6, top: 6 }, background: editor(colorScheme).background, }, + hamburgerButton: { + icon: { + color: text(layer, "sans", "default", { size: "sm" }).color, + asset: "icons/hamburger.svg", + dimensions: { + width: 15, + height: 15, + }, + }, + container: {} + }, userSender: { ...text(layer, "sans", "default", { size: "sm", weight: "bold" }), }, From 0932149c48083e90c13c867b3a33cfc009a23cce Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 20 Jun 2023 20:21:43 -0600 Subject: [PATCH 065/215] Fix filename --- styles/src/styleTree/assistant.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index 0f294dcc51..13ef484391 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -17,7 +17,7 @@ export default function assistant(colorScheme: ColorScheme) { hamburgerButton: { icon: { color: text(layer, "sans", "default", { size: "sm" }).color, - asset: "icons/hamburger.svg", + asset: "icons/hamburger_15.svg", dimensions: { width: 15, height: 15, From 9217224fa6c7a0fbe5dc5c51990f8ed6addea3f6 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 21 Jun 2023 08:54:38 +0200 Subject: [PATCH 066/215] Finish renaming `AssistantEditor` to `ConversationEditor` --- assets/keymaps/default.json | 2 +- crates/ai/src/assistant.rs | 237 ++++++++++++++++++------------------ 2 files changed, 120 insertions(+), 119 deletions(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index 3d51c07856..444d1f9ed7 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -198,7 +198,7 @@ } }, { - "context": "AssistantEditor > Editor", + "context": "ConversationEditor > Editor", "bindings": { "cmd-enter": "assistant::Assist", "cmd-s": "workspace::Save", diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index dac3d8dda0..785725ceaa 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -212,11 +212,11 @@ impl AssistantPanel { fn handle_conversation_editor_event( &mut self, _: ViewHandle, - event: &AssistantEditorEvent, + event: &ConversationEditorEvent, cx: &mut ViewContext, ) { match event { - AssistantEditorEvent::TabContentChanged => cx.notify(), + ConversationEditorEvent::TabContentChanged => cx.notify(), } } @@ -465,7 +465,7 @@ impl Panel for AssistantPanel { } } -enum AssistantEvent { +enum ConversationEvent { MessagesEdited, SummaryChanged, StreamedCompletion, @@ -497,7 +497,7 @@ struct Conversation { } impl Entity for Conversation { - type Event = AssistantEvent; + type Event = ConversationEvent; } impl Conversation { @@ -570,7 +570,7 @@ impl Conversation { match event { language::Event::Edited => { self.count_remaining_tokens(cx); - cx.emit(AssistantEvent::MessagesEdited); + cx.emit(ConversationEvent::MessagesEdited); } _ => {} } @@ -602,7 +602,7 @@ impl Conversation { .await?; this.upgrade(&cx) - .ok_or_else(|| anyhow!("assistant was dropped"))? + .ok_or_else(|| anyhow!("conversation was dropped"))? .update(&mut cx, |this, cx| { this.max_token_count = tiktoken_rs::model::get_context_size(&this.model); this.token_count = Some(token_count); @@ -703,7 +703,7 @@ impl Conversation { let mut message = message?; if let Some(choice) = message.choices.pop() { this.upgrade(&cx) - .ok_or_else(|| anyhow!("assistant was dropped"))? + .ok_or_else(|| anyhow!("conversation was dropped"))? .update(&mut cx, |this, cx| { let text: Arc = choice.delta.content?.into(); let message_ix = this.message_anchors.iter().position( @@ -721,7 +721,7 @@ impl Conversation { }); buffer.edit([(offset..offset, text)], None, cx); }); - cx.emit(AssistantEvent::StreamedCompletion); + cx.emit(ConversationEvent::StreamedCompletion); Some(()) }); @@ -730,7 +730,7 @@ impl Conversation { } this.upgrade(&cx) - .ok_or_else(|| anyhow!("assistant was dropped"))? + .ok_or_else(|| anyhow!("conversation was dropped"))? .update(&mut cx, |this, cx| { this.pending_completions.retain(|completion| { completion.id != this.completion_count @@ -784,7 +784,7 @@ impl Conversation { for id in ids { if let Some(metadata) = self.messages_metadata.get_mut(&id) { metadata.role.cycle(); - cx.emit(AssistantEvent::MessagesEdited); + cx.emit(ConversationEvent::MessagesEdited); cx.notify(); } } @@ -824,7 +824,7 @@ impl Conversation { status, }, ); - cx.emit(AssistantEvent::MessagesEdited); + cx.emit(ConversationEvent::MessagesEdited); Some(message) } else { None @@ -899,7 +899,7 @@ impl Conversation { } let selection = if let Some(prefix_end) = prefix_end { - cx.emit(AssistantEvent::MessagesEdited); + cx.emit(ConversationEvent::MessagesEdited); MessageAnchor { id: MessageId(post_inc(&mut self.next_message_id.0)), start: self.buffer.read(cx).anchor_before(prefix_end), @@ -929,7 +929,7 @@ impl Conversation { }; if !edited_buffer { - cx.emit(AssistantEvent::MessagesEdited); + cx.emit(ConversationEvent::MessagesEdited); } new_messages } else { @@ -971,7 +971,7 @@ impl Conversation { .get_or_insert(Default::default()) .text .push_str(&text); - cx.emit(AssistantEvent::SummaryChanged); + cx.emit(ConversationEvent::SummaryChanged); }); } } @@ -979,7 +979,7 @@ impl Conversation { this.update(&mut cx, |this, cx| { if let Some(summary) = this.summary.as_mut() { summary.done = true; - cx.emit(AssistantEvent::SummaryChanged); + cx.emit(ConversationEvent::SummaryChanged); } }); @@ -1131,7 +1131,7 @@ struct PendingCompletion { _tasks: Vec>, } -enum AssistantEditorEvent { +enum ConversationEditorEvent { TabContentChanged, } @@ -1142,7 +1142,7 @@ struct ScrollPosition { } struct ConversationEditor { - assistant: ModelHandle, + conversation: ModelHandle, fs: Arc, editor: ViewHandle, blocks: HashSet, @@ -1157,22 +1157,22 @@ impl ConversationEditor { fs: Arc, cx: &mut ViewContext, ) -> Self { - let assistant = cx.add_model(|cx| Conversation::new(api_key, language_registry, cx)); + let conversation = cx.add_model(|cx| Conversation::new(api_key, language_registry, cx)); let editor = cx.add_view(|cx| { - let mut editor = Editor::for_buffer(assistant.read(cx).buffer.clone(), None, cx); + let mut editor = Editor::for_buffer(conversation.read(cx).buffer.clone(), None, cx); editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx); editor.set_show_gutter(false, cx); editor }); let _subscriptions = vec![ - cx.observe(&assistant, |_, _, cx| cx.notify()), - cx.subscribe(&assistant, Self::handle_assistant_event), + cx.observe(&conversation, |_, _, cx| cx.notify()), + cx.subscribe(&conversation, Self::handle_conversation_event), cx.subscribe(&editor, Self::handle_editor_event), ]; let mut this = Self { - assistant, + conversation, editor, blocks: Default::default(), scroll_position: None, @@ -1186,20 +1186,20 @@ impl ConversationEditor { fn assist(&mut self, _: &Assist, cx: &mut ViewContext) { let cursors = self.cursors(cx); - let user_messages = self.assistant.update(cx, |assistant, cx| { - let selected_messages = assistant + let user_messages = self.conversation.update(cx, |conversation, cx| { + let selected_messages = conversation .messages_for_offsets(cursors, cx) .into_iter() .map(|message| message.id) .collect(); - assistant.assist(selected_messages, cx) + conversation.assist(selected_messages, cx) }); let new_selections = user_messages .iter() .map(|message| { let cursor = message .start - .to_offset(self.assistant.read(cx).buffer.read(cx)); + .to_offset(self.conversation.read(cx).buffer.read(cx)); cursor..cursor }) .collect::>(); @@ -1216,8 +1216,8 @@ impl ConversationEditor { fn cancel_last_assist(&mut self, _: &editor::Cancel, cx: &mut ViewContext) { if !self - .assistant - .update(cx, |assistant, _| assistant.cancel_last_assist()) + .conversation + .update(cx, |conversation, _| conversation.cancel_last_assist()) { cx.propagate_action(); } @@ -1225,13 +1225,13 @@ impl ConversationEditor { fn cycle_message_role(&mut self, _: &CycleMessageRole, cx: &mut ViewContext) { let cursors = self.cursors(cx); - self.assistant.update(cx, |assistant, cx| { - let messages = assistant + self.conversation.update(cx, |conversation, cx| { + let messages = conversation .messages_for_offsets(cursors, cx) .into_iter() .map(|message| message.id) .collect(); - assistant.cycle_message_roles(messages, cx) + conversation.cycle_message_roles(messages, cx) }); } @@ -1243,26 +1243,26 @@ impl ConversationEditor { .collect() } - fn handle_assistant_event( + fn handle_conversation_event( &mut self, _: ModelHandle, - event: &AssistantEvent, + event: &ConversationEvent, cx: &mut ViewContext, ) { match event { - AssistantEvent::MessagesEdited => { + ConversationEvent::MessagesEdited => { self.update_message_headers(cx); - self.assistant.update(cx, |assistant, cx| { - assistant.save(Some(Duration::from_millis(500)), self.fs.clone(), cx); + self.conversation.update(cx, |conversation, cx| { + conversation.save(Some(Duration::from_millis(500)), self.fs.clone(), cx); }); } - AssistantEvent::SummaryChanged => { - cx.emit(AssistantEditorEvent::TabContentChanged); - self.assistant.update(cx, |assistant, cx| { - assistant.save(None, self.fs.clone(), cx); + ConversationEvent::SummaryChanged => { + cx.emit(ConversationEditorEvent::TabContentChanged); + self.conversation.update(cx, |conversation, cx| { + conversation.save(None, self.fs.clone(), cx); }); } - AssistantEvent::StreamedCompletion => { + ConversationEvent::StreamedCompletion => { self.editor.update(cx, |editor, cx| { if let Some(scroll_position) = self.scroll_position { let snapshot = editor.snapshot(cx); @@ -1332,7 +1332,7 @@ impl ConversationEditor { let excerpt_id = *buffer.as_singleton().unwrap().0; let old_blocks = std::mem::take(&mut self.blocks); let new_blocks = self - .assistant + .conversation .read(cx) .messages(cx) .map(|message| BlockProperties { @@ -1340,7 +1340,7 @@ impl ConversationEditor { height: 2, style: BlockStyle::Sticky, render: Arc::new({ - let assistant = self.assistant.clone(); + let conversation = self.conversation.clone(); // let metadata = message.metadata.clone(); // let message = message.clone(); move |cx| { @@ -1376,10 +1376,10 @@ impl ConversationEditor { ) .with_cursor_style(CursorStyle::PointingHand) .on_down(MouseButton::Left, { - let assistant = assistant.clone(); + let conversation = conversation.clone(); move |_, _, cx| { - assistant.update(cx, |assistant, cx| { - assistant.cycle_message_roles( + conversation.update(cx, |conversation, cx| { + conversation.cycle_message_roles( HashSet::from_iter(Some(message_id)), cx, ) @@ -1484,12 +1484,12 @@ impl ConversationEditor { if let Some(text) = text { panel.update(cx, |panel, cx| { - let editor = panel + let conversation = panel .active_conversation_editor() .cloned() .unwrap_or_else(|| panel.add_conversation(cx)); - editor.update(cx, |assistant, cx| { - assistant + conversation.update(cx, |conversation, cx| { + conversation .editor .update(cx, |editor, cx| editor.insert(&text, cx)) }); @@ -1499,12 +1499,12 @@ impl ConversationEditor { fn copy(&mut self, _: &editor::Copy, cx: &mut ViewContext) { let editor = self.editor.read(cx); - let assistant = self.assistant.read(cx); + let conversation = self.conversation.read(cx); if editor.selections.count() == 1 { let selection = editor.selections.newest::(cx); let mut copied_text = String::new(); let mut spanned_messages = 0; - for message in assistant.messages(cx) { + for message in conversation.messages(cx) { if message.range.start >= selection.range().end { break; } else if message.range.end >= selection.range().start { @@ -1513,7 +1513,7 @@ impl ConversationEditor { if !range.is_empty() { spanned_messages += 1; write!(&mut copied_text, "## {}\n\n", message.role).unwrap(); - for chunk in assistant.buffer.read(cx).text_for_range(range) { + for chunk in conversation.buffer.read(cx).text_for_range(range) { copied_text.push_str(&chunk); } copied_text.push('\n'); @@ -1532,36 +1532,36 @@ impl ConversationEditor { } fn split(&mut self, _: &Split, cx: &mut ViewContext) { - self.assistant.update(cx, |assistant, cx| { + self.conversation.update(cx, |conversation, cx| { let selections = self.editor.read(cx).selections.disjoint_anchors(); for selection in selections.into_iter() { let buffer = self.editor.read(cx).buffer().read(cx).snapshot(cx); let range = selection .map(|endpoint| endpoint.to_offset(&buffer)) .range(); - assistant.split_message(range, cx); + conversation.split_message(range, cx); } }); } fn save(&mut self, _: &Save, cx: &mut ViewContext) { - self.assistant.update(cx, |assistant, cx| { - assistant.save(None, self.fs.clone(), cx) + self.conversation.update(cx, |conversation, cx| { + conversation.save(None, self.fs.clone(), cx) }); } fn cycle_model(&mut self, cx: &mut ViewContext) { - self.assistant.update(cx, |assistant, cx| { - let new_model = match assistant.model.as_str() { + self.conversation.update(cx, |conversation, cx| { + let new_model = match conversation.model.as_str() { "gpt-4-0613" => "gpt-3.5-turbo-0613", _ => "gpt-4-0613", }; - assistant.set_model(new_model.into(), cx); + conversation.set_model(new_model.into(), cx); }); } fn title(&self, cx: &AppContext) -> String { - self.assistant + self.conversation .read(cx) .summary .as_ref() @@ -1571,20 +1571,20 @@ impl ConversationEditor { } impl Entity for ConversationEditor { - type Event = AssistantEditorEvent; + type Event = ConversationEditorEvent; } impl View for ConversationEditor { fn ui_name() -> &'static str { - "AssistantEditor" + "ConversationEditor" } fn render(&mut self, cx: &mut ViewContext) -> AnyElement { enum Model {} let theme = &theme::current(cx).assistant; - let assistant = &self.assistant.read(cx); - let model = assistant.model.clone(); - let remaining_tokens = assistant.remaining_tokens().map(|remaining_tokens| { + let conversation = self.conversation.read(cx); + let model = conversation.model.clone(); + let remaining_tokens = conversation.remaining_tokens().map(|remaining_tokens| { let remaining_tokens_style = if remaining_tokens <= 0 { &theme.no_remaining_tokens } else { @@ -1838,22 +1838,22 @@ mod tests { #[gpui::test] fn test_inserting_and_removing_messages(cx: &mut AppContext) { let registry = Arc::new(LanguageRegistry::test()); - let assistant = cx.add_model(|cx| Conversation::new(Default::default(), registry, cx)); - let buffer = assistant.read(cx).buffer.clone(); + let conversation = cx.add_model(|cx| Conversation::new(Default::default(), registry, cx)); + let buffer = conversation.read(cx).buffer.clone(); - let message_1 = assistant.read(cx).message_anchors[0].clone(); + let message_1 = conversation.read(cx).message_anchors[0].clone(); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![(message_1.id, Role::User, 0..0)] ); - let message_2 = assistant.update(cx, |assistant, cx| { - assistant + let message_2 = conversation.update(cx, |conversation, cx| { + conversation .insert_message_after(message_1.id, Role::Assistant, MessageStatus::Done, cx) .unwrap() }); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..1), (message_2.id, Role::Assistant, 1..1) @@ -1864,20 +1864,20 @@ mod tests { buffer.edit([(0..0, "1"), (1..1, "2")], None, cx) }); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..2), (message_2.id, Role::Assistant, 2..3) ] ); - let message_3 = assistant.update(cx, |assistant, cx| { - assistant + let message_3 = conversation.update(cx, |conversation, cx| { + conversation .insert_message_after(message_2.id, Role::User, MessageStatus::Done, cx) .unwrap() }); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..2), (message_2.id, Role::Assistant, 2..4), @@ -1885,13 +1885,13 @@ mod tests { ] ); - let message_4 = assistant.update(cx, |assistant, cx| { - assistant + let message_4 = conversation.update(cx, |conversation, cx| { + conversation .insert_message_after(message_2.id, Role::User, MessageStatus::Done, cx) .unwrap() }); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..2), (message_2.id, Role::Assistant, 2..4), @@ -1904,7 +1904,7 @@ mod tests { buffer.edit([(4..4, "C"), (5..5, "D")], None, cx) }); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..2), (message_2.id, Role::Assistant, 2..4), @@ -1916,7 +1916,7 @@ mod tests { // Deleting across message boundaries merges the messages. buffer.update(cx, |buffer, cx| buffer.edit([(1..4, "")], None, cx)); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..3), (message_3.id, Role::User, 3..4), @@ -1926,7 +1926,7 @@ mod tests { // Undoing the deletion should also undo the merge. buffer.update(cx, |buffer, cx| buffer.undo(cx)); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..2), (message_2.id, Role::Assistant, 2..4), @@ -1938,7 +1938,7 @@ mod tests { // Redoing the deletion should also redo the merge. buffer.update(cx, |buffer, cx| buffer.redo(cx)); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..3), (message_3.id, Role::User, 3..4), @@ -1946,13 +1946,13 @@ mod tests { ); // Ensure we can still insert after a merged message. - let message_5 = assistant.update(cx, |assistant, cx| { - assistant + let message_5 = conversation.update(cx, |conversation, cx| { + conversation .insert_message_after(message_1.id, Role::System, MessageStatus::Done, cx) .unwrap() }); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..3), (message_5.id, Role::System, 3..4), @@ -1964,12 +1964,12 @@ mod tests { #[gpui::test] fn test_message_splitting(cx: &mut AppContext) { let registry = Arc::new(LanguageRegistry::test()); - let assistant = cx.add_model(|cx| Conversation::new(Default::default(), registry, cx)); - let buffer = assistant.read(cx).buffer.clone(); + let conversation = cx.add_model(|cx| Conversation::new(Default::default(), registry, cx)); + let buffer = conversation.read(cx).buffer.clone(); - let message_1 = assistant.read(cx).message_anchors[0].clone(); + let message_1 = conversation.read(cx).message_anchors[0].clone(); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![(message_1.id, Role::User, 0..0)] ); @@ -1978,13 +1978,13 @@ mod tests { }); let (_, message_2) = - assistant.update(cx, |assistant, cx| assistant.split_message(3..3, cx)); + conversation.update(cx, |conversation, cx| conversation.split_message(3..3, cx)); let message_2 = message_2.unwrap(); // We recycle newlines in the middle of a split message assert_eq!(buffer.read(cx).text(), "aaa\nbbb\nccc\nddd\n"); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..4), (message_2.id, Role::User, 4..16), @@ -1992,13 +1992,13 @@ mod tests { ); let (_, message_3) = - assistant.update(cx, |assistant, cx| assistant.split_message(3..3, cx)); + conversation.update(cx, |conversation, cx| conversation.split_message(3..3, cx)); let message_3 = message_3.unwrap(); // We don't recycle newlines at the end of a split message assert_eq!(buffer.read(cx).text(), "aaa\n\nbbb\nccc\nddd\n"); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..4), (message_3.id, Role::User, 4..5), @@ -2007,11 +2007,11 @@ mod tests { ); let (_, message_4) = - assistant.update(cx, |assistant, cx| assistant.split_message(9..9, cx)); + conversation.update(cx, |conversation, cx| conversation.split_message(9..9, cx)); let message_4 = message_4.unwrap(); assert_eq!(buffer.read(cx).text(), "aaa\n\nbbb\nccc\nddd\n"); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..4), (message_3.id, Role::User, 4..5), @@ -2021,11 +2021,11 @@ mod tests { ); let (_, message_5) = - assistant.update(cx, |assistant, cx| assistant.split_message(9..9, cx)); + conversation.update(cx, |conversation, cx| conversation.split_message(9..9, cx)); let message_5 = message_5.unwrap(); assert_eq!(buffer.read(cx).text(), "aaa\n\nbbb\n\nccc\nddd\n"); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..4), (message_3.id, Role::User, 4..5), @@ -2035,13 +2035,14 @@ mod tests { ] ); - let (message_6, message_7) = - assistant.update(cx, |assistant, cx| assistant.split_message(14..16, cx)); + let (message_6, message_7) = conversation.update(cx, |conversation, cx| { + conversation.split_message(14..16, cx) + }); let message_6 = message_6.unwrap(); let message_7 = message_7.unwrap(); assert_eq!(buffer.read(cx).text(), "aaa\n\nbbb\n\nccc\ndd\nd\n"); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..4), (message_3.id, Role::User, 4..5), @@ -2057,33 +2058,33 @@ mod tests { #[gpui::test] fn test_messages_for_offsets(cx: &mut AppContext) { let registry = Arc::new(LanguageRegistry::test()); - let assistant = cx.add_model(|cx| Conversation::new(Default::default(), registry, cx)); - let buffer = assistant.read(cx).buffer.clone(); + let conversation = cx.add_model(|cx| Conversation::new(Default::default(), registry, cx)); + let buffer = conversation.read(cx).buffer.clone(); - let message_1 = assistant.read(cx).message_anchors[0].clone(); + let message_1 = conversation.read(cx).message_anchors[0].clone(); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![(message_1.id, Role::User, 0..0)] ); buffer.update(cx, |buffer, cx| buffer.edit([(0..0, "aaa")], None, cx)); - let message_2 = assistant - .update(cx, |assistant, cx| { - assistant.insert_message_after(message_1.id, Role::User, MessageStatus::Done, cx) + let message_2 = conversation + .update(cx, |conversation, cx| { + conversation.insert_message_after(message_1.id, Role::User, MessageStatus::Done, cx) }) .unwrap(); buffer.update(cx, |buffer, cx| buffer.edit([(4..4, "bbb")], None, cx)); - let message_3 = assistant - .update(cx, |assistant, cx| { - assistant.insert_message_after(message_2.id, Role::User, MessageStatus::Done, cx) + let message_3 = conversation + .update(cx, |conversation, cx| { + conversation.insert_message_after(message_2.id, Role::User, MessageStatus::Done, cx) }) .unwrap(); buffer.update(cx, |buffer, cx| buffer.edit([(8..8, "ccc")], None, cx)); assert_eq!(buffer.read(cx).text(), "aaa\nbbb\nccc"); assert_eq!( - messages(&assistant, cx), + messages(&conversation, cx), vec![ (message_1.id, Role::User, 0..4), (message_2.id, Role::User, 4..8), @@ -2092,20 +2093,20 @@ mod tests { ); assert_eq!( - message_ids_for_offsets(&assistant, &[0, 4, 9], cx), + message_ids_for_offsets(&conversation, &[0, 4, 9], cx), [message_1.id, message_2.id, message_3.id] ); assert_eq!( - message_ids_for_offsets(&assistant, &[0, 1, 11], cx), + message_ids_for_offsets(&conversation, &[0, 1, 11], cx), [message_1.id, message_3.id] ); fn message_ids_for_offsets( - assistant: &ModelHandle, + conversation: &ModelHandle, offsets: &[usize], cx: &AppContext, ) -> Vec { - assistant + conversation .read(cx) .messages_for_offsets(offsets.iter().copied(), cx) .into_iter() @@ -2115,10 +2116,10 @@ mod tests { } fn messages( - assistant: &ModelHandle, + conversation: &ModelHandle, cx: &AppContext, ) -> Vec<(MessageId, Role, Range)> { - assistant + conversation .read(cx) .messages(cx) .map(|message| (message.id, message.role, message.range)) From 06701e78aae2e18afd2984193308e333d7680266 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 21 Jun 2023 11:44:32 +0200 Subject: [PATCH 067/215] WIP --- crates/ai/src/ai.rs | 4 +-- crates/ai/src/assistant.rs | 59 +++++++++++++++++++++++++++++++------- crates/theme/src/theme.rs | 9 ++++++ 3 files changed, 59 insertions(+), 13 deletions(-) diff --git a/crates/ai/src/ai.rs b/crates/ai/src/ai.rs index 728648a293..75aabe561c 100644 --- a/crates/ai/src/ai.rs +++ b/crates/ai/src/ai.rs @@ -34,7 +34,7 @@ struct SavedConversation { struct SavedConversationMetadata { title: String, path: PathBuf, - mtime: SystemTime, + mtime: chrono::DateTime, } impl SavedConversationMetadata { @@ -59,7 +59,7 @@ impl SavedConversationMetadata { conversations.push(Self { title: title.into_owned(), path, - mtime: metadata.mtime, + mtime: metadata.mtime.into(), }); } } diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 785725ceaa..a21ab29fc0 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -104,9 +104,10 @@ pub enum AssistantPanelEvent { pub struct AssistantPanel { width: Option, height: Option, - active_conversation_index: usize, + active_conversation_index: Option, conversation_editors: Vec>, saved_conversations: Vec, + saved_conversations_list_state: UniformListState, zoomed: bool, has_focus: bool, api_key: Rc>>, @@ -153,9 +154,10 @@ impl AssistantPanel { }); let mut this = Self { - active_conversation_index: 0, + active_conversation_index: Default::default(), conversation_editors: Default::default(), saved_conversations, + saved_conversations_list_state: Default::default(), zoomed: false, has_focus: false, api_key: Rc::new(RefCell::new(None)), @@ -202,7 +204,7 @@ impl AssistantPanel { self.subscriptions .push(cx.subscribe(&editor, Self::handle_conversation_editor_event)); - self.active_conversation_index = self.conversation_editors.len(); + self.active_conversation_index = Some(self.conversation_editors.len()); self.conversation_editors.push(editor.clone()); cx.notify(); @@ -258,18 +260,43 @@ impl AssistantPanel { fn active_conversation_editor(&self) -> Option<&ViewHandle> { self.conversation_editors - .get(self.active_conversation_index) + .get(self.active_conversation_index?) } - fn render_hamburger_button( - &self, - style: &IconStyle, - cx: &ViewContext, - ) -> impl Element { + fn render_hamburger_button(style: &IconStyle) -> impl Element { Svg::for_style(style.icon.clone()) .contained() .with_style(style.container) } + + fn render_saved_conversation( + &mut self, + index: usize, + cx: &mut ViewContext, + ) -> impl Element { + MouseEventHandler::::new(index, cx, move |state, cx| { + let style = &theme::current(cx).assistant.saved_conversation; + let conversation = &self.saved_conversations[index]; + Flex::row() + .with_child( + Label::new( + conversation.mtime.format("%c").to_string(), + style.saved_at.text.clone(), + ) + .contained() + .with_style(style.saved_at.container), + ) + .with_child( + Label::new(conversation.title.clone(), style.title.text.clone()) + .contained() + .with_style(style.title.container), + ) + .contained() + .with_style(*style.container.style_for(state, false)) + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this, cx| {}) + } } fn build_api_key_editor(cx: &mut ViewContext) -> ViewHandle { @@ -318,7 +345,7 @@ impl View for AssistantPanel { Flex::column() .with_child( Flex::row() - .with_child(self.render_hamburger_button(&style.hamburger_button, cx)) + .with_child(Self::render_hamburger_button(&style.hamburger_button)) .contained() .with_style(theme.workspace.tab_bar.container) .constrained() @@ -327,7 +354,17 @@ impl View for AssistantPanel { .with_child(ChildView::new(editor, cx).flex(1., true)) .into_any() } else { - Empty::new().into_any() + UniformList::new( + self.saved_conversations_list_state.clone(), + self.saved_conversations.len(), + cx, + |this, range, items, cx| { + for ix in range { + items.push(this.render_saved_conversation(ix, cx).into_any()); + } + }, + ) + .into_any() } } diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 38e66cbb4c..2ab12f1d96 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -1007,6 +1007,15 @@ pub struct AssistantStyle { pub error_icon: Icon, pub api_key_editor: FieldEditor, pub api_key_prompt: ContainedText, + pub saved_conversation: SavedConversation, +} + +#[derive(Clone, Deserialize, Default)] +pub struct SavedConversation { + #[serde(flatten)] + pub container: Interactive, + pub saved_at: ContainedText, + pub title: ContainedText, } #[derive(Clone, Deserialize, Default)] From bd97767c7251dc3666fcd9389907fe8b4cf93ae9 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 21 Jun 2023 13:20:42 +0300 Subject: [PATCH 068/215] Run LSP response deserialization outside of main thread Improves latency when big inlay hints LSP responses for ~8k line files Co-Authored-By: Antonio Scandurra --- crates/lsp/src/lsp.rs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs index af73a16ec2..5074989277 100644 --- a/crates/lsp/src/lsp.rs +++ b/crates/lsp/src/lsp.rs @@ -33,7 +33,7 @@ const JSON_RPC_VERSION: &str = "2.0"; const CONTENT_LEN_HEADER: &str = "Content-Length: "; type NotificationHandler = Box, &str, AsyncAppContext)>; -type ResponseHandler = Box)>; +type ResponseHandler = Box)>; type IoHandler = Box; pub struct LanguageServer { @@ -302,9 +302,9 @@ impl LanguageServer { if let Some(error) = error { handler(Err(error)); } else if let Some(result) = result { - handler(Ok(result.get())); + handler(Ok(result.get().into())); } else { - handler(Ok("null")); + handler(Ok("null".into())); } } } else { @@ -457,11 +457,13 @@ impl LanguageServer { let response_handlers = self.response_handlers.clone(); let next_id = AtomicUsize::new(self.next_id.load(SeqCst)); let outbound_tx = self.outbound_tx.clone(); + let executor = self.executor.clone(); let mut output_done = self.output_done_rx.lock().take().unwrap(); let shutdown_request = Self::request_internal::( &next_id, &response_handlers, &outbound_tx, + &executor, (), ); let exit = Self::notify_internal::(&outbound_tx, ()); @@ -658,6 +660,7 @@ impl LanguageServer { &self.next_id, &self.response_handlers, &self.outbound_tx, + &self.executor, params, ) } @@ -666,6 +669,7 @@ impl LanguageServer { next_id: &AtomicUsize, response_handlers: &Mutex>>, outbound_tx: &channel::Sender, + executor: &Arc, params: T::Params, ) -> impl 'static + Future> where @@ -686,15 +690,20 @@ impl LanguageServer { .as_mut() .ok_or_else(|| anyhow!("server shut down")) .map(|handlers| { + let executor = executor.clone(); handlers.insert( id, Box::new(move |result| { - let response = match result { - Ok(response) => serde_json::from_str(response) - .context("failed to deserialize response"), - Err(error) => Err(anyhow!("{}", error.message)), - }; - let _ = tx.send(response); + executor + .spawn(async move { + let response = match result { + Ok(response) => serde_json::from_str(&response) + .context("failed to deserialize response"), + Err(error) => Err(anyhow!("{}", error.message)), + }; + let _ = tx.send(response); + }) + .detach(); }), ); }); From a011ced6981d8691ce5d0bc9679a626eaad1cdeb Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 21 Jun 2023 16:06:09 +0200 Subject: [PATCH 069/215] Allow loading a previously-saved conversation --- crates/ai/Cargo.toml | 2 +- crates/ai/src/ai.rs | 38 ++++- crates/ai/src/assistant.rs | 271 +++++++++++++++++++++++------- crates/theme/src/theme.rs | 1 + styles/src/styleTree/assistant.ts | 31 +++- 5 files changed, 279 insertions(+), 64 deletions(-) diff --git a/crates/ai/Cargo.toml b/crates/ai/Cargo.toml index 785bc657cf..013565e14f 100644 --- a/crates/ai/Cargo.toml +++ b/crates/ai/Cargo.toml @@ -22,7 +22,7 @@ util = { path = "../util" } workspace = { path = "../workspace" } anyhow.workspace = true -chrono = "0.4" +chrono = { version = "0.4", features = ["serde"] } futures.workspace = true isahc.workspace = true regex.workspace = true diff --git a/crates/ai/src/ai.rs b/crates/ai/src/ai.rs index 75aabe561c..c1e6a4c569 100644 --- a/crates/ai/src/ai.rs +++ b/crates/ai/src/ai.rs @@ -3,6 +3,8 @@ mod assistant_settings; use anyhow::Result; pub use assistant::AssistantPanel; +use chrono::{DateTime, Local}; +use collections::HashMap; use fs::Fs; use futures::StreamExt; use gpui::AppContext; @@ -12,7 +14,6 @@ use std::{ fmt::{self, Display}, path::PathBuf, sync::Arc, - time::SystemTime, }; use util::paths::CONVERSATIONS_DIR; @@ -24,11 +25,44 @@ struct OpenAIRequest { stream: bool, } +#[derive( + Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord, Hash, Serialize, Deserialize, +)] +struct MessageId(usize); + +#[derive(Clone, Debug, Serialize, Deserialize)] +struct MessageMetadata { + role: Role, + sent_at: DateTime, + status: MessageStatus, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +enum MessageStatus { + Pending, + Done, + Error(Arc), +} + +#[derive(Serialize, Deserialize)] +struct SavedMessage { + id: MessageId, + start: usize, +} + #[derive(Serialize, Deserialize)] struct SavedConversation { zed: String, version: String, - messages: Vec, + text: String, + messages: Vec, + message_metadata: HashMap, + summary: String, + model: String, +} + +impl SavedConversation { + const VERSION: &'static str = "0.1.0"; } struct SavedConversationMetadata { diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index a21ab29fc0..e8faa48000 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -1,7 +1,7 @@ use crate::{ assistant_settings::{AssistantDockPosition, AssistantSettings}, - OpenAIRequest, OpenAIResponseStreamEvent, RequestMessage, Role, SavedConversation, - SavedConversationMetadata, + MessageId, MessageMetadata, MessageStatus, OpenAIRequest, OpenAIResponseStreamEvent, + RequestMessage, Role, SavedConversation, SavedConversationMetadata, SavedMessage, }; use anyhow::{anyhow, Result}; use chrono::{DateTime, Local}; @@ -27,10 +27,18 @@ use language::{language_settings::SoftWrap, Buffer, LanguageRegistry, ToOffset a use serde::Deserialize; use settings::SettingsStore; use std::{ - borrow::Cow, cell::RefCell, cmp, env, fmt::Write, io, iter, ops::Range, path::PathBuf, rc::Rc, - sync::Arc, time::Duration, + borrow::Cow, + cell::RefCell, + cmp, env, + fmt::Write, + io, iter, + ops::Range, + path::{Path, PathBuf}, + rc::Rc, + sync::Arc, + time::Duration, }; -use theme::{ui::IconStyle, IconButton, Theme}; +use theme::ui::IconStyle; use util::{ channel::ReleaseChannel, paths::CONVERSATIONS_DIR, post_inc, truncate_and_trailoff, ResultExt, TryFutureExt, @@ -68,7 +76,7 @@ pub fn init(cx: &mut AppContext) { |workspace: &mut Workspace, _: &NewContext, cx: &mut ViewContext| { if let Some(this) = workspace.panel::(cx) { this.update(cx, |this, cx| { - this.add_conversation(cx); + this.new_conversation(cx); }) } @@ -187,13 +195,8 @@ impl AssistantPanel { }) } - fn add_conversation(&mut self, cx: &mut ViewContext) -> ViewHandle { - let focus = self.has_focus(cx); + fn new_conversation(&mut self, cx: &mut ViewContext) -> ViewHandle { let editor = cx.add_view(|cx| { - if focus { - cx.focus_self(); - } - ConversationEditor::new( self.api_key.clone(), self.languages.clone(), @@ -201,14 +204,24 @@ impl AssistantPanel { cx, ) }); + self.add_conversation(editor.clone(), cx); + editor + } + + fn add_conversation( + &mut self, + editor: ViewHandle, + cx: &mut ViewContext, + ) { self.subscriptions .push(cx.subscribe(&editor, Self::handle_conversation_editor_event)); self.active_conversation_index = Some(self.conversation_editors.len()); self.conversation_editors.push(editor.clone()); - + if self.has_focus(cx) { + cx.focus(&editor); + } cx.notify(); - editor } fn handle_conversation_editor_event( @@ -264,9 +277,28 @@ impl AssistantPanel { } fn render_hamburger_button(style: &IconStyle) -> impl Element { + enum ListConversations {} Svg::for_style(style.icon.clone()) .contained() .with_style(style.container) + .mouse::(0) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this: &mut Self, cx| { + this.active_conversation_index = None; + cx.notify(); + }) + } + + fn render_plus_button(style: &IconStyle) -> impl Element { + enum AddConversation {} + Svg::for_style(style.icon.clone()) + .contained() + .with_style(style.container) + .mouse::(0) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this: &mut Self, cx| { + this.new_conversation(cx); + }) } fn render_saved_conversation( @@ -274,20 +306,23 @@ impl AssistantPanel { index: usize, cx: &mut ViewContext, ) -> impl Element { + let conversation = &self.saved_conversations[index]; + let path = conversation.path.clone(); MouseEventHandler::::new(index, cx, move |state, cx| { let style = &theme::current(cx).assistant.saved_conversation; - let conversation = &self.saved_conversations[index]; Flex::row() .with_child( Label::new( - conversation.mtime.format("%c").to_string(), + conversation.mtime.format("%F %I:%M%p").to_string(), style.saved_at.text.clone(), ) + .aligned() .contained() .with_style(style.saved_at.container), ) .with_child( Label::new(conversation.title.clone(), style.title.text.clone()) + .aligned() .contained() .with_style(style.title.container), ) @@ -295,7 +330,48 @@ impl AssistantPanel { .with_style(*style.container.style_for(state, false)) }) .with_cursor_style(CursorStyle::PointingHand) - .on_click(MouseButton::Left, |_, this, cx| {}) + .on_click(MouseButton::Left, move |_, this, cx| { + this.open_conversation(path.clone(), cx) + .detach_and_log_err(cx) + }) + } + + fn open_conversation(&mut self, path: PathBuf, cx: &mut ViewContext) -> Task> { + if let Some(ix) = self.conversation_editor_index_for_path(&path, cx) { + self.active_conversation_index = Some(ix); + cx.notify(); + return Task::ready(Ok(())); + } + + let fs = self.fs.clone(); + let conversation = Conversation::load( + path.clone(), + self.api_key.clone(), + self.languages.clone(), + self.fs.clone(), + cx, + ); + cx.spawn(|this, mut cx| async move { + let conversation = conversation.await?; + this.update(&mut cx, |this, cx| { + // If, by the time we've loaded the conversation, the user has already opened + // the same conversation, we don't want to open it again. + if let Some(ix) = this.conversation_editor_index_for_path(&path, cx) { + this.active_conversation_index = Some(ix); + } else { + let editor = cx + .add_view(|cx| ConversationEditor::from_conversation(conversation, fs, cx)); + this.add_conversation(editor, cx); + } + })?; + Ok(()) + }) + } + + fn conversation_editor_index_for_path(&self, path: &Path, cx: &AppContext) -> Option { + self.conversation_editors + .iter() + .position(|editor| editor.read(cx).conversation.read(cx).path.as_deref() == Some(path)) } } @@ -341,30 +417,37 @@ impl View for AssistantPanel { .with_style(style.api_key_prompt.container) .aligned() .into_any() - } else if let Some(editor) = self.active_conversation_editor() { + } else { Flex::column() .with_child( Flex::row() - .with_child(Self::render_hamburger_button(&style.hamburger_button)) + .with_child( + Self::render_hamburger_button(&style.hamburger_button).aligned(), + ) + .with_child(Self::render_plus_button(&style.plus_button).aligned()) .contained() .with_style(theme.workspace.tab_bar.container) + .expanded() .constrained() .with_height(theme.workspace.tab_bar.height), ) - .with_child(ChildView::new(editor, cx).flex(1., true)) + .with_child(if let Some(editor) = self.active_conversation_editor() { + ChildView::new(editor, cx).flex(1., true).into_any() + } else { + UniformList::new( + self.saved_conversations_list_state.clone(), + self.saved_conversations.len(), + cx, + |this, range, items, cx| { + for ix in range { + items.push(this.render_saved_conversation(ix, cx).into_any()); + } + }, + ) + .flex(1., true) + .into_any() + }) .into_any() - } else { - UniformList::new( - self.saved_conversations_list_state.clone(), - self.saved_conversations.len(), - cx, - |this, range, items, cx| { - for ix in range { - items.push(this.render_saved_conversation(ix, cx).into_any()); - } - }, - ) - .into_any() } } @@ -468,7 +551,7 @@ impl Panel for AssistantPanel { } if self.conversation_editors.is_empty() { - self.add_conversation(cx); + self.new_conversation(cx); } } } @@ -598,6 +681,74 @@ impl Conversation { this } + fn load( + path: PathBuf, + api_key: Rc>>, + language_registry: Arc, + fs: Arc, + cx: &mut AppContext, + ) -> Task>> { + cx.spawn(|mut cx| async move { + let saved_conversation = fs.load(&path).await?; + let saved_conversation: SavedConversation = serde_json::from_str(&saved_conversation)?; + + let model = saved_conversation.model; + let markdown = language_registry.language_for_name("Markdown"); + let mut message_anchors = Vec::new(); + let mut next_message_id = MessageId(0); + let buffer = cx.add_model(|cx| { + let mut buffer = Buffer::new(0, saved_conversation.text, cx); + for message in saved_conversation.messages { + message_anchors.push(MessageAnchor { + id: message.id, + start: buffer.anchor_before(message.start), + }); + next_message_id = cmp::max(next_message_id, MessageId(message.id.0 + 1)); + } + buffer.set_language_registry(language_registry); + cx.spawn_weak(|buffer, mut cx| async move { + let markdown = markdown.await?; + let buffer = buffer + .upgrade(&cx) + .ok_or_else(|| anyhow!("buffer was dropped"))?; + buffer.update(&mut cx, |buffer, cx| { + buffer.set_language(Some(markdown), cx) + }); + anyhow::Ok(()) + }) + .detach_and_log_err(cx); + buffer + }); + let conversation = cx.add_model(|cx| { + let mut this = Self { + message_anchors, + messages_metadata: saved_conversation.message_metadata, + next_message_id, + summary: Some(Summary { + text: saved_conversation.summary, + done: true, + }), + pending_summary: Task::ready(None), + completion_count: Default::default(), + pending_completions: Default::default(), + token_count: None, + max_token_count: tiktoken_rs::model::get_context_size(&model), + pending_token_count: Task::ready(None), + model, + _subscriptions: vec![cx.subscribe(&buffer, Self::handle_buffer_event)], + pending_save: Task::ready(Ok(())), + path: Some(path), + api_key, + buffer, + }; + + this.count_remaining_tokens(cx); + this + }); + Ok(conversation) + }) + } + fn handle_buffer_event( &mut self, _: ModelHandle, @@ -1122,15 +1273,22 @@ impl Conversation { }); if let Some(summary) = summary { - let conversation = SavedConversation { + let conversation = this.read_with(&cx, |this, cx| SavedConversation { zed: "conversation".into(), - version: "0.1".into(), - messages: this.read_with(&cx, |this, cx| { - this.messages(cx) - .map(|message| message.to_open_ai_message(this.buffer.read(cx))) - .collect() - }), - }; + version: SavedConversation::VERSION.into(), + text: this.buffer.read(cx).text(), + message_metadata: this.messages_metadata.clone(), + messages: this + .message_anchors + .iter() + .map(|message| SavedMessage { + id: message.id, + start: message.start.to_offset(this.buffer.read(cx)), + }) + .collect(), + summary: summary.clone(), + model: this.model.clone(), + }); let path = if let Some(old_path) = old_path { old_path @@ -1195,6 +1353,14 @@ impl ConversationEditor { cx: &mut ViewContext, ) -> Self { let conversation = cx.add_model(|cx| Conversation::new(api_key, language_registry, cx)); + Self::from_conversation(conversation, fs, cx) + } + + fn from_conversation( + conversation: ModelHandle, + fs: Arc, + cx: &mut ViewContext, + ) -> Self { let editor = cx.add_view(|cx| { let mut editor = Editor::for_buffer(conversation.read(cx).buffer.clone(), None, cx); editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx); @@ -1524,7 +1690,7 @@ impl ConversationEditor { let conversation = panel .active_conversation_editor() .cloned() - .unwrap_or_else(|| panel.add_conversation(cx)); + .unwrap_or_else(|| panel.new_conversation(cx)); conversation.update(cx, |conversation, cx| { conversation .editor @@ -1693,29 +1859,12 @@ impl Item for ConversationEditor { } } -#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)] -struct MessageId(usize); - #[derive(Clone, Debug)] struct MessageAnchor { id: MessageId, start: language::Anchor, } -#[derive(Clone, Debug)] -struct MessageMetadata { - role: Role, - sent_at: DateTime, - status: MessageStatus, -} - -#[derive(Clone, Debug)] -enum MessageStatus { - Pending, - Done, - Error(Arc), -} - #[derive(Clone, Debug)] pub struct Message { range: Range, @@ -1733,7 +1882,7 @@ impl Message { content.extend(buffer.text_for_range(self.range.clone())); RequestMessage { role: self.role, - content, + content: content.trim_end().into(), } } } @@ -1826,6 +1975,8 @@ async fn stream_completion( #[cfg(test)] mod tests { + use crate::MessageId; + use super::*; use fs::FakeFs; use gpui::{AppContext, TestAppContext}; diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 2ab12f1d96..d76c3432d1 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -995,6 +995,7 @@ pub struct TerminalStyle { pub struct AssistantStyle { pub container: ContainerStyle, pub hamburger_button: IconStyle, + pub plus_button: IconStyle, pub message_header: ContainerStyle, pub sent_at: ContainedText, pub user_sender: Interactive, diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index 13ef484391..94547bd154 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -23,7 +23,36 @@ export default function assistant(colorScheme: ColorScheme) { height: 15, }, }, - container: {} + container: { + margin: { left: 8 }, + } + }, + plusButton: { + icon: { + color: text(layer, "sans", "default", { size: "sm" }).color, + asset: "icons/plus_12.svg", + dimensions: { + width: 12, + height: 12, + }, + }, + container: { + margin: { left: 8 }, + } + }, + savedConversation: { + background: background(layer, "on"), + hover: { + background: background(layer, "on", "hovered"), + }, + savedAt: { + margin: { left: 8 }, + ...text(layer, "sans", "default", { size: "xs" }), + }, + title: { + margin: { left: 8 }, + ...text(layer, "sans", "default", { size: "sm", weight: "bold" }), + } }, userSender: { ...text(layer, "sans", "default", { size: "sm", weight: "bold" }), From 43b912bc408885a20cf1bd8268305cf131eabd86 Mon Sep 17 00:00:00 2001 From: Sergey Onufrienko Date: Wed, 21 Jun 2023 16:12:01 +0200 Subject: [PATCH 070/215] chore: ignore generated files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 5a4d2ff25e..12711bd349 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ /plugins/bin /script/node_modules /styles/node_modules +/styles/src/types/zed.ts +/crates/theme/schemas/theme.json /crates/collab/static/styles.css /vendor/bin /assets/themes/*.json From 01b9e8807925350651193a6139409546175ddbe0 Mon Sep 17 00:00:00 2001 From: Sergey Onufrienko Date: Wed, 21 Jun 2023 16:12:27 +0200 Subject: [PATCH 071/215] chore: move schema gen to theme --- crates/theme/src/theme.rs | 13 +++++++++++++ crates/theme/src/theme_settings.rs | 17 ----------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 97223911f5..2510e450ec 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -1082,3 +1082,16 @@ pub struct Style { pub border: Color, pub foreground: Color, } + +#[cfg(test)] +mod tests { + use super::*; + use schemars::schema_for; + + #[test] + fn export_schema() { + let theme = schema_for!(Theme); + let output = serde_json::to_string_pretty(&theme).unwrap(); + std::fs::write("schemas/theme.json", output).ok(); + } +} diff --git a/crates/theme/src/theme_settings.rs b/crates/theme/src/theme_settings.rs index 7e275c399c..b9e6f7a133 100644 --- a/crates/theme/src/theme_settings.rs +++ b/crates/theme/src/theme_settings.rs @@ -183,20 +183,3 @@ fn merge(target: &mut T, value: Option) { *target = value; } } - -#[cfg(test)] -mod tests { - use super::*; - use schemars::schema_for; - - #[test] - fn export_schema() { - let theme_settings_content = schema_for!(ThemeSettingsContent); - let output1 = serde_json::to_string_pretty(&theme_settings_content).unwrap(); - std::fs::write("schemas/theme_settings_content.json", output1).ok(); - - let theme_settings = schema_for!(ThemeSettings); - let output2 = serde_json::to_string_pretty(&theme_settings).unwrap(); - std::fs::write("schemas/theme_settings.json", output2).ok(); - } -} From a9fec7f15b28e4bf6d8ffe3aba9739ff4db06b55 Mon Sep 17 00:00:00 2001 From: Sergey Onufrienko Date: Wed, 21 Jun 2023 16:13:04 +0200 Subject: [PATCH 072/215] fix: create schemas folder --- crates/theme/src/theme.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 2510e450ec..1dbe636318 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -1092,6 +1092,7 @@ mod tests { fn export_schema() { let theme = schema_for!(Theme); let output = serde_json::to_string_pretty(&theme).unwrap(); + std::fs::create_dir("schemas").ok(); std::fs::write("schemas/theme.json", output).ok(); } } From 6e4439b4ca5bb78819b47824ee55f7251672efcb Mon Sep 17 00:00:00 2001 From: Sergey Onufrienko Date: Wed, 21 Jun 2023 16:13:41 +0200 Subject: [PATCH 073/215] feat: move gen to styles and add scripts --- json-to-ts/index.mjs | 55 --- json-to-ts/package-lock.json | 474 -------------------- json-to-ts/package.json | 15 - styles/package-lock.json | 829 +++++++++++++++++++++++++++++++++++ styles/package.json | 4 +- styles/src/buildTypes.ts | 64 +++ 6 files changed, 896 insertions(+), 545 deletions(-) delete mode 100644 json-to-ts/index.mjs delete mode 100644 json-to-ts/package-lock.json delete mode 100644 json-to-ts/package.json create mode 100644 styles/src/buildTypes.ts diff --git a/json-to-ts/index.mjs b/json-to-ts/index.mjs deleted file mode 100644 index 2feac8c093..0000000000 --- a/json-to-ts/index.mjs +++ /dev/null @@ -1,55 +0,0 @@ -import * as fs from 'fs/promises'; -import * as path from 'path'; -import * as url from 'url'; -import { compile } from 'json-schema-to-typescript'; - -// or just __dirname if running non-ES-Module Node -const dirname = path.dirname(url.fileURLToPath(import.meta.url)); - -async function main() { - let schemasPath = path.join(dirname, '..', 'crates/theme/schemas'); - // let schemasPath = path.join(dirname, '..', '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); - let schema = JSON.parse(await fs.readFile(filePath)); - 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 = Array.from(compiledTypes).join('\n\n'); - let outputPath = path.join(dirname, 'types', 'theme.ts'); - - try { - let existing = await fs.readFile(outputPath); - if (existing == output) { - // Skip writing if it hasn't changed, so that we don't confuse any sort - // of incremental builds. This check isn't ideal but the script runs - // quickly enough and rarely enough that it doesn't matter. - console.log('Schemas are up to date'); - return; - } - } catch (e) { - // It's fine if there's no output from a previous run. - if (e.code !== 'ENOENT') { - throw e; - } - } - - await fs.writeFile(outputPath, output); - console.log(`Wrote Typescript types to ${outputPath}`); -} - -main().catch((e) => { - console.error(e); - process.exit(1); -}); diff --git a/json-to-ts/package-lock.json b/json-to-ts/package-lock.json deleted file mode 100644 index 4f308dce46..0000000000 --- a/json-to-ts/package-lock.json +++ /dev/null @@ -1,474 +0,0 @@ -{ - "name": "json-to-ts", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "json-to-ts", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "json-schema-to-typescript": "^13.0.2" - } - }, - "node_modules/@bcherny/json-schema-ref-parser": { - "version": "10.0.5-fork", - "resolved": "https://registry.npmjs.org/@bcherny/json-schema-ref-parser/-/json-schema-ref-parser-10.0.5-fork.tgz", - "integrity": "sha512-E/jKbPoca1tfUPj3iSbitDZTGnq6FUFjkH6L8U2oDwSuwK1WhnnVtCG7oFOTg/DDnyoXbQYUiUiGOibHqaGVnw==", - "dependencies": { - "@jsdevtools/ono": "^7.1.3", - "@types/json-schema": "^7.0.6", - "call-me-maybe": "^1.0.1", - "js-yaml": "^4.1.0" - }, - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://github.com/sponsors/philsturgeon" - } - }, - "node_modules/@jsdevtools/ono": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", - "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==" - }, - "node_modules/@types/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==", - "dependencies": { - "@types/minimatch": "*", - "@types/node": "*" - } - }, - "node_modules/@types/json-schema": { - "version": "7.0.12", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", - "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==" - }, - "node_modules/@types/lodash": { - "version": "4.14.195", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.195.tgz", - "integrity": "sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg==" - }, - "node_modules/@types/minimatch": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", - "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==" - }, - "node_modules/@types/node": { - "version": "20.3.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.1.tgz", - "integrity": "sha512-EhcH/wvidPy1WeML3TtYFGR83UzjxeWRen9V402T8aUGYsCHOmfoisV3ZSg03gAFIbLq8TnWOJ0f4cALtnSEUg==" - }, - "node_modules/@types/prettier": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", - "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==" - }, - "node_modules/any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==" - }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" - }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/call-me-maybe": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", - "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==" - }, - "node_modules/cli-color": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.3.tgz", - "integrity": "sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==", - "dependencies": { - "d": "^1.0.1", - "es5-ext": "^0.10.61", - "es6-iterator": "^2.0.3", - "memoizee": "^0.4.15", - "timers-ext": "^0.1.7" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" - }, - "node_modules/d": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", - "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", - "dependencies": { - "es5-ext": "^0.10.50", - "type": "^1.0.1" - } - }, - "node_modules/es5-ext": { - "version": "0.10.62", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", - "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", - "hasInstallScript": true, - "dependencies": { - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.3", - "next-tick": "^1.1.0" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/es6-iterator": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", - "dependencies": { - "d": "1", - "es5-ext": "^0.10.35", - "es6-symbol": "^3.1.1" - } - }, - "node_modules/es6-symbol": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", - "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", - "dependencies": { - "d": "^1.0.1", - "ext": "^1.1.2" - } - }, - "node_modules/es6-weak-map": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", - "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", - "dependencies": { - "d": "1", - "es5-ext": "^0.10.46", - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.1" - } - }, - "node_modules/event-emitter": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", - "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", - "dependencies": { - "d": "1", - "es5-ext": "~0.10.14" - } - }, - "node_modules/ext": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", - "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", - "dependencies": { - "type": "^2.7.2" - } - }, - "node_modules/ext/node_modules/type": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", - "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" - }, - "node_modules/get-stdin": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", - "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/glob-promise": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/glob-promise/-/glob-promise-4.2.2.tgz", - "integrity": "sha512-xcUzJ8NWN5bktoTIX7eOclO1Npxd/dyVqUJxlLIDasT4C7KZyqlPIwkdJ0Ypiy3p2ZKahTjK4M9uC3sNSfNMzw==", - "dependencies": { - "@types/glob": "^7.1.3" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "type": "individual", - "url": "https://github.com/sponsors/ahmadnassri" - }, - "peerDependencies": { - "glob": "^7.1.6" - } - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-promise": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", - "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==" - }, - "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/json-schema-to-typescript": { - "version": "13.0.2", - "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-13.0.2.tgz", - "integrity": "sha512-TCaEVW4aI2FmMQe7f98mvr3/oiVmXEC1xZjkTZ9L/BSoTXFlC7p64mD5AD2d8XWycNBQZUnHwXL5iVXt1HWwNQ==", - "dependencies": { - "@bcherny/json-schema-ref-parser": "10.0.5-fork", - "@types/json-schema": "^7.0.11", - "@types/lodash": "^4.14.182", - "@types/prettier": "^2.6.1", - "cli-color": "^2.0.2", - "get-stdin": "^8.0.0", - "glob": "^7.1.6", - "glob-promise": "^4.2.2", - "is-glob": "^4.0.3", - "lodash": "^4.17.21", - "minimist": "^1.2.6", - "mkdirp": "^1.0.4", - "mz": "^2.7.0", - "prettier": "^2.6.2" - }, - "bin": { - "json2ts": "dist/src/cli.js" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, - "node_modules/lru-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", - "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==", - "dependencies": { - "es5-ext": "~0.10.2" - } - }, - "node_modules/memoizee": { - "version": "0.4.15", - "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", - "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", - "dependencies": { - "d": "^1.0.1", - "es5-ext": "^0.10.53", - "es6-weak-map": "^2.0.3", - "event-emitter": "^0.3.5", - "is-promise": "^2.2.2", - "lru-queue": "^0.1.0", - "next-tick": "^1.1.0", - "timers-ext": "^0.1.7" - } - }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "bin": { - "mkdirp": "bin/cmd.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/mz": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", - "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", - "dependencies": { - "any-promise": "^1.0.0", - "object-assign": "^4.0.1", - "thenify-all": "^1.0.0" - } - }, - "node_modules/next-tick": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", - "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" - }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", - "bin": { - "prettier": "bin-prettier.js" - }, - "engines": { - "node": ">=10.13.0" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, - "node_modules/thenify": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", - "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", - "dependencies": { - "any-promise": "^1.0.0" - } - }, - "node_modules/thenify-all": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", - "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", - "dependencies": { - "thenify": ">= 3.1.0 < 4" - }, - "engines": { - "node": ">=0.8" - } - }, - "node_modules/timers-ext": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", - "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==", - "dependencies": { - "es5-ext": "~0.10.46", - "next-tick": "1" - } - }, - "node_modules/type": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", - "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" - } - } -} diff --git a/json-to-ts/package.json b/json-to-ts/package.json deleted file mode 100644 index 79ff207146..0000000000 --- a/json-to-ts/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "json-to-ts", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "json-schema-to-typescript": "^13.0.2" - } -} diff --git a/styles/package-lock.json b/styles/package-lock.json index d1d0ed0eb8..85855d9064 100644 --- a/styles/package-lock.json +++ b/styles/package-lock.json @@ -17,10 +17,28 @@ "case-anything": "^2.1.10", "chroma-js": "^2.4.2", "deepmerge": "^4.3.0", + "json-schema-to-typescript": "^13.0.2", "toml": "^3.0.0", "ts-node": "^10.9.1" } }, + "node_modules/@bcherny/json-schema-ref-parser": { + "version": "10.0.5-fork", + "resolved": "https://registry.npmjs.org/@bcherny/json-schema-ref-parser/-/json-schema-ref-parser-10.0.5-fork.tgz", + "integrity": "sha512-E/jKbPoca1tfUPj3iSbitDZTGnq6FUFjkH6L8U2oDwSuwK1WhnnVtCG7oFOTg/DDnyoXbQYUiUiGOibHqaGVnw==", + "dependencies": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.6", + "call-me-maybe": "^1.0.1", + "js-yaml": "^4.1.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/philsturgeon" + } + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -54,6 +72,11 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@jsdevtools/ono": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==" + }, "node_modules/@tokens-studio/types": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/@tokens-studio/types/-/types-0.2.3.tgz", @@ -84,11 +107,40 @@ "resolved": "https://registry.npmjs.org/@types/chroma-js/-/chroma-js-2.4.0.tgz", "integrity": "sha512-JklMxityrwjBTjGY2anH8JaTx3yjRU3/sEHSblLH1ba5lqcSh1LnImXJZO5peJfXyqKYWjHTGy4s5Wz++hARrw==" }, + "node_modules/@types/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==", + "dependencies": { + "@types/minimatch": "*", + "@types/node": "*" + } + }, + "node_modules/@types/json-schema": { + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==" + }, + "node_modules/@types/lodash": { + "version": "4.14.195", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.195.tgz", + "integrity": "sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg==" + }, + "node_modules/@types/minimatch": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==" + }, "node_modules/@types/node": { "version": "18.14.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.1.tgz", "integrity": "sha512-QH+37Qds3E0eDlReeboBxfHbX9omAcBCXEzswCu6jySP642jiM3cYSIkU/REqwhCUqXdonHFuBfJDiAJxMNhaQ==" }, + "node_modules/@types/prettier": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", + "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==" + }, "node_modules/acorn": { "version": "8.8.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", @@ -108,11 +160,21 @@ "node": ">=0.4.0" } }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==" + }, "node_modules/arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, "node_modules/ayu": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/ayu/-/ayu-8.0.1.tgz", @@ -123,11 +185,30 @@ "nonenumerable": "^1.1.1" } }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, "node_modules/bezier-easing": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/bezier-easing/-/bezier-easing-2.1.0.tgz", "integrity": "sha512-gbIqZ/eslnUFC1tjEvtz0sgx+xTK20wDnYMIA27VA04R7w6xxXQPZDbibjA9DTWZRA2CXtwHykkVzlCaAJAZig==" }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/call-me-maybe": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", + "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==" + }, "node_modules/case-anything": { "version": "2.1.10", "resolved": "https://registry.npmjs.org/case-anything/-/case-anything-2.1.10.tgz", @@ -144,11 +225,40 @@ "resolved": "https://registry.npmjs.org/chroma-js/-/chroma-js-2.4.2.tgz", "integrity": "sha512-U9eDw6+wt7V8z5NncY2jJfZa+hUH8XEj8FQHgFJTrUFnJfXYf4Ml4adI2vXZOjqRDpFWtYVWypDfZwnJ+HIR4A==" }, + "node_modules/cli-color": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.3.tgz", + "integrity": "sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.61", + "es6-iterator": "^2.0.3", + "memoizee": "^0.4.15", + "timers-ext": "^0.1.7" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" }, + "node_modules/d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "dependencies": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, "node_modules/deepmerge": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.0.tgz", @@ -165,16 +275,350 @@ "node": ">=0.3.1" } }, + "node_modules/es5-ext": { + "version": "0.10.62", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "hasInstallScript": true, + "dependencies": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "node_modules/es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "dependencies": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "node_modules/es6-weak-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.1" + } + }, + "node_modules/event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "dependencies": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, + "node_modules/ext": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "dependencies": { + "type": "^2.7.2" + } + }, + "node_modules/ext/node_modules/type": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "node_modules/get-stdin": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", + "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-promise": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/glob-promise/-/glob-promise-4.2.2.tgz", + "integrity": "sha512-xcUzJ8NWN5bktoTIX7eOclO1Npxd/dyVqUJxlLIDasT4C7KZyqlPIwkdJ0Ypiy3p2ZKahTjK4M9uC3sNSfNMzw==", + "dependencies": { + "@types/glob": "^7.1.3" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "individual", + "url": "https://github.com/sponsors/ahmadnassri" + }, + "peerDependencies": { + "glob": "^7.1.6" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-promise": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==" + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-schema-to-typescript": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-13.0.2.tgz", + "integrity": "sha512-TCaEVW4aI2FmMQe7f98mvr3/oiVmXEC1xZjkTZ9L/BSoTXFlC7p64mD5AD2d8XWycNBQZUnHwXL5iVXt1HWwNQ==", + "dependencies": { + "@bcherny/json-schema-ref-parser": "10.0.5-fork", + "@types/json-schema": "^7.0.11", + "@types/lodash": "^4.14.182", + "@types/prettier": "^2.6.1", + "cli-color": "^2.0.2", + "get-stdin": "^8.0.0", + "glob": "^7.1.6", + "glob-promise": "^4.2.2", + "is-glob": "^4.0.3", + "lodash": "^4.17.21", + "minimist": "^1.2.6", + "mkdirp": "^1.0.4", + "mz": "^2.7.0", + "prettier": "^2.6.2" + }, + "bin": { + "json2ts": "dist/src/cli.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/lru-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", + "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==", + "dependencies": { + "es5-ext": "~0.10.2" + } + }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" }, + "node_modules/memoizee": { + "version": "0.4.15", + "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", + "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.53", + "es6-weak-map": "^2.0.3", + "event-emitter": "^0.3.5", + "is-promise": "^2.2.2", + "lru-queue": "^0.1.0", + "next-tick": "^1.1.0", + "timers-ext": "^0.1.7" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "node_modules/next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, "node_modules/nonenumerable": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/nonenumerable/-/nonenumerable-1.1.1.tgz", "integrity": "sha512-ptUD9w9D8WqW6fuJJkZNCImkf+0vdbgUTbRK3i7jsy3olqtH96hYE6Q/S3Tx9NWbcB/ocAjYshXCAUP0lZ9B4Q==" }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/timers-ext": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", + "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==", + "dependencies": { + "es5-ext": "~0.10.46", + "next-tick": "1" + } + }, "node_modules/toml": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", @@ -222,6 +666,11 @@ } } }, + "node_modules/type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, "node_modules/typescript": { "version": "4.9.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", @@ -240,6 +689,11 @@ "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, "node_modules/yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", @@ -250,6 +704,17 @@ } }, "dependencies": { + "@bcherny/json-schema-ref-parser": { + "version": "10.0.5-fork", + "resolved": "https://registry.npmjs.org/@bcherny/json-schema-ref-parser/-/json-schema-ref-parser-10.0.5-fork.tgz", + "integrity": "sha512-E/jKbPoca1tfUPj3iSbitDZTGnq6FUFjkH6L8U2oDwSuwK1WhnnVtCG7oFOTg/DDnyoXbQYUiUiGOibHqaGVnw==", + "requires": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.6", + "call-me-maybe": "^1.0.1", + "js-yaml": "^4.1.0" + } + }, "@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -277,6 +742,11 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "@jsdevtools/ono": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==" + }, "@tokens-studio/types": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/@tokens-studio/types/-/types-0.2.3.tgz", @@ -307,11 +777,40 @@ "resolved": "https://registry.npmjs.org/@types/chroma-js/-/chroma-js-2.4.0.tgz", "integrity": "sha512-JklMxityrwjBTjGY2anH8JaTx3yjRU3/sEHSblLH1ba5lqcSh1LnImXJZO5peJfXyqKYWjHTGy4s5Wz++hARrw==" }, + "@types/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==", + "requires": { + "@types/minimatch": "*", + "@types/node": "*" + } + }, + "@types/json-schema": { + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==" + }, + "@types/lodash": { + "version": "4.14.195", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.195.tgz", + "integrity": "sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg==" + }, + "@types/minimatch": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==" + }, "@types/node": { "version": "18.14.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.1.tgz", "integrity": "sha512-QH+37Qds3E0eDlReeboBxfHbX9omAcBCXEzswCu6jySP642jiM3cYSIkU/REqwhCUqXdonHFuBfJDiAJxMNhaQ==" }, + "@types/prettier": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", + "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==" + }, "acorn": { "version": "8.8.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", @@ -322,11 +821,21 @@ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==" }, + "any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==" + }, "arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, "ayu": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/ayu/-/ayu-8.0.1.tgz", @@ -337,11 +846,30 @@ "nonenumerable": "^1.1.1" } }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, "bezier-easing": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/bezier-easing/-/bezier-easing-2.1.0.tgz", "integrity": "sha512-gbIqZ/eslnUFC1tjEvtz0sgx+xTK20wDnYMIA27VA04R7w6xxXQPZDbibjA9DTWZRA2CXtwHykkVzlCaAJAZig==" }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "call-me-maybe": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", + "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==" + }, "case-anything": { "version": "2.1.10", "resolved": "https://registry.npmjs.org/case-anything/-/case-anything-2.1.10.tgz", @@ -352,11 +880,37 @@ "resolved": "https://registry.npmjs.org/chroma-js/-/chroma-js-2.4.2.tgz", "integrity": "sha512-U9eDw6+wt7V8z5NncY2jJfZa+hUH8XEj8FQHgFJTrUFnJfXYf4Ml4adI2vXZOjqRDpFWtYVWypDfZwnJ+HIR4A==" }, + "cli-color": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.3.tgz", + "integrity": "sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==", + "requires": { + "d": "^1.0.1", + "es5-ext": "^0.10.61", + "es6-iterator": "^2.0.3", + "memoizee": "^0.4.15", + "timers-ext": "^0.1.7" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, "create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" }, + "d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "requires": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, "deepmerge": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.0.tgz", @@ -367,16 +921,281 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" }, + "es5-ext": { + "version": "0.10.62", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "requires": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "requires": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "requires": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "es6-weak-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", + "requires": { + "d": "1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.1" + } + }, + "event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "requires": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, + "ext": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "requires": { + "type": "^2.7.2" + }, + "dependencies": { + "type": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + } + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "get-stdin": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", + "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==" + }, + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-promise": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/glob-promise/-/glob-promise-4.2.2.tgz", + "integrity": "sha512-xcUzJ8NWN5bktoTIX7eOclO1Npxd/dyVqUJxlLIDasT4C7KZyqlPIwkdJ0Ypiy3p2ZKahTjK4M9uC3sNSfNMzw==", + "requires": { + "@types/glob": "^7.1.3" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-promise": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==" + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "requires": { + "argparse": "^2.0.1" + } + }, + "json-schema-to-typescript": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-13.0.2.tgz", + "integrity": "sha512-TCaEVW4aI2FmMQe7f98mvr3/oiVmXEC1xZjkTZ9L/BSoTXFlC7p64mD5AD2d8XWycNBQZUnHwXL5iVXt1HWwNQ==", + "requires": { + "@bcherny/json-schema-ref-parser": "10.0.5-fork", + "@types/json-schema": "^7.0.11", + "@types/lodash": "^4.14.182", + "@types/prettier": "^2.6.1", + "cli-color": "^2.0.2", + "get-stdin": "^8.0.0", + "glob": "^7.1.6", + "glob-promise": "^4.2.2", + "is-glob": "^4.0.3", + "lodash": "^4.17.21", + "minimist": "^1.2.6", + "mkdirp": "^1.0.4", + "mz": "^2.7.0", + "prettier": "^2.6.2" + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "lru-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", + "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==", + "requires": { + "es5-ext": "~0.10.2" + } + }, "make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" }, + "memoizee": { + "version": "0.4.15", + "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", + "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", + "requires": { + "d": "^1.0.1", + "es5-ext": "^0.10.53", + "es6-weak-map": "^2.0.3", + "event-emitter": "^0.3.5", + "is-promise": "^2.2.2", + "lru-queue": "^0.1.0", + "next-tick": "^1.1.0", + "timers-ext": "^0.1.7" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==" + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" + }, + "mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "requires": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, "nonenumerable": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/nonenumerable/-/nonenumerable-1.1.1.tgz", "integrity": "sha512-ptUD9w9D8WqW6fuJJkZNCImkf+0vdbgUTbRK3i7jsy3olqtH96hYE6Q/S3Tx9NWbcB/ocAjYshXCAUP0lZ9B4Q==" }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==" + }, + "prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==" + }, + "thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "requires": { + "any-promise": "^1.0.0" + } + }, + "thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "requires": { + "thenify": ">= 3.1.0 < 4" + } + }, + "timers-ext": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", + "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==", + "requires": { + "es5-ext": "~0.10.46", + "next-tick": "1" + } + }, "toml": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", @@ -402,6 +1221,11 @@ "yn": "3.1.1" } }, + "type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, "typescript": { "version": "4.9.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", @@ -413,6 +1237,11 @@ "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, "yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", diff --git a/styles/package.json b/styles/package.json index 2a0881863b..64beb7d99a 100644 --- a/styles/package.json +++ b/styles/package.json @@ -6,7 +6,8 @@ "scripts": { "build": "ts-node ./src/buildThemes.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" }, "author": "", "license": "ISC", @@ -19,6 +20,7 @@ "case-anything": "^2.1.10", "chroma-js": "^2.4.2", "deepmerge": "^4.3.0", + "json-schema-to-typescript": "^13.0.2", "toml": "^3.0.0", "ts-node": "^10.9.1" }, diff --git a/styles/src/buildTypes.ts b/styles/src/buildTypes.ts new file mode 100644 index 0000000000..8c1981cf97 --- /dev/null +++ b/styles/src/buildTypes.ts @@ -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) +}) From 5ffe74f47e2a51d0f8e3ede963896157d2c1f215 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 21 Jun 2023 08:50:33 -0700 Subject: [PATCH 074/215] Fix race condition in sharing mic on connection co-authored-by: antonio --- crates/call/src/room.rs | 32 ++++++------------- crates/collab_ui/src/collab_ui.rs | 8 ++--- .../Sources/LiveKitBridge/LiveKitBridge.swift | 9 ++---- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 9f9a64c1ac..22e59ac467 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -148,8 +148,13 @@ impl Room { } }); - cx.foreground() - .spawn(room.connect(&connection_info.server_url, &connection_info.token)) + let connect = room.connect(&connection_info.server_url, &connection_info.token); + cx.spawn(|this, mut cx| async move { + connect.await?; + this.update(&mut cx, |this, cx| this.share_microphone(cx)).await?; + + anyhow::Ok(()) + }) .detach_and_log_err(cx); Some(LiveKitRoom { @@ -228,15 +233,6 @@ impl Room { .await { Ok(()) => { - if option_env!("START_MIC").is_some() - || &*util::channel::RELEASE_CHANNEL != &ReleaseChannel::Dev - { - let share_mic = room.update(&mut cx, |room, cx| room.share_mic(cx)); - cx.update(|cx| { - cx.background().spawn(share_mic).detach_and_log_err(cx); - }); - } - Ok(room) } Err(error) => Err(anyhow!("room creation failed: {:?}", error)), @@ -266,14 +262,6 @@ impl Room { room.update(&mut cx, |room, cx| { room.leave_when_empty = true; room.apply_room_update(room_proto, cx)?; - - if option_env!("START_MIC").is_some() - || &*util::channel::RELEASE_CHANNEL != &ReleaseChannel::Dev - { - let share_mic = room.share_mic(cx); - cx.background().spawn(share_mic).detach_and_log_err(cx); - } - anyhow::Ok(()) })?; Ok(room) @@ -1022,7 +1010,7 @@ impl Room { self.live_kit.as_ref().map(|live_kit| live_kit.deafened) } - pub fn share_mic(&mut self, cx: &mut ModelContext) -> Task> { + pub fn share_microphone(&mut self, cx: &mut ModelContext) -> Task> { if self.status.is_offline() { return Task::ready(Err(anyhow!("room is offline"))); } else if self.is_sharing_mic() { @@ -1225,11 +1213,11 @@ impl Room { .room .remote_audio_track_publications(&participant.user.id.to_string()) { - tasks.push(cx.background().spawn(track.set_enabled(!live_kit.deafened))); + tasks.push(cx.foreground().spawn(track.set_enabled(!live_kit.deafened))); } } - Ok(cx.background().spawn(async move { + Ok(cx.foreground().spawn(async move { for task in tasks { task.await?; } diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rs index 4b5deaa0be..e9c2bcf7f9 100644 --- a/crates/collab_ui/src/collab_ui.rs +++ b/crates/collab_ui/src/collab_ui.rs @@ -16,7 +16,7 @@ use std::sync::Arc; use util::ResultExt; use workspace::AppState; -actions!(collab, [ToggleScreenSharing, ToggleMute, ToggleDeafen, ShareMic]); +actions!(collab, [ToggleScreenSharing, ToggleMute, ToggleDeafen, ShareMicrophone]); pub fn init(app_state: &Arc, cx: &mut AppContext) { collab_titlebar_item::init(cx); @@ -30,7 +30,7 @@ pub fn init(app_state: &Arc, cx: &mut AppContext) { cx.add_global_action(toggle_screen_sharing); cx.add_global_action(toggle_mute); cx.add_global_action(toggle_deafen); - cx.add_global_action(share_mic); + cx.add_global_action(share_microphone); } pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) { @@ -62,8 +62,8 @@ pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) { } } -pub fn share_mic(_: &ShareMic, cx: &mut AppContext) { +pub fn share_microphone(_: &ShareMicrophone, cx: &mut AppContext) { if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { - room.update(cx, Room::share_mic).detach_and_log_err(cx) + room.update(cx, Room::share_microphone).detach_and_log_err(cx) } } diff --git a/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift b/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift index 666da3d533..74d43d7865 100644 --- a/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift +++ b/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift @@ -10,7 +10,7 @@ class LKRoomDelegate: RoomDelegate { var onDidUnsubscribeFromRemoteAudioTrack: @convention(c) (UnsafeRawPointer, CFString, CFString) -> Void var onDidSubscribeToRemoteVideoTrack: @convention(c) (UnsafeRawPointer, CFString, CFString, UnsafeRawPointer) -> Void var onDidUnsubscribeFromRemoteVideoTrack: @convention(c) (UnsafeRawPointer, CFString, CFString) -> Void - + init( data: UnsafeRawPointer, onDidDisconnect: @escaping @convention(c) (UnsafeRawPointer) -> Void, @@ -40,7 +40,7 @@ class LKRoomDelegate: RoomDelegate { self.onDidSubscribeToRemoteAudioTrack(self.data, participant.identity as CFString, track.sid! as CFString, Unmanaged.passUnretained(track).toOpaque()) } } - + func room(_ room: Room, participant: RemoteParticipant, didUnsubscribe publication: RemoteTrackPublication, track: Track) { if track.kind == .video { self.onDidUnsubscribeFromRemoteVideoTrack(self.data, participant.identity as CFString, track.sid! as CFString) @@ -279,13 +279,10 @@ public func LKRemoteTrackPublicationSetEnabled( callback_data: UnsafeRawPointer ) { let publication = Unmanaged.fromOpaque(publication).takeUnretainedValue() - + publication.set(enabled: enabled).then { on_complete(callback_data, nil) }.catch { error in on_complete(callback_data, error.localizedDescription as CFString) } } - - - From d78fbbc63e3c3f11bd89c8f0e1edecdba2d3caa6 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 21 Jun 2023 09:54:49 -0600 Subject: [PATCH 075/215] Add title to assistant panel and move + to right --- crates/ai/src/assistant.rs | 14 +++++++++++++- crates/theme/src/theme.rs | 1 + styles/src/styleTree/assistant.ts | 6 +++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index e8faa48000..d81434082d 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -418,13 +418,25 @@ impl View for AssistantPanel { .aligned() .into_any() } else { + let title = self.active_conversation_editor().map(|editor| { + Label::new(editor.read(cx).title(cx), style.title.text.clone()) + .contained() + .with_style(style.title.container) + .aligned() + }); + Flex::column() .with_child( Flex::row() .with_child( Self::render_hamburger_button(&style.hamburger_button).aligned(), ) - .with_child(Self::render_plus_button(&style.plus_button).aligned()) + .with_children(title) + .with_child( + Self::render_plus_button(&style.plus_button) + .aligned() + .flex_float(), + ) .contained() .with_style(theme.workspace.tab_bar.container) .expanded() diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index d76c3432d1..72976ad82b 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -996,6 +996,7 @@ pub struct AssistantStyle { pub container: ContainerStyle, pub hamburger_button: IconStyle, pub plus_button: IconStyle, + pub title: ContainedText, pub message_header: ContainerStyle, pub sent_at: ContainedText, pub user_sender: Interactive, diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index 94547bd154..14bb836ee8 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -37,9 +37,13 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - margin: { left: 8 }, + margin: { right: 8 }, } }, + title: { + margin: { left: 8 }, + ...text(layer, "sans", "default", { size: "sm" }) + }, savedConversation: { background: background(layer, "on"), hover: { From 05c97ed355b3c255f4322c5823c05a96c43a1b26 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 21 Jun 2023 09:05:36 -0700 Subject: [PATCH 076/215] Fix segfault with remote track publications co-authored-by: antonio --- crates/live_kit_client/src/prod.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/live_kit_client/src/prod.rs b/crates/live_kit_client/src/prod.rs index 2ec4f96dd5..dbd9e1917e 100644 --- a/crates/live_kit_client/src/prod.rs +++ b/crates/live_kit_client/src/prod.rs @@ -219,7 +219,7 @@ impl Room { let tx = unsafe { Box::from_raw(tx as *mut oneshot::Sender>) }; if error.is_null() { - let _ = tx.send(Ok(LocalTrackPublication(publication))); + let _ = tx.send(Ok(LocalTrackPublication::new(publication))); } else { let error = unsafe { CFString::wrap_under_get_rule(error).to_string() }; let _ = tx.send(Err(anyhow!(error))); @@ -245,7 +245,7 @@ impl Room { let tx = unsafe { Box::from_raw(tx as *mut oneshot::Sender>) }; if error.is_null() { - let _ = tx.send(Ok(LocalTrackPublication(publication))); + let _ = tx.send(Ok(LocalTrackPublication::new(publication))); } else { let error = unsafe { CFString::wrap_under_get_rule(error).to_string() }; let _ = tx.send(Err(anyhow!(error))); @@ -344,7 +344,7 @@ impl Room { .into_iter() .map(|native_track_publication| { let native_track_publication = *native_track_publication; - Arc::new(RemoteTrackPublication(native_track_publication)) + Arc::new(RemoteTrackPublication::new(native_track_publication)) }) .collect() } @@ -564,6 +564,13 @@ impl Drop for LocalVideoTrack { pub struct LocalTrackPublication(*const c_void); impl LocalTrackPublication { + pub fn new(native_track_publication: *const c_void) -> Self { + unsafe { + CFRetain(native_track_publication); + } + Self(native_track_publication) + } + pub fn set_mute(&self, muted: bool) -> impl Future> { let (tx, rx) = futures::channel::oneshot::channel(); @@ -599,6 +606,13 @@ impl Drop for LocalTrackPublication { pub struct RemoteTrackPublication(*const c_void); impl RemoteTrackPublication { + pub fn new(native_track_publication: *const c_void) -> Self { + unsafe { + CFRetain(native_track_publication); + } + Self(native_track_publication) + } + pub fn set_enabled(&self, enabled: bool) -> impl Future> { let (tx, rx) = futures::channel::oneshot::channel(); From f0138a7a878f9c512d104d82c9d0fa81874012e9 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 21 Jun 2023 12:15:24 -0400 Subject: [PATCH 077/215] Add initial syntax highlighting doc --- docs/zed/syntax-highlighting.md | 79 +++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 docs/zed/syntax-highlighting.md diff --git a/docs/zed/syntax-highlighting.md b/docs/zed/syntax-highlighting.md new file mode 100644 index 0000000000..3878fcc6e9 --- /dev/null +++ b/docs/zed/syntax-highlighting.md @@ -0,0 +1,79 @@ +# Syntax Highlighting in Zed + +This doc is a work in progress! + +## Defining syntax highlighting rules + +We use tree-sitter queries to match certian properties to highlight. + +### Simple Example: + +```scheme +(property_identifier) @property +``` + +```ts +const font: FontFamily = { + weight: "normal", + underline: false, + italic: false, +} +``` + +Match a property identifier and highlight it using the identifier `@property`. In the above example, `weight`, `underline`, and `italic` would be highlighted. + +### Complex example: + +```scheme +(_ + return_type: (type_annotation + [ + (type_identifier) @type.return + (generic_type + name: (type_identifier) @type.return) + ])) +``` + +```ts +function buildDefaultSyntax(colorScheme: ColorScheme): Partial { + // ... +} +``` + +Match a function return type, and highlight the type using the identifier `@type.return`. In the above example, `Partial` would be highlighted. + +### Example - Typescript + +Here is an example portion of our `highlights.scm` for TypeScript: + +```scheme +; crates/zed/src/languages/typescript/highlights.scm + +; Variables + +(identifier) @variable + +; Properties + +(property_identifier) @property + +; Function and method calls + +(call_expression + function: (identifier) @function) + +(call_expression + function: (member_expression + property: (property_identifier) @function.method)) + +; Function and method definitions + +(function + name: (identifier) @function) +(function_declaration + name: (identifier) @function) +(method_definition + name: (property_identifier) @function.method) + +; ... +``` From eeb155a951132cbd321fca65c617521fd2b7ffeb Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 21 Jun 2023 12:20:47 -0400 Subject: [PATCH 078/215] Remove unused light variable --- styles/src/theme/syntax.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/styles/src/theme/syntax.ts b/styles/src/theme/syntax.ts index 380fd31786..369fceb070 100644 --- a/styles/src/theme/syntax.ts +++ b/styles/src/theme/syntax.ts @@ -129,8 +129,6 @@ function buildDefaultSyntax(colorScheme: ColorScheme): Syntax { [key: string]: Omit } = {} - const light = colorScheme.isLight - // then spread the default to each style for (const key of Object.keys({} as Syntax)) { syntax[key as keyof Syntax] = { From a3e65528baa6409f49d11a749eb2e8f3bd2570f5 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 21 Jun 2023 12:21:01 -0400 Subject: [PATCH 079/215] Update syntax colors --- styles/src/themes/rose-pine/common.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/styles/src/themes/rose-pine/common.ts b/styles/src/themes/rose-pine/common.ts index 28ed090c5d..8b3b3b7000 100644 --- a/styles/src/themes/rose-pine/common.ts +++ b/styles/src/themes/rose-pine/common.ts @@ -1,3 +1,5 @@ +import { ThemeSyntax } from "../../common"; + export const color = { default: { base: '#191724', @@ -52,20 +54,20 @@ export const color = { } }; -export const syntax = (c: typeof color.default) => { +export const syntax = (c: typeof color.default): Partial => { return { comment: { color: c.muted }, - operator: { color: c.subtle }, + operator: { color: c.pine }, punctuation: { color: c.subtle }, variable: { color: c.text }, string: { color: c.gold }, - "type.builtin": { color: c.rose }, + type: { color: c.foam }, + "type.builtin": { color: c.foam }, boolean: { color: c.rose }, function: { color: c.rose }, keyword: { color: c.pine }, tag: { color: c.foam }, - type: { color: c.foam }, - "function.method": { color: c.iris }, + "function.method": { color: c.rose }, title: { color: c.gold }, linkText: { color: c.foam, italic: false }, linkUri: { color: c.rose }, From c48bd394c16f818bd7fe42bca6f4d8063c8b26c0 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 21 Jun 2023 10:32:02 -0600 Subject: [PATCH 080/215] Start on joining lines Co-Authored-By: Conrad Irwin --- crates/editor/src/editor.rs | 13 +++++++++++ crates/editor/src/editor_tests.rs | 36 ++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index dd9952e870..b1027eeadd 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -206,6 +206,7 @@ actions!( DuplicateLine, MoveLineUp, MoveLineDown, + JoinLines, Transpose, Cut, Copy, @@ -321,6 +322,7 @@ pub fn init(cx: &mut AppContext) { cx.add_action(Editor::indent); cx.add_action(Editor::outdent); cx.add_action(Editor::delete_line); + cx.add_action(Editor::join_lines); cx.add_action(Editor::delete_to_previous_word_start); cx.add_action(Editor::delete_to_previous_subword_start); cx.add_action(Editor::delete_to_next_word_end); @@ -3952,6 +3954,17 @@ impl Editor { }); } + pub fn join_lines(&mut self, _: &JoinLines, cx: &mut ViewContext) { + let cursor_position = self.selections.newest::(cx).head(); + let snapshot = self.buffer.read(cx).snapshot(cx); + let end_of_line = Point::new(cursor_position.row, snapshot.line_len(cursor_position.row)); + let start_of_next_line = end_of_line + Point::new(1, 0); + + self.buffer.update(cx, |buffer, cx| { + buffer.edit([(end_of_line..start_of_next_line, " ")], None, cx) + }); + } + pub fn duplicate_line(&mut self, _: &DuplicateLine, cx: &mut ViewContext) { let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx)); let buffer = &display_map.buffer_snapshot; diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index e2b876f4b7..1e9a745e9c 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -1,7 +1,10 @@ use super::*; -use crate::test::{ - assert_text_with_selections, build_editor, editor_lsp_test_context::EditorLspTestContext, - editor_test_context::EditorTestContext, select_ranges, +use crate::{ + test::{ + assert_text_with_selections, build_editor, editor_lsp_test_context::EditorLspTestContext, + editor_test_context::EditorTestContext, select_ranges, + }, + JoinLines, }; use drag_and_drop::DragAndDrop; use futures::StreamExt; @@ -2325,6 +2328,33 @@ fn test_delete_line(cx: &mut TestAppContext) { }); } +#[gpui::test] +fn test_join_lines(cx: &mut TestAppContext) { + init_test(cx, |_| {}); + + let (_, editor) = cx.add_window(|cx| { + let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx); + let mut editor = build_editor(buffer.clone(), cx); + let buffer = buffer.read(cx).as_singleton().unwrap(); + + assert_eq!( + editor.selections.ranges::(cx), + &[Point::new(0, 0)..Point::new(0, 0)] + ); + + editor.join_lines(&JoinLines, cx); + + // assert_eq!( + // editor.selections.ranges::(cx), + // &[Point::new(0, 0), Point::new(0, 0)] + // ); + + assert_eq!(buffer.read(cx).text(), "abc def\nghi\n"); + + editor + }); +} + #[gpui::test] fn test_duplicate_line(cx: &mut TestAppContext) { init_test(cx, |_| {}); From 9aa7a509510e99a5167c55ba30163169200b509f Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 21 Jun 2023 18:48:09 +0200 Subject: [PATCH 081/215] Use xtask for theme generation --- .cargo/config.toml | 2 + Cargo.lock | 99 +++++++++++++++++++++++++++++++++++++-- Cargo.toml | 1 + crates/theme/src/theme.rs | 14 ------ crates/xtask/Cargo.toml | 12 +++++ crates/xtask/src/cli.rs | 0 crates/xtask/src/main.rs | 11 +++++ 7 files changed, 122 insertions(+), 17 deletions(-) create mode 100644 .cargo/config.toml create mode 100644 crates/xtask/Cargo.toml create mode 100644 crates/xtask/src/cli.rs create mode 100644 crates/xtask/src/main.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000000..35049cbcb1 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[alias] +xtask = "run --package xtask --" diff --git a/Cargo.lock b/Cargo.lock index fba46c59cf..4df64bfac7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -189,6 +189,55 @@ dependencies = [ "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]] name = "anyhow" version = "1.0.71" @@ -1102,7 +1151,7 @@ dependencies = [ "atty", "bitflags", "clap_derive", - "clap_lex", + "clap_lex 0.2.4", "indexmap", "once_cell", "strsim", @@ -1110,6 +1159,28 @@ dependencies = [ "textwrap", ] +[[package]] +name = "clap" +version = "4.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2686c4115cb0810d9a984776e197823d08ec94f176549a89a9efded477c456dc" +dependencies = [ + "clap_builder", +] + +[[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]] name = "clap_derive" version = "3.2.25" @@ -1132,12 +1203,18 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "clap_lex" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" + [[package]] name = "cli" version = "0.1.0" dependencies = [ "anyhow", - "clap", + "clap 3.2.25", "core-foundation", "core-services", "dirs 3.0.2", @@ -1247,7 +1324,7 @@ dependencies = [ "axum-extra", "base64 0.13.1", "call", - "clap", + "clap 3.2.25", "client", "collections", "ctor", @@ -1342,6 +1419,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "command_palette" version = "0.1.0" @@ -8756,6 +8839,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" +[[package]] +name = "xtask" +version = "0.1.0" +dependencies = [ + "clap 4.3.5", + "schemars", + "serde_json", + "theme", +] + [[package]] name = "yaml-rust" version = "0.4.5" diff --git a/Cargo.toml b/Cargo.toml index 72a93177a9..528b7199cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,6 +66,7 @@ members = [ "crates/vim", "crates/workspace", "crates/welcome", + "crates/xtask", "crates/zed", ] default-members = ["crates/zed"] diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 1dbe636318..97223911f5 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -1082,17 +1082,3 @@ pub struct Style { pub border: Color, pub foreground: Color, } - -#[cfg(test)] -mod tests { - use super::*; - use schemars::schema_for; - - #[test] - fn export_schema() { - let theme = schema_for!(Theme); - let output = serde_json::to_string_pretty(&theme).unwrap(); - std::fs::create_dir("schemas").ok(); - std::fs::write("schemas/theme.json", output).ok(); - } -} diff --git a/crates/xtask/Cargo.toml b/crates/xtask/Cargo.toml new file mode 100644 index 0000000000..818070c8ab --- /dev/null +++ b/crates/xtask/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "xtask" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = "4.0" +theme = {path = "../theme"} +serde_json.workspace = true +schemars.workspace = true diff --git a/crates/xtask/src/cli.rs b/crates/xtask/src/cli.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/xtask/src/main.rs b/crates/xtask/src/main.rs new file mode 100644 index 0000000000..03e342fa4a --- /dev/null +++ b/crates/xtask/src/main.rs @@ -0,0 +1,11 @@ +mod cli; + +use schemars::schema_for; + +use theme::Theme; +fn main() { + let theme = schema_for!(Theme); + let output = serde_json::to_string_pretty(&theme).unwrap(); + std::fs::create_dir("schemas").ok(); + std::fs::write("schemas/theme.json", output).ok(); +} From d194edc49f92cec05d10cd0da572d8711abff030 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 21 Jun 2023 18:51:06 +0200 Subject: [PATCH 082/215] xtask: publish = false --- crates/xtask/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/xtask/Cargo.toml b/crates/xtask/Cargo.toml index 818070c8ab..2f4ba75ca7 100644 --- a/crates/xtask/Cargo.toml +++ b/crates/xtask/Cargo.toml @@ -2,7 +2,7 @@ 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] From d3a333b8733a6283b686dcd20bd4fb02a73a13f1 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 21 Jun 2023 19:06:34 +0200 Subject: [PATCH 083/215] Tidy up xtask --- Cargo.lock | 17 ++++++++++++++++- crates/xtask/Cargo.toml | 3 ++- crates/xtask/src/cli.rs | 23 +++++++++++++++++++++++ crates/xtask/src/main.rs | 28 +++++++++++++++++++++++----- 4 files changed, 64 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4df64bfac7..3f6ebf306f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1150,7 +1150,7 @@ checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", "bitflags", - "clap_derive", + "clap_derive 3.2.25", "clap_lex 0.2.4", "indexmap", "once_cell", @@ -1166,6 +1166,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2686c4115cb0810d9a984776e197823d08ec94f176549a89a9efded477c456dc" dependencies = [ "clap_builder", + "clap_derive 4.3.2", + "once_cell", ] [[package]] @@ -1194,6 +1196,18 @@ dependencies = [ "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]] name = "clap_lex" version = "0.2.4" @@ -8843,6 +8857,7 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" name = "xtask" version = "0.1.0" dependencies = [ + "anyhow", "clap 4.3.5", "schemars", "serde_json", diff --git a/crates/xtask/Cargo.toml b/crates/xtask/Cargo.toml index 2f4ba75ca7..3d3f7d4357 100644 --- a/crates/xtask/Cargo.toml +++ b/crates/xtask/Cargo.toml @@ -6,7 +6,8 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -clap = "4.0" +anyhow = "1.0" +clap = {version = "4.0", features = ["derive"]} theme = {path = "../theme"} serde_json.workspace = true schemars.workspace = true diff --git a/crates/xtask/src/cli.rs b/crates/xtask/src/cli.rs index e69de29bb2..bffda1bc16 100644 --- a/crates/xtask/src/cli.rs +++ b/crates/xtask/src/cli.rs @@ -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, + }, +} diff --git a/crates/xtask/src/main.rs b/crates/xtask/src/main.rs index 03e342fa4a..881a65fd38 100644 --- a/crates/xtask/src/main.rs +++ b/crates/xtask/src/main.rs @@ -1,11 +1,29 @@ mod cli; -use schemars::schema_for; +use std::path::PathBuf; +use anyhow::Result; +use clap::Parser; +use schemars::schema_for; use theme::Theme; -fn main() { + +fn build_themes(mut out_dir: PathBuf, file_name: PathBuf) -> Result<()> { let theme = schema_for!(Theme); - let output = serde_json::to_string_pretty(&theme).unwrap(); - std::fs::create_dir("schemas").ok(); - std::fs::write("schemas/theme.json", output).ok(); + let output = serde_json::to_string_pretty(&theme)?; + + std::fs::create_dir(&out_dir)?; + + let mut file_path = out_dir; + out_dir.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), + } } From 86506a89aba71d85afd0123af16fe13b527b59fc Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 21 Jun 2023 19:11:55 +0200 Subject: [PATCH 084/215] Remove theme_testbench --- Cargo.lock | 13 - Cargo.toml | 1 - crates/theme_testbench/Cargo.toml | 19 -- crates/theme_testbench/src/theme_testbench.rs | 300 ------------------ crates/zed/Cargo.toml | 1 - crates/zed/src/main.rs | 1 - 6 files changed, 335 deletions(-) delete mode 100644 crates/theme_testbench/Cargo.toml delete mode 100644 crates/theme_testbench/src/theme_testbench.rs diff --git a/Cargo.lock b/Cargo.lock index a4b12223e5..206859ee45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6916,18 +6916,6 @@ dependencies = [ "workspace", ] -[[package]] -name = "theme_testbench" -version = "0.1.0" -dependencies = [ - "gpui", - "project", - "settings", - "smallvec", - "theme", - "workspace", -] - [[package]] name = "thiserror" version = "1.0.40" @@ -8888,7 +8876,6 @@ dependencies = [ "text", "theme", "theme_selector", - "theme_testbench", "thiserror", "tiny_http", "toml", diff --git a/Cargo.toml b/Cargo.toml index fca7355964..a49d75d3e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,6 @@ members = [ "crates/text", "crates/theme", "crates/theme_selector", - "crates/theme_testbench", "crates/util", "crates/vim", "crates/workspace", diff --git a/crates/theme_testbench/Cargo.toml b/crates/theme_testbench/Cargo.toml deleted file mode 100644 index 32dca6a07a..0000000000 --- a/crates/theme_testbench/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "theme_testbench" -version = "0.1.0" -edition = "2021" -publish = false - -[lib] -path = "src/theme_testbench.rs" -doctest = false - - -[dependencies] -gpui = { path = "../gpui" } -theme = { path = "../theme" } -settings = { path = "../settings" } -workspace = { path = "../workspace" } -project = { path = "../project" } - -smallvec.workspace = true diff --git a/crates/theme_testbench/src/theme_testbench.rs b/crates/theme_testbench/src/theme_testbench.rs deleted file mode 100644 index 258249b599..0000000000 --- a/crates/theme_testbench/src/theme_testbench.rs +++ /dev/null @@ -1,300 +0,0 @@ -use gpui::{ - actions, - color::Color, - elements::{ - AnyElement, Canvas, Container, ContainerStyle, Flex, Label, Margin, MouseEventHandler, - Padding, ParentElement, - }, - fonts::TextStyle, - AppContext, Border, Element, Entity, ModelHandle, Quad, Task, View, ViewContext, ViewHandle, - WeakViewHandle, -}; -use project::Project; -use theme::{ColorScheme, Layer, Style, StyleSet, ThemeSettings}; -use workspace::{item::Item, register_deserializable_item, Pane, Workspace}; - -actions!(theme, [DeployThemeTestbench]); - -pub fn init(cx: &mut AppContext) { - cx.add_action(ThemeTestbench::deploy); - - register_deserializable_item::(cx) -} - -pub struct ThemeTestbench {} - -impl ThemeTestbench { - pub fn deploy( - workspace: &mut Workspace, - _: &DeployThemeTestbench, - cx: &mut ViewContext, - ) { - let view = cx.add_view(|_| ThemeTestbench {}); - workspace.add_item(Box::new(view), cx); - } - - fn render_ramps(color_scheme: &ColorScheme) -> Flex { - fn display_ramp(ramp: &Vec) -> AnyElement { - Flex::row() - .with_children(ramp.iter().cloned().map(|color| { - Canvas::new(move |scene, bounds, _, _, _| { - scene.push_quad(Quad { - bounds, - background: Some(color), - ..Default::default() - }); - }) - .flex(1.0, false) - })) - .flex(1.0, false) - .into_any() - } - - Flex::column() - .with_child(display_ramp(&color_scheme.ramps.neutral)) - .with_child(display_ramp(&color_scheme.ramps.red)) - .with_child(display_ramp(&color_scheme.ramps.orange)) - .with_child(display_ramp(&color_scheme.ramps.yellow)) - .with_child(display_ramp(&color_scheme.ramps.green)) - .with_child(display_ramp(&color_scheme.ramps.cyan)) - .with_child(display_ramp(&color_scheme.ramps.blue)) - .with_child(display_ramp(&color_scheme.ramps.violet)) - .with_child(display_ramp(&color_scheme.ramps.magenta)) - } - - fn render_layer( - layer_index: usize, - layer: &Layer, - cx: &mut ViewContext, - ) -> Container { - Flex::column() - .with_child( - Self::render_button_set(0, layer_index, "base", &layer.base, cx).flex(1., false), - ) - .with_child( - Self::render_button_set(1, layer_index, "variant", &layer.variant, cx) - .flex(1., false), - ) - .with_child( - Self::render_button_set(2, layer_index, "on", &layer.on, cx).flex(1., false), - ) - .with_child( - Self::render_button_set(3, layer_index, "accent", &layer.accent, cx) - .flex(1., false), - ) - .with_child( - Self::render_button_set(4, layer_index, "positive", &layer.positive, cx) - .flex(1., false), - ) - .with_child( - Self::render_button_set(5, layer_index, "warning", &layer.warning, cx) - .flex(1., false), - ) - .with_child( - Self::render_button_set(6, layer_index, "negative", &layer.negative, cx) - .flex(1., false), - ) - .contained() - .with_style(ContainerStyle { - margin: Margin { - top: 10., - bottom: 10., - left: 10., - right: 10., - }, - background_color: Some(layer.base.default.background), - ..Default::default() - }) - } - - fn render_button_set( - set_index: usize, - layer_index: usize, - set_name: &'static str, - style_set: &StyleSet, - cx: &mut ViewContext, - ) -> Flex { - Flex::row() - .with_child(Self::render_button( - set_index * 6, - layer_index, - set_name, - &style_set, - None, - cx, - )) - .with_child(Self::render_button( - set_index * 6 + 1, - layer_index, - "hovered", - &style_set, - Some(|style_set| &style_set.hovered), - cx, - )) - .with_child(Self::render_button( - set_index * 6 + 2, - layer_index, - "pressed", - &style_set, - Some(|style_set| &style_set.pressed), - cx, - )) - .with_child(Self::render_button( - set_index * 6 + 3, - layer_index, - "active", - &style_set, - Some(|style_set| &style_set.active), - cx, - )) - .with_child(Self::render_button( - set_index * 6 + 4, - layer_index, - "disabled", - &style_set, - Some(|style_set| &style_set.disabled), - cx, - )) - .with_child(Self::render_button( - set_index * 6 + 5, - layer_index, - "inverted", - &style_set, - Some(|style_set| &style_set.inverted), - cx, - )) - } - - fn render_button( - button_index: usize, - layer_index: usize, - text: &'static str, - style_set: &StyleSet, - style_override: Option &Style>, - cx: &mut ViewContext, - ) -> AnyElement { - enum TestBenchButton {} - MouseEventHandler::::new(layer_index + button_index, cx, |state, cx| { - let style = if let Some(style_override) = style_override { - style_override(&style_set) - } else if state.clicked().is_some() { - &style_set.pressed - } else if state.hovered() { - &style_set.hovered - } else { - &style_set.default - }; - - Self::render_label(text.to_string(), style, cx) - .contained() - .with_style(ContainerStyle { - margin: Margin { - top: 4., - bottom: 4., - left: 4., - right: 4., - }, - padding: Padding { - top: 4., - bottom: 4., - left: 4., - right: 4., - }, - background_color: Some(style.background), - border: Border { - width: 1., - color: style.border, - overlay: false, - top: true, - bottom: true, - left: true, - right: true, - }, - corner_radius: 2., - ..Default::default() - }) - }) - .flex(1., true) - .into_any() - } - - fn render_label(text: String, style: &Style, cx: &mut ViewContext) -> Label { - let settings = settings::get::(cx); - let font_cache = cx.font_cache(); - let family_id = settings.buffer_font_family; - let font_size = settings.buffer_font_size(cx); - let font_id = font_cache - .select_font(family_id, &Default::default()) - .unwrap(); - - let text_style = TextStyle { - color: style.foreground, - font_family_id: family_id, - font_family_name: font_cache.family_name(family_id).unwrap(), - font_id, - font_size, - font_properties: Default::default(), - underline: Default::default(), - }; - - Label::new(text, text_style) - } -} - -impl Entity for ThemeTestbench { - type Event = (); -} - -impl View for ThemeTestbench { - fn ui_name() -> &'static str { - "ThemeTestbench" - } - - fn render(&mut self, cx: &mut gpui::ViewContext) -> AnyElement { - let color_scheme = &theme::current(cx).clone().color_scheme; - - Flex::row() - .with_child( - Self::render_ramps(color_scheme) - .contained() - .with_margin_right(10.) - .flex(0.1, false), - ) - .with_child( - Flex::column() - .with_child(Self::render_layer(100, &color_scheme.lowest, cx).flex(1., true)) - .with_child(Self::render_layer(200, &color_scheme.middle, cx).flex(1., true)) - .with_child(Self::render_layer(300, &color_scheme.highest, cx).flex(1., true)) - .flex(1., false), - ) - .into_any() - } -} - -impl Item for ThemeTestbench { - fn tab_content( - &self, - _: Option, - style: &theme::Tab, - _: &AppContext, - ) -> AnyElement { - Label::new("Theme Testbench", style.label.clone()) - .aligned() - .contained() - .into_any() - } - - fn serialized_item_kind() -> Option<&'static str> { - Some("ThemeTestBench") - } - - fn deserialize( - _project: ModelHandle, - _workspace: WeakViewHandle, - _workspace_id: workspace::WorkspaceId, - _item_id: workspace::ItemId, - cx: &mut ViewContext, - ) -> Task>> { - Task::ready(Ok(cx.add_view(|_| Self {}))) - } -} diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index d8e47d1c3e..6c15973b50 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -62,7 +62,6 @@ text = { path = "../text" } terminal_view = { path = "../terminal_view" } theme = { path = "../theme" } theme_selector = { path = "../theme_selector" } -theme_testbench = { path = "../theme_testbench" } util = { path = "../util" } vim = { path = "../vim" } workspace = { path = "../workspace" } diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index dcdf5c1ea5..23ecbf978b 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -154,7 +154,6 @@ fn main() { search::init(cx); vim::init(cx); terminal_view::init(cx); - theme_testbench::init(cx); copilot::init(http.clone(), node_runtime, cx); ai::init(cx); From 127f4aa506118470cfc981f751eb1ffb27befb44 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 21 Jun 2023 13:14:39 -0400 Subject: [PATCH 085/215] Fix status bar buttons --- styles/src/styleTree/statusBar.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index e4a48e8215..636da15bad 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -132,6 +132,15 @@ export default function statusBar(colorScheme: ColorScheme) { iconColor: foreground(layer, "active"), background: background(layer, "active"), }, + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "hovered"), + }, + clicked: { + iconColor: foreground(layer, "pressed"), + background: background(layer, "pressed"), + }, + } } } From f07a929350d55499fc91271a199a3538e3eae7ac Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 21 Jun 2023 11:18:28 -0600 Subject: [PATCH 086/215] Allow joining multiple lines and deleting empty lines Co-Authored-By: Conrad Irwin --- crates/editor/src/editor.rs | 33 ++++++++++++++++++++++---- crates/editor/src/editor_tests.rs | 39 +++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index b1027eeadd..84c1948a3a 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3955,13 +3955,36 @@ impl Editor { } pub fn join_lines(&mut self, _: &JoinLines, cx: &mut ViewContext) { - let cursor_position = self.selections.newest::(cx).head(); + let selection = self.selections.newest::(cx); let snapshot = self.buffer.read(cx).snapshot(cx); - let end_of_line = Point::new(cursor_position.row, snapshot.line_len(cursor_position.row)); - let start_of_next_line = end_of_line + Point::new(1, 0); - self.buffer.update(cx, |buffer, cx| { - buffer.edit([(end_of_line..start_of_next_line, " ")], None, cx) + let row_range = if selection.start.row == selection.end.row { + selection.start.row..selection.start.row + 1 + } else { + selection.start.row..selection.end.row + }; + + self.transact(cx, |this, cx| { + for (ix, row) in row_range.rev().enumerate() { + let end_of_line = Point::new(row, snapshot.line_len(row)); + let start_of_next_line = end_of_line + Point::new(1, 0); + + let replace = if snapshot.line_len(row + 1) > 0 { + " " + } else { + "" + }; + + this.buffer.update(cx, |buffer, cx| { + buffer.edit([(end_of_line..start_of_next_line, replace)], None, cx) + }); + + if ix == 0 { + this.change_selections(Some(Autoscroll::fit()), cx, |s| { + s.select_ranges([end_of_line..end_of_line]) + }) + } + } }); } diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 1e9a745e9c..d11ddb5324 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -2332,8 +2332,8 @@ fn test_delete_line(cx: &mut TestAppContext) { fn test_join_lines(cx: &mut TestAppContext) { init_test(cx, |_| {}); - let (_, editor) = cx.add_window(|cx| { - let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx); + cx.add_window(|cx| { + let buffer = MultiBuffer::build_simple("aaa\nbbb\nccc\nddd\n\n", cx); let mut editor = build_editor(buffer.clone(), cx); let buffer = buffer.read(cx).as_singleton().unwrap(); @@ -2343,13 +2343,38 @@ fn test_join_lines(cx: &mut TestAppContext) { ); editor.join_lines(&JoinLines, cx); + assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd\n\n"); + assert_eq!( + editor.selections.ranges::(cx), + &[Point::new(0, 3)..Point::new(0, 3)] + ); - // assert_eq!( - // editor.selections.ranges::(cx), - // &[Point::new(0, 0), Point::new(0, 0)] - // ); + editor.change_selections(None, cx, |s| { + s.select_ranges([Point::new(0, 5)..Point::new(2, 2)]) + }); + editor.join_lines(&JoinLines, cx); + assert_eq!(buffer.read(cx).text(), "aaa bbb ccc ddd\n\n"); + assert_eq!( + editor.selections.ranges::(cx), + &[Point::new(0, 11)..Point::new(0, 11)] + ); - assert_eq!(buffer.read(cx).text(), "abc def\nghi\n"); + editor.undo(&Undo, cx); + assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd\n\n"); + assert_eq!( + editor.selections.ranges::(cx), + &[Point::new(0, 5)..Point::new(2, 2)] + ); + + editor.change_selections(None, cx, |s| { + s.select_ranges([Point::new(2, 1)..Point::new(2, 2)]) + }); + editor.join_lines(&JoinLines, cx); + assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd\n"); + assert_eq!( + editor.selections.ranges::(cx), + [Point::new(2, 3)..Point::new(2, 3)] + ); editor }); From 61352f68ea36f02576148b1c29580ce167fc9887 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 21 Jun 2023 11:21:09 -0600 Subject: [PATCH 087/215] Add more assertions for joining lines at the end of the file Co-Authored-By: Conrad Irwin --- crates/editor/src/editor_tests.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index d11ddb5324..27ea26f788 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -2376,6 +2376,20 @@ fn test_join_lines(cx: &mut TestAppContext) { [Point::new(2, 3)..Point::new(2, 3)] ); + editor.join_lines(&JoinLines, cx); + assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd"); + assert_eq!( + editor.selections.ranges::(cx), + [Point::new(2, 3)..Point::new(2, 3)] + ); + + editor.join_lines(&JoinLines, cx); + assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd"); + assert_eq!( + editor.selections.ranges::(cx), + [Point::new(2, 3)..Point::new(2, 3)] + ); + editor }); } From cf38264edab689cd20b5ffa2a055ebda1a3e8be7 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 21 Jun 2023 11:47:06 -0600 Subject: [PATCH 088/215] Handle multiple selections when joining lines Co-Authored-By: Conrad Irwin --- crates/editor/src/editor.rs | 73 +++++++++++++++++++------------ crates/editor/src/editor_tests.rs | 39 ++++++++++++++++- 2 files changed, 84 insertions(+), 28 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 84c1948a3a..e5fa551b3b 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3955,36 +3955,55 @@ impl Editor { } pub fn join_lines(&mut self, _: &JoinLines, cx: &mut ViewContext) { - let selection = self.selections.newest::(cx); - let snapshot = self.buffer.read(cx).snapshot(cx); + let mut row_ranges = Vec::>::new(); + for selection in self.selections.ranges::(cx) { + let start = selection.start.row; + let end = if selection.start.row == selection.end.row { + selection.start.row + 1 + } else { + selection.end.row + }; - let row_range = if selection.start.row == selection.end.row { - selection.start.row..selection.start.row + 1 - } else { - selection.start.row..selection.end.row - }; - - self.transact(cx, |this, cx| { - for (ix, row) in row_range.rev().enumerate() { - let end_of_line = Point::new(row, snapshot.line_len(row)); - let start_of_next_line = end_of_line + Point::new(1, 0); - - let replace = if snapshot.line_len(row + 1) > 0 { - " " - } else { - "" - }; - - this.buffer.update(cx, |buffer, cx| { - buffer.edit([(end_of_line..start_of_next_line, replace)], None, cx) - }); - - if ix == 0 { - this.change_selections(Some(Autoscroll::fit()), cx, |s| { - s.select_ranges([end_of_line..end_of_line]) - }) + if let Some(last_row_range) = row_ranges.last_mut() { + if start <= last_row_range.end { + last_row_range.end = end; + continue; } } + row_ranges.push(start..end); + } + + let snapshot = self.buffer.read(cx).snapshot(cx); + let mut cursor_positions = Vec::new(); + for row_range in &row_ranges { + let anchor = snapshot.anchor_before(Point::new( + row_range.end - 1, + snapshot.line_len(row_range.end - 1), + )); + cursor_positions.push(anchor.clone()..anchor); + } + + self.transact(cx, |this, cx| { + for row_range in row_ranges.into_iter().rev() { + for row in row_range.rev() { + let end_of_line = Point::new(row, snapshot.line_len(row)); + let start_of_next_line = end_of_line + Point::new(1, 0); + + let replace = if snapshot.line_len(row + 1) > 0 { + " " + } else { + "" + }; + + this.buffer.update(cx, |buffer, cx| { + buffer.edit([(end_of_line..start_of_next_line, replace)], None, cx) + }); + } + } + + this.change_selections(Some(Autoscroll::fit()), cx, |s| { + s.select_anchor_ranges(cursor_positions) + }); }); } diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 27ea26f788..ab950fd5a5 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -2329,7 +2329,7 @@ fn test_delete_line(cx: &mut TestAppContext) { } #[gpui::test] -fn test_join_lines(cx: &mut TestAppContext) { +fn test_join_lines_with_single_selection(cx: &mut TestAppContext) { init_test(cx, |_| {}); cx.add_window(|cx| { @@ -2342,6 +2342,7 @@ fn test_join_lines(cx: &mut TestAppContext) { &[Point::new(0, 0)..Point::new(0, 0)] ); + // When on single line, replace newline at end by space editor.join_lines(&JoinLines, cx); assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd\n\n"); assert_eq!( @@ -2349,6 +2350,7 @@ fn test_join_lines(cx: &mut TestAppContext) { &[Point::new(0, 3)..Point::new(0, 3)] ); + // When multiple lines are selected, remove newlines that are spanned by the selection editor.change_selections(None, cx, |s| { s.select_ranges([Point::new(0, 5)..Point::new(2, 2)]) }); @@ -2359,6 +2361,7 @@ fn test_join_lines(cx: &mut TestAppContext) { &[Point::new(0, 11)..Point::new(0, 11)] ); + // Undo should be transactional editor.undo(&Undo, cx); assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd\n\n"); assert_eq!( @@ -2366,6 +2369,7 @@ fn test_join_lines(cx: &mut TestAppContext) { &[Point::new(0, 5)..Point::new(2, 2)] ); + // When joining an empty line don't insert a space editor.change_selections(None, cx, |s| { s.select_ranges([Point::new(2, 1)..Point::new(2, 2)]) }); @@ -2376,6 +2380,7 @@ fn test_join_lines(cx: &mut TestAppContext) { [Point::new(2, 3)..Point::new(2, 3)] ); + // We can remove trailing newlines editor.join_lines(&JoinLines, cx); assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd"); assert_eq!( @@ -2383,6 +2388,7 @@ fn test_join_lines(cx: &mut TestAppContext) { [Point::new(2, 3)..Point::new(2, 3)] ); + // We don't blow up on the last line editor.join_lines(&JoinLines, cx); assert_eq!(buffer.read(cx).text(), "aaa bbb\nccc\nddd"); assert_eq!( @@ -2394,6 +2400,37 @@ fn test_join_lines(cx: &mut TestAppContext) { }); } +#[gpui::test] +fn test_join_lines_with_multi_selection(cx: &mut TestAppContext) { + init_test(cx, |_| {}); + + cx.add_window(|cx| { + let buffer = MultiBuffer::build_simple("aaa\nbbb\nccc\nddd\n\n", cx); + let mut editor = build_editor(buffer.clone(), cx); + let buffer = buffer.read(cx).as_singleton().unwrap(); + + editor.change_selections(None, cx, |s| { + s.select_ranges([ + Point::new(0, 2)..Point::new(1, 1), + Point::new(1, 2)..Point::new(1, 2), + Point::new(3, 1)..Point::new(3, 2), + ]) + }); + + editor.join_lines(&JoinLines, cx); + assert_eq!(buffer.read(cx).text(), "aaa bbb ccc\nddd\n"); + + assert_eq!( + editor.selections.ranges::(cx), + [ + Point::new(0, 7)..Point::new(0, 7), + Point::new(1, 3)..Point::new(1, 3) + ] + ); + editor + }); +} + #[gpui::test] fn test_duplicate_line(cx: &mut TestAppContext) { init_test(cx, |_| {}); From cde8d7d747261e1c52763a3e88b3c73a640ab01b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 21 Jun 2023 11:53:11 -0600 Subject: [PATCH 089/215] Don't use test-only method; add ctrl-j binding Co-Authored-By: Conrad Irwin --- assets/keymaps/default.json | 1 + crates/editor/src/editor.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index a642697a37..84b11b53a1 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -411,6 +411,7 @@ "ctrl-shift-k": "editor::DeleteLine", "cmd-shift-d": "editor::DuplicateLine", "cmd-shift-l": "editor::SplitSelectionIntoLines", + "ctrl-j": "editor::JoinLines", "ctrl-cmd-up": "editor::MoveLineUp", "ctrl-cmd-down": "editor::MoveLineDown", "ctrl-alt-backspace": "editor::DeleteToPreviousSubwordStart", diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index e5fa551b3b..c8daff3fd5 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3956,7 +3956,7 @@ impl Editor { pub fn join_lines(&mut self, _: &JoinLines, cx: &mut ViewContext) { let mut row_ranges = Vec::>::new(); - for selection in self.selections.ranges::(cx) { + for selection in self.selections.all::(cx) { let start = selection.start.row; let end = if selection.start.row == selection.end.row { selection.start.row + 1 From ed8bdd186e9515e648a83d3448e7c9805cb3d2eb Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 21 Jun 2023 13:56:27 -0400 Subject: [PATCH 090/215] Update toggle active styles --- styles/src/styleTree/contactList.ts | 13 ++++- styles/src/styleTree/contextMenu.ts | 8 ++- styles/src/styleTree/editor.ts | 27 +++++++---- styles/src/styleTree/picker.ts | 19 +++++++- styles/src/styleTree/projectPanel.ts | 54 +++++++++++++-------- styles/src/styleTree/search.ts | 23 ++++++--- styles/src/styleTree/tabBar.ts | 9 ++++ styles/src/styleTree/toolbarDropdownMenu.ts | 9 ++-- styles/src/styleTree/workspace.ts | 11 +++-- 9 files changed, 126 insertions(+), 47 deletions(-) diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index 57034109f1..cee17219c8 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -83,7 +83,12 @@ export default function contactsPanel(colorScheme: ColorScheme) { background: background(layer, "default"), // posiewic: breaking change }, state: { - hovered: { background: background(layer, "default") }, + hovered: { + background: background(layer, "hovered"), + }, + clicked: { + background: background(layer, "pressed"), + } }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. }), state: { @@ -92,6 +97,12 @@ export default function contactsPanel(colorScheme: ColorScheme) { ...text(layer, "mono", "active", { size: "sm" }), background: background(layer, "active"), }, + hovered: { + background: background(layer, "hovered"), + }, + clicked: { + background: background(layer, "pressed"), + } } } }), diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index 7b2b9be6c2..a217018c97 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -40,6 +40,9 @@ export default function contextMenu(colorScheme: ColorScheme) { padding: { left: 3, right: 3 }, }, }, + clicked: { + background: background(layer, "pressed"), + }, }, }), state: { @@ -48,7 +51,10 @@ export default function contextMenu(colorScheme: ColorScheme) { background: background(layer, "active"), }, hovered: { - background: background(layer, "active"), + background: background(layer, "hovered"), + }, + clicked: { + background: background(layer, "pressed"), }, } } diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index b02366192a..62792f6feb 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -56,18 +56,24 @@ export default function editor(colorScheme: ColorScheme) { color: foreground(layer, "variant"), }, state: { - clicked: { - color: foreground(layer, "base"), - }, hovered: { - color: foreground(layer, "on"), + color: foreground(layer, "variant", "hovered"), + }, + clicked: { + color: foreground(layer, "variant", "pressed"), }, }, }), state: { active: { default: { - color: foreground(layer, "on"), + color: foreground(layer, "accent"), + }, + hovered: { + color: foreground(layer, "accent", "hovered"), + }, + clicked: { + color: foreground(layer, "accent", "pressed"), }, } } @@ -87,18 +93,21 @@ export default function editor(colorScheme: ColorScheme) { color: foreground(layer, "variant"), }, state: { - clicked: { - color: foreground(layer, "base"), - }, hovered: { color: foreground(layer, "on"), }, + clicked: { + color: foreground(layer, "base"), + }, }, }), state: { active: { default: { - color: foreground(layer, "on"), + color: foreground(layer, "default"), + }, + hovered: { + color: foreground(layer, "variant"), }, } } diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 809cd1743f..57ee71efb4 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -67,6 +67,12 @@ export default function picker(colorScheme: ColorScheme): any { 0.5 ), }, + clicked: { + background: withOpacity( + background(layer, "pressed"), + 0.5 + ), + }, }, }), state: { @@ -76,7 +82,18 @@ export default function picker(colorScheme: ColorScheme): any { background(layer, "base", "active"), 0.5 ), - //text: text(layer, "sans", "base", "active"), + }, + hovered: { + background: withOpacity( + background(layer, "hovered"), + 0.5 + ), + }, + clicked: { + background: withOpacity( + background(layer, "pressed"), + 0.5 + ), }, } } diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 7c37ce6bd3..2c94a51dba 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -28,33 +28,44 @@ export default function projectPanel(colorScheme: ColorScheme) { }, } + const default_entry = interactive({ + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, + }, + state: { + default: { + background: background(layer), + }, + hovered: { + background: background(layer, "variant", "hovered"), + }, + clicked: { + background: background(layer, "variant", "pressed"), + } + }, + }) + let entry = toggleable({ - base: - interactive({ + base: default_entry, + state: { + active: interactive({ base: { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - status, + ...default_entry }, state: { + default: { + background: background(colorScheme.lowest), + }, hovered: { - background: background(layer, "variant", "hovered"), + background: background(colorScheme.lowest, "hovered"), + }, + clicked: { + background: background(colorScheme.lowest, "pressed"), }, }, }), - state: { - active: { - default: { - /*background: colorScheme.isLight - ? withOpacity(background(layer, "active"), 0.5) - : background(layer, "active") ,*/ // todo posiewic - text: text(layer, "mono", "active", { size: "sm" }), - }, - hovered: { - //background: background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), - }, - } } } ) @@ -84,6 +95,11 @@ export default function projectPanel(colorScheme: ColorScheme) { background: background(layer, "hovered"), border: border(layer, "active"), }, + clicked: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "pressed"), + border: border(layer, "active"), + } }, }), background: background(layer), diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index 0123ddee22..40816e673c 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -55,24 +55,28 @@ export default function search(colorScheme: ColorScheme) { }, }, state: { - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, hovered: { ...text(layer, "mono", "on", "hovered"), background: background(layer, "on", "hovered"), border: border(layer, "on", "hovered"), }, + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, }, }), state: { active: { default: { - ...text(layer, "mono", "on", "inverted"), - background: background(layer, "on", "inverted"), - border: border(layer, "on", "inverted"), + ...text(layer, "mono", "accent"), + }, + hovered: { + ...text(layer, "mono", "accent", "hovered"), + }, + clicked: { + ...text(layer, "mono", "accent", "pressed"), }, } } @@ -124,6 +128,9 @@ export default function search(colorScheme: ColorScheme) { hovered: { color: foreground(layer, "hovered"), }, + clicked: { + color: foreground(layer, "pressed"), + }, }, }), } diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index f2c99ea736..85291c9edb 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -100,6 +100,9 @@ export default function tabBar(colorScheme: ColorScheme) { hovered: { color: foreground(layer, "hovered"), }, + clicked: { + color: foreground(layer, "pressed"), + }, }, }), state: @@ -108,6 +111,12 @@ export default function tabBar(colorScheme: ColorScheme) { default: { color: foreground(layer, "accent"), }, + hovered: { + color: foreground(layer, "hovered"), + }, + clicked: { + color: foreground(layer, "pressed"), + }, } } } diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index b1b28d789e..3837f5e1a4 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -19,13 +19,14 @@ export default function dropdownMenu(colorScheme: ColorScheme) { secondaryTextSpacing: 10, padding: { left: 8, right: 8, top: 2, bottom: 2 }, cornerRadius: 6, - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), + background: background(layer, "on") }, state: { hovered: { background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), + }, + clicked: { + background: background(layer, "pressed"), }, }, }), @@ -55,7 +56,7 @@ export default function dropdownMenu(colorScheme: ColorScheme) { background: background(layer, "active"), }, hovered: { - background: background(layer, "active"), + background: background(layer, "hovered"), }, } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index fdc7657481..d835dfe3a1 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -287,20 +287,23 @@ export default function workspace(colorScheme: ColorScheme) { state: { clicked: { background: background(layer, "variant", "pressed"), - color: foreground(layer, "variant", "pressed"), }, hovered: { background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), }, }, }), state: { active: { default: { - background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active"), + background: background(layer, "on", "default"), }, + hovered: { + background: background(layer, "on", "hovered"), + }, + clicked: { + background: background(layer, "on", "pressed"), + } } } } From a365b2f1775ad80886270975159ce5e62455a0c8 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 21 Jun 2023 11:58:31 -0600 Subject: [PATCH 091/215] Add shift-J binding to Vim normal mode Co-Authored-By: Conrad Irwin --- assets/keymaps/vim.json | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 47c5f8c458..bf5eed5350 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -143,6 +143,7 @@ "Delete" ], "shift-d": "vim::DeleteToEndOfLine", + "shift-j": "editor::JoinLines", "y": [ "vim::PushOperator", "Yank" From a845e82173366e2e37504ea9b3f6cf0582c0995d Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 21 Jun 2023 13:58:42 -0400 Subject: [PATCH 092/215] Update settings.json --- styles/.zed/settings.json | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/styles/.zed/settings.json b/styles/.zed/settings.json index 0a3c761b8e..5c31fc5ac1 100644 --- a/styles/.zed/settings.json +++ b/styles/.zed/settings.json @@ -3,9 +3,18 @@ // For a full list of overridable settings, and general information on folder-specific settings, // see the documentation: https://docs.zed.dev/configuration/configuring-zed#folder-specific-settings { - "languages": { - "TypeScript": { - "tab_size": 4 + "languages": { + "TypeScript": { + "tab_size": 4 + }, + "TSX": { + "tab_size": 4 + }, + "JavaScript": { + "tab_size": 4 + }, + "JSON": { + "tab_size": 4 + } } - } } From 9d9bbfdabfb04389beb7989babed076369ce3cb5 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 21 Jun 2023 13:58:54 -0400 Subject: [PATCH 093/215] Format --- styles/src/buildTokens.ts | 86 +++++++------- styles/src/element/interactive.ts | 118 ++++++++++---------- styles/src/element/toggle.ts | 30 ++--- styles/src/styleTree/commandPalette.ts | 6 +- styles/src/styleTree/contactList.ts | 78 ++++++------- styles/src/styleTree/contextMenu.ts | 56 +++++----- styles/src/styleTree/editor.ts | 60 +++++----- styles/src/styleTree/picker.ts | 72 ++++++------ styles/src/styleTree/projectPanel.ts | 11 +- styles/src/styleTree/search.ts | 62 +++++----- styles/src/styleTree/statusBar.ts | 41 ++++--- styles/src/styleTree/tabBar.ts | 37 +++--- styles/src/styleTree/toolbarDropdownMenu.ts | 36 +++--- styles/src/styleTree/workspace.ts | 106 +++++++++--------- 14 files changed, 387 insertions(+), 412 deletions(-) diff --git a/styles/src/buildTokens.ts b/styles/src/buildTokens.ts index 0cf1ea037e..6c6acd2f22 100644 --- a/styles/src/buildTokens.ts +++ b/styles/src/buildTokens.ts @@ -1,13 +1,13 @@ -import * as fs from "fs"; -import * as path from "path"; -import { ColorScheme, createColorScheme } from "./common"; -import { themes } from "./themes"; -import { slugify } from "./utils/slugify"; -import { colorSchemeTokens } from "./theme/tokens/colorScheme"; +import * as fs from "fs" +import * as path from "path" +import { ColorScheme, createColorScheme } from "./common" +import { themes } from "./themes" +import { slugify } from "./utils/slugify" +import { colorSchemeTokens } from "./theme/tokens/colorScheme" -const TOKENS_DIRECTORY = path.join(__dirname, "..", "target", "tokens"); -const TOKENS_FILE = path.join(TOKENS_DIRECTORY, "$themes.json"); -const METADATA_FILE = path.join(TOKENS_DIRECTORY, "$metadata.json"); +const TOKENS_DIRECTORY = path.join(__dirname, "..", "target", "tokens") +const TOKENS_FILE = path.join(TOKENS_DIRECTORY, "$themes.json") +const METADATA_FILE = path.join(TOKENS_DIRECTORY, "$metadata.json") function clearTokens(tokensDirectory: string) { if (!fs.existsSync(tokensDirectory)) { @@ -22,64 +22,66 @@ function clearTokens(tokensDirectory: string) { } type TokenSet = { - id: string; - name: string; - selectedTokenSets: { [key: string]: "enabled" }; -}; + id: string + name: string + selectedTokenSets: { [key: string]: "enabled" } +} -function buildTokenSetOrder(colorSchemes: ColorScheme[]): { tokenSetOrder: string[] } { - const tokenSetOrder: string[] = colorSchemes.map( - (scheme) => scheme.name.toLowerCase().replace(/\s+/g, "_") - ); - return { tokenSetOrder }; +function buildTokenSetOrder(colorSchemes: ColorScheme[]): { + tokenSetOrder: string[] +} { + const tokenSetOrder: string[] = colorSchemes.map((scheme) => + scheme.name.toLowerCase().replace(/\s+/g, "_") + ) + return { tokenSetOrder } } function buildThemesIndex(colorSchemes: ColorScheme[]): TokenSet[] { const themesIndex: TokenSet[] = colorSchemes.map((scheme, index) => { const id = `${scheme.isLight ? "light" : "dark"}_${scheme.name .toLowerCase() - .replace(/\s+/g, "_")}_${index}`; - const selectedTokenSets: { [key: string]: "enabled" } = {}; - const tokenSet = scheme.name.toLowerCase().replace(/\s+/g, "_"); - selectedTokenSets[tokenSet] = "enabled"; + .replace(/\s+/g, "_")}_${index}` + const selectedTokenSets: { [key: string]: "enabled" } = {} + const tokenSet = scheme.name.toLowerCase().replace(/\s+/g, "_") + selectedTokenSets[tokenSet] = "enabled" return { id, name: `${scheme.name} - ${scheme.isLight ? "Light" : "Dark"}`, selectedTokenSets, - }; - }); + } + }) - return themesIndex; + return themesIndex } function writeTokens(colorSchemes: ColorScheme[], tokensDirectory: string) { - clearTokens(tokensDirectory); + clearTokens(tokensDirectory) for (const colorScheme of colorSchemes) { - const fileName = slugify(colorScheme.name) + ".json"; - const tokens = colorSchemeTokens(colorScheme); - const tokensJSON = JSON.stringify(tokens, null, 2); - const outPath = path.join(tokensDirectory, fileName); - fs.writeFileSync(outPath, tokensJSON, { mode: 0o644 }); - console.log(`- ${outPath} created`); + const fileName = slugify(colorScheme.name) + ".json" + const tokens = colorSchemeTokens(colorScheme) + const tokensJSON = JSON.stringify(tokens, null, 2) + const outPath = path.join(tokensDirectory, fileName) + fs.writeFileSync(outPath, tokensJSON, { mode: 0o644 }) + console.log(`- ${outPath} created`) } - const themeIndexData = buildThemesIndex(colorSchemes); + const themeIndexData = buildThemesIndex(colorSchemes) - const themesJSON = JSON.stringify(themeIndexData, null, 2); - fs.writeFileSync(TOKENS_FILE, themesJSON, { mode: 0o644 }); - console.log(`- ${TOKENS_FILE} created`); + const themesJSON = JSON.stringify(themeIndexData, null, 2) + fs.writeFileSync(TOKENS_FILE, themesJSON, { mode: 0o644 }) + console.log(`- ${TOKENS_FILE} created`) - const tokenSetOrderData = buildTokenSetOrder(colorSchemes); + const tokenSetOrderData = buildTokenSetOrder(colorSchemes) - const metadataJSON = JSON.stringify(tokenSetOrderData, null, 2); - fs.writeFileSync(METADATA_FILE, metadataJSON, { mode: 0o644 }); - console.log(`- ${METADATA_FILE} created`); + const metadataJSON = JSON.stringify(tokenSetOrderData, null, 2) + fs.writeFileSync(METADATA_FILE, metadataJSON, { mode: 0o644 }) + console.log(`- ${METADATA_FILE} created`) } const colorSchemes: ColorScheme[] = themes.map((theme) => createColorScheme(theme) -); +) -writeTokens(colorSchemes, TOKENS_DIRECTORY); +writeTokens(colorSchemes, TOKENS_DIRECTORY) diff --git a/styles/src/element/interactive.ts b/styles/src/element/interactive.ts index bd90e28aad..1c0f393cff 100644 --- a/styles/src/element/interactive.ts +++ b/styles/src/element/interactive.ts @@ -2,28 +2,28 @@ import merge from "ts-deepmerge" import { DeepPartial } from "utility-types" type InteractiveState = - | "default" - | "hovered" - | "clicked" - | "selected" - | "disabled" + | "default" + | "hovered" + | "clicked" + | "selected" + | "disabled" type Interactive = { - default: T - hovered?: T - clicked?: T - selected?: T - disabled?: T + default: T + hovered?: T + clicked?: T + selected?: T + disabled?: T } export const NO_DEFAULT_OR_BASE_ERROR = - "An interactive object must have a default state, or a base property." + "An interactive object must have a default state, or a base property." export const NOT_ENOUGH_STATES_ERROR = - "An interactive object must have a default and at least one other state." + "An interactive object must have a default and at least one other state." interface InteractiveProps { - base?: T - state: Partial>> + base?: T + state: Partial>> } /** @@ -38,60 +38,60 @@ interface InteractiveProps { * @returns Interactive object with fields from `base` and `state`. */ export function interactive({ - base, - state, + base, + state, }: InteractiveProps): Interactive { - if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR) + if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR) - let defaultState: T + let defaultState: T - if (state.default && base) { - defaultState = merge(base, state.default) as T - } else { - defaultState = base ? base : (state.default as T) - } + if (state.default && base) { + defaultState = merge(base, state.default) as T + } else { + defaultState = base ? base : (state.default as T) + } - let interactiveObj: Interactive = { - default: defaultState, - } + let interactiveObj: Interactive = { + default: defaultState, + } - let stateCount = 0 + let stateCount = 0 - if (state.hovered !== undefined) { - interactiveObj.hovered = merge( - interactiveObj.default, - state.hovered - ) as T - stateCount++ - } + if (state.hovered !== undefined) { + interactiveObj.hovered = merge( + interactiveObj.default, + state.hovered + ) as T + stateCount++ + } - if (state.clicked !== undefined) { - interactiveObj.clicked = merge( - interactiveObj.default, - state.clicked - ) as T - stateCount++ - } + if (state.clicked !== undefined) { + interactiveObj.clicked = merge( + interactiveObj.default, + state.clicked + ) as T + stateCount++ + } - if (state.selected !== undefined) { - interactiveObj.selected = merge( - interactiveObj.default, - state.selected - ) as T - stateCount++ - } + if (state.selected !== undefined) { + interactiveObj.selected = merge( + interactiveObj.default, + state.selected + ) as T + stateCount++ + } - if (state.disabled !== undefined) { - interactiveObj.disabled = merge( - interactiveObj.default, - state.disabled - ) as T - stateCount++ - } + if (state.disabled !== undefined) { + interactiveObj.disabled = merge( + interactiveObj.default, + state.disabled + ) as T + stateCount++ + } - if (stateCount < 1) { - throw new Error(NOT_ENOUGH_STATES_ERROR) - } + if (stateCount < 1) { + throw new Error(NOT_ENOUGH_STATES_ERROR) + } - return interactiveObj + return interactiveObj } diff --git a/styles/src/element/toggle.ts b/styles/src/element/toggle.ts index cbf28b71e7..ead8f1e824 100644 --- a/styles/src/element/toggle.ts +++ b/styles/src/element/toggle.ts @@ -6,12 +6,12 @@ type ToggleState = "inactive" | "active" type Toggleable = Record export const NO_INACTIVE_OR_BASE_ERROR = - "A toggleable object must have an inactive state, or a base property." + "A toggleable object must have an inactive state, or a base property." export const NO_ACTIVE_ERROR = "A toggleable object must have an active state." interface ToggleableProps { - base?: T - state: Partial>> + base?: T + state: Partial>> } /** @@ -28,20 +28,20 @@ interface ToggleableProps { * ``` */ export function toggleable( - props: ToggleableProps + props: ToggleableProps ): Toggleable { - const { base, state } = props + const { base, state } = props - if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR) - if (!state.active) throw new Error(NO_ACTIVE_ERROR) + if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR) + if (!state.active) throw new Error(NO_ACTIVE_ERROR) - const inactiveState = base - ? ((state.inactive ? merge(base, state.inactive) : base) as T) - : (state.inactive as T) + const inactiveState = base + ? ((state.inactive ? merge(base, state.inactive) : base) as T) + : (state.inactive as T) - const toggleObj: Toggleable = { - inactive: inactiveState, - active: merge(base ?? {}, state.active) as T, - } - return toggleObj + const toggleObj: Toggleable = { + inactive: inactiveState, + active: merge(base ?? {}, state.active) as T, + } + return toggleObj } diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index 5389a775ed..5d4b7373c3 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -27,8 +27,8 @@ export default function commandPalette(colorScheme: ColorScheme) { active: { text: text(layer, "mono", "on", "default", { size: "xs" }), background: withOpacity(background(layer, "on"), 0.2), - } - } + }, + }, }) return { @@ -37,6 +37,6 @@ export default function commandPalette(colorScheme: ColorScheme) { key: { inactive: { ...key.inactive }, active: key.active, - } + }, } } diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index cee17219c8..88ae04277e 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -88,7 +88,7 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, clicked: { background: background(layer, "pressed"), - } + }, }, // hack, we want headerRow to be interactive for whatever reason. It probably shouldn't be interactive in the first place. }), state: { @@ -102,9 +102,9 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, clicked: { background: background(layer, "pressed"), - } - } - } + }, + }, + }, }), leaveCall: interactive({ base: { @@ -190,55 +190,51 @@ export default function contactsPanel(colorScheme: ColorScheme) { ...text(layer, "mono", "variant", { size: "xs" }), }, treeBranch: toggleable({ - base: - interactive({ - base: { + base: interactive({ + base: { + color: borderColor(layer), + width: 1, + }, + state: { + hovered: { color: borderColor(layer), - width: 1, }, - state: { - hovered: { - color: borderColor(layer), - }, - }, - }), + }, + }), state: { active: { default: { color: borderColor(layer), }, - } - } - } - ), + }, + }, + }), projectRow: toggleable({ - base: - interactive({ - base: { - ...projectRow, - background: background(layer), - icon: { - margin: { left: nameMargin }, - color: foreground(layer, "variant"), - width: 12, - }, - name: { - ...projectRow.name, - ...text(layer, "mono", { size: "sm" }), - }, + base: interactive({ + base: { + ...projectRow, + background: background(layer), + icon: { + margin: { left: nameMargin }, + color: foreground(layer, "variant"), + width: 12, }, - state: { - hovered: { - background: background(layer, "hovered"), - }, + name: { + ...projectRow.name, + ...text(layer, "mono", { size: "sm" }), }, - }), + }, + state: { + hovered: { + background: background(layer, "hovered"), + }, + }, + }), state: { active: { default: { background: background(layer, "active") }, - } - } - } - ), + }, + }, + }), } } diff --git a/styles/src/styleTree/contextMenu.ts b/styles/src/styleTree/contextMenu.ts index a217018c97..a59284c43a 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -12,39 +12,38 @@ export default function contextMenu(colorScheme: ColorScheme) { border: border(layer), keystrokeMargin: 30, item: toggleable({ - base: - interactive({ - base: { - iconSpacing: 8, - iconWidth: 14, - padding: { left: 6, right: 6, top: 2, bottom: 2 }, - cornerRadius: 6, - label: text(layer, "sans", { size: "sm" }), + base: interactive({ + base: { + iconSpacing: 8, + iconWidth: 14, + padding: { left: 6, right: 6, top: 2, bottom: 2 }, + cornerRadius: 6, + label: text(layer, "sans", { size: "sm" }), + keystroke: { + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), + padding: { left: 3, right: 3 }, + }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + label: text(layer, "sans", "hovered", { size: "sm" }), keystroke: { - ...text(layer, "sans", "variant", { + ...text(layer, "sans", "hovered", { size: "sm", weight: "bold", }), padding: { left: 3, right: 3 }, }, }, - state: { - hovered: { - background: background(layer, "hovered"), - label: text(layer, "sans", "hovered", { size: "sm" }), - keystroke: { - ...text(layer, "sans", "hovered", { - size: "sm", - weight: "bold", - }), - padding: { left: 3, right: 3 }, - }, - }, - clicked: { - background: background(layer, "pressed"), - }, + clicked: { + background: background(layer, "pressed"), }, - }), + }, + }), state: { active: { default: { @@ -56,10 +55,9 @@ export default function contextMenu(colorScheme: ColorScheme) { clicked: { background: background(layer, "pressed"), }, - } - } - } - ), + }, + }, + }), separator: { background: borderColor(layer), diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 62792f6feb..c53f3ba2ff 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -50,20 +50,19 @@ export default function editor(colorScheme: ColorScheme) { suggestion: syntax.predictive, codeActions: { indicator: toggleable({ - base: - interactive({ - base: { - color: foreground(layer, "variant"), + base: interactive({ + base: { + color: foreground(layer, "variant"), + }, + state: { + hovered: { + color: foreground(layer, "variant", "hovered"), }, - state: { - hovered: { - color: foreground(layer, "variant", "hovered"), - }, - clicked: { - color: foreground(layer, "variant", "pressed"), - }, + clicked: { + color: foreground(layer, "variant", "pressed"), }, - }), + }, + }), state: { active: { default: { @@ -75,10 +74,9 @@ export default function editor(colorScheme: ColorScheme) { clicked: { color: foreground(layer, "accent", "pressed"), }, - } - } - } - ), + }, + }, + }), verticalScale: 0.55, }, @@ -87,20 +85,19 @@ export default function editor(colorScheme: ColorScheme) { foldedIcon: "icons/chevron_right_8.svg", foldableIcon: "icons/chevron_down_8.svg", indicator: toggleable({ - base: - interactive({ - base: { - color: foreground(layer, "variant"), + base: interactive({ + base: { + color: foreground(layer, "variant"), + }, + state: { + hovered: { + color: foreground(layer, "on"), }, - state: { - hovered: { - color: foreground(layer, "on"), - }, - clicked: { - color: foreground(layer, "base"), - }, + clicked: { + color: foreground(layer, "base"), }, - }), + }, + }), state: { active: { default: { @@ -109,10 +106,9 @@ export default function editor(colorScheme: ColorScheme) { hovered: { color: foreground(layer, "variant"), }, - } - } - } - ), + }, + }, + }), ellipses: { textColor: colorScheme.ramps.neutral(0.71).hex(), cornerRadiusFactor: 0.15, diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index 57ee71efb4..5501bd4df2 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -40,41 +40,40 @@ export default function picker(colorScheme: ColorScheme): any { padding: {}, }, item: toggleable({ - base: - interactive({ - base: { - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, - }, - margin: { - top: 1, - left: 4, - right: 4, - }, - cornerRadius: 8, - text: text(layer, "sans", "variant"), - highlightText: text(layer, "sans", "accent", { - weight: "bold", - }), + base: interactive({ + base: { + padding: { + bottom: 4, + left: 12, + right: 12, + top: 4, }, - state: { - hovered: { - background: withOpacity( - background(layer, "hovered"), - 0.5 - ), - }, - clicked: { - background: withOpacity( - background(layer, "pressed"), - 0.5 - ), - }, + margin: { + top: 1, + left: 4, + right: 4, }, - }), + cornerRadius: 8, + text: text(layer, "sans", "variant"), + highlightText: text(layer, "sans", "accent", { + weight: "bold", + }), + }, + state: { + hovered: { + background: withOpacity( + background(layer, "hovered"), + 0.5 + ), + }, + clicked: { + background: withOpacity( + background(layer, "pressed"), + 0.5 + ), + }, + }, + }), state: { active: { default: { @@ -95,10 +94,9 @@ export default function picker(colorScheme: ColorScheme): any { 0.5 ), }, - } - } - } - ), + }, + }, + }), inputEditor, emptyInputEditor, diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 2c94a51dba..6bec951288 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -43,7 +43,7 @@ export default function projectPanel(colorScheme: ColorScheme) { }, clicked: { background: background(layer, "variant", "pressed"), - } + }, }, }) @@ -52,7 +52,7 @@ export default function projectPanel(colorScheme: ColorScheme) { state: { active: interactive({ base: { - ...default_entry + ...default_entry, }, state: { default: { @@ -66,9 +66,8 @@ export default function projectPanel(colorScheme: ColorScheme) { }, }, }), - } - } - ) + }, + }) return { openProjectButton: interactive({ @@ -99,7 +98,7 @@ export default function projectPanel(colorScheme: ColorScheme) { ...text(layer, "sans", "default", { size: "sm" }), background: background(layer, "pressed"), border: border(layer, "active"), - } + }, }, }), background: background(layer), diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index 40816e673c..b471e6cbda 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -37,36 +37,35 @@ export default function search(colorScheme: ColorScheme) { // TODO: Add an activeMatchBackground on the rust side to differentiate between active and inactive matchBackground: withOpacity(foreground(layer, "accent"), 0.4), optionButton: toggleable({ - base: - interactive({ - base: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, - }, - padding: { - bottom: 2, - left: 10, - right: 10, - top: 2, - }, + base: interactive({ + base: { + ...text(layer, "mono", "on"), + background: background(layer, "on"), + cornerRadius: 6, + border: border(layer, "on"), + margin: { + right: 4, }, - state: { - hovered: { - ...text(layer, "mono", "on", "hovered"), - background: background(layer, "on", "hovered"), - border: border(layer, "on", "hovered"), - }, - clicked: { - ...text(layer, "mono", "on", "pressed"), - background: background(layer, "on", "pressed"), - border: border(layer, "on", "pressed"), - }, + padding: { + bottom: 2, + left: 10, + right: 10, + top: 2, }, - }), + }, + state: { + hovered: { + ...text(layer, "mono", "on", "hovered"), + background: background(layer, "on", "hovered"), + border: border(layer, "on", "hovered"), + }, + clicked: { + ...text(layer, "mono", "on", "pressed"), + background: background(layer, "on", "pressed"), + border: border(layer, "on", "pressed"), + }, + }, + }), state: { active: { default: { @@ -78,10 +77,9 @@ export default function search(colorScheme: ColorScheme) { clicked: { ...text(layer, "mono", "accent", "pressed"), }, - } - } - } - ), + }, + }, + }), editor, invalidEditor: { ...editor, diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 636da15bad..339e2e40cf 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -108,25 +108,24 @@ export default function statusBar(colorScheme: ColorScheme) { groupBottom: {}, groupRight: {}, button: toggleable({ - base: - interactive({ - base: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), - }, + base: interactive({ + base: { + ...statusContainer, + iconSize: 16, + iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), }, - state: { - hovered: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - }, + }, + state: { + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "variant"), }, - }), state: - { + }, + }), + state: { active: { default: { iconColor: foreground(layer, "active"), @@ -140,11 +139,9 @@ export default function statusBar(colorScheme: ColorScheme) { iconColor: foreground(layer, "pressed"), background: background(layer, "pressed"), }, - - } - } - } - ), + }, + }, + }), badge: { cornerRadius: 3, padding: 2, diff --git a/styles/src/styleTree/tabBar.ts b/styles/src/styleTree/tabBar.ts index 85291c9edb..af35a8fef4 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -89,24 +89,22 @@ export default function tabBar(colorScheme: ColorScheme) { }, draggedTab, paneButton: toggleable({ - base: - interactive({ - base: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, + base: interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), }, - state: { - hovered: { - color: foreground(layer, "hovered"), - }, - clicked: { - color: foreground(layer, "pressed"), - }, + clicked: { + color: foreground(layer, "pressed"), }, - }), - state: - { + }, + }), + state: { active: { default: { color: foreground(layer, "accent"), @@ -117,10 +115,9 @@ export default function tabBar(colorScheme: ColorScheme) { clicked: { color: foreground(layer, "pressed"), }, - } - } - } - ), + }, + }, + }), paneButtonContainer: { background: tab.background, border: { diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 3837f5e1a4..d82e5f1cde 100644 --- a/styles/src/styleTree/toolbarDropdownMenu.ts +++ b/styles/src/styleTree/toolbarDropdownMenu.ts @@ -19,7 +19,7 @@ export default function dropdownMenu(colorScheme: ColorScheme) { secondaryTextSpacing: 10, padding: { left: 8, right: 8, top: 2, bottom: 2 }, cornerRadius: 6, - background: background(layer, "on") + background: background(layer, "on"), }, state: { hovered: { @@ -35,21 +35,20 @@ export default function dropdownMenu(colorScheme: ColorScheme) { padding: { left: 8, right: 8, top: 8, bottom: 8 }, }, item: toggleable({ - base: - interactive({ - base: { - ...text(layer, "sans", { size: "sm" }), - secondaryTextSpacing: 10, - secondaryText: text(layer, "sans", { size: "sm" }), - padding: { left: 18, right: 18, top: 2, bottom: 2 }, + base: interactive({ + base: { + ...text(layer, "sans", { size: "sm" }), + secondaryTextSpacing: 10, + secondaryText: text(layer, "sans", { size: "sm" }), + padding: { left: 18, right: 18, top: 2, bottom: 2 }, + }, + state: { + hovered: { + background: background(layer, "hovered"), + ...text(layer, "sans", "hovered", { size: "sm" }), }, - state: { - hovered: { - background: background(layer, "hovered"), - ...text(layer, "sans", "hovered", { size: "sm" }), - }, - }, - }), + }, + }), state: { active: { default: { @@ -58,9 +57,8 @@ export default function dropdownMenu(colorScheme: ColorScheme) { hovered: { background: background(layer, "hovered"), }, - } - } - } - ), + }, + }, + }), } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index d835dfe3a1..bd14a3af72 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -18,37 +18,36 @@ export default function workspace(colorScheme: ColorScheme) { const isLight = colorScheme.isLight const itemSpacing = 8 const titlebarButton = toggleable({ - base: - interactive({ - base: { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), + base: interactive({ + base: { + cornerRadius: 6, + padding: { + top: 1, + bottom: 1, + left: 8, + right: 8, }, - state: { - hovered: { - ...text(layer, "sans", "variant", "hovered", { - size: "xs", - }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { - size: "xs", - }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - }, + ...text(layer, "sans", "variant", { size: "xs" }), + background: background(layer, "variant"), + border: border(layer), + }, + state: { + hovered: { + ...text(layer, "sans", "variant", "hovered", { + size: "xs", + }), + background: background(layer, "variant", "hovered"), + border: border(layer, "variant", "hovered"), }, - }), + clicked: { + ...text(layer, "sans", "variant", "pressed", { + size: "xs", + }), + background: background(layer, "variant", "pressed"), + border: border(layer, "variant", "pressed"), + }, + }, + }), state: { active: { default: { @@ -56,10 +55,9 @@ export default function workspace(colorScheme: ColorScheme) { background: background(layer, "variant", "active"), border: border(layer, "variant", "active"), }, - } - } - } - ) + }, + }, + }) const avatarWidth = 18 const avatarOuterWidth = avatarWidth + 4 const followerAvatarWidth = 14 @@ -275,25 +273,24 @@ export default function workspace(colorScheme: ColorScheme) { }, }), toggleContactsButton: toggleable({ - base: - interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, + base: interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { + clicked: { + background: background(layer, "variant", "pressed"), }, - state: { - clicked: { - background: background(layer, "variant", "pressed"), - }, - hovered: { - background: background(layer, "variant", "hovered"), - }, + hovered: { + background: background(layer, "variant", "hovered"), }, - }), state: - { + }, + }), + state: { active: { default: { background: background(layer, "on", "default"), @@ -303,11 +300,10 @@ export default function workspace(colorScheme: ColorScheme) { }, clicked: { background: background(layer, "on", "pressed"), - } - } - } - } - ), + }, + }, + }, + }), userMenuButton: merge(titlebarButton, { inactive: { default: { From cc027dc626c6ec06d2e0106cbf04f8ad4bb996d4 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Wed, 21 Jun 2023 13:59:07 -0400 Subject: [PATCH 094/215] v0.93.x dev --- Cargo.lock | 2 +- crates/zed/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4b12223e5..24477edb7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8809,7 +8809,7 @@ dependencies = [ [[package]] name = "zed" -version = "0.92.0" +version = "0.93.0" dependencies = [ "activity_indicator", "ai", diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index d8e47d1c3e..69da1fef5d 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -3,7 +3,7 @@ authors = ["Nathan Sobo "] description = "The fast, collaborative code editor." edition = "2021" name = "zed" -version = "0.92.0" +version = "0.93.0" publish = false [lib] From 91bd8e305e773b6300577568ab35c72b9352ccf2 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 21 Jun 2023 13:14:21 -0600 Subject: [PATCH 095/215] join_lines: Skip over leading indentation --- crates/editor/src/editor.rs | 5 +++-- crates/editor/src/editor_tests.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index c8daff3fd5..3c6410cef9 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3987,9 +3987,10 @@ impl Editor { for row_range in row_ranges.into_iter().rev() { for row in row_range.rev() { let end_of_line = Point::new(row, snapshot.line_len(row)); - let start_of_next_line = end_of_line + Point::new(1, 0); + let indent = snapshot.indent_size_for_line(row + 1); + let start_of_next_line = Point::new(row + 1, indent.len); - let replace = if snapshot.line_len(row + 1) > 0 { + let replace = if snapshot.line_len(row + 1) > indent.len { " " } else { "" diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index ab950fd5a5..6fcb6f778f 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -2396,6 +2396,34 @@ fn test_join_lines_with_single_selection(cx: &mut TestAppContext) { [Point::new(2, 3)..Point::new(2, 3)] ); + // reset to test indentation + editor.buffer.update(cx, |buffer, cx| { + buffer.edit( + [ + (Point::new(1, 0)..Point::new(1, 2), " "), + (Point::new(2, 0)..Point::new(2, 3), " \n\td"), + ], + None, + cx, + ) + }); + + // We remove any leading spaces + assert_eq!(buffer.read(cx).text(), "aaa bbb\n c\n \n\td"); + editor.change_selections(None, cx, |s| { + s.select_ranges([Point::new(0, 1)..Point::new(0, 1)]) + }); + editor.join_lines(&JoinLines, cx); + assert_eq!(buffer.read(cx).text(), "aaa bbb c\n \n\td"); + + // We don't insert a space for a line containing only spaces + editor.join_lines(&JoinLines, cx); + assert_eq!(buffer.read(cx).text(), "aaa bbb c\n\td"); + + // We ignore any leading tabs + editor.join_lines(&JoinLines, cx); + assert_eq!(buffer.read(cx).text(), "aaa bbb c d"); + editor }); } From d6b1af6244f5658adb798e3619208164dc03bb1d Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 21 Jun 2023 14:02:32 -0600 Subject: [PATCH 096/215] vim: Allow up/down/left/right in vim mode The user impact of this is to 5 to move 5 lines at a time. --- assets/keymaps/vim.json | 4 ++++ crates/vim/src/test.rs | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 47c5f8c458..74625b1ea8 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -25,11 +25,15 @@ } ], "h": "vim::Left", + "left": "vim::Left", "backspace": "vim::Backspace", "j": "vim::Down", + "down": "vim::Down", "enter": "vim::NextLineStart", "k": "vim::Up", + "up": "vim::Up", "l": "vim::Right", + "right": "vim::Right", "$": "vim::EndOfLine", "shift-g": "vim::EndOfDocument", "w": "vim::NextWordStart", diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index 0214806e11..2ee3c85435 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -98,3 +98,14 @@ async fn test_buffer_search(cx: &mut gpui::TestAppContext) { assert_eq!(bar.query_editor.read(cx).text(cx), "jumps"); }) } + +#[gpui::test] +async fn test_count_down(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + cx.set_state(indoc! {"aˇa\nbb\ncc\ndd\nee"}, Mode::Normal); + cx.simulate_keystrokes(["2", "down"]); + cx.assert_editor_state("aa\nbb\ncˇc\ndd\nee"); + cx.simulate_keystrokes(["9", "down"]); + cx.assert_editor_state("aa\nbb\ncc\ndd\neˇe"); +} From 0c40ed5d854dfd53e2efa81f90a4918c34a5dac0 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 21 Jun 2023 14:34:35 -0600 Subject: [PATCH 097/215] vim: ctrl+] and ctrl+o to jump to definition and back Equivalent to f12 and ctrl-- in non-vim mode. --- assets/keymaps/vim.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 74625b1ea8..e6fca1e28f 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -94,6 +94,8 @@ } } ], + "ctrl-o": "pane::GoBack", + "ctrl-]": "editor::GoToDefinition", "escape": "editor::Cancel", "0": "vim::StartOfLine", // When no number operator present, use start of line motion "1": [ @@ -188,7 +190,6 @@ "p": "vim::Paste", "u": "editor::Undo", "ctrl-r": "editor::Redo", - "ctrl-o": "pane::GoBack", "/": [ "buffer_search::Deploy", { From dcca98b5ccafd88a6a7a919b2b7ebb0faf2921e7 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 21 Jun 2023 15:05:54 -0600 Subject: [PATCH 098/215] vim: Add basic 's' support --- assets/keymaps/vim.json | 3 ++- crates/vim/src/normal.rs | 26 ++++++++++++++++++++++++++ crates/vim/src/test.rs | 10 ++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 47c5f8c458..389efcdd0b 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -214,7 +214,8 @@ "r": [ "vim::PushOperator", "Replace" - ] + ], + "s": "vim::Substitute" } }, { diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index 1f90d259d3..c72fffbc21 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -45,6 +45,7 @@ actions!( DeleteToEndOfLine, Paste, Yank, + Substitute, ] ); @@ -56,6 +57,12 @@ pub fn init(cx: &mut AppContext) { cx.add_action(insert_end_of_line); cx.add_action(insert_line_above); cx.add_action(insert_line_below); + cx.add_action(|_: &mut Workspace, _: &Substitute, cx| { + Vim::update(cx, |vim, cx| { + let times = vim.pop_number_operator(cx); + substitute(vim, times, cx); + }) + }); cx.add_action(|_: &mut Workspace, _: &DeleteLeft, cx| { Vim::update(cx, |vim, cx| { let times = vim.pop_number_operator(cx); @@ -471,6 +478,25 @@ pub(crate) fn normal_replace(text: Arc, cx: &mut WindowContext) { }); } +pub fn substitute(vim: &mut Vim, count: usize, cx: &mut WindowContext) { + vim.update_active_editor(cx, |editor, cx| { + editor.transact(cx, |editor, cx| { + let selection = editor.selections.newest::(cx); + + let end = if selection.start == selection.end { + selection.start + Point::new(0, 1) + } else { + selection.end + }; + + editor.buffer().update(cx, |buffer, cx| { + buffer.edit([(selection.start..end, "")], None, cx) + }) + }) + }); + vim.switch_mode(Mode::Insert, true, cx) +} + #[cfg(test)] mod test { use gpui::TestAppContext; diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index 0214806e11..ec8998adc9 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -98,3 +98,13 @@ async fn test_buffer_search(cx: &mut gpui::TestAppContext) { assert_eq!(bar.query_editor.read(cx).text(cx), "jumps"); }) } + + +#[gpui::test] +async fn test_substitute(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + cx.set_state(indoc! {"ˇabc\n"}, Mode::Normal); + cx.simulate_keystrokes(["s", "x"]); + cx.assert_editor_state("xˇbc\n"); +} From e1f975e52eceaeccbb732d5b5939aea19021a269 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 21 Jun 2023 15:44:19 -0600 Subject: [PATCH 099/215] vim: Support s on selections and with multiple cursors --- assets/keymaps/vim.json | 1 + crates/vim/src/normal.rs | 22 +++++++++++----------- crates/vim/src/test.rs | 12 +++++++++++- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 389efcdd0b..eb2d7ecf41 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -302,6 +302,7 @@ "x": "vim::VisualDelete", "y": "vim::VisualYank", "p": "vim::VisualPaste", + "s": "vim::Substitute", "r": [ "vim::PushOperator", "Replace" diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index c72fffbc21..19d000d397 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -481,17 +481,17 @@ pub(crate) fn normal_replace(text: Arc, cx: &mut WindowContext) { pub fn substitute(vim: &mut Vim, count: usize, cx: &mut WindowContext) { vim.update_active_editor(cx, |editor, cx| { editor.transact(cx, |editor, cx| { - let selection = editor.selections.newest::(cx); - - let end = if selection.start == selection.end { - selection.start + Point::new(0, 1) - } else { - selection.end - }; - - editor.buffer().update(cx, |buffer, cx| { - buffer.edit([(selection.start..end, "")], None, cx) - }) + let selections = editor.selections.all::(cx); + for selection in selections.into_iter().rev() { + let end = if selection.start == selection.end { + selection.start + Point::new(0, 1) + } else { + selection.end + }; + editor.buffer().update(cx, |buffer, cx| { + buffer.edit([(selection.start..end, "")], None, cx) + }) + } }) }); vim.switch_mode(Mode::Insert, true, cx) diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index ec8998adc9..293a4813e6 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -99,12 +99,22 @@ async fn test_buffer_search(cx: &mut gpui::TestAppContext) { }) } - #[gpui::test] async fn test_substitute(cx: &mut gpui::TestAppContext) { let mut cx = VimTestContext::new(cx, true).await; + // supports a single cursor cx.set_state(indoc! {"ˇabc\n"}, Mode::Normal); cx.simulate_keystrokes(["s", "x"]); cx.assert_editor_state("xˇbc\n"); + + // supports a selection + cx.set_state(indoc! {"a«bcˇ»\n"}, Mode::Visual { line: false }); + cx.simulate_keystrokes(["s", "x"]); + cx.assert_editor_state("axˇ\n"); + + // supports multiple cursors + cx.set_state(indoc! {"a«bcˇ»deˇfg\n"}, Mode::Normal); + cx.simulate_keystrokes(["s", "x"]); + cx.assert_editor_state("axˇdexˇg\n"); } From a75341db97a96eacc8be539edc4a876c7de81709 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 21 Jun 2023 19:01:30 -0600 Subject: [PATCH 100/215] Move model and remaining tokens to assistant toolbar --- assets/settings/default.json | 2 +- crates/ai/src/assistant.rs | 162 ++++++++++++++++++------------ styles/src/styleTree/assistant.ts | 21 ++-- 3 files changed, 106 insertions(+), 79 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index c570660f38..c69d8089bc 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -85,7 +85,7 @@ // Where to dock the assistant. Can be 'left', 'right' or 'bottom'. "dock": "right", // Default width when the assistant is docked to the left or right. - "default_width": 450, + "default_width": 640, // Default height when the assistant is docked to the bottom. "default_height": 320 }, diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index d81434082d..14d84d054b 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -38,7 +38,7 @@ use std::{ sync::Arc, time::Duration, }; -use theme::ui::IconStyle; +use theme::{ui::IconStyle, AssistantStyle}; use util::{ channel::ReleaseChannel, paths::CONVERSATIONS_DIR, post_inc, truncate_and_trailoff, ResultExt, TryFutureExt, @@ -112,8 +112,8 @@ pub enum AssistantPanelEvent { pub struct AssistantPanel { width: Option, height: Option, - active_conversation_index: Option, - conversation_editors: Vec>, + active_editor_index: Option, + editors: Vec>, saved_conversations: Vec, saved_conversations_list_state: UniformListState, zoomed: bool, @@ -162,8 +162,8 @@ impl AssistantPanel { }); let mut this = Self { - active_conversation_index: Default::default(), - conversation_editors: Default::default(), + active_editor_index: Default::default(), + editors: Default::default(), saved_conversations, saved_conversations_list_state: Default::default(), zoomed: false, @@ -216,8 +216,12 @@ impl AssistantPanel { self.subscriptions .push(cx.subscribe(&editor, Self::handle_conversation_editor_event)); - self.active_conversation_index = Some(self.conversation_editors.len()); - self.conversation_editors.push(editor.clone()); + let conversation = editor.read(cx).conversation.clone(); + self.subscriptions + .push(cx.observe(&conversation, |_, _, cx| cx.notify())); + + self.active_editor_index = Some(self.editors.len()); + self.editors.push(editor.clone()); if self.has_focus(cx) { cx.focus(&editor); } @@ -271,9 +275,8 @@ impl AssistantPanel { } } - fn active_conversation_editor(&self) -> Option<&ViewHandle> { - self.conversation_editors - .get(self.active_conversation_index?) + fn active_editor(&self) -> Option<&ViewHandle> { + self.editors.get(self.active_editor_index?) } fn render_hamburger_button(style: &IconStyle) -> impl Element { @@ -284,11 +287,71 @@ impl AssistantPanel { .mouse::(0) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, |_, this: &mut Self, cx| { - this.active_conversation_index = None; + this.active_editor_index = None; cx.notify(); }) } + fn render_current_model( + &self, + style: &AssistantStyle, + cx: &mut ViewContext, + ) -> Option> { + enum Model {} + + let model = self + .active_editor()? + .read(cx) + .conversation + .read(cx) + .model + .clone(); + + Some( + MouseEventHandler::::new(0, cx, |state, _| { + let style = style.model.style_for(state, false); + Label::new(model, style.text.clone()) + .contained() + .with_style(style.container) + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this, cx| { + if let Some(editor) = this.active_editor() { + editor.update(cx, |editor, cx| { + editor.cycle_model(cx); + }); + } + }), + ) + } + + fn render_remaining_tokens( + &self, + style: &AssistantStyle, + cx: &mut ViewContext, + ) -> Option> { + self.active_editor().and_then(|editor| { + editor + .read(cx) + .conversation + .read(cx) + .remaining_tokens() + .map(|remaining_tokens| { + let remaining_tokens_style = if remaining_tokens <= 0 { + &style.no_remaining_tokens + } else { + &style.remaining_tokens + }; + Label::new( + remaining_tokens.to_string(), + remaining_tokens_style.text.clone(), + ) + .contained() + .with_style(remaining_tokens_style.container) + }) + }) + } + fn render_plus_button(style: &IconStyle) -> impl Element { enum AddConversation {} Svg::for_style(style.icon.clone()) @@ -337,8 +400,8 @@ impl AssistantPanel { } fn open_conversation(&mut self, path: PathBuf, cx: &mut ViewContext) -> Task> { - if let Some(ix) = self.conversation_editor_index_for_path(&path, cx) { - self.active_conversation_index = Some(ix); + if let Some(ix) = self.editor_index_for_path(&path, cx) { + self.active_editor_index = Some(ix); cx.notify(); return Task::ready(Ok(())); } @@ -356,8 +419,8 @@ impl AssistantPanel { this.update(&mut cx, |this, cx| { // If, by the time we've loaded the conversation, the user has already opened // the same conversation, we don't want to open it again. - if let Some(ix) = this.conversation_editor_index_for_path(&path, cx) { - this.active_conversation_index = Some(ix); + if let Some(ix) = this.editor_index_for_path(&path, cx) { + this.active_editor_index = Some(ix); } else { let editor = cx .add_view(|cx| ConversationEditor::from_conversation(conversation, fs, cx)); @@ -368,8 +431,8 @@ impl AssistantPanel { }) } - fn conversation_editor_index_for_path(&self, path: &Path, cx: &AppContext) -> Option { - self.conversation_editors + fn editor_index_for_path(&self, path: &Path, cx: &AppContext) -> Option { + self.editors .iter() .position(|editor| editor.read(cx).conversation.read(cx).path.as_deref() == Some(path)) } @@ -418,11 +481,13 @@ impl View for AssistantPanel { .aligned() .into_any() } else { - let title = self.active_conversation_editor().map(|editor| { + let title = self.active_editor().map(|editor| { Label::new(editor.read(cx).title(cx), style.title.text.clone()) .contained() .with_style(style.title.container) .aligned() + .left() + .flex(1., false) }); Flex::column() @@ -432,6 +497,14 @@ impl View for AssistantPanel { Self::render_hamburger_button(&style.hamburger_button).aligned(), ) .with_children(title) + .with_children( + self.render_current_model(&style, cx) + .map(|current_model| current_model.aligned().flex_float()), + ) + .with_children( + self.render_remaining_tokens(&style, cx) + .map(|remaining_tokens| remaining_tokens.aligned().flex_float()), + ) .with_child( Self::render_plus_button(&style.plus_button) .aligned() @@ -443,7 +516,7 @@ impl View for AssistantPanel { .constrained() .with_height(theme.workspace.tab_bar.height), ) - .with_child(if let Some(editor) = self.active_conversation_editor() { + .with_child(if let Some(editor) = self.active_editor() { ChildView::new(editor, cx).flex(1., true).into_any() } else { UniformList::new( @@ -466,7 +539,7 @@ impl View for AssistantPanel { fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext) { self.has_focus = true; if cx.is_self_focused() { - if let Some(editor) = self.active_conversation_editor() { + if let Some(editor) = self.active_editor() { cx.focus(editor); } else if let Some(api_key_editor) = self.api_key_editor.as_ref() { cx.focus(api_key_editor); @@ -562,7 +635,7 @@ impl Panel for AssistantPanel { } } - if self.conversation_editors.is_empty() { + if self.editors.is_empty() { self.new_conversation(cx); } } @@ -1700,7 +1773,7 @@ impl ConversationEditor { if let Some(text) = text { panel.update(cx, |panel, cx| { let conversation = panel - .active_conversation_editor() + .active_editor() .cloned() .unwrap_or_else(|| panel.new_conversation(cx)); conversation.update(cx, |conversation, cx| { @@ -1781,7 +1854,7 @@ impl ConversationEditor { .summary .as_ref() .map(|summary| summary.text.clone()) - .unwrap_or_else(|| "New Context".into()) + .unwrap_or_else(|| "New Conversation".into()) } } @@ -1795,49 +1868,10 @@ impl View for ConversationEditor { } fn render(&mut self, cx: &mut ViewContext) -> AnyElement { - enum Model {} let theme = &theme::current(cx).assistant; - let conversation = self.conversation.read(cx); - let model = conversation.model.clone(); - let remaining_tokens = conversation.remaining_tokens().map(|remaining_tokens| { - let remaining_tokens_style = if remaining_tokens <= 0 { - &theme.no_remaining_tokens - } else { - &theme.remaining_tokens - }; - Label::new( - remaining_tokens.to_string(), - remaining_tokens_style.text.clone(), - ) + ChildView::new(&self.editor, cx) .contained() - .with_style(remaining_tokens_style.container) - }); - - Stack::new() - .with_child( - ChildView::new(&self.editor, cx) - .contained() - .with_style(theme.container), - ) - .with_child( - Flex::row() - .with_child( - MouseEventHandler::::new(0, cx, |state, _| { - let style = theme.model.style_for(state, false); - Label::new(model, style.text.clone()) - .contained() - .with_style(style.container) - }) - .with_cursor_style(CursorStyle::PointingHand) - .on_click(MouseButton::Left, |_, this, cx| this.cycle_model(cx)), - ) - .with_children(remaining_tokens) - .contained() - .with_style(theme.model_info_container) - .aligned() - .top() - .right(), - ) + .with_style(theme.container) .into_any() } diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index 14bb836ee8..dc5be7dbb5 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -24,7 +24,7 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - margin: { left: 8 }, + margin: { left: 12 }, } }, plusButton: { @@ -37,11 +37,11 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - margin: { right: 8 }, + margin: { right: 12 }, } }, title: { - margin: { left: 8 }, + margin: { left: 12 }, ...text(layer, "sans", "default", { size: "sm" }) }, savedConversation: { @@ -76,28 +76,21 @@ export default function assistant(colorScheme: ColorScheme) { }, model: { background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), + margin: { right: 8 }, padding: 4, cornerRadius: 4, ...text(layer, "sans", "default", { size: "xs" }), hover: { background: background(layer, "on", "hovered"), + border: border(layer, "on", { overlay: true }), }, }, remainingTokens: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - margin: { left: 4 }, - cornerRadius: 4, + margin: { right: 12 }, ...text(layer, "sans", "positive", { size: "xs" }), }, noRemainingTokens: { - background: background(layer, "on"), - border: border(layer, "on", { overlay: true }), - padding: 4, - margin: { left: 4 }, - cornerRadius: 4, + margin: { right: 12 }, ...text(layer, "sans", "negative", { size: "xs" }), }, errorIcon: { From a49189a7048db76082eee9aaee72f19f4c6c048d Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 21 Jun 2023 19:50:22 -0600 Subject: [PATCH 101/215] Add Zoom button to assistant panel --- crates/ai/src/assistant.rs | 33 ++++++++++++++++++++++++++++++- crates/theme/src/theme.rs | 2 ++ styles/src/styleTree/assistant.ts | 26 ++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 14d84d054b..c8e3dce862 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -46,7 +46,7 @@ use util::{ use workspace::{ dock::{DockPosition, Panel}, item::Item, - Save, Workspace, + Save, ToggleZoom, Workspace, }; const OPENAI_API_URL: &'static str = "https://api.openai.com/v1"; @@ -364,6 +364,36 @@ impl AssistantPanel { }) } + fn render_zoom_button( + &self, + style: &AssistantStyle, + cx: &mut ViewContext, + ) -> impl Element { + enum ToggleZoomButton {} + + let style = if self.zoomed { + &style.zoom_out_button + } else { + &style.zoom_in_button + }; + + MouseEventHandler::::new(0, cx, |_, _| { + Svg::for_style(style.icon.clone()) + .contained() + .with_style(style.container) + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this, cx| { + if this.zoomed { + cx.emit(AssistantPanelEvent::ZoomOut) + } else { + this.has_focus = true; // Hack: Because focus_in is processed last, we need to set this here. + cx.focus_self(); + cx.emit(AssistantPanelEvent::ZoomIn); + } + }) + } + fn render_saved_conversation( &mut self, index: usize, @@ -510,6 +540,7 @@ impl View for AssistantPanel { .aligned() .flex_float(), ) + .with_child(self.render_zoom_button(&style, cx).aligned().flex_float()) .contained() .with_style(theme.workspace.tab_bar.container) .expanded() diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 72976ad82b..7147336479 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -995,6 +995,8 @@ pub struct TerminalStyle { pub struct AssistantStyle { pub container: ContainerStyle, pub hamburger_button: IconStyle, + pub zoom_in_button: IconStyle, + pub zoom_out_button: IconStyle, pub plus_button: IconStyle, pub title: ContainedText, pub message_header: ContainerStyle, diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index dc5be7dbb5..e4e342eb01 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -27,6 +27,32 @@ export default function assistant(colorScheme: ColorScheme) { margin: { left: 12 }, } }, + zoomInButton: { + icon: { + color: text(layer, "sans", "default", { size: "sm" }).color, + asset: "icons/maximize_8.svg", + dimensions: { + width: 12, + height: 12, + }, + }, + container: { + margin: { right: 12 }, + } + }, + zoomOutButton: { + icon: { + color: text(layer, "sans", "default", { size: "sm" }).color, + asset: "icons/minimize_8.svg", + dimensions: { + width: 12, + height: 12, + }, + }, + container: { + margin: { right: 12 }, + } + }, plusButton: { icon: { color: text(layer, "sans", "default", { size: "sm" }).color, From 4583d22ede058bce747142df33fc2f93625fa3ba Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 13:49:36 +0200 Subject: [PATCH 102/215] cargo fmt --- crates/call/src/room.rs | 15 +++++++-------- crates/collab_ui/src/collab_ui.rs | 13 +++++++++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 22e59ac467..77f22ea2ca 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -150,12 +150,13 @@ impl Room { let connect = room.connect(&connection_info.server_url, &connection_info.token); cx.spawn(|this, mut cx| async move { - connect.await?; - this.update(&mut cx, |this, cx| this.share_microphone(cx)).await?; + connect.await?; + this.update(&mut cx, |this, cx| this.share_microphone(cx)) + .await?; - anyhow::Ok(()) - }) - .detach_and_log_err(cx); + anyhow::Ok(()) + }) + .detach_and_log_err(cx); Some(LiveKitRoom { room, @@ -232,9 +233,7 @@ impl Room { }) .await { - Ok(()) => { - Ok(room) - } + Ok(()) => Ok(room), Err(error) => Err(anyhow!("room creation failed: {:?}", error)), } }) diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rs index e9c2bcf7f9..38a39762f4 100644 --- a/crates/collab_ui/src/collab_ui.rs +++ b/crates/collab_ui/src/collab_ui.rs @@ -16,7 +16,15 @@ use std::sync::Arc; use util::ResultExt; use workspace::AppState; -actions!(collab, [ToggleScreenSharing, ToggleMute, ToggleDeafen, ShareMicrophone]); +actions!( + collab, + [ + ToggleScreenSharing, + ToggleMute, + ToggleDeafen, + ShareMicrophone + ] +); pub fn init(app_state: &Arc, cx: &mut AppContext) { collab_titlebar_item::init(cx); @@ -64,6 +72,7 @@ pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) { pub fn share_microphone(_: &ShareMicrophone, cx: &mut AppContext) { if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { - room.update(cx, Room::share_microphone).detach_and_log_err(cx) + room.update(cx, Room::share_microphone) + .detach_and_log_err(cx) } } From 85d1c89d34868b9de3fec5f7e5166e5f368fce53 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 13:52:21 +0200 Subject: [PATCH 103/215] Remove unused import --- crates/call/src/room.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 77f22ea2ca..0c0855fd6c 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -19,7 +19,7 @@ use live_kit_client::{ use postage::stream::Stream; use project::Project; use std::{future::Future, mem, pin::Pin, sync::Arc, time::Duration}; -use util::{channel::ReleaseChannel, post_inc, ResultExt, TryFutureExt}; +use util::{post_inc, ResultExt, TryFutureExt}; pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(30); From bdccdaca1c679dcd3bd8cdedf17d65cce8d77fe4 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 13:57:41 +0200 Subject: [PATCH 104/215] Remove unused variable --- crates/collab_ui/src/collab_titlebar_item.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 80af71f06e..740af0254d 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -505,7 +505,6 @@ impl CollabTitlebarItem { ) -> AnyElement { let titlebar = &theme.workspace.titlebar; let avatar_style = &theme.workspace.titlebar.follower_avatar; - let active = self.user_menu.read(cx).visible(); Stack::new() .with_child( MouseEventHandler::::new(0, cx, |state, _| { From 1707652643a52fbc3f24d51f68d2c25b0cf7d924 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 22 Jun 2023 06:55:31 -0600 Subject: [PATCH 105/215] Always focus a panel when zooming it This allows us to zoom a panel when clicking a button, even if the panel isn't currently focused. --- crates/ai/src/assistant.rs | 8 +------- crates/workspace/src/workspace.rs | 7 ++++--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index c8e3dce862..5426715bf0 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -384,13 +384,7 @@ impl AssistantPanel { }) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, |_, this, cx| { - if this.zoomed { - cx.emit(AssistantPanelEvent::ZoomOut) - } else { - this.has_focus = true; // Hack: Because focus_in is processed last, we need to set this here. - cx.focus_self(); - cx.emit(AssistantPanelEvent::ZoomIn); - } + this.toggle_zoom(&ToggleZoom, cx); }) } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index d93dae2d13..6fcb12e77c 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -905,10 +905,11 @@ impl Workspace { }); } else if T::should_zoom_in_on_event(event) { dock.update(cx, |dock, cx| dock.set_panel_zoomed(&panel, true, cx)); - if panel.has_focus(cx) { - this.zoomed = Some(panel.downgrade().into_any()); - this.zoomed_position = Some(panel.read(cx).position(cx)); + if !panel.has_focus(cx) { + cx.focus(&panel); } + this.zoomed = Some(panel.downgrade().into_any()); + this.zoomed_position = Some(panel.read(cx).position(cx)); } else if T::should_zoom_out_on_event(event) { dock.update(cx, |dock, cx| dock.set_panel_zoomed(&panel, false, cx)); if this.zoomed_position == Some(prev_position) { From bee6c591546d8a86220fa92a9a56e6bd8724b4cf Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 16:28:05 +0200 Subject: [PATCH 106/215] Add caret next to user avatar --- crates/collab_ui/src/collab_titlebar_item.rs | 27 ++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 740af0254d..1d7884fcb7 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -510,19 +510,26 @@ impl CollabTitlebarItem { MouseEventHandler::::new(0, cx, |state, _| { let style = titlebar.call_control.style_for(state); - let img = if let Some(avatar_img) = avatar { - Self::render_face(avatar_img, *avatar_style, Color::transparent_black()) - } else { - Svg::new("icons/ellipsis_14.svg") - .with_color(style.color) - .into_any() - }; + let mut dropdown = Flex::row().align_children_center(); - img.constrained() - .with_width(style.icon_width) + if let Some(avatar_img) = avatar { + dropdown = dropdown.with_child(Self::render_face( + avatar_img, + *avatar_style, + Color::transparent_black(), + )); + }; + dropdown + .with_child( + Svg::new("icons/caret_down_8.svg") + .with_color(style.color) + .constrained() + .with_width(style.icon_width) + .contained() + .into_any(), + ) .aligned() .constrained() - .with_width(style.button_width) .with_height(style.button_width) .contained() .with_style(style.container) From 5291bf3d9f2f5be3920ff311e88afd19e00683d4 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 16:50:26 +0200 Subject: [PATCH 107/215] Use nextest instead of test (#2639) This should speed up our test CI by a minute or so. =) [current best case CI run](https://github.com/zed-industries/zed/actions/runs/5337351944/jobs/9673291188), where we don't rebuild anything (and only run tests) takes about 2m30s [with nextest](https://github.com/zed-industries/zed/actions/runs/5346819257/jobs/9694617720?pr=2639), that's down to 1m30s. Release Notes: - N/A --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1c16b2d4d..a906c8b82d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,6 +51,7 @@ jobs: rustup set profile minimal rustup update stable rustup target add wasm32-wasi + cargo install cargo-nextest - name: Install Node uses: actions/setup-node@v2 @@ -70,7 +71,7 @@ jobs: run: cargo check --workspace - name: Run tests - run: cargo test --workspace --no-fail-fast + run: cargo nextest run --workspace --no-fail-fast - name: Build collab run: cargo build -p collab From b16b6dcec7ac8852d93a88028d6ddf11d5eb60e4 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 17:40:29 +0200 Subject: [PATCH 108/215] Render microphone toggle --- assets/icons/microphone_active_12.svg | 4 ++ assets/icons/microphone_inactive_12.svg | 5 ++ crates/collab_ui/src/collab_titlebar_item.rs | 54 ++++++++++++++++++-- 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 assets/icons/microphone_active_12.svg create mode 100644 assets/icons/microphone_inactive_12.svg diff --git a/assets/icons/microphone_active_12.svg b/assets/icons/microphone_active_12.svg new file mode 100644 index 0000000000..797e64820b --- /dev/null +++ b/assets/icons/microphone_active_12.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/icons/microphone_inactive_12.svg b/assets/icons/microphone_inactive_12.svg new file mode 100644 index 0000000000..90ac393fc2 --- /dev/null +++ b/assets/icons/microphone_inactive_12.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 1d7884fcb7..c0603421bc 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -1,6 +1,6 @@ use crate::{ - contact_notification::ContactNotification, contacts_popover, face_pile::FacePile, - toggle_screen_sharing, ToggleScreenSharing, + contact_notification::ContactNotification, contacts_popover, face_pile::FacePile, toggle_mute, + toggle_screen_sharing, ToggleMute, ToggleScreenSharing, }; use call::{ActiveCall, ParticipantLocation, Room}; use client::{proto::PeerId, Client, ContactEventKind, SignIn, SignOut, User, UserStore}; @@ -88,6 +88,7 @@ impl View for CollabTitlebarItem { left_container .add_child(self.render_current_user(&workspace, &theme, &user, peer_id, cx)); left_container.add_children(self.render_collaborators(&workspace, &theme, &room, cx)); + right_container.add_child(self.render_toggle_microphone(&theme, &room, cx)); right_container.add_child(self.render_toggle_screen_sharing_button(&theme, &room, cx)); } @@ -396,7 +397,6 @@ impl CollabTitlebarItem { .with_children(self.render_contacts_popover_host(titlebar, cx)) .into_any() } - fn render_toggle_screen_sharing_button( &self, theme: &Theme, @@ -441,6 +441,54 @@ impl CollabTitlebarItem { .aligned() .into_any() } + fn render_toggle_microphone( + &self, + theme: &Theme, + room: &ModelHandle, + cx: &mut ViewContext, + ) -> AnyElement { + let icon; + let tooltip; + let background; + if room.read(cx).is_muted().unwrap_or(false) { + icon = "icons/microphone_inactive_12.svg"; + tooltip = "Unmute microphone\nRight click for options"; + background = Color::red(); + } else { + icon = "icons/microphone_active_12.svg"; + tooltip = "Mute microphone\nRight click for options"; + background = Color::transparent_black(); + } + + let titlebar = &theme.workspace.titlebar; + MouseEventHandler::::new(0, cx, |state, _| { + let style = titlebar.call_control.style_for(state); + Svg::new(icon) + .with_color(style.color) + .constrained() + .with_width(style.icon_width) + .aligned() + .constrained() + .with_width(style.button_width) + .with_height(style.button_width) + .contained() + .with_style(style.container) + .with_background_color(background) + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, move |_, _, cx| { + toggle_mute(&Default::default(), cx) + }) + .with_tooltip::( + 0, + tooltip.into(), + Some(Box::new(ToggleMute)), + theme.tooltip.clone(), + cx, + ) + .aligned() + .into_any() + } fn render_in_call_share_unshare_button( &self, From 05730afdf0d12945ad63534809d419db37a59d95 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 22 Jun 2023 11:58:51 -0400 Subject: [PATCH 109/215] Add radix icons There are a lot of them, but they add less than 350kb to the app --- assets/icons/radix/accessibility.svg | 8 ++ assets/icons/radix/activity-log.svg | 8 ++ assets/icons/radix/align-baseline.svg | 8 ++ assets/icons/radix/align-bottom.svg | 8 ++ .../icons/radix/align-center-horizontally.svg | 8 ++ .../icons/radix/align-center-vertically.svg | 8 ++ assets/icons/radix/align-center.svg | 8 ++ assets/icons/radix/align-end.svg | 8 ++ .../icons/radix/align-horizontal-centers.svg | 8 ++ assets/icons/radix/align-left.svg | 8 ++ assets/icons/radix/align-right.svg | 8 ++ assets/icons/radix/align-start.svg | 8 ++ assets/icons/radix/align-stretch.svg | 8 ++ assets/icons/radix/align-top.svg | 8 ++ assets/icons/radix/align-vertical-centers.svg | 8 ++ assets/icons/radix/all-sides.svg | 8 ++ assets/icons/radix/angle.svg | 8 ++ assets/icons/radix/archive.svg | 8 ++ assets/icons/radix/arrow-bottom-left.svg | 8 ++ assets/icons/radix/arrow-bottom-right.svg | 8 ++ assets/icons/radix/arrow-down.svg | 8 ++ assets/icons/radix/arrow-left.svg | 8 ++ assets/icons/radix/arrow-right.svg | 8 ++ assets/icons/radix/arrow-top-left.svg | 8 ++ assets/icons/radix/arrow-top-right.svg | 8 ++ assets/icons/radix/arrow-up.svg | 8 ++ assets/icons/radix/aspect-ratio.svg | 8 ++ assets/icons/radix/avatar.svg | 8 ++ assets/icons/radix/backpack.svg | 8 ++ assets/icons/radix/badge.svg | 8 ++ assets/icons/radix/bar-chart.svg | 8 ++ assets/icons/radix/bell.svg | 8 ++ assets/icons/radix/blending-mode.svg | 8 ++ assets/icons/radix/bookmark-filled.svg | 8 ++ assets/icons/radix/bookmark.svg | 8 ++ assets/icons/radix/border-all.svg | 17 ++++ assets/icons/radix/border-bottom.svg | 29 +++++++ assets/icons/radix/border-dashed.svg | 8 ++ assets/icons/radix/border-dotted.svg | 8 ++ assets/icons/radix/border-left.svg | 29 +++++++ assets/icons/radix/border-none.svg | 35 +++++++++ assets/icons/radix/border-right.svg | 29 +++++++ assets/icons/radix/border-solid.svg | 8 ++ assets/icons/radix/border-split.svg | 21 +++++ assets/icons/radix/border-style.svg | 8 ++ assets/icons/radix/border-top.svg | 29 +++++++ assets/icons/radix/border-width.svg | 8 ++ assets/icons/radix/box-model.svg | 8 ++ assets/icons/radix/box.svg | 8 ++ assets/icons/radix/button.svg | 8 ++ assets/icons/radix/calendar.svg | 8 ++ assets/icons/radix/camera.svg | 8 ++ assets/icons/radix/card-stack-minus.svg | 8 ++ assets/icons/radix/card-stack-plus.svg | 8 ++ assets/icons/radix/card-stack.svg | 8 ++ assets/icons/radix/caret-down.svg | 8 ++ assets/icons/radix/caret-left.svg | 8 ++ assets/icons/radix/caret-right.svg | 8 ++ assets/icons/radix/caret-sort.svg | 8 ++ assets/icons/radix/caret-up.svg | 8 ++ assets/icons/radix/chat-bubble.svg | 8 ++ assets/icons/radix/check-circled.svg | 8 ++ assets/icons/radix/check.svg | 8 ++ assets/icons/radix/checkbox.svg | 8 ++ assets/icons/radix/chevron-down.svg | 8 ++ assets/icons/radix/chevron-left.svg | 8 ++ assets/icons/radix/chevron-right.svg | 8 ++ assets/icons/radix/chevron-up.svg | 8 ++ assets/icons/radix/circle-backslash.svg | 8 ++ assets/icons/radix/circle.svg | 8 ++ assets/icons/radix/clipboard-copy.svg | 8 ++ assets/icons/radix/clipboard.svg | 8 ++ assets/icons/radix/clock.svg | 8 ++ assets/icons/radix/code.svg | 8 ++ assets/icons/radix/codesandbox-logo.svg | 8 ++ assets/icons/radix/color-wheel.svg | 8 ++ assets/icons/radix/column-spacing.svg | 8 ++ assets/icons/radix/columns.svg | 8 ++ assets/icons/radix/commit.svg | 8 ++ assets/icons/radix/component-1.svg | 8 ++ assets/icons/radix/component-2.svg | 8 ++ assets/icons/radix/component-boolean.svg | 8 ++ assets/icons/radix/component-instance.svg | 8 ++ assets/icons/radix/component-none.svg | 8 ++ assets/icons/radix/component-placeholder.svg | 12 +++ assets/icons/radix/container.svg | 8 ++ assets/icons/radix/cookie.svg | 8 ++ assets/icons/radix/copy.svg | 8 ++ assets/icons/radix/corner-bottom-left.svg | 8 ++ assets/icons/radix/corner-bottom-right.svg | 8 ++ assets/icons/radix/corner-top-left.svg | 8 ++ assets/icons/radix/corner-top-right.svg | 8 ++ assets/icons/radix/corners.svg | 8 ++ assets/icons/radix/countdown-timer.svg | 8 ++ .../icons/radix/counter-clockwise-clock.svg | 8 ++ assets/icons/radix/crop.svg | 8 ++ assets/icons/radix/cross-1.svg | 8 ++ assets/icons/radix/cross-2.svg | 8 ++ assets/icons/radix/cross-circled.svg | 8 ++ assets/icons/radix/crosshair-1.svg | 8 ++ assets/icons/radix/crosshair-2.svg | 8 ++ assets/icons/radix/crumpled-paper.svg | 8 ++ assets/icons/radix/cube.svg | 8 ++ assets/icons/radix/cursor-arrow.svg | 8 ++ assets/icons/radix/cursor-text.svg | 8 ++ assets/icons/radix/dash.svg | 8 ++ assets/icons/radix/dashboard.svg | 8 ++ assets/icons/radix/desktop.svg | 8 ++ assets/icons/radix/dimensions.svg | 8 ++ assets/icons/radix/disc.svg | 8 ++ assets/icons/radix/discord-logo.svg | 13 ++++ assets/icons/radix/divider-horizontal.svg | 8 ++ assets/icons/radix/divider-vertical.svg | 8 ++ assets/icons/radix/dot-filled.svg | 6 ++ assets/icons/radix/dot-solid.svg | 6 ++ assets/icons/radix/dot.svg | 8 ++ assets/icons/radix/dots-horizontal.svg | 8 ++ assets/icons/radix/dots-vertical.svg | 8 ++ assets/icons/radix/double-arrow-down.svg | 8 ++ assets/icons/radix/double-arrow-left.svg | 8 ++ assets/icons/radix/double-arrow-right.svg | 8 ++ assets/icons/radix/double-arrow-up.svg | 8 ++ assets/icons/radix/download.svg | 8 ++ assets/icons/radix/drag-handle-dots-1.svg | 26 +++++++ assets/icons/radix/drag-handle-dots-2.svg | 8 ++ assets/icons/radix/drag-handle-horizontal.svg | 8 ++ assets/icons/radix/drag-handle-vertical.svg | 8 ++ assets/icons/radix/drawing-pin-filled.svg | 14 ++++ assets/icons/radix/drawing-pin-solid.svg | 14 ++++ assets/icons/radix/drawing-pin.svg | 8 ++ assets/icons/radix/dropdown-menu.svg | 8 ++ assets/icons/radix/enter-full-screen.svg | 8 ++ assets/icons/radix/enter.svg | 8 ++ assets/icons/radix/envelope-closed.svg | 8 ++ assets/icons/radix/envelope-open.svg | 8 ++ assets/icons/radix/eraser.svg | 8 ++ assets/icons/radix/exclamation-triangle.svg | 8 ++ assets/icons/radix/exit-full-screen.svg | 8 ++ assets/icons/radix/exit.svg | 8 ++ assets/icons/radix/external-link.svg | 8 ++ assets/icons/radix/eye-closed.svg | 8 ++ assets/icons/radix/eye-none.svg | 8 ++ assets/icons/radix/eye-open.svg | 8 ++ assets/icons/radix/face.svg | 8 ++ assets/icons/radix/figma-logo.svg | 8 ++ assets/icons/radix/file-minus.svg | 8 ++ assets/icons/radix/file-plus.svg | 8 ++ assets/icons/radix/file-text.svg | 8 ++ assets/icons/radix/file.svg | 8 ++ assets/icons/radix/font-bold.svg | 6 ++ assets/icons/radix/font-family.svg | 6 ++ assets/icons/radix/font-italic.svg | 8 ++ assets/icons/radix/font-roman.svg | 8 ++ assets/icons/radix/font-size.svg | 8 ++ assets/icons/radix/font-style.svg | 8 ++ assets/icons/radix/frame.svg | 8 ++ assets/icons/radix/framer-logo.svg | 8 ++ assets/icons/radix/gear.svg | 8 ++ assets/icons/radix/github-logo.svg | 8 ++ assets/icons/radix/globe.svg | 26 +++++++ assets/icons/radix/grid.svg | 8 ++ assets/icons/radix/group.svg | 8 ++ assets/icons/radix/half-1.svg | 8 ++ assets/icons/radix/half-2.svg | 8 ++ assets/icons/radix/hamburger-menu.svg | 8 ++ assets/icons/radix/hand.svg | 8 ++ assets/icons/radix/heading.svg | 8 ++ assets/icons/radix/heart-filled.svg | 8 ++ assets/icons/radix/heart.svg | 8 ++ assets/icons/radix/height.svg | 8 ++ assets/icons/radix/hobby-knife.svg | 8 ++ assets/icons/radix/home.svg | 8 ++ assets/icons/radix/iconjar-logo.svg | 8 ++ assets/icons/radix/id-card.svg | 8 ++ assets/icons/radix/image.svg | 8 ++ assets/icons/radix/info-circled.svg | 8 ++ assets/icons/radix/inner-shadow.svg | 78 +++++++++++++++++++ assets/icons/radix/input.svg | 8 ++ assets/icons/radix/instagram-logo.svg | 8 ++ assets/icons/radix/justify-center.svg | 8 ++ assets/icons/radix/justify-end.svg | 8 ++ assets/icons/radix/justify-start.svg | 8 ++ assets/icons/radix/justify-stretch.svg | 8 ++ assets/icons/radix/keyboard.svg | 7 ++ assets/icons/radix/lap-timer.svg | 8 ++ assets/icons/radix/laptop.svg | 8 ++ assets/icons/radix/layers.svg | 8 ++ assets/icons/radix/layout.svg | 8 ++ assets/icons/radix/letter-case-capitalize.svg | 8 ++ assets/icons/radix/letter-case-lowercase.svg | 8 ++ assets/icons/radix/letter-case-toggle.svg | 8 ++ assets/icons/radix/letter-case-uppercase.svg | 8 ++ assets/icons/radix/letter-spacing.svg | 8 ++ assets/icons/radix/lightning-bolt.svg | 8 ++ assets/icons/radix/line-height.svg | 8 ++ assets/icons/radix/link-1.svg | 8 ++ assets/icons/radix/link-2.svg | 8 ++ assets/icons/radix/link-break-1.svg | 8 ++ assets/icons/radix/link-break-2.svg | 8 ++ assets/icons/radix/link-none-1.svg | 8 ++ assets/icons/radix/link-none-2.svg | 8 ++ assets/icons/radix/linkedin-logo.svg | 8 ++ assets/icons/radix/list-bullet.svg | 8 ++ assets/icons/radix/lock-closed.svg | 8 ++ assets/icons/radix/lock-open-1.svg | 8 ++ assets/icons/radix/lock-open-2.svg | 8 ++ assets/icons/radix/loop.svg | 8 ++ assets/icons/radix/magic-wand.svg | 8 ++ assets/icons/radix/magnifying-glass.svg | 8 ++ assets/icons/radix/margin.svg | 8 ++ assets/icons/radix/mask-off.svg | 8 ++ assets/icons/radix/mask-on.svg | 8 ++ assets/icons/radix/minus-circled.svg | 8 ++ assets/icons/radix/minus.svg | 8 ++ assets/icons/radix/mix.svg | 8 ++ assets/icons/radix/mixer-horizontal.svg | 8 ++ assets/icons/radix/mixer-vertical.svg | 8 ++ assets/icons/radix/mobile.svg | 8 ++ assets/icons/radix/modulz-logo.svg | 8 ++ assets/icons/radix/moon.svg | 8 ++ assets/icons/radix/move.svg | 8 ++ assets/icons/radix/notion-logo.svg | 6 ++ assets/icons/radix/opacity.svg | 8 ++ assets/icons/radix/open-in-new-window.svg | 10 +++ assets/icons/radix/outer-shadow.svg | 43 ++++++++++ assets/icons/radix/overline.svg | 8 ++ assets/icons/radix/padding.svg | 8 ++ assets/icons/radix/paper-plane.svg | 8 ++ assets/icons/radix/pause.svg | 8 ++ assets/icons/radix/pencil-1.svg | 8 ++ assets/icons/radix/pencil-2.svg | 8 ++ assets/icons/radix/person.svg | 8 ++ assets/icons/radix/pie-chart.svg | 8 ++ assets/icons/radix/pilcrow.svg | 8 ++ assets/icons/radix/pin-bottom.svg | 8 ++ assets/icons/radix/pin-left.svg | 8 ++ assets/icons/radix/pin-right.svg | 8 ++ assets/icons/radix/pin-top.svg | 8 ++ assets/icons/radix/play.svg | 8 ++ assets/icons/radix/plus-circled.svg | 8 ++ assets/icons/radix/plus.svg | 8 ++ assets/icons/radix/question-mark-circled.svg | 8 ++ assets/icons/radix/question-mark.svg | 8 ++ assets/icons/radix/quote.svg | 8 ++ assets/icons/radix/radiobutton.svg | 8 ++ assets/icons/radix/reader.svg | 8 ++ assets/icons/radix/reload.svg | 8 ++ assets/icons/radix/reset.svg | 8 ++ assets/icons/radix/resume.svg | 8 ++ assets/icons/radix/rocket.svg | 8 ++ .../icons/radix/rotate-counter-clockwise.svg | 8 ++ assets/icons/radix/row-spacing.svg | 8 ++ assets/icons/radix/rows.svg | 8 ++ assets/icons/radix/ruler-horizontal.svg | 8 ++ assets/icons/radix/ruler-square.svg | 8 ++ assets/icons/radix/scissors.svg | 8 ++ assets/icons/radix/section.svg | 8 ++ assets/icons/radix/sewing-pin-filled.svg | 8 ++ assets/icons/radix/sewing-pin-solid.svg | 8 ++ assets/icons/radix/sewing-pin.svg | 8 ++ assets/icons/radix/shadow-inner.svg | 78 +++++++++++++++++++ assets/icons/radix/shadow-none.svg | 78 +++++++++++++++++++ assets/icons/radix/shadow-outer.svg | 43 ++++++++++ assets/icons/radix/shadow.svg | 78 +++++++++++++++++++ assets/icons/radix/share-1.svg | 8 ++ assets/icons/radix/share-2.svg | 8 ++ assets/icons/radix/shuffle.svg | 8 ++ assets/icons/radix/size.svg | 8 ++ assets/icons/radix/sketch-logo.svg | 8 ++ assets/icons/radix/slash.svg | 8 ++ assets/icons/radix/slider.svg | 8 ++ .../radix/space-between-horizontally.svg | 8 ++ .../icons/radix/space-between-vertically.svg | 8 ++ .../icons/radix/space-evenly-horizontally.svg | 8 ++ .../icons/radix/space-evenly-vertically.svg | 8 ++ assets/icons/radix/speaker-loud.svg | 8 ++ assets/icons/radix/speaker-moderate.svg | 8 ++ assets/icons/radix/speaker-off.svg | 8 ++ assets/icons/radix/speaker-quiet.svg | 8 ++ assets/icons/radix/square.svg | 8 ++ assets/icons/radix/stack.svg | 8 ++ assets/icons/radix/star-filled.svg | 6 ++ assets/icons/radix/star.svg | 8 ++ assets/icons/radix/stitches-logo.svg | 8 ++ assets/icons/radix/stop.svg | 8 ++ assets/icons/radix/stopwatch.svg | 8 ++ assets/icons/radix/stretch-horizontally.svg | 8 ++ assets/icons/radix/stretch-vertically.svg | 8 ++ assets/icons/radix/strikethrough.svg | 8 ++ assets/icons/radix/sun.svg | 8 ++ assets/icons/radix/switch.svg | 8 ++ assets/icons/radix/symbol.svg | 8 ++ assets/icons/radix/table.svg | 8 ++ assets/icons/radix/target.svg | 8 ++ assets/icons/radix/text-align-bottom.svg | 8 ++ assets/icons/radix/text-align-center.svg | 8 ++ assets/icons/radix/text-align-justify.svg | 8 ++ assets/icons/radix/text-align-left.svg | 8 ++ assets/icons/radix/text-align-middle.svg | 8 ++ assets/icons/radix/text-align-right.svg | 8 ++ assets/icons/radix/text-align-top.svg | 8 ++ assets/icons/radix/text-none.svg | 8 ++ assets/icons/radix/text.svg | 8 ++ assets/icons/radix/thick-arrow-down.svg | 8 ++ assets/icons/radix/thick-arrow-left.svg | 8 ++ assets/icons/radix/thick-arrow-right.svg | 8 ++ assets/icons/radix/thick-arrow-up.svg | 8 ++ assets/icons/radix/timer.svg | 8 ++ assets/icons/radix/tokens.svg | 8 ++ assets/icons/radix/track-next.svg | 8 ++ assets/icons/radix/track-previous.svg | 8 ++ assets/icons/radix/transform.svg | 8 ++ assets/icons/radix/transparency-grid.svg | 9 +++ assets/icons/radix/trash.svg | 8 ++ assets/icons/radix/triangle-down.svg | 3 + assets/icons/radix/triangle-left.svg | 3 + assets/icons/radix/triangle-right.svg | 3 + assets/icons/radix/triangle-up.svg | 3 + assets/icons/radix/twitter-logo.svg | 8 ++ assets/icons/radix/underline.svg | 8 ++ assets/icons/radix/update.svg | 8 ++ assets/icons/radix/upload.svg | 8 ++ assets/icons/radix/value-none.svg | 8 ++ assets/icons/radix/value.svg | 8 ++ assets/icons/radix/vercel-logo.svg | 8 ++ assets/icons/radix/video.svg | 8 ++ assets/icons/radix/view-grid.svg | 8 ++ assets/icons/radix/view-horizontal.svg | 8 ++ assets/icons/radix/view-none.svg | 8 ++ assets/icons/radix/view-vertical.svg | 8 ++ assets/icons/radix/width.svg | 8 ++ assets/icons/radix/zoom-in.svg | 8 ++ assets/icons/radix/zoom-out.svg | 8 ++ 333 files changed, 3174 insertions(+) create mode 100644 assets/icons/radix/accessibility.svg create mode 100644 assets/icons/radix/activity-log.svg create mode 100644 assets/icons/radix/align-baseline.svg create mode 100644 assets/icons/radix/align-bottom.svg create mode 100644 assets/icons/radix/align-center-horizontally.svg create mode 100644 assets/icons/radix/align-center-vertically.svg create mode 100644 assets/icons/radix/align-center.svg create mode 100644 assets/icons/radix/align-end.svg create mode 100644 assets/icons/radix/align-horizontal-centers.svg create mode 100644 assets/icons/radix/align-left.svg create mode 100644 assets/icons/radix/align-right.svg create mode 100644 assets/icons/radix/align-start.svg create mode 100644 assets/icons/radix/align-stretch.svg create mode 100644 assets/icons/radix/align-top.svg create mode 100644 assets/icons/radix/align-vertical-centers.svg create mode 100644 assets/icons/radix/all-sides.svg create mode 100644 assets/icons/radix/angle.svg create mode 100644 assets/icons/radix/archive.svg create mode 100644 assets/icons/radix/arrow-bottom-left.svg create mode 100644 assets/icons/radix/arrow-bottom-right.svg create mode 100644 assets/icons/radix/arrow-down.svg create mode 100644 assets/icons/radix/arrow-left.svg create mode 100644 assets/icons/radix/arrow-right.svg create mode 100644 assets/icons/radix/arrow-top-left.svg create mode 100644 assets/icons/radix/arrow-top-right.svg create mode 100644 assets/icons/radix/arrow-up.svg create mode 100644 assets/icons/radix/aspect-ratio.svg create mode 100644 assets/icons/radix/avatar.svg create mode 100644 assets/icons/radix/backpack.svg create mode 100644 assets/icons/radix/badge.svg create mode 100644 assets/icons/radix/bar-chart.svg create mode 100644 assets/icons/radix/bell.svg create mode 100644 assets/icons/radix/blending-mode.svg create mode 100644 assets/icons/radix/bookmark-filled.svg create mode 100644 assets/icons/radix/bookmark.svg create mode 100644 assets/icons/radix/border-all.svg create mode 100644 assets/icons/radix/border-bottom.svg create mode 100644 assets/icons/radix/border-dashed.svg create mode 100644 assets/icons/radix/border-dotted.svg create mode 100644 assets/icons/radix/border-left.svg create mode 100644 assets/icons/radix/border-none.svg create mode 100644 assets/icons/radix/border-right.svg create mode 100644 assets/icons/radix/border-solid.svg create mode 100644 assets/icons/radix/border-split.svg create mode 100644 assets/icons/radix/border-style.svg create mode 100644 assets/icons/radix/border-top.svg create mode 100644 assets/icons/radix/border-width.svg create mode 100644 assets/icons/radix/box-model.svg create mode 100644 assets/icons/radix/box.svg create mode 100644 assets/icons/radix/button.svg create mode 100644 assets/icons/radix/calendar.svg create mode 100644 assets/icons/radix/camera.svg create mode 100644 assets/icons/radix/card-stack-minus.svg create mode 100644 assets/icons/radix/card-stack-plus.svg create mode 100644 assets/icons/radix/card-stack.svg create mode 100644 assets/icons/radix/caret-down.svg create mode 100644 assets/icons/radix/caret-left.svg create mode 100644 assets/icons/radix/caret-right.svg create mode 100644 assets/icons/radix/caret-sort.svg create mode 100644 assets/icons/radix/caret-up.svg create mode 100644 assets/icons/radix/chat-bubble.svg create mode 100644 assets/icons/radix/check-circled.svg create mode 100644 assets/icons/radix/check.svg create mode 100644 assets/icons/radix/checkbox.svg create mode 100644 assets/icons/radix/chevron-down.svg create mode 100644 assets/icons/radix/chevron-left.svg create mode 100644 assets/icons/radix/chevron-right.svg create mode 100644 assets/icons/radix/chevron-up.svg create mode 100644 assets/icons/radix/circle-backslash.svg create mode 100644 assets/icons/radix/circle.svg create mode 100644 assets/icons/radix/clipboard-copy.svg create mode 100644 assets/icons/radix/clipboard.svg create mode 100644 assets/icons/radix/clock.svg create mode 100644 assets/icons/radix/code.svg create mode 100644 assets/icons/radix/codesandbox-logo.svg create mode 100644 assets/icons/radix/color-wheel.svg create mode 100644 assets/icons/radix/column-spacing.svg create mode 100644 assets/icons/radix/columns.svg create mode 100644 assets/icons/radix/commit.svg create mode 100644 assets/icons/radix/component-1.svg create mode 100644 assets/icons/radix/component-2.svg create mode 100644 assets/icons/radix/component-boolean.svg create mode 100644 assets/icons/radix/component-instance.svg create mode 100644 assets/icons/radix/component-none.svg create mode 100644 assets/icons/radix/component-placeholder.svg create mode 100644 assets/icons/radix/container.svg create mode 100644 assets/icons/radix/cookie.svg create mode 100644 assets/icons/radix/copy.svg create mode 100644 assets/icons/radix/corner-bottom-left.svg create mode 100644 assets/icons/radix/corner-bottom-right.svg create mode 100644 assets/icons/radix/corner-top-left.svg create mode 100644 assets/icons/radix/corner-top-right.svg create mode 100644 assets/icons/radix/corners.svg create mode 100644 assets/icons/radix/countdown-timer.svg create mode 100644 assets/icons/radix/counter-clockwise-clock.svg create mode 100644 assets/icons/radix/crop.svg create mode 100644 assets/icons/radix/cross-1.svg create mode 100644 assets/icons/radix/cross-2.svg create mode 100644 assets/icons/radix/cross-circled.svg create mode 100644 assets/icons/radix/crosshair-1.svg create mode 100644 assets/icons/radix/crosshair-2.svg create mode 100644 assets/icons/radix/crumpled-paper.svg create mode 100644 assets/icons/radix/cube.svg create mode 100644 assets/icons/radix/cursor-arrow.svg create mode 100644 assets/icons/radix/cursor-text.svg create mode 100644 assets/icons/radix/dash.svg create mode 100644 assets/icons/radix/dashboard.svg create mode 100644 assets/icons/radix/desktop.svg create mode 100644 assets/icons/radix/dimensions.svg create mode 100644 assets/icons/radix/disc.svg create mode 100644 assets/icons/radix/discord-logo.svg create mode 100644 assets/icons/radix/divider-horizontal.svg create mode 100644 assets/icons/radix/divider-vertical.svg create mode 100644 assets/icons/radix/dot-filled.svg create mode 100644 assets/icons/radix/dot-solid.svg create mode 100644 assets/icons/radix/dot.svg create mode 100644 assets/icons/radix/dots-horizontal.svg create mode 100644 assets/icons/radix/dots-vertical.svg create mode 100644 assets/icons/radix/double-arrow-down.svg create mode 100644 assets/icons/radix/double-arrow-left.svg create mode 100644 assets/icons/radix/double-arrow-right.svg create mode 100644 assets/icons/radix/double-arrow-up.svg create mode 100644 assets/icons/radix/download.svg create mode 100644 assets/icons/radix/drag-handle-dots-1.svg create mode 100644 assets/icons/radix/drag-handle-dots-2.svg create mode 100644 assets/icons/radix/drag-handle-horizontal.svg create mode 100644 assets/icons/radix/drag-handle-vertical.svg create mode 100644 assets/icons/radix/drawing-pin-filled.svg create mode 100644 assets/icons/radix/drawing-pin-solid.svg create mode 100644 assets/icons/radix/drawing-pin.svg create mode 100644 assets/icons/radix/dropdown-menu.svg create mode 100644 assets/icons/radix/enter-full-screen.svg create mode 100644 assets/icons/radix/enter.svg create mode 100644 assets/icons/radix/envelope-closed.svg create mode 100644 assets/icons/radix/envelope-open.svg create mode 100644 assets/icons/radix/eraser.svg create mode 100644 assets/icons/radix/exclamation-triangle.svg create mode 100644 assets/icons/radix/exit-full-screen.svg create mode 100644 assets/icons/radix/exit.svg create mode 100644 assets/icons/radix/external-link.svg create mode 100644 assets/icons/radix/eye-closed.svg create mode 100644 assets/icons/radix/eye-none.svg create mode 100644 assets/icons/radix/eye-open.svg create mode 100644 assets/icons/radix/face.svg create mode 100644 assets/icons/radix/figma-logo.svg create mode 100644 assets/icons/radix/file-minus.svg create mode 100644 assets/icons/radix/file-plus.svg create mode 100644 assets/icons/radix/file-text.svg create mode 100644 assets/icons/radix/file.svg create mode 100644 assets/icons/radix/font-bold.svg create mode 100644 assets/icons/radix/font-family.svg create mode 100644 assets/icons/radix/font-italic.svg create mode 100644 assets/icons/radix/font-roman.svg create mode 100644 assets/icons/radix/font-size.svg create mode 100644 assets/icons/radix/font-style.svg create mode 100644 assets/icons/radix/frame.svg create mode 100644 assets/icons/radix/framer-logo.svg create mode 100644 assets/icons/radix/gear.svg create mode 100644 assets/icons/radix/github-logo.svg create mode 100644 assets/icons/radix/globe.svg create mode 100644 assets/icons/radix/grid.svg create mode 100644 assets/icons/radix/group.svg create mode 100644 assets/icons/radix/half-1.svg create mode 100644 assets/icons/radix/half-2.svg create mode 100644 assets/icons/radix/hamburger-menu.svg create mode 100644 assets/icons/radix/hand.svg create mode 100644 assets/icons/radix/heading.svg create mode 100644 assets/icons/radix/heart-filled.svg create mode 100644 assets/icons/radix/heart.svg create mode 100644 assets/icons/radix/height.svg create mode 100644 assets/icons/radix/hobby-knife.svg create mode 100644 assets/icons/radix/home.svg create mode 100644 assets/icons/radix/iconjar-logo.svg create mode 100644 assets/icons/radix/id-card.svg create mode 100644 assets/icons/radix/image.svg create mode 100644 assets/icons/radix/info-circled.svg create mode 100644 assets/icons/radix/inner-shadow.svg create mode 100644 assets/icons/radix/input.svg create mode 100644 assets/icons/radix/instagram-logo.svg create mode 100644 assets/icons/radix/justify-center.svg create mode 100644 assets/icons/radix/justify-end.svg create mode 100644 assets/icons/radix/justify-start.svg create mode 100644 assets/icons/radix/justify-stretch.svg create mode 100644 assets/icons/radix/keyboard.svg create mode 100644 assets/icons/radix/lap-timer.svg create mode 100644 assets/icons/radix/laptop.svg create mode 100644 assets/icons/radix/layers.svg create mode 100644 assets/icons/radix/layout.svg create mode 100644 assets/icons/radix/letter-case-capitalize.svg create mode 100644 assets/icons/radix/letter-case-lowercase.svg create mode 100644 assets/icons/radix/letter-case-toggle.svg create mode 100644 assets/icons/radix/letter-case-uppercase.svg create mode 100644 assets/icons/radix/letter-spacing.svg create mode 100644 assets/icons/radix/lightning-bolt.svg create mode 100644 assets/icons/radix/line-height.svg create mode 100644 assets/icons/radix/link-1.svg create mode 100644 assets/icons/radix/link-2.svg create mode 100644 assets/icons/radix/link-break-1.svg create mode 100644 assets/icons/radix/link-break-2.svg create mode 100644 assets/icons/radix/link-none-1.svg create mode 100644 assets/icons/radix/link-none-2.svg create mode 100644 assets/icons/radix/linkedin-logo.svg create mode 100644 assets/icons/radix/list-bullet.svg create mode 100644 assets/icons/radix/lock-closed.svg create mode 100644 assets/icons/radix/lock-open-1.svg create mode 100644 assets/icons/radix/lock-open-2.svg create mode 100644 assets/icons/radix/loop.svg create mode 100644 assets/icons/radix/magic-wand.svg create mode 100644 assets/icons/radix/magnifying-glass.svg create mode 100644 assets/icons/radix/margin.svg create mode 100644 assets/icons/radix/mask-off.svg create mode 100644 assets/icons/radix/mask-on.svg create mode 100644 assets/icons/radix/minus-circled.svg create mode 100644 assets/icons/radix/minus.svg create mode 100644 assets/icons/radix/mix.svg create mode 100644 assets/icons/radix/mixer-horizontal.svg create mode 100644 assets/icons/radix/mixer-vertical.svg create mode 100644 assets/icons/radix/mobile.svg create mode 100644 assets/icons/radix/modulz-logo.svg create mode 100644 assets/icons/radix/moon.svg create mode 100644 assets/icons/radix/move.svg create mode 100644 assets/icons/radix/notion-logo.svg create mode 100644 assets/icons/radix/opacity.svg create mode 100644 assets/icons/radix/open-in-new-window.svg create mode 100644 assets/icons/radix/outer-shadow.svg create mode 100644 assets/icons/radix/overline.svg create mode 100644 assets/icons/radix/padding.svg create mode 100644 assets/icons/radix/paper-plane.svg create mode 100644 assets/icons/radix/pause.svg create mode 100644 assets/icons/radix/pencil-1.svg create mode 100644 assets/icons/radix/pencil-2.svg create mode 100644 assets/icons/radix/person.svg create mode 100644 assets/icons/radix/pie-chart.svg create mode 100644 assets/icons/radix/pilcrow.svg create mode 100644 assets/icons/radix/pin-bottom.svg create mode 100644 assets/icons/radix/pin-left.svg create mode 100644 assets/icons/radix/pin-right.svg create mode 100644 assets/icons/radix/pin-top.svg create mode 100644 assets/icons/radix/play.svg create mode 100644 assets/icons/radix/plus-circled.svg create mode 100644 assets/icons/radix/plus.svg create mode 100644 assets/icons/radix/question-mark-circled.svg create mode 100644 assets/icons/radix/question-mark.svg create mode 100644 assets/icons/radix/quote.svg create mode 100644 assets/icons/radix/radiobutton.svg create mode 100644 assets/icons/radix/reader.svg create mode 100644 assets/icons/radix/reload.svg create mode 100644 assets/icons/radix/reset.svg create mode 100644 assets/icons/radix/resume.svg create mode 100644 assets/icons/radix/rocket.svg create mode 100644 assets/icons/radix/rotate-counter-clockwise.svg create mode 100644 assets/icons/radix/row-spacing.svg create mode 100644 assets/icons/radix/rows.svg create mode 100644 assets/icons/radix/ruler-horizontal.svg create mode 100644 assets/icons/radix/ruler-square.svg create mode 100644 assets/icons/radix/scissors.svg create mode 100644 assets/icons/radix/section.svg create mode 100644 assets/icons/radix/sewing-pin-filled.svg create mode 100644 assets/icons/radix/sewing-pin-solid.svg create mode 100644 assets/icons/radix/sewing-pin.svg create mode 100644 assets/icons/radix/shadow-inner.svg create mode 100644 assets/icons/radix/shadow-none.svg create mode 100644 assets/icons/radix/shadow-outer.svg create mode 100644 assets/icons/radix/shadow.svg create mode 100644 assets/icons/radix/share-1.svg create mode 100644 assets/icons/radix/share-2.svg create mode 100644 assets/icons/radix/shuffle.svg create mode 100644 assets/icons/radix/size.svg create mode 100644 assets/icons/radix/sketch-logo.svg create mode 100644 assets/icons/radix/slash.svg create mode 100644 assets/icons/radix/slider.svg create mode 100644 assets/icons/radix/space-between-horizontally.svg create mode 100644 assets/icons/radix/space-between-vertically.svg create mode 100644 assets/icons/radix/space-evenly-horizontally.svg create mode 100644 assets/icons/radix/space-evenly-vertically.svg create mode 100644 assets/icons/radix/speaker-loud.svg create mode 100644 assets/icons/radix/speaker-moderate.svg create mode 100644 assets/icons/radix/speaker-off.svg create mode 100644 assets/icons/radix/speaker-quiet.svg create mode 100644 assets/icons/radix/square.svg create mode 100644 assets/icons/radix/stack.svg create mode 100644 assets/icons/radix/star-filled.svg create mode 100644 assets/icons/radix/star.svg create mode 100644 assets/icons/radix/stitches-logo.svg create mode 100644 assets/icons/radix/stop.svg create mode 100644 assets/icons/radix/stopwatch.svg create mode 100644 assets/icons/radix/stretch-horizontally.svg create mode 100644 assets/icons/radix/stretch-vertically.svg create mode 100644 assets/icons/radix/strikethrough.svg create mode 100644 assets/icons/radix/sun.svg create mode 100644 assets/icons/radix/switch.svg create mode 100644 assets/icons/radix/symbol.svg create mode 100644 assets/icons/radix/table.svg create mode 100644 assets/icons/radix/target.svg create mode 100644 assets/icons/radix/text-align-bottom.svg create mode 100644 assets/icons/radix/text-align-center.svg create mode 100644 assets/icons/radix/text-align-justify.svg create mode 100644 assets/icons/radix/text-align-left.svg create mode 100644 assets/icons/radix/text-align-middle.svg create mode 100644 assets/icons/radix/text-align-right.svg create mode 100644 assets/icons/radix/text-align-top.svg create mode 100644 assets/icons/radix/text-none.svg create mode 100644 assets/icons/radix/text.svg create mode 100644 assets/icons/radix/thick-arrow-down.svg create mode 100644 assets/icons/radix/thick-arrow-left.svg create mode 100644 assets/icons/radix/thick-arrow-right.svg create mode 100644 assets/icons/radix/thick-arrow-up.svg create mode 100644 assets/icons/radix/timer.svg create mode 100644 assets/icons/radix/tokens.svg create mode 100644 assets/icons/radix/track-next.svg create mode 100644 assets/icons/radix/track-previous.svg create mode 100644 assets/icons/radix/transform.svg create mode 100644 assets/icons/radix/transparency-grid.svg create mode 100644 assets/icons/radix/trash.svg create mode 100644 assets/icons/radix/triangle-down.svg create mode 100644 assets/icons/radix/triangle-left.svg create mode 100644 assets/icons/radix/triangle-right.svg create mode 100644 assets/icons/radix/triangle-up.svg create mode 100644 assets/icons/radix/twitter-logo.svg create mode 100644 assets/icons/radix/underline.svg create mode 100644 assets/icons/radix/update.svg create mode 100644 assets/icons/radix/upload.svg create mode 100644 assets/icons/radix/value-none.svg create mode 100644 assets/icons/radix/value.svg create mode 100644 assets/icons/radix/vercel-logo.svg create mode 100644 assets/icons/radix/video.svg create mode 100644 assets/icons/radix/view-grid.svg create mode 100644 assets/icons/radix/view-horizontal.svg create mode 100644 assets/icons/radix/view-none.svg create mode 100644 assets/icons/radix/view-vertical.svg create mode 100644 assets/icons/radix/width.svg create mode 100644 assets/icons/radix/zoom-in.svg create mode 100644 assets/icons/radix/zoom-out.svg diff --git a/assets/icons/radix/accessibility.svg b/assets/icons/radix/accessibility.svg new file mode 100644 index 0000000000..32d78f2d8d --- /dev/null +++ b/assets/icons/radix/accessibility.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/activity-log.svg b/assets/icons/radix/activity-log.svg new file mode 100644 index 0000000000..8feab7d449 --- /dev/null +++ b/assets/icons/radix/activity-log.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-baseline.svg b/assets/icons/radix/align-baseline.svg new file mode 100644 index 0000000000..07213dc1ae --- /dev/null +++ b/assets/icons/radix/align-baseline.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-bottom.svg b/assets/icons/radix/align-bottom.svg new file mode 100644 index 0000000000..7d11c0cd5a --- /dev/null +++ b/assets/icons/radix/align-bottom.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-center-horizontally.svg b/assets/icons/radix/align-center-horizontally.svg new file mode 100644 index 0000000000..69509a7d09 --- /dev/null +++ b/assets/icons/radix/align-center-horizontally.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-center-vertically.svg b/assets/icons/radix/align-center-vertically.svg new file mode 100644 index 0000000000..4f1b50cc43 --- /dev/null +++ b/assets/icons/radix/align-center-vertically.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-center.svg b/assets/icons/radix/align-center.svg new file mode 100644 index 0000000000..caaec36477 --- /dev/null +++ b/assets/icons/radix/align-center.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-end.svg b/assets/icons/radix/align-end.svg new file mode 100644 index 0000000000..18f1b64912 --- /dev/null +++ b/assets/icons/radix/align-end.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-horizontal-centers.svg b/assets/icons/radix/align-horizontal-centers.svg new file mode 100644 index 0000000000..2d1d64ea4b --- /dev/null +++ b/assets/icons/radix/align-horizontal-centers.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-left.svg b/assets/icons/radix/align-left.svg new file mode 100644 index 0000000000..0d5dba095c --- /dev/null +++ b/assets/icons/radix/align-left.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-right.svg b/assets/icons/radix/align-right.svg new file mode 100644 index 0000000000..1b6b3f0ffa --- /dev/null +++ b/assets/icons/radix/align-right.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-start.svg b/assets/icons/radix/align-start.svg new file mode 100644 index 0000000000..ada50e1079 --- /dev/null +++ b/assets/icons/radix/align-start.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-stretch.svg b/assets/icons/radix/align-stretch.svg new file mode 100644 index 0000000000..3cb28605cb --- /dev/null +++ b/assets/icons/radix/align-stretch.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-top.svg b/assets/icons/radix/align-top.svg new file mode 100644 index 0000000000..23db80f4dd --- /dev/null +++ b/assets/icons/radix/align-top.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/align-vertical-centers.svg b/assets/icons/radix/align-vertical-centers.svg new file mode 100644 index 0000000000..07eaee7bf7 --- /dev/null +++ b/assets/icons/radix/align-vertical-centers.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/all-sides.svg b/assets/icons/radix/all-sides.svg new file mode 100644 index 0000000000..8ace7df03f --- /dev/null +++ b/assets/icons/radix/all-sides.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/angle.svg b/assets/icons/radix/angle.svg new file mode 100644 index 0000000000..a0d93f3460 --- /dev/null +++ b/assets/icons/radix/angle.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/archive.svg b/assets/icons/radix/archive.svg new file mode 100644 index 0000000000..74063f1d1e --- /dev/null +++ b/assets/icons/radix/archive.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/arrow-bottom-left.svg b/assets/icons/radix/arrow-bottom-left.svg new file mode 100644 index 0000000000..7a4511aa2d --- /dev/null +++ b/assets/icons/radix/arrow-bottom-left.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/arrow-bottom-right.svg b/assets/icons/radix/arrow-bottom-right.svg new file mode 100644 index 0000000000..2ba9fef101 --- /dev/null +++ b/assets/icons/radix/arrow-bottom-right.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/arrow-down.svg b/assets/icons/radix/arrow-down.svg new file mode 100644 index 0000000000..5dc21a6689 --- /dev/null +++ b/assets/icons/radix/arrow-down.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/arrow-left.svg b/assets/icons/radix/arrow-left.svg new file mode 100644 index 0000000000..3a64c8394f --- /dev/null +++ b/assets/icons/radix/arrow-left.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/arrow-right.svg b/assets/icons/radix/arrow-right.svg new file mode 100644 index 0000000000..e3d30988d5 --- /dev/null +++ b/assets/icons/radix/arrow-right.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/arrow-top-left.svg b/assets/icons/radix/arrow-top-left.svg new file mode 100644 index 0000000000..69fef41dee --- /dev/null +++ b/assets/icons/radix/arrow-top-left.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/arrow-top-right.svg b/assets/icons/radix/arrow-top-right.svg new file mode 100644 index 0000000000..c1016376e3 --- /dev/null +++ b/assets/icons/radix/arrow-top-right.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/arrow-up.svg b/assets/icons/radix/arrow-up.svg new file mode 100644 index 0000000000..ba426119e9 --- /dev/null +++ b/assets/icons/radix/arrow-up.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/aspect-ratio.svg b/assets/icons/radix/aspect-ratio.svg new file mode 100644 index 0000000000..0851f2e1e9 --- /dev/null +++ b/assets/icons/radix/aspect-ratio.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/avatar.svg b/assets/icons/radix/avatar.svg new file mode 100644 index 0000000000..cb229c77fe --- /dev/null +++ b/assets/icons/radix/avatar.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/backpack.svg b/assets/icons/radix/backpack.svg new file mode 100644 index 0000000000..a5c9cedbd3 --- /dev/null +++ b/assets/icons/radix/backpack.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/badge.svg b/assets/icons/radix/badge.svg new file mode 100644 index 0000000000..aa764d4726 --- /dev/null +++ b/assets/icons/radix/badge.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/bar-chart.svg b/assets/icons/radix/bar-chart.svg new file mode 100644 index 0000000000..f8054781d9 --- /dev/null +++ b/assets/icons/radix/bar-chart.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/bell.svg b/assets/icons/radix/bell.svg new file mode 100644 index 0000000000..ea1c6dd42e --- /dev/null +++ b/assets/icons/radix/bell.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/blending-mode.svg b/assets/icons/radix/blending-mode.svg new file mode 100644 index 0000000000..bd58cf4ee3 --- /dev/null +++ b/assets/icons/radix/blending-mode.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/bookmark-filled.svg b/assets/icons/radix/bookmark-filled.svg new file mode 100644 index 0000000000..5b725cd88d --- /dev/null +++ b/assets/icons/radix/bookmark-filled.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/bookmark.svg b/assets/icons/radix/bookmark.svg new file mode 100644 index 0000000000..90c4d827f1 --- /dev/null +++ b/assets/icons/radix/bookmark.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/border-all.svg b/assets/icons/radix/border-all.svg new file mode 100644 index 0000000000..3bfde7d59b --- /dev/null +++ b/assets/icons/radix/border-all.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/assets/icons/radix/border-bottom.svg b/assets/icons/radix/border-bottom.svg new file mode 100644 index 0000000000..f2d3c3d554 --- /dev/null +++ b/assets/icons/radix/border-bottom.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/radix/border-dashed.svg b/assets/icons/radix/border-dashed.svg new file mode 100644 index 0000000000..85fdcdfe5d --- /dev/null +++ b/assets/icons/radix/border-dashed.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/border-dotted.svg b/assets/icons/radix/border-dotted.svg new file mode 100644 index 0000000000..5eb514ed2a --- /dev/null +++ b/assets/icons/radix/border-dotted.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/border-left.svg b/assets/icons/radix/border-left.svg new file mode 100644 index 0000000000..5deb197da5 --- /dev/null +++ b/assets/icons/radix/border-left.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/radix/border-none.svg b/assets/icons/radix/border-none.svg new file mode 100644 index 0000000000..1ad3f59d7c --- /dev/null +++ b/assets/icons/radix/border-none.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/radix/border-right.svg b/assets/icons/radix/border-right.svg new file mode 100644 index 0000000000..c939095ad7 --- /dev/null +++ b/assets/icons/radix/border-right.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/radix/border-solid.svg b/assets/icons/radix/border-solid.svg new file mode 100644 index 0000000000..5c0d26a058 --- /dev/null +++ b/assets/icons/radix/border-solid.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/border-split.svg b/assets/icons/radix/border-split.svg new file mode 100644 index 0000000000..7fdf6cc34e --- /dev/null +++ b/assets/icons/radix/border-split.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + diff --git a/assets/icons/radix/border-style.svg b/assets/icons/radix/border-style.svg new file mode 100644 index 0000000000..f729cb993b --- /dev/null +++ b/assets/icons/radix/border-style.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/border-top.svg b/assets/icons/radix/border-top.svg new file mode 100644 index 0000000000..bde739d755 --- /dev/null +++ b/assets/icons/radix/border-top.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/radix/border-width.svg b/assets/icons/radix/border-width.svg new file mode 100644 index 0000000000..37c270756e --- /dev/null +++ b/assets/icons/radix/border-width.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/box-model.svg b/assets/icons/radix/box-model.svg new file mode 100644 index 0000000000..45d1a7ce41 --- /dev/null +++ b/assets/icons/radix/box-model.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/box.svg b/assets/icons/radix/box.svg new file mode 100644 index 0000000000..6e035c21ed --- /dev/null +++ b/assets/icons/radix/box.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/button.svg b/assets/icons/radix/button.svg new file mode 100644 index 0000000000..31622bcf15 --- /dev/null +++ b/assets/icons/radix/button.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/calendar.svg b/assets/icons/radix/calendar.svg new file mode 100644 index 0000000000..2adbe0bc28 --- /dev/null +++ b/assets/icons/radix/calendar.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/camera.svg b/assets/icons/radix/camera.svg new file mode 100644 index 0000000000..d7cccf74c2 --- /dev/null +++ b/assets/icons/radix/camera.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/card-stack-minus.svg b/assets/icons/radix/card-stack-minus.svg new file mode 100644 index 0000000000..04d8e51178 --- /dev/null +++ b/assets/icons/radix/card-stack-minus.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/card-stack-plus.svg b/assets/icons/radix/card-stack-plus.svg new file mode 100644 index 0000000000..a184f4bc1a --- /dev/null +++ b/assets/icons/radix/card-stack-plus.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/card-stack.svg b/assets/icons/radix/card-stack.svg new file mode 100644 index 0000000000..defea0e165 --- /dev/null +++ b/assets/icons/radix/card-stack.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/caret-down.svg b/assets/icons/radix/caret-down.svg new file mode 100644 index 0000000000..ff8b8c3b88 --- /dev/null +++ b/assets/icons/radix/caret-down.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/caret-left.svg b/assets/icons/radix/caret-left.svg new file mode 100644 index 0000000000..969bc3b95c --- /dev/null +++ b/assets/icons/radix/caret-left.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/caret-right.svg b/assets/icons/radix/caret-right.svg new file mode 100644 index 0000000000..75c55d8676 --- /dev/null +++ b/assets/icons/radix/caret-right.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/caret-sort.svg b/assets/icons/radix/caret-sort.svg new file mode 100644 index 0000000000..a65e20b660 --- /dev/null +++ b/assets/icons/radix/caret-sort.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/caret-up.svg b/assets/icons/radix/caret-up.svg new file mode 100644 index 0000000000..53026b83d8 --- /dev/null +++ b/assets/icons/radix/caret-up.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/chat-bubble.svg b/assets/icons/radix/chat-bubble.svg new file mode 100644 index 0000000000..5766f46de8 --- /dev/null +++ b/assets/icons/radix/chat-bubble.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/check-circled.svg b/assets/icons/radix/check-circled.svg new file mode 100644 index 0000000000..19ee22eb51 --- /dev/null +++ b/assets/icons/radix/check-circled.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/check.svg b/assets/icons/radix/check.svg new file mode 100644 index 0000000000..476a3baa18 --- /dev/null +++ b/assets/icons/radix/check.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/checkbox.svg b/assets/icons/radix/checkbox.svg new file mode 100644 index 0000000000..d6bb3c7ef2 --- /dev/null +++ b/assets/icons/radix/checkbox.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/chevron-down.svg b/assets/icons/radix/chevron-down.svg new file mode 100644 index 0000000000..175c1312fd --- /dev/null +++ b/assets/icons/radix/chevron-down.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/chevron-left.svg b/assets/icons/radix/chevron-left.svg new file mode 100644 index 0000000000..d7628202f2 --- /dev/null +++ b/assets/icons/radix/chevron-left.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/chevron-right.svg b/assets/icons/radix/chevron-right.svg new file mode 100644 index 0000000000..e3ebd73d99 --- /dev/null +++ b/assets/icons/radix/chevron-right.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/chevron-up.svg b/assets/icons/radix/chevron-up.svg new file mode 100644 index 0000000000..0e8e796dab --- /dev/null +++ b/assets/icons/radix/chevron-up.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/circle-backslash.svg b/assets/icons/radix/circle-backslash.svg new file mode 100644 index 0000000000..40c4dd5398 --- /dev/null +++ b/assets/icons/radix/circle-backslash.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/circle.svg b/assets/icons/radix/circle.svg new file mode 100644 index 0000000000..ba4a8f22fe --- /dev/null +++ b/assets/icons/radix/circle.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/clipboard-copy.svg b/assets/icons/radix/clipboard-copy.svg new file mode 100644 index 0000000000..5293fdc493 --- /dev/null +++ b/assets/icons/radix/clipboard-copy.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/clipboard.svg b/assets/icons/radix/clipboard.svg new file mode 100644 index 0000000000..e18b32943b --- /dev/null +++ b/assets/icons/radix/clipboard.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/clock.svg b/assets/icons/radix/clock.svg new file mode 100644 index 0000000000..ac3b526fbb --- /dev/null +++ b/assets/icons/radix/clock.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/code.svg b/assets/icons/radix/code.svg new file mode 100644 index 0000000000..70fe381b68 --- /dev/null +++ b/assets/icons/radix/code.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/codesandbox-logo.svg b/assets/icons/radix/codesandbox-logo.svg new file mode 100644 index 0000000000..4a3f549c2f --- /dev/null +++ b/assets/icons/radix/codesandbox-logo.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/color-wheel.svg b/assets/icons/radix/color-wheel.svg new file mode 100644 index 0000000000..2153b84428 --- /dev/null +++ b/assets/icons/radix/color-wheel.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/column-spacing.svg b/assets/icons/radix/column-spacing.svg new file mode 100644 index 0000000000..aafcf555cb --- /dev/null +++ b/assets/icons/radix/column-spacing.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/columns.svg b/assets/icons/radix/columns.svg new file mode 100644 index 0000000000..e1607611b1 --- /dev/null +++ b/assets/icons/radix/columns.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/commit.svg b/assets/icons/radix/commit.svg new file mode 100644 index 0000000000..ac128a2b08 --- /dev/null +++ b/assets/icons/radix/commit.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/component-1.svg b/assets/icons/radix/component-1.svg new file mode 100644 index 0000000000..e3e9f38af1 --- /dev/null +++ b/assets/icons/radix/component-1.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/component-2.svg b/assets/icons/radix/component-2.svg new file mode 100644 index 0000000000..df2091d143 --- /dev/null +++ b/assets/icons/radix/component-2.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/component-boolean.svg b/assets/icons/radix/component-boolean.svg new file mode 100644 index 0000000000..942e8832eb --- /dev/null +++ b/assets/icons/radix/component-boolean.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/component-instance.svg b/assets/icons/radix/component-instance.svg new file mode 100644 index 0000000000..048c401291 --- /dev/null +++ b/assets/icons/radix/component-instance.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/component-none.svg b/assets/icons/radix/component-none.svg new file mode 100644 index 0000000000..a622c3ee96 --- /dev/null +++ b/assets/icons/radix/component-none.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/component-placeholder.svg b/assets/icons/radix/component-placeholder.svg new file mode 100644 index 0000000000..b8892d5d23 --- /dev/null +++ b/assets/icons/radix/component-placeholder.svg @@ -0,0 +1,12 @@ + + + + diff --git a/assets/icons/radix/container.svg b/assets/icons/radix/container.svg new file mode 100644 index 0000000000..1c2a4fd0e1 --- /dev/null +++ b/assets/icons/radix/container.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/cookie.svg b/assets/icons/radix/cookie.svg new file mode 100644 index 0000000000..8c165601a2 --- /dev/null +++ b/assets/icons/radix/cookie.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/copy.svg b/assets/icons/radix/copy.svg new file mode 100644 index 0000000000..bf2b504ecf --- /dev/null +++ b/assets/icons/radix/copy.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/corner-bottom-left.svg b/assets/icons/radix/corner-bottom-left.svg new file mode 100644 index 0000000000..26df9dbad8 --- /dev/null +++ b/assets/icons/radix/corner-bottom-left.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/corner-bottom-right.svg b/assets/icons/radix/corner-bottom-right.svg new file mode 100644 index 0000000000..15e3957123 --- /dev/null +++ b/assets/icons/radix/corner-bottom-right.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/corner-top-left.svg b/assets/icons/radix/corner-top-left.svg new file mode 100644 index 0000000000..8fc1b84b82 --- /dev/null +++ b/assets/icons/radix/corner-top-left.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/corner-top-right.svg b/assets/icons/radix/corner-top-right.svg new file mode 100644 index 0000000000..533ea6c678 --- /dev/null +++ b/assets/icons/radix/corner-top-right.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/corners.svg b/assets/icons/radix/corners.svg new file mode 100644 index 0000000000..c41c4e0183 --- /dev/null +++ b/assets/icons/radix/corners.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/countdown-timer.svg b/assets/icons/radix/countdown-timer.svg new file mode 100644 index 0000000000..58494bd416 --- /dev/null +++ b/assets/icons/radix/countdown-timer.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/counter-clockwise-clock.svg b/assets/icons/radix/counter-clockwise-clock.svg new file mode 100644 index 0000000000..0b3acbcebf --- /dev/null +++ b/assets/icons/radix/counter-clockwise-clock.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/crop.svg b/assets/icons/radix/crop.svg new file mode 100644 index 0000000000..008457fff6 --- /dev/null +++ b/assets/icons/radix/crop.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/cross-1.svg b/assets/icons/radix/cross-1.svg new file mode 100644 index 0000000000..62135d27ed --- /dev/null +++ b/assets/icons/radix/cross-1.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/cross-2.svg b/assets/icons/radix/cross-2.svg new file mode 100644 index 0000000000..4c55700928 --- /dev/null +++ b/assets/icons/radix/cross-2.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/cross-circled.svg b/assets/icons/radix/cross-circled.svg new file mode 100644 index 0000000000..df3cb896c8 --- /dev/null +++ b/assets/icons/radix/cross-circled.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/crosshair-1.svg b/assets/icons/radix/crosshair-1.svg new file mode 100644 index 0000000000..05b22f8461 --- /dev/null +++ b/assets/icons/radix/crosshair-1.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/crosshair-2.svg b/assets/icons/radix/crosshair-2.svg new file mode 100644 index 0000000000..f5ee0a92af --- /dev/null +++ b/assets/icons/radix/crosshair-2.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/crumpled-paper.svg b/assets/icons/radix/crumpled-paper.svg new file mode 100644 index 0000000000..33e9b65581 --- /dev/null +++ b/assets/icons/radix/crumpled-paper.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/cube.svg b/assets/icons/radix/cube.svg new file mode 100644 index 0000000000..b327158be4 --- /dev/null +++ b/assets/icons/radix/cube.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/cursor-arrow.svg b/assets/icons/radix/cursor-arrow.svg new file mode 100644 index 0000000000..b0227e4ded --- /dev/null +++ b/assets/icons/radix/cursor-arrow.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/cursor-text.svg b/assets/icons/radix/cursor-text.svg new file mode 100644 index 0000000000..05939503b8 --- /dev/null +++ b/assets/icons/radix/cursor-text.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/dash.svg b/assets/icons/radix/dash.svg new file mode 100644 index 0000000000..d70daf7fed --- /dev/null +++ b/assets/icons/radix/dash.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/dashboard.svg b/assets/icons/radix/dashboard.svg new file mode 100644 index 0000000000..38008c64e4 --- /dev/null +++ b/assets/icons/radix/dashboard.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/desktop.svg b/assets/icons/radix/desktop.svg new file mode 100644 index 0000000000..ad252e64cf --- /dev/null +++ b/assets/icons/radix/desktop.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/dimensions.svg b/assets/icons/radix/dimensions.svg new file mode 100644 index 0000000000..767d1d2896 --- /dev/null +++ b/assets/icons/radix/dimensions.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/disc.svg b/assets/icons/radix/disc.svg new file mode 100644 index 0000000000..6e19caab35 --- /dev/null +++ b/assets/icons/radix/disc.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/discord-logo.svg b/assets/icons/radix/discord-logo.svg new file mode 100644 index 0000000000..50567c212e --- /dev/null +++ b/assets/icons/radix/discord-logo.svg @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/assets/icons/radix/divider-horizontal.svg b/assets/icons/radix/divider-horizontal.svg new file mode 100644 index 0000000000..59e43649c9 --- /dev/null +++ b/assets/icons/radix/divider-horizontal.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/divider-vertical.svg b/assets/icons/radix/divider-vertical.svg new file mode 100644 index 0000000000..95f5cc8f2f --- /dev/null +++ b/assets/icons/radix/divider-vertical.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/dot-filled.svg b/assets/icons/radix/dot-filled.svg new file mode 100644 index 0000000000..0c1a17b3bd --- /dev/null +++ b/assets/icons/radix/dot-filled.svg @@ -0,0 +1,6 @@ + + + diff --git a/assets/icons/radix/dot-solid.svg b/assets/icons/radix/dot-solid.svg new file mode 100644 index 0000000000..0c1a17b3bd --- /dev/null +++ b/assets/icons/radix/dot-solid.svg @@ -0,0 +1,6 @@ + + + diff --git a/assets/icons/radix/dot.svg b/assets/icons/radix/dot.svg new file mode 100644 index 0000000000..c553a1422d --- /dev/null +++ b/assets/icons/radix/dot.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/dots-horizontal.svg b/assets/icons/radix/dots-horizontal.svg new file mode 100644 index 0000000000..347d1ae13d --- /dev/null +++ b/assets/icons/radix/dots-horizontal.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/dots-vertical.svg b/assets/icons/radix/dots-vertical.svg new file mode 100644 index 0000000000..5ca1a181e3 --- /dev/null +++ b/assets/icons/radix/dots-vertical.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/double-arrow-down.svg b/assets/icons/radix/double-arrow-down.svg new file mode 100644 index 0000000000..8b86db2f8a --- /dev/null +++ b/assets/icons/radix/double-arrow-down.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/double-arrow-left.svg b/assets/icons/radix/double-arrow-left.svg new file mode 100644 index 0000000000..0ef30ff955 --- /dev/null +++ b/assets/icons/radix/double-arrow-left.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/double-arrow-right.svg b/assets/icons/radix/double-arrow-right.svg new file mode 100644 index 0000000000..9997fdc403 --- /dev/null +++ b/assets/icons/radix/double-arrow-right.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/double-arrow-up.svg b/assets/icons/radix/double-arrow-up.svg new file mode 100644 index 0000000000..8d571fcd66 --- /dev/null +++ b/assets/icons/radix/double-arrow-up.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/download.svg b/assets/icons/radix/download.svg new file mode 100644 index 0000000000..49a05d5f47 --- /dev/null +++ b/assets/icons/radix/download.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/drag-handle-dots-1.svg b/assets/icons/radix/drag-handle-dots-1.svg new file mode 100644 index 0000000000..fc046bb9d9 --- /dev/null +++ b/assets/icons/radix/drag-handle-dots-1.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/radix/drag-handle-dots-2.svg b/assets/icons/radix/drag-handle-dots-2.svg new file mode 100644 index 0000000000..aed0e702d7 --- /dev/null +++ b/assets/icons/radix/drag-handle-dots-2.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/drag-handle-horizontal.svg b/assets/icons/radix/drag-handle-horizontal.svg new file mode 100644 index 0000000000..c1bb138a24 --- /dev/null +++ b/assets/icons/radix/drag-handle-horizontal.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/drag-handle-vertical.svg b/assets/icons/radix/drag-handle-vertical.svg new file mode 100644 index 0000000000..8d48c7894a --- /dev/null +++ b/assets/icons/radix/drag-handle-vertical.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/drawing-pin-filled.svg b/assets/icons/radix/drawing-pin-filled.svg new file mode 100644 index 0000000000..e1894619c3 --- /dev/null +++ b/assets/icons/radix/drawing-pin-filled.svg @@ -0,0 +1,14 @@ + + + + diff --git a/assets/icons/radix/drawing-pin-solid.svg b/assets/icons/radix/drawing-pin-solid.svg new file mode 100644 index 0000000000..e1894619c3 --- /dev/null +++ b/assets/icons/radix/drawing-pin-solid.svg @@ -0,0 +1,14 @@ + + + + diff --git a/assets/icons/radix/drawing-pin.svg b/assets/icons/radix/drawing-pin.svg new file mode 100644 index 0000000000..5625e7588f --- /dev/null +++ b/assets/icons/radix/drawing-pin.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/dropdown-menu.svg b/assets/icons/radix/dropdown-menu.svg new file mode 100644 index 0000000000..c938052be8 --- /dev/null +++ b/assets/icons/radix/dropdown-menu.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/enter-full-screen.svg b/assets/icons/radix/enter-full-screen.svg new file mode 100644 index 0000000000..d368a6d415 --- /dev/null +++ b/assets/icons/radix/enter-full-screen.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/enter.svg b/assets/icons/radix/enter.svg new file mode 100644 index 0000000000..cc57d74cea --- /dev/null +++ b/assets/icons/radix/enter.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/envelope-closed.svg b/assets/icons/radix/envelope-closed.svg new file mode 100644 index 0000000000..4b5e037840 --- /dev/null +++ b/assets/icons/radix/envelope-closed.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/envelope-open.svg b/assets/icons/radix/envelope-open.svg new file mode 100644 index 0000000000..df1e3fea95 --- /dev/null +++ b/assets/icons/radix/envelope-open.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/eraser.svg b/assets/icons/radix/eraser.svg new file mode 100644 index 0000000000..bb448d4d23 --- /dev/null +++ b/assets/icons/radix/eraser.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/exclamation-triangle.svg b/assets/icons/radix/exclamation-triangle.svg new file mode 100644 index 0000000000..210d4c45c6 --- /dev/null +++ b/assets/icons/radix/exclamation-triangle.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/exit-full-screen.svg b/assets/icons/radix/exit-full-screen.svg new file mode 100644 index 0000000000..9b6439b043 --- /dev/null +++ b/assets/icons/radix/exit-full-screen.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/exit.svg b/assets/icons/radix/exit.svg new file mode 100644 index 0000000000..2cc6ce120d --- /dev/null +++ b/assets/icons/radix/exit.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/external-link.svg b/assets/icons/radix/external-link.svg new file mode 100644 index 0000000000..0ee7420162 --- /dev/null +++ b/assets/icons/radix/external-link.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/eye-closed.svg b/assets/icons/radix/eye-closed.svg new file mode 100644 index 0000000000..f824fe55f9 --- /dev/null +++ b/assets/icons/radix/eye-closed.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/eye-none.svg b/assets/icons/radix/eye-none.svg new file mode 100644 index 0000000000..d4beecd33a --- /dev/null +++ b/assets/icons/radix/eye-none.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/eye-open.svg b/assets/icons/radix/eye-open.svg new file mode 100644 index 0000000000..d39d26b2c1 --- /dev/null +++ b/assets/icons/radix/eye-open.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/face.svg b/assets/icons/radix/face.svg new file mode 100644 index 0000000000..81b14dd8d7 --- /dev/null +++ b/assets/icons/radix/face.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/figma-logo.svg b/assets/icons/radix/figma-logo.svg new file mode 100644 index 0000000000..6c19276554 --- /dev/null +++ b/assets/icons/radix/figma-logo.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/file-minus.svg b/assets/icons/radix/file-minus.svg new file mode 100644 index 0000000000..bd1a841881 --- /dev/null +++ b/assets/icons/radix/file-minus.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/file-plus.svg b/assets/icons/radix/file-plus.svg new file mode 100644 index 0000000000..2396e20015 --- /dev/null +++ b/assets/icons/radix/file-plus.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/file-text.svg b/assets/icons/radix/file-text.svg new file mode 100644 index 0000000000..f341ab8abf --- /dev/null +++ b/assets/icons/radix/file-text.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/file.svg b/assets/icons/radix/file.svg new file mode 100644 index 0000000000..5f256b42e1 --- /dev/null +++ b/assets/icons/radix/file.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/font-bold.svg b/assets/icons/radix/font-bold.svg new file mode 100644 index 0000000000..7dc6caf3b0 --- /dev/null +++ b/assets/icons/radix/font-bold.svg @@ -0,0 +1,6 @@ + + + diff --git a/assets/icons/radix/font-family.svg b/assets/icons/radix/font-family.svg new file mode 100644 index 0000000000..9134b9086d --- /dev/null +++ b/assets/icons/radix/font-family.svg @@ -0,0 +1,6 @@ + + + diff --git a/assets/icons/radix/font-italic.svg b/assets/icons/radix/font-italic.svg new file mode 100644 index 0000000000..6e6288d6bc --- /dev/null +++ b/assets/icons/radix/font-italic.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/font-roman.svg b/assets/icons/radix/font-roman.svg new file mode 100644 index 0000000000..c595b790fc --- /dev/null +++ b/assets/icons/radix/font-roman.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/font-size.svg b/assets/icons/radix/font-size.svg new file mode 100644 index 0000000000..e389a58d73 --- /dev/null +++ b/assets/icons/radix/font-size.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/font-style.svg b/assets/icons/radix/font-style.svg new file mode 100644 index 0000000000..31c3730130 --- /dev/null +++ b/assets/icons/radix/font-style.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/frame.svg b/assets/icons/radix/frame.svg new file mode 100644 index 0000000000..ec61a48efa --- /dev/null +++ b/assets/icons/radix/frame.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/framer-logo.svg b/assets/icons/radix/framer-logo.svg new file mode 100644 index 0000000000..68be3b317b --- /dev/null +++ b/assets/icons/radix/framer-logo.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/gear.svg b/assets/icons/radix/gear.svg new file mode 100644 index 0000000000..52f9e17312 --- /dev/null +++ b/assets/icons/radix/gear.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/github-logo.svg b/assets/icons/radix/github-logo.svg new file mode 100644 index 0000000000..e46612cf56 --- /dev/null +++ b/assets/icons/radix/github-logo.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/globe.svg b/assets/icons/radix/globe.svg new file mode 100644 index 0000000000..4728b827df --- /dev/null +++ b/assets/icons/radix/globe.svg @@ -0,0 +1,26 @@ + + + + + + diff --git a/assets/icons/radix/grid.svg b/assets/icons/radix/grid.svg new file mode 100644 index 0000000000..5d9af33572 --- /dev/null +++ b/assets/icons/radix/grid.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/group.svg b/assets/icons/radix/group.svg new file mode 100644 index 0000000000..c3c91d211f --- /dev/null +++ b/assets/icons/radix/group.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/half-1.svg b/assets/icons/radix/half-1.svg new file mode 100644 index 0000000000..9890e26bb8 --- /dev/null +++ b/assets/icons/radix/half-1.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/half-2.svg b/assets/icons/radix/half-2.svg new file mode 100644 index 0000000000..4db1d564cb --- /dev/null +++ b/assets/icons/radix/half-2.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/hamburger-menu.svg b/assets/icons/radix/hamburger-menu.svg new file mode 100644 index 0000000000..039168055b --- /dev/null +++ b/assets/icons/radix/hamburger-menu.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/hand.svg b/assets/icons/radix/hand.svg new file mode 100644 index 0000000000..12afac8f5f --- /dev/null +++ b/assets/icons/radix/hand.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/heading.svg b/assets/icons/radix/heading.svg new file mode 100644 index 0000000000..0a5e2caaf1 --- /dev/null +++ b/assets/icons/radix/heading.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/heart-filled.svg b/assets/icons/radix/heart-filled.svg new file mode 100644 index 0000000000..94928accd7 --- /dev/null +++ b/assets/icons/radix/heart-filled.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/heart.svg b/assets/icons/radix/heart.svg new file mode 100644 index 0000000000..91cbc450fd --- /dev/null +++ b/assets/icons/radix/heart.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/height.svg b/assets/icons/radix/height.svg new file mode 100644 index 0000000000..28424f4d51 --- /dev/null +++ b/assets/icons/radix/height.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/hobby-knife.svg b/assets/icons/radix/hobby-knife.svg new file mode 100644 index 0000000000..c2ed3fb1ed --- /dev/null +++ b/assets/icons/radix/hobby-knife.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/home.svg b/assets/icons/radix/home.svg new file mode 100644 index 0000000000..733bd79113 --- /dev/null +++ b/assets/icons/radix/home.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/iconjar-logo.svg b/assets/icons/radix/iconjar-logo.svg new file mode 100644 index 0000000000..c154b4e864 --- /dev/null +++ b/assets/icons/radix/iconjar-logo.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/id-card.svg b/assets/icons/radix/id-card.svg new file mode 100644 index 0000000000..efde9ffa7e --- /dev/null +++ b/assets/icons/radix/id-card.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/image.svg b/assets/icons/radix/image.svg new file mode 100644 index 0000000000..0ff4475252 --- /dev/null +++ b/assets/icons/radix/image.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/info-circled.svg b/assets/icons/radix/info-circled.svg new file mode 100644 index 0000000000..4ab1b260e3 --- /dev/null +++ b/assets/icons/radix/info-circled.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/inner-shadow.svg b/assets/icons/radix/inner-shadow.svg new file mode 100644 index 0000000000..1056a7bffc --- /dev/null +++ b/assets/icons/radix/inner-shadow.svg @@ -0,0 +1,78 @@ + + + + + + + + + + + + + diff --git a/assets/icons/radix/input.svg b/assets/icons/radix/input.svg new file mode 100644 index 0000000000..4ed4605b2c --- /dev/null +++ b/assets/icons/radix/input.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/instagram-logo.svg b/assets/icons/radix/instagram-logo.svg new file mode 100644 index 0000000000..5d78937966 --- /dev/null +++ b/assets/icons/radix/instagram-logo.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/assets/icons/radix/justify-center.svg b/assets/icons/radix/justify-center.svg new file mode 100644 index 0000000000..7999a4ea46 --- /dev/null +++ b/assets/icons/radix/justify-center.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/justify-end.svg b/assets/icons/radix/justify-end.svg new file mode 100644 index 0000000000..bb52f493d7 --- /dev/null +++ b/assets/icons/radix/justify-end.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/justify-start.svg b/assets/icons/radix/justify-start.svg new file mode 100644 index 0000000000..648ca0b603 --- /dev/null +++ b/assets/icons/radix/justify-start.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/justify-stretch.svg b/assets/icons/radix/justify-stretch.svg new file mode 100644 index 0000000000..83df0a8959 --- /dev/null +++ b/assets/icons/radix/justify-stretch.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/keyboard.svg b/assets/icons/radix/keyboard.svg new file mode 100644 index 0000000000..fc6f86bfc2 --- /dev/null +++ b/assets/icons/radix/keyboard.svg @@ -0,0 +1,7 @@ + + + + diff --git a/assets/icons/radix/lap-timer.svg b/assets/icons/radix/lap-timer.svg new file mode 100644 index 0000000000..1de0b3be6c --- /dev/null +++ b/assets/icons/radix/lap-timer.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/laptop.svg b/assets/icons/radix/laptop.svg new file mode 100644 index 0000000000..6aff5d6d44 --- /dev/null +++ b/assets/icons/radix/laptop.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/layers.svg b/assets/icons/radix/layers.svg new file mode 100644 index 0000000000..821993fc70 --- /dev/null +++ b/assets/icons/radix/layers.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/layout.svg b/assets/icons/radix/layout.svg new file mode 100644 index 0000000000..8e4a352f50 --- /dev/null +++ b/assets/icons/radix/layout.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/letter-case-capitalize.svg b/assets/icons/radix/letter-case-capitalize.svg new file mode 100644 index 0000000000..16617ecf7e --- /dev/null +++ b/assets/icons/radix/letter-case-capitalize.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/letter-case-lowercase.svg b/assets/icons/radix/letter-case-lowercase.svg new file mode 100644 index 0000000000..61aefb9aad --- /dev/null +++ b/assets/icons/radix/letter-case-lowercase.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/letter-case-toggle.svg b/assets/icons/radix/letter-case-toggle.svg new file mode 100644 index 0000000000..a021a2b922 --- /dev/null +++ b/assets/icons/radix/letter-case-toggle.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/letter-case-uppercase.svg b/assets/icons/radix/letter-case-uppercase.svg new file mode 100644 index 0000000000..ccd2be04e7 --- /dev/null +++ b/assets/icons/radix/letter-case-uppercase.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/letter-spacing.svg b/assets/icons/radix/letter-spacing.svg new file mode 100644 index 0000000000..073023e0f4 --- /dev/null +++ b/assets/icons/radix/letter-spacing.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/lightning-bolt.svg b/assets/icons/radix/lightning-bolt.svg new file mode 100644 index 0000000000..7c35df9cfe --- /dev/null +++ b/assets/icons/radix/lightning-bolt.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/line-height.svg b/assets/icons/radix/line-height.svg new file mode 100644 index 0000000000..1c302d1ffc --- /dev/null +++ b/assets/icons/radix/line-height.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/link-1.svg b/assets/icons/radix/link-1.svg new file mode 100644 index 0000000000..d5682b113e --- /dev/null +++ b/assets/icons/radix/link-1.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/link-2.svg b/assets/icons/radix/link-2.svg new file mode 100644 index 0000000000..be8370606e --- /dev/null +++ b/assets/icons/radix/link-2.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/link-break-1.svg b/assets/icons/radix/link-break-1.svg new file mode 100644 index 0000000000..05ae93e47a --- /dev/null +++ b/assets/icons/radix/link-break-1.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/link-break-2.svg b/assets/icons/radix/link-break-2.svg new file mode 100644 index 0000000000..78f28f98e8 --- /dev/null +++ b/assets/icons/radix/link-break-2.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/link-none-1.svg b/assets/icons/radix/link-none-1.svg new file mode 100644 index 0000000000..6ea56a386f --- /dev/null +++ b/assets/icons/radix/link-none-1.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/link-none-2.svg b/assets/icons/radix/link-none-2.svg new file mode 100644 index 0000000000..0b19d940d1 --- /dev/null +++ b/assets/icons/radix/link-none-2.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/linkedin-logo.svg b/assets/icons/radix/linkedin-logo.svg new file mode 100644 index 0000000000..0f0138bdf6 --- /dev/null +++ b/assets/icons/radix/linkedin-logo.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/list-bullet.svg b/assets/icons/radix/list-bullet.svg new file mode 100644 index 0000000000..2630b95ef0 --- /dev/null +++ b/assets/icons/radix/list-bullet.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/lock-closed.svg b/assets/icons/radix/lock-closed.svg new file mode 100644 index 0000000000..3871b5d5ad --- /dev/null +++ b/assets/icons/radix/lock-closed.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/lock-open-1.svg b/assets/icons/radix/lock-open-1.svg new file mode 100644 index 0000000000..8f6bfd5bbf --- /dev/null +++ b/assets/icons/radix/lock-open-1.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/lock-open-2.svg b/assets/icons/radix/lock-open-2.svg new file mode 100644 index 0000000000..ce69f67f29 --- /dev/null +++ b/assets/icons/radix/lock-open-2.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/loop.svg b/assets/icons/radix/loop.svg new file mode 100644 index 0000000000..bfa90ed084 --- /dev/null +++ b/assets/icons/radix/loop.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/magic-wand.svg b/assets/icons/radix/magic-wand.svg new file mode 100644 index 0000000000..bbc9826aa5 --- /dev/null +++ b/assets/icons/radix/magic-wand.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/magnifying-glass.svg b/assets/icons/radix/magnifying-glass.svg new file mode 100644 index 0000000000..a3a89bfa50 --- /dev/null +++ b/assets/icons/radix/magnifying-glass.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/margin.svg b/assets/icons/radix/margin.svg new file mode 100644 index 0000000000..1a513b37d6 --- /dev/null +++ b/assets/icons/radix/margin.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/mask-off.svg b/assets/icons/radix/mask-off.svg new file mode 100644 index 0000000000..5f847668e8 --- /dev/null +++ b/assets/icons/radix/mask-off.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/mask-on.svg b/assets/icons/radix/mask-on.svg new file mode 100644 index 0000000000..684c1b934d --- /dev/null +++ b/assets/icons/radix/mask-on.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/minus-circled.svg b/assets/icons/radix/minus-circled.svg new file mode 100644 index 0000000000..2c6df4cebf --- /dev/null +++ b/assets/icons/radix/minus-circled.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/minus.svg b/assets/icons/radix/minus.svg new file mode 100644 index 0000000000..2b39602979 --- /dev/null +++ b/assets/icons/radix/minus.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/mix.svg b/assets/icons/radix/mix.svg new file mode 100644 index 0000000000..9412a01843 --- /dev/null +++ b/assets/icons/radix/mix.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/mixer-horizontal.svg b/assets/icons/radix/mixer-horizontal.svg new file mode 100644 index 0000000000..f29ba25548 --- /dev/null +++ b/assets/icons/radix/mixer-horizontal.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/mixer-vertical.svg b/assets/icons/radix/mixer-vertical.svg new file mode 100644 index 0000000000..dc85d3a9e7 --- /dev/null +++ b/assets/icons/radix/mixer-vertical.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/mobile.svg b/assets/icons/radix/mobile.svg new file mode 100644 index 0000000000..b62b6506ff --- /dev/null +++ b/assets/icons/radix/mobile.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/modulz-logo.svg b/assets/icons/radix/modulz-logo.svg new file mode 100644 index 0000000000..754b229db6 --- /dev/null +++ b/assets/icons/radix/modulz-logo.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/moon.svg b/assets/icons/radix/moon.svg new file mode 100644 index 0000000000..1dac2ca212 --- /dev/null +++ b/assets/icons/radix/moon.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/move.svg b/assets/icons/radix/move.svg new file mode 100644 index 0000000000..3d0a0e56c9 --- /dev/null +++ b/assets/icons/radix/move.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/notion-logo.svg b/assets/icons/radix/notion-logo.svg new file mode 100644 index 0000000000..c2df152619 --- /dev/null +++ b/assets/icons/radix/notion-logo.svg @@ -0,0 +1,6 @@ + + + diff --git a/assets/icons/radix/opacity.svg b/assets/icons/radix/opacity.svg new file mode 100644 index 0000000000..a2d01bff82 --- /dev/null +++ b/assets/icons/radix/opacity.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/open-in-new-window.svg b/assets/icons/radix/open-in-new-window.svg new file mode 100644 index 0000000000..22baf82cff --- /dev/null +++ b/assets/icons/radix/open-in-new-window.svg @@ -0,0 +1,10 @@ + + + + + diff --git a/assets/icons/radix/outer-shadow.svg b/assets/icons/radix/outer-shadow.svg new file mode 100644 index 0000000000..b44e3d553c --- /dev/null +++ b/assets/icons/radix/outer-shadow.svg @@ -0,0 +1,43 @@ + + + + + + + + diff --git a/assets/icons/radix/overline.svg b/assets/icons/radix/overline.svg new file mode 100644 index 0000000000..57262c76e6 --- /dev/null +++ b/assets/icons/radix/overline.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/padding.svg b/assets/icons/radix/padding.svg new file mode 100644 index 0000000000..483a25a27e --- /dev/null +++ b/assets/icons/radix/padding.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/paper-plane.svg b/assets/icons/radix/paper-plane.svg new file mode 100644 index 0000000000..37ad070300 --- /dev/null +++ b/assets/icons/radix/paper-plane.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/pause.svg b/assets/icons/radix/pause.svg new file mode 100644 index 0000000000..b399fb2f5a --- /dev/null +++ b/assets/icons/radix/pause.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/pencil-1.svg b/assets/icons/radix/pencil-1.svg new file mode 100644 index 0000000000..decf0122ef --- /dev/null +++ b/assets/icons/radix/pencil-1.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/pencil-2.svg b/assets/icons/radix/pencil-2.svg new file mode 100644 index 0000000000..2559a393a9 --- /dev/null +++ b/assets/icons/radix/pencil-2.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/person.svg b/assets/icons/radix/person.svg new file mode 100644 index 0000000000..051abcc703 --- /dev/null +++ b/assets/icons/radix/person.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/pie-chart.svg b/assets/icons/radix/pie-chart.svg new file mode 100644 index 0000000000..bb58e47274 --- /dev/null +++ b/assets/icons/radix/pie-chart.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/pilcrow.svg b/assets/icons/radix/pilcrow.svg new file mode 100644 index 0000000000..6996765fd6 --- /dev/null +++ b/assets/icons/radix/pilcrow.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/pin-bottom.svg b/assets/icons/radix/pin-bottom.svg new file mode 100644 index 0000000000..ad0842054f --- /dev/null +++ b/assets/icons/radix/pin-bottom.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/pin-left.svg b/assets/icons/radix/pin-left.svg new file mode 100644 index 0000000000..eb89b2912f --- /dev/null +++ b/assets/icons/radix/pin-left.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/pin-right.svg b/assets/icons/radix/pin-right.svg new file mode 100644 index 0000000000..89a98bae4e --- /dev/null +++ b/assets/icons/radix/pin-right.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/pin-top.svg b/assets/icons/radix/pin-top.svg new file mode 100644 index 0000000000..edfeb64d5d --- /dev/null +++ b/assets/icons/radix/pin-top.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/play.svg b/assets/icons/radix/play.svg new file mode 100644 index 0000000000..92af9e1ae7 --- /dev/null +++ b/assets/icons/radix/play.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/plus-circled.svg b/assets/icons/radix/plus-circled.svg new file mode 100644 index 0000000000..808ddc4c2c --- /dev/null +++ b/assets/icons/radix/plus-circled.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/plus.svg b/assets/icons/radix/plus.svg new file mode 100644 index 0000000000..57ce90219b --- /dev/null +++ b/assets/icons/radix/plus.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/question-mark-circled.svg b/assets/icons/radix/question-mark-circled.svg new file mode 100644 index 0000000000..be99968787 --- /dev/null +++ b/assets/icons/radix/question-mark-circled.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/question-mark.svg b/assets/icons/radix/question-mark.svg new file mode 100644 index 0000000000..577aae5349 --- /dev/null +++ b/assets/icons/radix/question-mark.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/quote.svg b/assets/icons/radix/quote.svg new file mode 100644 index 0000000000..50205479c3 --- /dev/null +++ b/assets/icons/radix/quote.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/radiobutton.svg b/assets/icons/radix/radiobutton.svg new file mode 100644 index 0000000000..f0c3a60aee --- /dev/null +++ b/assets/icons/radix/radiobutton.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/reader.svg b/assets/icons/radix/reader.svg new file mode 100644 index 0000000000..e893cfa685 --- /dev/null +++ b/assets/icons/radix/reader.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/reload.svg b/assets/icons/radix/reload.svg new file mode 100644 index 0000000000..cf1dfb7fa2 --- /dev/null +++ b/assets/icons/radix/reload.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/reset.svg b/assets/icons/radix/reset.svg new file mode 100644 index 0000000000..f21a508514 --- /dev/null +++ b/assets/icons/radix/reset.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/resume.svg b/assets/icons/radix/resume.svg new file mode 100644 index 0000000000..79cdec2374 --- /dev/null +++ b/assets/icons/radix/resume.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/rocket.svg b/assets/icons/radix/rocket.svg new file mode 100644 index 0000000000..2226aacb1a --- /dev/null +++ b/assets/icons/radix/rocket.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/rotate-counter-clockwise.svg b/assets/icons/radix/rotate-counter-clockwise.svg new file mode 100644 index 0000000000..c43c90b90b --- /dev/null +++ b/assets/icons/radix/rotate-counter-clockwise.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/row-spacing.svg b/assets/icons/radix/row-spacing.svg new file mode 100644 index 0000000000..e155bd5947 --- /dev/null +++ b/assets/icons/radix/row-spacing.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/rows.svg b/assets/icons/radix/rows.svg new file mode 100644 index 0000000000..fb4ca0f9e3 --- /dev/null +++ b/assets/icons/radix/rows.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/ruler-horizontal.svg b/assets/icons/radix/ruler-horizontal.svg new file mode 100644 index 0000000000..db6f1ef488 --- /dev/null +++ b/assets/icons/radix/ruler-horizontal.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/ruler-square.svg b/assets/icons/radix/ruler-square.svg new file mode 100644 index 0000000000..7de70cc5dc --- /dev/null +++ b/assets/icons/radix/ruler-square.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/scissors.svg b/assets/icons/radix/scissors.svg new file mode 100644 index 0000000000..2893b34712 --- /dev/null +++ b/assets/icons/radix/scissors.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/section.svg b/assets/icons/radix/section.svg new file mode 100644 index 0000000000..1e939e2b2f --- /dev/null +++ b/assets/icons/radix/section.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/sewing-pin-filled.svg b/assets/icons/radix/sewing-pin-filled.svg new file mode 100644 index 0000000000..97f6f1120d --- /dev/null +++ b/assets/icons/radix/sewing-pin-filled.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/sewing-pin-solid.svg b/assets/icons/radix/sewing-pin-solid.svg new file mode 100644 index 0000000000..97f6f1120d --- /dev/null +++ b/assets/icons/radix/sewing-pin-solid.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/sewing-pin.svg b/assets/icons/radix/sewing-pin.svg new file mode 100644 index 0000000000..068dfd7bdf --- /dev/null +++ b/assets/icons/radix/sewing-pin.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/shadow-inner.svg b/assets/icons/radix/shadow-inner.svg new file mode 100644 index 0000000000..4d073bf35f --- /dev/null +++ b/assets/icons/radix/shadow-inner.svg @@ -0,0 +1,78 @@ + + + + + + + + + + + + + diff --git a/assets/icons/radix/shadow-none.svg b/assets/icons/radix/shadow-none.svg new file mode 100644 index 0000000000..b02d3466ad --- /dev/null +++ b/assets/icons/radix/shadow-none.svg @@ -0,0 +1,78 @@ + + + + + + + + + + + + + diff --git a/assets/icons/radix/shadow-outer.svg b/assets/icons/radix/shadow-outer.svg new file mode 100644 index 0000000000..dc7ea84087 --- /dev/null +++ b/assets/icons/radix/shadow-outer.svg @@ -0,0 +1,43 @@ + + + + + + + + diff --git a/assets/icons/radix/shadow.svg b/assets/icons/radix/shadow.svg new file mode 100644 index 0000000000..c991af6156 --- /dev/null +++ b/assets/icons/radix/shadow.svg @@ -0,0 +1,78 @@ + + + + + + + + + + + + + diff --git a/assets/icons/radix/share-1.svg b/assets/icons/radix/share-1.svg new file mode 100644 index 0000000000..58328e4d1e --- /dev/null +++ b/assets/icons/radix/share-1.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/share-2.svg b/assets/icons/radix/share-2.svg new file mode 100644 index 0000000000..1302ea5fbe --- /dev/null +++ b/assets/icons/radix/share-2.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/shuffle.svg b/assets/icons/radix/shuffle.svg new file mode 100644 index 0000000000..8670e1a048 --- /dev/null +++ b/assets/icons/radix/shuffle.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/size.svg b/assets/icons/radix/size.svg new file mode 100644 index 0000000000..dece8c5182 --- /dev/null +++ b/assets/icons/radix/size.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/sketch-logo.svg b/assets/icons/radix/sketch-logo.svg new file mode 100644 index 0000000000..6c54c4c825 --- /dev/null +++ b/assets/icons/radix/sketch-logo.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/slash.svg b/assets/icons/radix/slash.svg new file mode 100644 index 0000000000..aa7dac30c1 --- /dev/null +++ b/assets/icons/radix/slash.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/slider.svg b/assets/icons/radix/slider.svg new file mode 100644 index 0000000000..66e0452bc0 --- /dev/null +++ b/assets/icons/radix/slider.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/space-between-horizontally.svg b/assets/icons/radix/space-between-horizontally.svg new file mode 100644 index 0000000000..a71638d52b --- /dev/null +++ b/assets/icons/radix/space-between-horizontally.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/space-between-vertically.svg b/assets/icons/radix/space-between-vertically.svg new file mode 100644 index 0000000000..bae247222f --- /dev/null +++ b/assets/icons/radix/space-between-vertically.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/space-evenly-horizontally.svg b/assets/icons/radix/space-evenly-horizontally.svg new file mode 100644 index 0000000000..70169492e4 --- /dev/null +++ b/assets/icons/radix/space-evenly-horizontally.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/space-evenly-vertically.svg b/assets/icons/radix/space-evenly-vertically.svg new file mode 100644 index 0000000000..469b4c05d4 --- /dev/null +++ b/assets/icons/radix/space-evenly-vertically.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/speaker-loud.svg b/assets/icons/radix/speaker-loud.svg new file mode 100644 index 0000000000..68982ee5e9 --- /dev/null +++ b/assets/icons/radix/speaker-loud.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/speaker-moderate.svg b/assets/icons/radix/speaker-moderate.svg new file mode 100644 index 0000000000..0f1d1b4210 --- /dev/null +++ b/assets/icons/radix/speaker-moderate.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/speaker-off.svg b/assets/icons/radix/speaker-off.svg new file mode 100644 index 0000000000..f60c35de7f --- /dev/null +++ b/assets/icons/radix/speaker-off.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/speaker-quiet.svg b/assets/icons/radix/speaker-quiet.svg new file mode 100644 index 0000000000..eb68cefcee --- /dev/null +++ b/assets/icons/radix/speaker-quiet.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/square.svg b/assets/icons/radix/square.svg new file mode 100644 index 0000000000..82843f51c3 --- /dev/null +++ b/assets/icons/radix/square.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/stack.svg b/assets/icons/radix/stack.svg new file mode 100644 index 0000000000..92426ffb0d --- /dev/null +++ b/assets/icons/radix/stack.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/star-filled.svg b/assets/icons/radix/star-filled.svg new file mode 100644 index 0000000000..2b17b7f579 --- /dev/null +++ b/assets/icons/radix/star-filled.svg @@ -0,0 +1,6 @@ + + + diff --git a/assets/icons/radix/star.svg b/assets/icons/radix/star.svg new file mode 100644 index 0000000000..23f09ad7b2 --- /dev/null +++ b/assets/icons/radix/star.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/stitches-logo.svg b/assets/icons/radix/stitches-logo.svg new file mode 100644 index 0000000000..319a1481f3 --- /dev/null +++ b/assets/icons/radix/stitches-logo.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/stop.svg b/assets/icons/radix/stop.svg new file mode 100644 index 0000000000..57aac59cab --- /dev/null +++ b/assets/icons/radix/stop.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/stopwatch.svg b/assets/icons/radix/stopwatch.svg new file mode 100644 index 0000000000..ce5661e5cc --- /dev/null +++ b/assets/icons/radix/stopwatch.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/stretch-horizontally.svg b/assets/icons/radix/stretch-horizontally.svg new file mode 100644 index 0000000000..37977363b3 --- /dev/null +++ b/assets/icons/radix/stretch-horizontally.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/stretch-vertically.svg b/assets/icons/radix/stretch-vertically.svg new file mode 100644 index 0000000000..c4b1fe79ce --- /dev/null +++ b/assets/icons/radix/stretch-vertically.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/strikethrough.svg b/assets/icons/radix/strikethrough.svg new file mode 100644 index 0000000000..b814ef420a --- /dev/null +++ b/assets/icons/radix/strikethrough.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/sun.svg b/assets/icons/radix/sun.svg new file mode 100644 index 0000000000..1807a51b4c --- /dev/null +++ b/assets/icons/radix/sun.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/switch.svg b/assets/icons/radix/switch.svg new file mode 100644 index 0000000000..6dea528ce9 --- /dev/null +++ b/assets/icons/radix/switch.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/symbol.svg b/assets/icons/radix/symbol.svg new file mode 100644 index 0000000000..b529b2b08b --- /dev/null +++ b/assets/icons/radix/symbol.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/table.svg b/assets/icons/radix/table.svg new file mode 100644 index 0000000000..8ff059b847 --- /dev/null +++ b/assets/icons/radix/table.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/target.svg b/assets/icons/radix/target.svg new file mode 100644 index 0000000000..d67989e01f --- /dev/null +++ b/assets/icons/radix/target.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/text-align-bottom.svg b/assets/icons/radix/text-align-bottom.svg new file mode 100644 index 0000000000..862a5aeb88 --- /dev/null +++ b/assets/icons/radix/text-align-bottom.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/text-align-center.svg b/assets/icons/radix/text-align-center.svg new file mode 100644 index 0000000000..673cf8cd0a --- /dev/null +++ b/assets/icons/radix/text-align-center.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/text-align-justify.svg b/assets/icons/radix/text-align-justify.svg new file mode 100644 index 0000000000..df877f9513 --- /dev/null +++ b/assets/icons/radix/text-align-justify.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/text-align-left.svg b/assets/icons/radix/text-align-left.svg new file mode 100644 index 0000000000..b7a64fbd43 --- /dev/null +++ b/assets/icons/radix/text-align-left.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/text-align-middle.svg b/assets/icons/radix/text-align-middle.svg new file mode 100644 index 0000000000..e739d04efa --- /dev/null +++ b/assets/icons/radix/text-align-middle.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/text-align-right.svg b/assets/icons/radix/text-align-right.svg new file mode 100644 index 0000000000..e7609908ff --- /dev/null +++ b/assets/icons/radix/text-align-right.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/text-align-top.svg b/assets/icons/radix/text-align-top.svg new file mode 100644 index 0000000000..21660fe7d3 --- /dev/null +++ b/assets/icons/radix/text-align-top.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/text-none.svg b/assets/icons/radix/text-none.svg new file mode 100644 index 0000000000..2a87f9372a --- /dev/null +++ b/assets/icons/radix/text-none.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/text.svg b/assets/icons/radix/text.svg new file mode 100644 index 0000000000..bd41d8ac19 --- /dev/null +++ b/assets/icons/radix/text.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/thick-arrow-down.svg b/assets/icons/radix/thick-arrow-down.svg new file mode 100644 index 0000000000..32923bec58 --- /dev/null +++ b/assets/icons/radix/thick-arrow-down.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/thick-arrow-left.svg b/assets/icons/radix/thick-arrow-left.svg new file mode 100644 index 0000000000..0cfd863903 --- /dev/null +++ b/assets/icons/radix/thick-arrow-left.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/thick-arrow-right.svg b/assets/icons/radix/thick-arrow-right.svg new file mode 100644 index 0000000000..a0cb605693 --- /dev/null +++ b/assets/icons/radix/thick-arrow-right.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/thick-arrow-up.svg b/assets/icons/radix/thick-arrow-up.svg new file mode 100644 index 0000000000..68687be28d --- /dev/null +++ b/assets/icons/radix/thick-arrow-up.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/timer.svg b/assets/icons/radix/timer.svg new file mode 100644 index 0000000000..20c52dff95 --- /dev/null +++ b/assets/icons/radix/timer.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/tokens.svg b/assets/icons/radix/tokens.svg new file mode 100644 index 0000000000..2bbbc82030 --- /dev/null +++ b/assets/icons/radix/tokens.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/track-next.svg b/assets/icons/radix/track-next.svg new file mode 100644 index 0000000000..24fd40e36f --- /dev/null +++ b/assets/icons/radix/track-next.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/track-previous.svg b/assets/icons/radix/track-previous.svg new file mode 100644 index 0000000000..d99e7ab53f --- /dev/null +++ b/assets/icons/radix/track-previous.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/transform.svg b/assets/icons/radix/transform.svg new file mode 100644 index 0000000000..e913ccc9a7 --- /dev/null +++ b/assets/icons/radix/transform.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/transparency-grid.svg b/assets/icons/radix/transparency-grid.svg new file mode 100644 index 0000000000..6559ef8c2b --- /dev/null +++ b/assets/icons/radix/transparency-grid.svg @@ -0,0 +1,9 @@ + + + diff --git a/assets/icons/radix/trash.svg b/assets/icons/radix/trash.svg new file mode 100644 index 0000000000..18780e492c --- /dev/null +++ b/assets/icons/radix/trash.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/triangle-down.svg b/assets/icons/radix/triangle-down.svg new file mode 100644 index 0000000000..ebfd8f2a12 --- /dev/null +++ b/assets/icons/radix/triangle-down.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/radix/triangle-left.svg b/assets/icons/radix/triangle-left.svg new file mode 100644 index 0000000000..0014139716 --- /dev/null +++ b/assets/icons/radix/triangle-left.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/radix/triangle-right.svg b/assets/icons/radix/triangle-right.svg new file mode 100644 index 0000000000..aed1393b9c --- /dev/null +++ b/assets/icons/radix/triangle-right.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/radix/triangle-up.svg b/assets/icons/radix/triangle-up.svg new file mode 100644 index 0000000000..5eb1b416d3 --- /dev/null +++ b/assets/icons/radix/triangle-up.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/radix/twitter-logo.svg b/assets/icons/radix/twitter-logo.svg new file mode 100644 index 0000000000..7dcf2f58eb --- /dev/null +++ b/assets/icons/radix/twitter-logo.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/underline.svg b/assets/icons/radix/underline.svg new file mode 100644 index 0000000000..3344685097 --- /dev/null +++ b/assets/icons/radix/underline.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/update.svg b/assets/icons/radix/update.svg new file mode 100644 index 0000000000..b529b2b08b --- /dev/null +++ b/assets/icons/radix/update.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/upload.svg b/assets/icons/radix/upload.svg new file mode 100644 index 0000000000..a7f6bddb2e --- /dev/null +++ b/assets/icons/radix/upload.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/value-none.svg b/assets/icons/radix/value-none.svg new file mode 100644 index 0000000000..a86c08be1a --- /dev/null +++ b/assets/icons/radix/value-none.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/value.svg b/assets/icons/radix/value.svg new file mode 100644 index 0000000000..59dd7d9373 --- /dev/null +++ b/assets/icons/radix/value.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/vercel-logo.svg b/assets/icons/radix/vercel-logo.svg new file mode 100644 index 0000000000..5466fd9f0e --- /dev/null +++ b/assets/icons/radix/vercel-logo.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/video.svg b/assets/icons/radix/video.svg new file mode 100644 index 0000000000..e405396bef --- /dev/null +++ b/assets/icons/radix/video.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/view-grid.svg b/assets/icons/radix/view-grid.svg new file mode 100644 index 0000000000..04825a870b --- /dev/null +++ b/assets/icons/radix/view-grid.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/view-horizontal.svg b/assets/icons/radix/view-horizontal.svg new file mode 100644 index 0000000000..2ca7336b99 --- /dev/null +++ b/assets/icons/radix/view-horizontal.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/view-none.svg b/assets/icons/radix/view-none.svg new file mode 100644 index 0000000000..71b08a46d2 --- /dev/null +++ b/assets/icons/radix/view-none.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/view-vertical.svg b/assets/icons/radix/view-vertical.svg new file mode 100644 index 0000000000..0c8f8164b4 --- /dev/null +++ b/assets/icons/radix/view-vertical.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/width.svg b/assets/icons/radix/width.svg new file mode 100644 index 0000000000..3ae2b56e3d --- /dev/null +++ b/assets/icons/radix/width.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/zoom-in.svg b/assets/icons/radix/zoom-in.svg new file mode 100644 index 0000000000..caac722ad0 --- /dev/null +++ b/assets/icons/radix/zoom-in.svg @@ -0,0 +1,8 @@ + + + diff --git a/assets/icons/radix/zoom-out.svg b/assets/icons/radix/zoom-out.svg new file mode 100644 index 0000000000..62046a9e0f --- /dev/null +++ b/assets/icons/radix/zoom-out.svg @@ -0,0 +1,8 @@ + + + From b430be5bc6998fb88b58ff39d482f0ba6c7efda5 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 17:59:56 +0200 Subject: [PATCH 110/215] cargo fmt --- crates/gpui/src/elements/container.rs | 5 +---- crates/settings/src/keymap_file.rs | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/gpui/src/elements/container.rs b/crates/gpui/src/elements/container.rs index eaeee6f0d9..3b95feb9ef 100644 --- a/crates/gpui/src/elements/container.rs +++ b/crates/gpui/src/elements/container.rs @@ -12,9 +12,7 @@ use crate::{ scene::{self, Border, CursorRegion, Quad}, AnyElement, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext, }; -use schemars::{ - JsonSchema, -}; +use schemars::JsonSchema; use serde::Deserialize; use serde_json::json; @@ -335,7 +333,6 @@ impl ToJson for ContainerStyle { } } - #[derive(Clone, Copy, Debug, Default, JsonSchema)] pub struct Margin { pub top: f32, diff --git a/crates/settings/src/keymap_file.rs b/crates/settings/src/keymap_file.rs index 42fbeebe57..d2e656ebe3 100644 --- a/crates/settings/src/keymap_file.rs +++ b/crates/settings/src/keymap_file.rs @@ -4,7 +4,8 @@ use collections::BTreeMap; use gpui::{keymap_matcher::Binding, AppContext}; use schemars::{ gen::{SchemaGenerator, SchemaSettings}, - schema::{InstanceType, Schema, SchemaObject, SingleOrVec, SubschemaValidation}, JsonSchema, + schema::{InstanceType, Schema, SchemaObject, SingleOrVec, SubschemaValidation}, + JsonSchema, }; use serde::Deserialize; use serde_json::Value; From 10798384436ac46f2dc30205a086338214a93af0 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 22 Jun 2023 12:00:42 -0400 Subject: [PATCH 111/215] Add mic and mic-mute icons --- assets/icons/radix/mic-mute.svg | 3 +++ assets/icons/radix/mic.svg | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 assets/icons/radix/mic-mute.svg create mode 100644 assets/icons/radix/mic.svg diff --git a/assets/icons/radix/mic-mute.svg b/assets/icons/radix/mic-mute.svg new file mode 100644 index 0000000000..fe5f8201cc --- /dev/null +++ b/assets/icons/radix/mic-mute.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/radix/mic.svg b/assets/icons/radix/mic.svg new file mode 100644 index 0000000000..01f4c9bf66 --- /dev/null +++ b/assets/icons/radix/mic.svg @@ -0,0 +1,3 @@ + + + From 417a743b5ec5b2370ffa0289f40a8288cd25cf19 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 18:06:17 +0200 Subject: [PATCH 112/215] chore: use codegen_units=1 (#2633) Reduces binary size by about 31Mb (total .dmg size down by 15Mb after compression). --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index a49d75d3e2..9a89d48519 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -117,3 +117,4 @@ split-debuginfo = "unpacked" [profile.release] debug = true lto = "thin" +codegen-units = 1 From fcce1bc4882854ead287e9e7f901fc3fbf7731a6 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 18:06:52 +0200 Subject: [PATCH 113/215] Fixup xtask compilation --- crates/xtask/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/xtask/src/main.rs b/crates/xtask/src/main.rs index 881a65fd38..38e5658ce7 100644 --- a/crates/xtask/src/main.rs +++ b/crates/xtask/src/main.rs @@ -7,14 +7,14 @@ use clap::Parser; use schemars::schema_for; use theme::Theme; -fn build_themes(mut out_dir: PathBuf, file_name: PathBuf) -> Result<()> { +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; - out_dir.push(file_name); + file_path.push(file_name); std::fs::write(file_path, output)?; From 1a0b2bfef8a91db86555c657727fa5bffad10fab Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 22 Jun 2023 12:21:59 -0400 Subject: [PATCH 114/215] Update stream control icons --- assets/icons/radix/desktop-mute.svg | 4 ++++ crates/collab_ui/src/collab_titlebar_item.rs | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 assets/icons/radix/desktop-mute.svg diff --git a/assets/icons/radix/desktop-mute.svg b/assets/icons/radix/desktop-mute.svg new file mode 100644 index 0000000000..83d249176f --- /dev/null +++ b/assets/icons/radix/desktop-mute.svg @@ -0,0 +1,4 @@ + + + + diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index c0603421bc..0bdca28037 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -370,7 +370,7 @@ impl CollabTitlebarItem { .toggle_contacts_button .in_state(self.contacts_popover.is_some()) .style_for(state); - Svg::new("icons/user_plus_16.svg") + Svg::new("icons/radix/person.svg") .with_color(style.color) .constrained() .with_width(style.icon_width) @@ -406,10 +406,10 @@ impl CollabTitlebarItem { let icon; let tooltip; if room.read(cx).is_screen_sharing() { - icon = "icons/enable_screen_sharing_12.svg"; + icon = "icons/radix/desktop-mute.svg"; tooltip = "Stop Sharing Screen" } else { - icon = "icons/disable_screen_sharing_12.svg"; + icon = "icons/radix/desktop.svg"; tooltip = "Share Screen"; } @@ -451,11 +451,11 @@ impl CollabTitlebarItem { let tooltip; let background; if room.read(cx).is_muted().unwrap_or(false) { - icon = "icons/microphone_inactive_12.svg"; + icon = "icons/radix/mic-mute.svg"; tooltip = "Unmute microphone\nRight click for options"; background = Color::red(); } else { - icon = "icons/microphone_active_12.svg"; + icon = "icons/radix/mic.svg"; tooltip = "Mute microphone\nRight click for options"; background = Color::transparent_black(); } @@ -502,9 +502,9 @@ impl CollabTitlebarItem { } let is_shared = project.read(cx).is_shared(); - let label = if is_shared { "Unshare" } else { "Share" }; + let label = if is_shared { "Stop Sharing" } else { "Share" }; let tooltip = if is_shared { - "Unshare project from call participants" + "Stop sharing project with call participants" } else { "Share project with call participants" }; From 10cc0d567fa28e08caaf83d8f82bed60d2117852 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 18:26:18 +0200 Subject: [PATCH 115/215] Reintroduce package-lock.json --- styles/package-lock.json | 1722 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 1722 insertions(+) create mode 100644 styles/package-lock.json diff --git a/styles/package-lock.json b/styles/package-lock.json new file mode 100644 index 0000000000..236e571148 --- /dev/null +++ b/styles/package-lock.json @@ -0,0 +1,1722 @@ +{ + "name": "styles", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "styles", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@tokens-studio/types": "^0.2.3", + "@types/chroma-js": "^2.4.0", + "@types/node": "^18.14.1", + "ayu": "^8.0.1", + "bezier-easing": "^2.1.0", + "case-anything": "^2.1.10", + "chroma-js": "^2.4.2", + "deepmerge": "^4.3.0", + "json-schema-to-typescript": "^13.0.2", + "toml": "^3.0.0", + "ts-deepmerge": "^6.0.3", + "ts-node": "^10.9.1", + "utility-types": "^3.10.0", + "vitest": "^0.32.0" + }, + "devDependencies": { + "@vitest/coverage-v8": "^0.32.0" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", + "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@bcherny/json-schema-ref-parser": { + "version": "10.0.5-fork", + "resolved": "https://registry.npmjs.org/@bcherny/json-schema-ref-parser/-/json-schema-ref-parser-10.0.5-fork.tgz", + "integrity": "sha512-E/jKbPoca1tfUPj3iSbitDZTGnq6FUFjkH6L8U2oDwSuwK1WhnnVtCG7oFOTg/DDnyoXbQYUiUiGOibHqaGVnw==", + "dependencies": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.6", + "call-me-maybe": "^1.0.1", + "js-yaml": "^4.1.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/philsturgeon" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", + "integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@jsdevtools/ono": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==" + }, + "node_modules/@tokens-studio/types": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@tokens-studio/types/-/types-0.2.3.tgz", + "integrity": "sha512-2KN3V0JPf+Zh8aoVMwykJq29Lsi7vYgKGYBQ/zQ+FbDEmrH6T/Vwn8kG7cvbTmW1JAAvgxVxMIivgC9PmFelNA==" + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", + "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==" + }, + "node_modules/@types/chai": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.5.tgz", + "integrity": "sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==" + }, + "node_modules/@types/chai-subset": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@types/chai-subset/-/chai-subset-1.3.3.tgz", + "integrity": "sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==", + "dependencies": { + "@types/chai": "*" + } + }, + "node_modules/@types/chroma-js": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@types/chroma-js/-/chroma-js-2.4.0.tgz", + "integrity": "sha512-JklMxityrwjBTjGY2anH8JaTx3yjRU3/sEHSblLH1ba5lqcSh1LnImXJZO5peJfXyqKYWjHTGy4s5Wz++hARrw==" + }, + "node_modules/@types/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==", + "dependencies": { + "@types/minimatch": "*", + "@types/node": "*" + } + }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", + "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", + "dev": true + }, + "node_modules/@types/json-schema": { + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==" + }, + "node_modules/@types/lodash": { + "version": "4.14.195", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.195.tgz", + "integrity": "sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg==" + }, + "node_modules/@types/minimatch": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==" + }, + "node_modules/@types/node": { + "version": "18.14.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.1.tgz", + "integrity": "sha512-QH+37Qds3E0eDlReeboBxfHbX9omAcBCXEzswCu6jySP642jiM3cYSIkU/REqwhCUqXdonHFuBfJDiAJxMNhaQ==" + }, + "node_modules/@types/prettier": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", + "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==" + }, + "node_modules/@vitest/coverage-v8": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-0.32.0.tgz", + "integrity": "sha512-VXXlWq9X/NbsoP/l/CHLBjutsFFww1UY1qEhzGjn/DY7Tqe+z0Nu8XKc8im/XUAmjiWsh2XV7sy/F0IKAl4eaw==", + "dev": true, + "dependencies": { + "@ampproject/remapping": "^2.2.1", + "@bcoe/v8-coverage": "^0.2.3", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.1", + "istanbul-reports": "^3.1.5", + "magic-string": "^0.30.0", + "picocolors": "^1.0.0", + "std-env": "^3.3.2", + "test-exclude": "^6.0.0", + "v8-to-istanbul": "^9.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "vitest": ">=0.32.0 <1" + } + }, + "node_modules/@vitest/expect": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.32.0.tgz", + "integrity": "sha512-VxVHhIxKw9Lux+O9bwLEEk2gzOUe93xuFHy9SzYWnnoYZFYg1NfBtnfnYWiJN7yooJ7KNElCK5YtA7DTZvtXtg==", + "dependencies": { + "@vitest/spy": "0.32.0", + "@vitest/utils": "0.32.0", + "chai": "^4.3.7" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.32.0.tgz", + "integrity": "sha512-QpCmRxftHkr72xt5A08xTEs9I4iWEXIOCHWhQQguWOKE4QH7DXSKZSOFibuwEIMAD7G0ERvtUyQn7iPWIqSwmw==", + "dependencies": { + "@vitest/utils": "0.32.0", + "concordance": "^5.0.4", + "p-limit": "^4.0.0", + "pathe": "^1.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-0.32.0.tgz", + "integrity": "sha512-yCKorPWjEnzpUxQpGlxulujTcSPgkblwGzAUEL+z01FTUg/YuCDZ8dxr9sHA08oO2EwxzHXNLjQKWJ2zc2a19Q==", + "dependencies": { + "magic-string": "^0.30.0", + "pathe": "^1.1.0", + "pretty-format": "^27.5.1" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.32.0.tgz", + "integrity": "sha512-MruAPlM0uyiq3d53BkwTeShXY0rYEfhNGQzVO5GHBmmX3clsxcWp79mMnkOVcV244sNTeDcHbcPFWIjOI4tZvw==", + "dependencies": { + "tinyspy": "^2.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.32.0.tgz", + "integrity": "sha512-53yXunzx47MmbuvcOPpLaVljHaeSu1G2dHdmy7+9ngMnQIkBQcvwOcoclWFnxDMxFbnq8exAfh3aKSZaK71J5A==", + "dependencies": { + "concordance": "^5.0.4", + "loupe": "^2.3.6", + "pretty-format": "^27.5.1" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/acorn": { + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==" + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "engines": { + "node": "*" + } + }, + "node_modules/ayu": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/ayu/-/ayu-8.0.1.tgz", + "integrity": "sha512-yuPZ2kZYQoYaPRQ/78F9rXDVx1rVGCJ1neBYithBoSprD6zPdIJdAKizUXG0jtTBu7nTFyAnVFFYuLnCS3cpDw==", + "dependencies": { + "@types/chroma-js": "^2.0.0", + "chroma-js": "^2.1.0", + "nonenumerable": "^1.1.1" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/bezier-easing": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/bezier-easing/-/bezier-easing-2.1.0.tgz", + "integrity": "sha512-gbIqZ/eslnUFC1tjEvtz0sgx+xTK20wDnYMIA27VA04R7w6xxXQPZDbibjA9DTWZRA2CXtwHykkVzlCaAJAZig==" + }, + "node_modules/blueimp-md5": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz", + "integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/call-me-maybe": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", + "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==" + }, + "node_modules/case-anything": { + "version": "2.1.10", + "resolved": "https://registry.npmjs.org/case-anything/-/case-anything-2.1.10.tgz", + "integrity": "sha512-JczJwVrCP0jPKh05McyVsuOg6AYosrB9XWZKbQzXeDAm2ClE/PJE/BcrrQrVyGYH7Jg8V/LDupmyL4kFlVsVFQ==", + "engines": { + "node": ">=12.13" + }, + "funding": { + "url": "https://github.com/sponsors/mesqueeb" + } + }, + "node_modules/chai": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", + "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==", + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^4.1.2", + "get-func-name": "^2.0.0", + "loupe": "^2.3.1", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", + "engines": { + "node": "*" + } + }, + "node_modules/chroma-js": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chroma-js/-/chroma-js-2.4.2.tgz", + "integrity": "sha512-U9eDw6+wt7V8z5NncY2jJfZa+hUH8XEj8FQHgFJTrUFnJfXYf4Ml4adI2vXZOjqRDpFWtYVWypDfZwnJ+HIR4A==" + }, + "node_modules/cli-color": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.3.tgz", + "integrity": "sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.61", + "es6-iterator": "^2.0.3", + "memoizee": "^0.4.15", + "timers-ext": "^0.1.7" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "node_modules/concordance": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/concordance/-/concordance-5.0.4.tgz", + "integrity": "sha512-OAcsnTEYu1ARJqWVGwf4zh4JDfHZEaSNlNccFmt8YjB2l/n19/PF2viLINHc57vO4FKIAFl2FWASIGZZWZ2Kxw==", + "dependencies": { + "date-time": "^3.1.0", + "esutils": "^2.0.3", + "fast-diff": "^1.2.0", + "js-string-escape": "^1.0.1", + "lodash": "^4.17.15", + "md5-hex": "^3.0.1", + "semver": "^7.3.2", + "well-known-symbols": "^2.0.0" + }, + "engines": { + "node": ">=10.18.0 <11 || >=12.14.0 <13 || >=14" + } + }, + "node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" + }, + "node_modules/d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "dependencies": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "node_modules/date-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/date-time/-/date-time-3.1.0.tgz", + "integrity": "sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg==", + "dependencies": { + "time-zone": "^1.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-eql": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/deepmerge": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.0.tgz", + "integrity": "sha512-z2wJZXrmeHdvYJp/Ux55wIjqo81G5Bp4c+oELTW+7ar6SogWHajt5a9gO3s3IDaGSAXjDk0vlQKN3rms8ab3og==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/es5-ext": { + "version": "0.10.62", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "hasInstallScript": true, + "dependencies": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "node_modules/es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "dependencies": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "node_modules/es6-weak-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.1" + } + }, + "node_modules/esbuild": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz", + "integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==", + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.17.19", + "@esbuild/android-arm64": "0.17.19", + "@esbuild/android-x64": "0.17.19", + "@esbuild/darwin-arm64": "0.17.19", + "@esbuild/darwin-x64": "0.17.19", + "@esbuild/freebsd-arm64": "0.17.19", + "@esbuild/freebsd-x64": "0.17.19", + "@esbuild/linux-arm": "0.17.19", + "@esbuild/linux-arm64": "0.17.19", + "@esbuild/linux-ia32": "0.17.19", + "@esbuild/linux-loong64": "0.17.19", + "@esbuild/linux-mips64el": "0.17.19", + "@esbuild/linux-ppc64": "0.17.19", + "@esbuild/linux-riscv64": "0.17.19", + "@esbuild/linux-s390x": "0.17.19", + "@esbuild/linux-x64": "0.17.19", + "@esbuild/netbsd-x64": "0.17.19", + "@esbuild/openbsd-x64": "0.17.19", + "@esbuild/sunos-x64": "0.17.19", + "@esbuild/win32-arm64": "0.17.19", + "@esbuild/win32-ia32": "0.17.19", + "@esbuild/win32-x64": "0.17.19" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "dependencies": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, + "node_modules/ext": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "dependencies": { + "type": "^2.7.2" + } + }, + "node_modules/ext/node_modules/type": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==" + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", + "engines": { + "node": "*" + } + }, + "node_modules/get-stdin": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", + "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-promise": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/glob-promise/-/glob-promise-4.2.2.tgz", + "integrity": "sha512-xcUzJ8NWN5bktoTIX7eOclO1Npxd/dyVqUJxlLIDasT4C7KZyqlPIwkdJ0Ypiy3p2ZKahTjK4M9uC3sNSfNMzw==", + "dependencies": { + "@types/glob": "^7.1.3" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "individual", + "url": "https://github.com/sponsors/ahmadnassri" + }, + "peerDependencies": { + "glob": "^7.1.6" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-promise": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==" + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", + "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/js-string-escape": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", + "integrity": "sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-schema-to-typescript": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-13.0.2.tgz", + "integrity": "sha512-TCaEVW4aI2FmMQe7f98mvr3/oiVmXEC1xZjkTZ9L/BSoTXFlC7p64mD5AD2d8XWycNBQZUnHwXL5iVXt1HWwNQ==", + "dependencies": { + "@bcherny/json-schema-ref-parser": "10.0.5-fork", + "@types/json-schema": "^7.0.11", + "@types/lodash": "^4.14.182", + "@types/prettier": "^2.6.1", + "cli-color": "^2.0.2", + "get-stdin": "^8.0.0", + "glob": "^7.1.6", + "glob-promise": "^4.2.2", + "is-glob": "^4.0.3", + "lodash": "^4.17.21", + "minimist": "^1.2.6", + "mkdirp": "^1.0.4", + "mz": "^2.7.0", + "prettier": "^2.6.2" + }, + "bin": { + "json2ts": "dist/src/cli.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==" + }, + "node_modules/local-pkg": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.3.tgz", + "integrity": "sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/loupe": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", + "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "dependencies": { + "get-func-name": "^2.0.0" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/lru-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", + "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==", + "dependencies": { + "es5-ext": "~0.10.2" + } + }, + "node_modules/magic-string": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.0.tgz", + "integrity": "sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.13" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "node_modules/md5-hex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/md5-hex/-/md5-hex-3.0.1.tgz", + "integrity": "sha512-BUiRtTtV39LIJwinWBjqVsU9xhdnz7/i889V859IBFpuqGAj6LuOvHv5XLbgZ2R7ptJoJaEcxkv88/h25T7Ciw==", + "dependencies": { + "blueimp-md5": "^2.10.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/memoizee": { + "version": "0.4.15", + "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", + "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.53", + "es6-weak-map": "^2.0.3", + "event-emitter": "^0.3.5", + "is-promise": "^2.2.2", + "lru-queue": "^0.1.0", + "next-tick": "^1.1.0", + "timers-ext": "^0.1.7" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mlly": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.3.0.tgz", + "integrity": "sha512-HT5mcgIQKkOrZecOjOX3DJorTikWXwsBfpcr/MGBkhfWcjiqvnaL/9ppxvIUXfjT6xt4DVIAsN9fMUz1ev4bIw==", + "dependencies": { + "acorn": "^8.8.2", + "pathe": "^1.1.0", + "pkg-types": "^1.0.3", + "ufo": "^1.1.2" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, + "node_modules/nonenumerable": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/nonenumerable/-/nonenumerable-1.1.1.tgz", + "integrity": "sha512-ptUD9w9D8WqW6fuJJkZNCImkf+0vdbgUTbRK3i7jsy3olqtH96hYE6Q/S3Tx9NWbcB/ocAjYshXCAUP0lZ9B4Q==" + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", + "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", + "dependencies": { + "yocto-queue": "^1.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pathe": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.1.tgz", + "integrity": "sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==" + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "engines": { + "node": "*" + } + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "node_modules/pkg-types": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.3.tgz", + "integrity": "sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==", + "dependencies": { + "jsonc-parser": "^3.2.0", + "mlly": "^1.2.0", + "pathe": "^1.1.0" + } + }, + "node_modules/postcss": { + "version": "8.4.24", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.24.tgz", + "integrity": "sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" + }, + "node_modules/rollup": { + "version": "3.25.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.1.tgz", + "integrity": "sha512-tywOR+rwIt5m2ZAWSe5AIJcTat8vGlnPFAv15ycCrw33t6iFsXZ6mzHVFh2psSjxQPmI+xgzMZZizUAukBI4aQ==", + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=14.18.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/semver": { + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.2.tgz", + "integrity": "sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==" + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==" + }, + "node_modules/std-env": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.3.3.tgz", + "integrity": "sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==" + }, + "node_modules/strip-literal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.1.tgz", + "integrity": "sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==", + "dependencies": { + "acorn": "^8.8.2" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/time-zone": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz", + "integrity": "sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/timers-ext": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", + "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==", + "dependencies": { + "es5-ext": "~0.10.46", + "next-tick": "1" + } + }, + "node_modules/tinybench": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.5.0.tgz", + "integrity": "sha512-kRwSG8Zx4tjF9ZiyH4bhaebu+EDz1BOx9hOigYHlUW4xxI/wKIUQUqo018UlU4ar6ATPBsaMrdbKZ+tmPdohFA==" + }, + "node_modules/tinypool": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.5.0.tgz", + "integrity": "sha512-paHQtnrlS1QZYKF/GnLoOM/DN9fqaGOFbCbxzAhwniySnzl9Ebk8w73/dd34DAhe/obUbPAOldTyYXQZxnPBPQ==", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-2.1.1.tgz", + "integrity": "sha512-XPJL2uSzcOyBMky6OFrusqWlzfFrXtE0hPuMgW8A2HmaqrPo4ZQHRN/V0QXN3FSjKxpsbRrFc5LI7KOwBsT1/w==", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/toml": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", + "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" + }, + "node_modules/ts-deepmerge": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/ts-deepmerge/-/ts-deepmerge-6.0.3.tgz", + "integrity": "sha512-MBBJL0UK/mMnZRONMz4J1CRu5NsGtsh+gR1nkn8KLE9LXo/PCzeHhQduhNary8m5/m9ryOOyFwVKxq81cPlaow==", + "engines": { + "node": ">=14.13.1" + } + }, + "node_modules/ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "engines": { + "node": ">=4" + } + }, + "node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/ufo": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.1.2.tgz", + "integrity": "sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==" + }, + "node_modules/utility-types": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", + "integrity": "sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==", + "engines": { + "node": ">= 4" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" + }, + "node_modules/v8-to-istanbul": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", + "integrity": "sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^1.6.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/v8-to-istanbul/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.18", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", + "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" + } + }, + "node_modules/vite": { + "version": "4.3.9", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.3.9.tgz", + "integrity": "sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==", + "dependencies": { + "esbuild": "^0.17.5", + "postcss": "^8.4.23", + "rollup": "^3.21.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "@types/node": ">= 14", + "less": "*", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.32.0.tgz", + "integrity": "sha512-220P/y8YacYAU+daOAqiGEFXx2A8AwjadDzQqos6wSukjvvTWNqleJSwoUn0ckyNdjHIKoxn93Nh1vWBqEKr3Q==", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.4", + "mlly": "^1.2.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "vite": "^3.0.0 || ^4.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": ">=v14.18.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vitest": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.32.0.tgz", + "integrity": "sha512-SW83o629gCqnV3BqBnTxhB10DAwzwEx3z+rqYZESehUB+eWsJxwcBQx7CKy0otuGMJTYh7qCVuUX23HkftGl/Q==", + "dependencies": { + "@types/chai": "^4.3.5", + "@types/chai-subset": "^1.3.3", + "@types/node": "*", + "@vitest/expect": "0.32.0", + "@vitest/runner": "0.32.0", + "@vitest/snapshot": "0.32.0", + "@vitest/spy": "0.32.0", + "@vitest/utils": "0.32.0", + "acorn": "^8.8.2", + "acorn-walk": "^8.2.0", + "cac": "^6.7.14", + "chai": "^4.3.7", + "concordance": "^5.0.4", + "debug": "^4.3.4", + "local-pkg": "^0.4.3", + "magic-string": "^0.30.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "std-env": "^3.3.2", + "strip-literal": "^1.0.1", + "tinybench": "^2.5.0", + "tinypool": "^0.5.0", + "vite": "^3.0.0 || ^4.0.0", + "vite-node": "0.32.0", + "why-is-node-running": "^2.2.2" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": ">=v14.18.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@vitest/browser": "*", + "@vitest/ui": "*", + "happy-dom": "*", + "jsdom": "*", + "playwright": "*", + "safaridriver": "*", + "webdriverio": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "playwright": { + "optional": true + }, + "safaridriver": { + "optional": true + }, + "webdriverio": { + "optional": true + } + } + }, + "node_modules/well-known-symbols": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz", + "integrity": "sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q==", + "engines": { + "node": ">=6" + } + }, + "node_modules/why-is-node-running": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz", + "integrity": "sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "engines": { + "node": ">=6" + } + }, + "node_modules/yocto-queue": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", + "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} From 18c4d43ee718172cab2179100017fcc28ba172b3 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 18:49:18 +0200 Subject: [PATCH 116/215] Add deafen button --- assets/icons/speakers_active_12.svg | 1 + assets/icons/speakers_inactive_12.svg | 1 + crates/collab_ui/src/collab_titlebar_item.rs | 53 ++++++++++++++++++-- 3 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 assets/icons/speakers_active_12.svg create mode 100644 assets/icons/speakers_inactive_12.svg diff --git a/assets/icons/speakers_active_12.svg b/assets/icons/speakers_active_12.svg new file mode 100644 index 0000000000..10416a8f79 --- /dev/null +++ b/assets/icons/speakers_active_12.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/speakers_inactive_12.svg b/assets/icons/speakers_inactive_12.svg new file mode 100644 index 0000000000..a74990d983 --- /dev/null +++ b/assets/icons/speakers_inactive_12.svg @@ -0,0 +1 @@ + diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 0bdca28037..ddc3f53801 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -1,6 +1,7 @@ use crate::{ - contact_notification::ContactNotification, contacts_popover, face_pile::FacePile, toggle_mute, - toggle_screen_sharing, ToggleMute, ToggleScreenSharing, + contact_notification::ContactNotification, contacts_popover, face_pile::FacePile, + toggle_deafen, toggle_mute, toggle_screen_sharing, ToggleDeafen, ToggleMute, + ToggleScreenSharing, }; use call::{ActiveCall, ParticipantLocation, Room}; use client::{proto::PeerId, Client, ContactEventKind, SignIn, SignOut, User, UserStore}; @@ -88,7 +89,8 @@ impl View for CollabTitlebarItem { left_container .add_child(self.render_current_user(&workspace, &theme, &user, peer_id, cx)); left_container.add_children(self.render_collaborators(&workspace, &theme, &room, cx)); - right_container.add_child(self.render_toggle_microphone(&theme, &room, cx)); + right_container.add_child(self.render_toggle_mute(&theme, &room, cx)); + right_container.add_child(self.render_toggle_deafen(&theme, &room, cx)); right_container.add_child(self.render_toggle_screen_sharing_button(&theme, &room, cx)); } @@ -441,7 +443,7 @@ impl CollabTitlebarItem { .aligned() .into_any() } - fn render_toggle_microphone( + fn render_toggle_mute( &self, theme: &Theme, room: &ModelHandle, @@ -489,7 +491,50 @@ impl CollabTitlebarItem { .aligned() .into_any() } + fn render_toggle_deafen( + &self, + theme: &Theme, + room: &ModelHandle, + cx: &mut ViewContext, + ) -> AnyElement { + let icon; + let tooltip; + if room.read(cx).is_deafened().unwrap_or(false) { + icon = "icons/speakers_inactive_12.svg"; + tooltip = "Unmute speakers\nRight click for options"; + } else { + icon = "icons/speakers_active_12.svg"; + tooltip = "Mute speakers\nRight click for options"; + } + let titlebar = &theme.workspace.titlebar; + MouseEventHandler::::new(0, cx, |state, _| { + let style = titlebar.call_control.style_for(state); + Svg::new(icon) + .with_color(style.color) + .constrained() + .with_width(style.icon_width) + .aligned() + .constrained() + .with_width(style.button_width) + .with_height(style.button_width) + .contained() + .with_style(style.container) + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, move |_, _, cx| { + toggle_deafen(&Default::default(), cx) + }) + .with_tooltip::( + 0, + tooltip.into(), + Some(Box::new(ToggleDeafen)), + theme.tooltip.clone(), + cx, + ) + .aligned() + .into_any() + } fn render_in_call_share_unshare_button( &self, workspace: &ViewHandle, From f774dbfe2e5db9c6fd79b17e2879b397fbaa65c1 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 18:58:11 +0200 Subject: [PATCH 117/215] Use new icons, delete old ones --- assets/icons/microphone_active_12.svg | 4 ---- assets/icons/microphone_inactive_12.svg | 5 ----- assets/icons/speakers_active_12.svg | 1 - assets/icons/speakers_inactive_12.svg | 1 - crates/collab_ui/src/collab_titlebar_item.rs | 4 ++-- 5 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 assets/icons/microphone_active_12.svg delete mode 100644 assets/icons/microphone_inactive_12.svg delete mode 100644 assets/icons/speakers_active_12.svg delete mode 100644 assets/icons/speakers_inactive_12.svg diff --git a/assets/icons/microphone_active_12.svg b/assets/icons/microphone_active_12.svg deleted file mode 100644 index 797e64820b..0000000000 --- a/assets/icons/microphone_active_12.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/assets/icons/microphone_inactive_12.svg b/assets/icons/microphone_inactive_12.svg deleted file mode 100644 index 90ac393fc2..0000000000 --- a/assets/icons/microphone_inactive_12.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/assets/icons/speakers_active_12.svg b/assets/icons/speakers_active_12.svg deleted file mode 100644 index 10416a8f79..0000000000 --- a/assets/icons/speakers_active_12.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/speakers_inactive_12.svg b/assets/icons/speakers_inactive_12.svg deleted file mode 100644 index a74990d983..0000000000 --- a/assets/icons/speakers_inactive_12.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index ddc3f53801..1cfa18f432 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -500,10 +500,10 @@ impl CollabTitlebarItem { let icon; let tooltip; if room.read(cx).is_deafened().unwrap_or(false) { - icon = "icons/speakers_inactive_12.svg"; + icon = "icons/radix/speaker-off.svg"; tooltip = "Unmute speakers\nRight click for options"; } else { - icon = "icons/speakers_active_12.svg"; + icon = "icons/radix/speaker-loud.svg"; tooltip = "Mute speakers\nRight click for options"; } From 4c03231863904422bf7c661aa68ca74268f7671f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 13 Jun 2023 16:01:53 -0700 Subject: [PATCH 118/215] Maintain on the background scanner a set of expanded directories --- crates/collab/src/rpc.rs | 2 + crates/project/src/project.rs | 113 ++++++++++++++++++++++ crates/project/src/worktree.rs | 101 ++++++++++++++----- crates/project_panel/src/project_panel.rs | 62 +++++++----- crates/rpc/proto/zed.proto | 12 +++ crates/rpc/src/proto.rs | 6 ++ crates/rpc/src/rpc.rs | 2 +- 7 files changed, 250 insertions(+), 48 deletions(-) diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index 8d210513c2..fd27557041 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -224,6 +224,8 @@ impl Server { .add_request_handler(forward_project_request::) .add_request_handler(forward_project_request::) .add_request_handler(forward_project_request::) + .add_request_handler(forward_project_request::) + .add_request_handler(forward_project_request::) .add_request_handler(forward_project_request::) .add_message_handler(create_buffer_for_peer) .add_request_handler(update_buffer) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 27d424879f..9242168754 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -51,6 +51,7 @@ use lsp_command::*; use postage::watch; use project_settings::ProjectSettings; use rand::prelude::*; +use rpc::proto::PeerId; use search::SearchQuery; use serde::Serialize; use settings::SettingsStore; @@ -478,6 +479,8 @@ impl Project { client.add_model_request_handler(Self::handle_rename_project_entry); client.add_model_request_handler(Self::handle_copy_project_entry); client.add_model_request_handler(Self::handle_delete_project_entry); + client.add_model_request_handler(Self::handle_expand_project_entry); + client.add_model_request_handler(Self::handle_collapse_project_entry); client.add_model_request_handler(Self::handle_apply_additional_edits_for_completion); client.add_model_request_handler(Self::handle_apply_code_action); client.add_model_request_handler(Self::handle_on_type_formatting); @@ -5403,6 +5406,56 @@ impl Project { Some(ProjectPath { worktree_id, path }) } + pub fn mark_entry_expanded( + &mut self, + worktree_id: WorktreeId, + entry_id: ProjectEntryId, + cx: &mut ModelContext, + ) -> Option<()> { + if self.is_local() { + let worktree = self.worktree_for_id(worktree_id, cx)?; + worktree.update(cx, |worktree, cx| { + worktree + .as_local_mut() + .unwrap() + .mark_entry_expanded(entry_id, true, 0, cx); + }); + } else if let Some(project_id) = self.remote_id() { + cx.background() + .spawn(self.client.request(proto::ExpandProjectEntry { + project_id, + entry_id: entry_id.to_proto(), + })) + .log_err(); + } + Some(()) + } + + pub fn mark_entry_collapsed( + &mut self, + worktree_id: WorktreeId, + entry_id: ProjectEntryId, + cx: &mut ModelContext, + ) -> Option<()> { + if self.is_local() { + let worktree = self.worktree_for_id(worktree_id, cx)?; + worktree.update(cx, |worktree, cx| { + worktree + .as_local_mut() + .unwrap() + .mark_entry_expanded(entry_id, false, 0, cx); + }); + } else if let Some(project_id) = self.remote_id() { + cx.background() + .spawn(self.client.request(proto::CollapseProjectEntry { + project_id, + entry_id: entry_id.to_proto(), + })) + .log_err(); + } + Some(()) + } + pub fn absolute_path(&self, project_path: &ProjectPath, cx: &AppContext) -> Option { let workspace_root = self .worktree_for_id(project_path.worktree_id, cx)? @@ -5705,6 +5758,66 @@ impl Project { }) } + async fn handle_expand_project_entry( + this: ModelHandle, + envelope: TypedEnvelope, + _: Arc, + cx: AsyncAppContext, + ) -> Result { + Self::handle_expand_or_collapse_project_entry( + this, + envelope.payload.entry_id, + envelope.original_sender_id, + true, + cx, + ) + .await + } + + async fn handle_collapse_project_entry( + this: ModelHandle, + envelope: TypedEnvelope, + _: Arc, + cx: AsyncAppContext, + ) -> Result { + Self::handle_expand_or_collapse_project_entry( + this, + envelope.payload.entry_id, + envelope.original_sender_id, + false, + cx, + ) + .await + } + + async fn handle_expand_or_collapse_project_entry( + this: ModelHandle, + entry_id: u64, + original_sender_id: Option, + is_expanded: bool, + mut cx: AsyncAppContext, + ) -> Result { + let entry_id = ProjectEntryId::from_proto(entry_id); + let (worktree, replica_id) = this + .read_with(&cx, |this, cx| { + let replica_id = original_sender_id + .and_then(|peer_id| this.collaborators.get(&peer_id))? + .replica_id; + let worktree = this.worktree_for_entry(entry_id, cx)?; + Some((worktree, replica_id)) + }) + .ok_or_else(|| anyhow!("invalid request"))?; + worktree.update(&mut cx, |worktree, cx| { + worktree.as_local_mut().unwrap().mark_entry_expanded( + entry_id, + is_expanded, + replica_id, + cx, + ) + }); + Ok(proto::Ack {}) + } + async fn handle_update_diagnostic_summary( this: ModelHandle, envelope: TypedEnvelope, diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 2b0ba3d521..5ffbbe5b83 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -5,7 +5,7 @@ use ::ignore::gitignore::{Gitignore, GitignoreBuilder}; use anyhow::{anyhow, Context, Result}; use client::{proto, Client}; use clock::ReplicaId; -use collections::{HashMap, VecDeque}; +use collections::{HashMap, HashSet, VecDeque}; use fs::{ repository::{GitFileStatus, GitRepository, RepoPath}, Fs, LineEnding, @@ -67,7 +67,7 @@ pub enum Worktree { pub struct LocalWorktree { snapshot: LocalSnapshot, - path_changes_tx: channel::Sender<(Vec, barrier::Sender)>, + scan_requests_tx: channel::Sender, is_scanning: (watch::Sender, watch::Receiver), _background_scanner_task: Task<()>, share: Option, @@ -84,6 +84,18 @@ pub struct LocalWorktree { visible: bool, } +enum ScanRequest { + RescanPaths { + paths: Vec, + done: barrier::Sender, + }, + SetDirExpanded { + entry_id: ProjectEntryId, + replica_id: ReplicaId, + is_expanded: bool, + }, +} + pub struct RemoteWorktree { snapshot: Snapshot, background_snapshot: Arc>, @@ -214,6 +226,7 @@ pub struct LocalSnapshot { struct BackgroundScannerState { snapshot: LocalSnapshot, + expanded_dirs: HashSet<(ProjectEntryId, ReplicaId)>, /// The ids of all of the entries that were removed from the snapshot /// as part of the current update. These entry ids may be re-used /// if the same inode is discovered at a new path, or if the given @@ -330,7 +343,7 @@ impl Worktree { ); } - let (path_changes_tx, path_changes_rx) = channel::unbounded(); + let (scan_requests_tx, scan_requests_rx) = channel::unbounded(); let (scan_states_tx, mut scan_states_rx) = mpsc::unbounded(); cx.spawn_weak(|this, mut cx| async move { @@ -370,7 +383,7 @@ impl Worktree { fs, scan_states_tx, background, - path_changes_rx, + scan_requests_rx, ) .run(events) .await; @@ -381,7 +394,7 @@ impl Worktree { snapshot, is_scanning: watch::channel_with(true), share: None, - path_changes_tx, + scan_requests_tx, _background_scanner_task: background_scanner_task, diagnostics: Default::default(), diagnostic_summaries: Default::default(), @@ -1068,8 +1081,11 @@ impl LocalWorktree { this.update(&mut cx, |this, _| { this.as_local_mut() .unwrap() - .path_changes_tx - .try_send((vec![abs_path], tx)) + .scan_requests_tx + .try_send(ScanRequest::RescanPaths { + paths: vec![abs_path], + done: tx, + }) })?; rx.recv().await; Ok(()) @@ -1135,6 +1151,22 @@ impl LocalWorktree { })) } + pub fn mark_entry_expanded( + &mut self, + entry_id: ProjectEntryId, + is_expanded: bool, + replica_id: ReplicaId, + _cx: &mut ModelContext, + ) { + self.scan_requests_tx + .try_send(ScanRequest::SetDirExpanded { + entry_id, + replica_id, + is_expanded, + }) + .ok(); + } + fn refresh_entry( &self, path: Arc, @@ -1143,7 +1175,7 @@ impl LocalWorktree { ) -> Task> { let fs = self.fs.clone(); let abs_root_path = self.abs_path.clone(); - let path_changes_tx = self.path_changes_tx.clone(); + let path_changes_tx = self.scan_requests_tx.clone(); cx.spawn_weak(move |this, mut cx| async move { let abs_path = fs.canonicalize(&abs_root_path).await?; let mut paths = Vec::with_capacity(2); @@ -1161,7 +1193,7 @@ impl LocalWorktree { } let (tx, mut rx) = barrier::channel(); - path_changes_tx.try_send((paths, tx))?; + path_changes_tx.try_send(ScanRequest::RescanPaths { paths, done: tx })?; rx.recv().await; this.upgrade(&cx) .ok_or_else(|| anyhow!("worktree was dropped"))? @@ -2784,7 +2816,7 @@ struct BackgroundScanner { fs: Arc, status_updates_tx: UnboundedSender, executor: Arc, - refresh_requests_rx: channel::Receiver<(Vec, barrier::Sender)>, + scan_requests_rx: channel::Receiver, next_entry_id: Arc, phase: BackgroundScannerPhase, } @@ -2803,17 +2835,18 @@ impl BackgroundScanner { fs: Arc, status_updates_tx: UnboundedSender, executor: Arc, - refresh_requests_rx: channel::Receiver<(Vec, barrier::Sender)>, + scan_requests_rx: channel::Receiver, ) -> Self { Self { fs, status_updates_tx, executor, - refresh_requests_rx, + scan_requests_rx, next_entry_id, state: Mutex::new(BackgroundScannerState { prev_snapshot: snapshot.snapshot.clone(), snapshot, + expanded_dirs: Default::default(), removed_entry_ids: Default::default(), changed_paths: Default::default(), }), @@ -2898,9 +2931,9 @@ impl BackgroundScanner { select_biased! { // Process any path refresh requests from the worktree. Prioritize // these before handling changes reported by the filesystem. - request = self.refresh_requests_rx.recv().fuse() => { - let Ok((paths, barrier)) = request else { break }; - if !self.process_refresh_request(paths.clone(), barrier).await { + request = self.scan_requests_rx.recv().fuse() => { + let Ok(request) = request else { break }; + if !self.process_scan_request(request).await { return; } } @@ -2917,9 +2950,29 @@ impl BackgroundScanner { } } - async fn process_refresh_request(&self, paths: Vec, barrier: barrier::Sender) -> bool { - self.reload_entries_for_paths(paths, None).await; - self.send_status_update(false, Some(barrier)) + async fn process_scan_request(&self, request: ScanRequest) -> bool { + match request { + ScanRequest::RescanPaths { paths, done } => { + self.reload_entries_for_paths(paths, None).await; + self.send_status_update(false, Some(done)) + } + ScanRequest::SetDirExpanded { + entry_id, + replica_id, + is_expanded, + } => { + let mut state = self.state.lock(); + if is_expanded { + state.expanded_dirs.insert((entry_id, replica_id)); + } else { + state.expanded_dirs.remove(&(entry_id, replica_id)); + } + + // todo + + true + } + } } async fn process_events(&mut self, paths: Vec) { @@ -2995,9 +3048,9 @@ impl BackgroundScanner { select_biased! { // Process any path refresh requests before moving on to process // the scan queue, so that user operations are prioritized. - request = self.refresh_requests_rx.recv().fuse() => { - let Ok((paths, barrier)) = request else { break }; - if !self.process_refresh_request(paths, barrier).await { + request = self.scan_requests_rx.recv().fuse() => { + let Ok(request) = request else { break }; + if !self.process_scan_request(request).await { return; } } @@ -3487,9 +3540,9 @@ impl BackgroundScanner { select_biased! { // Process any path refresh requests before moving on to process // the queue of ignore statuses. - request = self.refresh_requests_rx.recv().fuse() => { - let Ok((paths, barrier)) = request else { break }; - if !self.process_refresh_request(paths, barrier).await { + request = self.scan_requests_rx.recv().fuse() => { + let Ok(request) = request else { break }; + if !self.process_scan_request(request).await { return; } } diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index dc592b7588..fd2ff1c6d5 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -431,18 +431,23 @@ impl ProjectPanel { fn collapse_selected_entry(&mut self, _: &CollapseSelectedEntry, cx: &mut ViewContext) { if let Some((worktree, mut entry)) = self.selected_entry(cx) { + let worktree_id = worktree.id(); let expanded_dir_ids = - if let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree.id()) { + if let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree_id) { expanded_dir_ids } else { return; }; loop { - match expanded_dir_ids.binary_search(&entry.id) { + let entry_id = entry.id; + match expanded_dir_ids.binary_search(&entry_id) { Ok(ix) => { expanded_dir_ids.remove(ix); - self.update_visible_entries(Some((worktree.id(), entry.id)), cx); + self.update_visible_entries(Some((worktree_id, entry_id)), cx); + self.project.update(cx, |project, cx| { + project.mark_entry_collapsed(worktree_id, entry_id, cx); + }); cx.notify(); break; } @@ -938,10 +943,19 @@ impl ProjectPanel { } fn selected_entry<'a>(&self, cx: &'a AppContext) -> Option<(&'a Worktree, &'a project::Entry)> { + let (worktree, entry) = self.selected_entry_handle(cx)?; + Some((worktree.read(cx), entry)) + } + + fn selected_entry_handle<'a>( + &self, + cx: &'a AppContext, + ) -> Option<(ModelHandle, &'a project::Entry)> { let selection = self.selection?; let project = self.project.read(cx); - let worktree = project.worktree_for_id(selection.worktree_id, cx)?.read(cx); - Some((worktree, worktree.entry_for_id(selection.entry_id)?)) + let worktree = project.worktree_for_id(selection.worktree_id, cx)?; + let entry = worktree.read(cx).entry_for_id(selection.entry_id)?; + Some((worktree, entry)) } fn update_visible_entries( @@ -1058,29 +1072,31 @@ impl ProjectPanel { entry_id: ProjectEntryId, cx: &mut ViewContext, ) { - let project = self.project.read(cx); - if let Some((worktree, expanded_dir_ids)) = project - .worktree_for_id(worktree_id, cx) - .zip(self.expanded_dir_ids.get_mut(&worktree_id)) - { - let worktree = worktree.read(cx); + self.project.update(cx, |project, cx| { + if let Some((worktree, expanded_dir_ids)) = project + .worktree_for_id(worktree_id, cx) + .zip(self.expanded_dir_ids.get_mut(&worktree_id)) + { + project.mark_entry_expanded(worktree_id, entry_id, cx); + let worktree = worktree.read(cx); - if let Some(mut entry) = worktree.entry_for_id(entry_id) { - loop { - if let Err(ix) = expanded_dir_ids.binary_search(&entry.id) { - expanded_dir_ids.insert(ix, entry.id); - } + if let Some(mut entry) = worktree.entry_for_id(entry_id) { + loop { + if let Err(ix) = expanded_dir_ids.binary_search(&entry.id) { + expanded_dir_ids.insert(ix, entry.id); + } - if let Some(parent_entry) = - entry.path.parent().and_then(|p| worktree.entry_for_path(p)) - { - entry = parent_entry; - } else { - break; + if let Some(parent_entry) = + entry.path.parent().and_then(|p| worktree.entry_for_path(p)) + { + entry = parent_entry; + } else { + break; + } } } } - } + }); } fn for_each_visible_entry( diff --git a/crates/rpc/proto/zed.proto b/crates/rpc/proto/zed.proto index ce4dd7f7cf..d7e8d16a0e 100644 --- a/crates/rpc/proto/zed.proto +++ b/crates/rpc/proto/zed.proto @@ -62,6 +62,8 @@ message Envelope { RenameProjectEntry rename_project_entry = 46; CopyProjectEntry copy_project_entry = 47; DeleteProjectEntry delete_project_entry = 48; + ExpandProjectEntry expand_project_entry = 114; + CollapseProjectEntry collapse_project_entry = 115; ProjectEntryResponse project_entry_response = 49; UpdateDiagnosticSummary update_diagnostic_summary = 50; @@ -372,6 +374,16 @@ message DeleteProjectEntry { uint64 entry_id = 2; } +message ExpandProjectEntry { + uint64 project_id = 1; + uint64 entry_id = 2; +} + +message CollapseProjectEntry { + uint64 project_id = 1; + uint64 entry_id = 2; +} + message ProjectEntryResponse { Entry entry = 1; uint64 worktree_scan_id = 2; diff --git a/crates/rpc/src/proto.rs b/crates/rpc/src/proto.rs index 13794ea64d..9f8e942492 100644 --- a/crates/rpc/src/proto.rs +++ b/crates/rpc/src/proto.rs @@ -150,6 +150,8 @@ messages!( (DeclineCall, Foreground), (DeleteProjectEntry, Foreground), (Error, Foreground), + (ExpandProjectEntry, Foreground), + (CollapseProjectEntry, Foreground), (Follow, Foreground), (FollowResponse, Foreground), (FormatBuffers, Foreground), @@ -255,6 +257,8 @@ request_messages!( (CreateRoom, CreateRoomResponse), (DeclineCall, Ack), (DeleteProjectEntry, ProjectEntryResponse), + (ExpandProjectEntry, Ack), + (CollapseProjectEntry, Ack), (Follow, FollowResponse), (FormatBuffers, FormatBuffersResponse), (GetChannelMessages, GetChannelMessagesResponse), @@ -311,6 +315,8 @@ entity_messages!( CreateBufferForPeer, CreateProjectEntry, DeleteProjectEntry, + ExpandProjectEntry, + CollapseProjectEntry, Follow, FormatBuffers, GetCodeActions, diff --git a/crates/rpc/src/rpc.rs b/crates/rpc/src/rpc.rs index 8b10167091..6b430d90e4 100644 --- a/crates/rpc/src/rpc.rs +++ b/crates/rpc/src/rpc.rs @@ -6,4 +6,4 @@ pub use conn::Connection; pub use peer::*; mod macros; -pub const PROTOCOL_VERSION: u32 = 58; +pub const PROTOCOL_VERSION: u32 = 59; From 55f1a6647fa2c5e9c191130b35aa8e0f431fe44c Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 13 Jun 2023 17:16:11 -0700 Subject: [PATCH 119/215] Model symlinks better in FakeFs, add read_link Fs method --- crates/fs/Cargo.toml | 3 ++ crates/fs/src/fs.rs | 86 +++++++++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 24 deletions(-) diff --git a/crates/fs/Cargo.toml b/crates/fs/Cargo.toml index 7dda3f7273..cb738f567c 100644 --- a/crates/fs/Cargo.toml +++ b/crates/fs/Cargo.toml @@ -32,5 +32,8 @@ serde_json.workspace = true log.workspace = true libc = "0.2" +[dev-dependencies] +gpui = { path = "../gpui", features = ["test-support"] } + [features] test-support = [] diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index fee7765d49..f5abe35dbd 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -108,6 +108,7 @@ pub trait Fs: Send + Sync { async fn canonicalize(&self, path: &Path) -> Result; async fn is_file(&self, path: &Path) -> bool; async fn metadata(&self, path: &Path) -> Result>; + async fn read_link(&self, path: &Path) -> Result; async fn read_dir( &self, path: &Path, @@ -323,6 +324,11 @@ impl Fs for RealFs { })) } + async fn read_link(&self, path: &Path) -> Result { + let path = smol::fs::read_link(path).await?; + Ok(path) + } + async fn read_dir( &self, path: &Path, @@ -407,46 +413,51 @@ enum FakeFsEntry { impl FakeFsState { fn read_path<'a>(&'a self, target: &Path) -> Result>> { Ok(self - .try_read_path(target) + .try_read_path(target, true) .ok_or_else(|| anyhow!("path does not exist: {}", target.display()))? .0) } - fn try_read_path<'a>(&'a self, target: &Path) -> Option<(Arc>, PathBuf)> { + fn try_read_path<'a>( + &'a self, + target: &Path, + follow_symlink: bool, + ) -> Option<(Arc>, PathBuf)> { let mut path = target.to_path_buf(); - let mut real_path = PathBuf::new(); + let mut canonical_path = PathBuf::new(); let mut entry_stack = Vec::new(); 'outer: loop { - let mut path_components = path.components().collect::>(); - while let Some(component) = path_components.pop_front() { + let mut path_components = path.components().peekable(); + while let Some(component) = path_components.next() { match component { Component::Prefix(_) => panic!("prefix paths aren't supported"), Component::RootDir => { entry_stack.clear(); entry_stack.push(self.root.clone()); - real_path.clear(); - real_path.push("/"); + canonical_path.clear(); + canonical_path.push("/"); } Component::CurDir => {} Component::ParentDir => { entry_stack.pop()?; - real_path.pop(); + canonical_path.pop(); } Component::Normal(name) => { let current_entry = entry_stack.last().cloned()?; let current_entry = current_entry.lock(); if let FakeFsEntry::Dir { entries, .. } = &*current_entry { let entry = entries.get(name.to_str().unwrap()).cloned()?; - let _entry = entry.lock(); - if let FakeFsEntry::Symlink { target, .. } = &*_entry { - let mut target = target.clone(); - target.extend(path_components); - path = target; - continue 'outer; - } else { - entry_stack.push(entry.clone()); - real_path.push(name); + if path_components.peek().is_some() || follow_symlink { + let entry = entry.lock(); + if let FakeFsEntry::Symlink { target, .. } = &*entry { + let mut target = target.clone(); + target.extend(path_components); + path = target; + continue 'outer; + } } + entry_stack.push(entry.clone()); + canonical_path.push(name); } else { return None; } @@ -455,7 +466,7 @@ impl FakeFsState { } break; } - entry_stack.pop().map(|entry| (entry, real_path)) + Some((entry_stack.pop()?, canonical_path)) } fn write_path(&self, path: &Path, callback: Fn) -> Result @@ -776,6 +787,10 @@ impl FakeFsEntry { matches!(self, Self::File { .. }) } + fn is_symlink(&self) -> bool { + matches!(self, Self::Symlink { .. }) + } + fn file_content(&self, path: &Path) -> Result<&String> { if let Self::File { content, .. } = self { Ok(content) @@ -1056,8 +1071,8 @@ impl Fs for FakeFs { let path = normalize_path(path); self.simulate_random_delay().await; let state = self.state.lock(); - if let Some((_, real_path)) = state.try_read_path(&path) { - Ok(real_path) + if let Some((_, canonical_path)) = state.try_read_path(&path, true) { + Ok(canonical_path) } else { Err(anyhow!("path does not exist: {}", path.display())) } @@ -1067,7 +1082,7 @@ impl Fs for FakeFs { let path = normalize_path(path); self.simulate_random_delay().await; let state = self.state.lock(); - if let Some((entry, _)) = state.try_read_path(&path) { + if let Some((entry, _)) = state.try_read_path(&path, true) { entry.lock().is_file() } else { false @@ -1078,10 +1093,17 @@ impl Fs for FakeFs { self.simulate_random_delay().await; let path = normalize_path(path); let state = self.state.lock(); - if let Some((entry, real_path)) = state.try_read_path(&path) { - let entry = entry.lock(); - let is_symlink = real_path != path; + if let Some((mut entry, _)) = state.try_read_path(&path, false) { + let is_symlink = entry.lock().is_symlink(); + if is_symlink { + if let Some(e) = state.try_read_path(&path, true).map(|e| e.0) { + entry = e; + } else { + return Ok(None); + } + } + let entry = entry.lock(); Ok(Some(match &*entry { FakeFsEntry::File { inode, mtime, .. } => Metadata { inode: *inode, @@ -1102,6 +1124,22 @@ impl Fs for FakeFs { } } + async fn read_link(&self, path: &Path) -> Result { + self.simulate_random_delay().await; + let path = normalize_path(path); + let state = self.state.lock(); + if let Some((entry, _)) = state.try_read_path(&path, false) { + let entry = entry.lock(); + if let FakeFsEntry::Symlink { target } = &*entry { + Ok(target.clone()) + } else { + Err(anyhow!("not a symlink: {}", path.display())) + } + } else { + Err(anyhow!("path does not exist: {}", path.display())) + } + } + async fn read_dir( &self, path: &Path, From f910d8fe3ea71be80b961f4c1e35e8e8d14dcd38 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 13 Jun 2023 17:16:19 -0700 Subject: [PATCH 120/215] Only scan ignored or externals paths if expanded in a project panel --- crates/project/src/worktree.rs | 106 +++++++++++++++++++--- crates/project/src/worktree_tests.rs | 68 ++++++++++++++ crates/project_panel/src/project_panel.rs | 34 ++++--- 3 files changed, 182 insertions(+), 26 deletions(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 5ffbbe5b83..1ce08a9a47 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -5,7 +5,7 @@ use ::ignore::gitignore::{Gitignore, GitignoreBuilder}; use anyhow::{anyhow, Context, Result}; use client::{proto, Client}; use clock::ReplicaId; -use collections::{HashMap, HashSet, VecDeque}; +use collections::{BTreeSet, HashMap, VecDeque}; use fs::{ repository::{GitFileStatus, GitRepository, RepoPath}, Fs, LineEnding, @@ -226,7 +226,7 @@ pub struct LocalSnapshot { struct BackgroundScannerState { snapshot: LocalSnapshot, - expanded_dirs: HashSet<(ProjectEntryId, ReplicaId)>, + expanded_dirs: BTreeSet<(ProjectEntryId, ReplicaId)>, /// The ids of all of the entries that were removed from the snapshot /// as part of the current update. These entry ids may be re-used /// if the same inode is discovered at a new path, or if the given @@ -2209,6 +2209,15 @@ impl LocalSnapshot { } impl BackgroundScannerState { + fn is_entry_expanded(&self, entry: &Entry) -> bool { + let expanded = self + .expanded_dirs + .range((entry.id, 0)..=(entry.id, ReplicaId::MAX)) + .next() + .is_some(); + expanded + } + fn reuse_entry_id(&mut self, entry: &mut Entry) { if let Some(removed_entry_id) = self.removed_entry_ids.remove(&entry.inode) { entry.id = removed_entry_id; @@ -2661,11 +2670,11 @@ impl Entry { } pub fn is_dir(&self) -> bool { - matches!(self.kind, EntryKind::Dir | EntryKind::PendingDir) + self.kind.is_dir() } pub fn is_file(&self) -> bool { - matches!(self.kind, EntryKind::File(_)) + self.kind.is_file() } pub fn git_status(&self) -> Option { @@ -2673,6 +2682,16 @@ impl Entry { } } +impl EntryKind { + pub fn is_dir(&self) -> bool { + matches!(self, EntryKind::Dir | EntryKind::PendingDir) + } + + pub fn is_file(&self) -> bool { + matches!(self, EntryKind::File(_)) + } +} + impl sum_tree::Item for Entry { type Summary = EntrySummary; @@ -2901,6 +2920,7 @@ impl BackgroundScanner { path: Arc::from(Path::new("")), ignore_stack, ancestor_inodes: TreeSet::from_ordered_entries(root_inode), + is_outside_root: false, scan_queue: scan_job_tx.clone(), })) .unwrap(); @@ -2961,15 +2981,27 @@ impl BackgroundScanner { replica_id, is_expanded, } => { - let mut state = self.state.lock(); - if is_expanded { - state.expanded_dirs.insert((entry_id, replica_id)); - } else { - state.expanded_dirs.remove(&(entry_id, replica_id)); + let path = { + let mut state = self.state.lock(); + if is_expanded { + state.expanded_dirs.insert((entry_id, replica_id)); + } else { + state.expanded_dirs.remove(&(entry_id, replica_id)); + } + state + .snapshot + .entry_for_id(entry_id) + .map(|e| state.snapshot.absolutize(&e.path)) + }; + if let Some(path) = path { + let (scan_job_tx, mut scan_job_rx) = channel::unbounded(); + self.reload_entries_for_paths(vec![path.clone()], Some(scan_job_tx)) + .await; + if let Some(job) = scan_job_rx.next().await { + self.scan_dir(&job).await.log_err(); + self.send_status_update(false, None); + } } - - // todo - true } } @@ -3120,7 +3152,16 @@ impl BackgroundScanner { let mut ignore_stack = job.ignore_stack.clone(); let mut new_ignore = None; let (root_abs_path, root_char_bag, next_entry_id, repository) = { - let snapshot = &self.state.lock().snapshot; + let state = self.state.lock(); + if job.is_outside_root || job.ignore_stack.is_all() { + if let Some(entry) = state.snapshot.entry_for_path(&job.path) { + if !state.is_entry_expanded(entry) { + return Ok(()); + } + } + } + + let snapshot = &state.snapshot; ( snapshot.abs_path().clone(), snapshot.root_char_bag, @@ -3131,6 +3172,7 @@ impl BackgroundScanner { ) }; + let mut root_canonical_path = None; let mut child_paths = self.fs.read_dir(&job.abs_path).await?; while let Some(child_abs_path) = child_paths.next().await { let child_abs_path: Arc = match child_abs_path { @@ -3198,6 +3240,38 @@ impl BackgroundScanner { root_char_bag, ); + let mut is_outside_root = false; + if child_metadata.is_symlink { + let canonical_path = match self.fs.canonicalize(&child_abs_path).await { + Ok(path) => path, + Err(err) => { + log::error!( + "error reading target of symlink {:?}: {:?}", + child_abs_path, + err + ); + continue; + } + }; + + // lazily canonicalize the root path in order to determine if + // symlinks point outside of the worktree. + let root_canonical_path = match &root_canonical_path { + Some(path) => path, + None => match self.fs.canonicalize(&root_abs_path).await { + Ok(path) => root_canonical_path.insert(path), + Err(err) => { + log::error!("error canonicalizing root {:?}: {:?}", root_abs_path, err); + continue; + } + }, + }; + + if !canonical_path.starts_with(root_canonical_path) { + is_outside_root = true; + } + } + if child_entry.is_dir() { let is_ignored = ignore_stack.is_abs_path_ignored(&child_abs_path, true); child_entry.is_ignored = is_ignored; @@ -3210,6 +3284,7 @@ impl BackgroundScanner { new_jobs.push(Some(ScanJob { abs_path: child_abs_path, path: child_path, + is_outside_root, ignore_stack: if is_ignored { IgnoreStack::all() } else { @@ -3259,7 +3334,7 @@ impl BackgroundScanner { for new_job in new_jobs { if let Some(new_job) = new_job { - job.scan_queue.send(new_job).await.unwrap(); + job.scan_queue.send(new_job).await.ok(); } } @@ -3354,12 +3429,14 @@ impl BackgroundScanner { if let Some(scan_queue_tx) = &scan_queue_tx { let mut ancestor_inodes = state.snapshot.ancestor_inodes_for_path(&path); if metadata.is_dir && !ancestor_inodes.contains(&metadata.inode) { + let is_outside_root = !abs_path.starts_with(&root_canonical_path); ancestor_inodes.insert(metadata.inode); smol::block_on(scan_queue_tx.send(ScanJob { abs_path, path, ignore_stack, ancestor_inodes, + is_outside_root, scan_queue: scan_queue_tx.clone(), })) .unwrap(); @@ -3748,6 +3825,7 @@ struct ScanJob { ignore_stack: Arc, scan_queue: Sender, ancestor_inodes: TreeSet, + is_outside_root: bool, } struct UpdateIgnoreStatusJob { diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rs index 3abf660282..6468ac9a16 100644 --- a/crates/project/src/worktree_tests.rs +++ b/crates/project/src/worktree_tests.rs @@ -256,6 +256,74 @@ async fn test_circular_symlinks(executor: Arc, cx: &mut TestAppCo }); } +#[gpui::test(iterations = 10)] +async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { + let fs = FakeFs::new(cx.background()); + fs.insert_tree( + "/root", + json!({ + "dir1": { + "deps": { + // symlinks here + }, + "src": { + "a.rs": "", + "b.rs": "", + }, + }, + "dir2": { + "src": { + "c.rs": "", + "d.rs": "", + } + }, + "dir3": { + "src": { + "e.rs": "", + "f.rs": "", + } + } + }), + ) + .await; + fs.insert_symlink("/root/dir1/deps/dep-dir2", "../../dir2".into()) + .await; + fs.insert_symlink("/root/dir1/deps/dep-dir3", "../../dir3".into()) + .await; + + let client = cx.read(|cx| Client::new(FakeHttpClient::with_404_response(), cx)); + let tree = Worktree::local( + client, + Path::new("/root/dir1"), + true, + fs.clone(), + Default::default(), + &mut cx.to_async(), + ) + .await + .unwrap(); + + cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete()) + .await; + + tree.read_with(cx, |tree, _| { + assert_eq!( + tree.entries(false) + .map(|entry| entry.path.as_ref()) + .collect::>(), + vec![ + Path::new(""), + Path::new("deps"), + Path::new("deps/dep-dir2"), + Path::new("deps/dep-dir3"), + Path::new("src"), + Path::new("src/a.rs"), + Path::new("src/b.rs"), + ] + ); + }); +} + #[gpui::test] async fn test_rescan_with_gitignore(cx: &mut TestAppContext) { // .gitignores are handled explicitly by Zed and do not use the git diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index fd2ff1c6d5..78a9fb032f 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -410,17 +410,23 @@ impl ProjectPanel { fn expand_selected_entry(&mut self, _: &ExpandSelectedEntry, cx: &mut ViewContext) { if let Some((worktree, entry)) = self.selected_entry(cx) { if entry.is_dir() { + let worktree_id = worktree.id(); + let entry_id = entry.id; let expanded_dir_ids = - if let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree.id()) { + if let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree_id) { expanded_dir_ids } else { return; }; - match expanded_dir_ids.binary_search(&entry.id) { + match expanded_dir_ids.binary_search(&entry_id) { Ok(_) => self.select_next(&SelectNext, cx), Err(ix) => { - expanded_dir_ids.insert(ix, entry.id); + self.project.update(cx, |project, cx| { + project.mark_entry_expanded(worktree_id, entry_id, cx); + }); + + expanded_dir_ids.insert(ix, entry_id); self.update_visible_entries(None, cx); cx.notify(); } @@ -468,14 +474,18 @@ impl ProjectPanel { fn toggle_expanded(&mut self, entry_id: ProjectEntryId, cx: &mut ViewContext) { if let Some(worktree_id) = self.project.read(cx).worktree_id_for_entry(entry_id, cx) { if let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree_id) { - match expanded_dir_ids.binary_search(&entry_id) { - Ok(ix) => { - expanded_dir_ids.remove(ix); + self.project.update(cx, |project, cx| { + match expanded_dir_ids.binary_search(&entry_id) { + Ok(ix) => { + project.mark_entry_collapsed(worktree_id, entry_id, cx); + expanded_dir_ids.remove(ix); + } + Err(ix) => { + project.mark_entry_expanded(worktree_id, entry_id, cx); + expanded_dir_ids.insert(ix, entry_id); + } } - Err(ix) => { - expanded_dir_ids.insert(ix, entry_id); - } - } + }); self.update_visible_entries(Some((worktree_id, entry_id)), cx); cx.focus_self(); cx.notify(); @@ -1206,7 +1216,7 @@ impl ProjectPanel { Flex::row() .with_child( - if kind == EntryKind::Dir { + if kind.is_dir() { if details.is_expanded { Svg::new("icons/chevron_down_8.svg").with_color(style.icon_color) } else { @@ -1303,7 +1313,7 @@ impl ProjectPanel { }) .on_click(MouseButton::Left, move |event, this, cx| { if !show_editor { - if kind == EntryKind::Dir { + if kind.is_dir() { this.toggle_expanded(entry_id, cx); } else { this.open_entry(entry_id, event.click_count > 1, cx); From aa6f2f1816079bb15b942b60b8579a7f7002c37a Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 15 Jun 2023 15:58:29 -0700 Subject: [PATCH 121/215] Remove logic for marking worktree entries as collapsed --- crates/collab/src/rpc.rs | 1 - crates/project/src/project.rs | 84 +++-------------------- crates/project/src/worktree.rs | 35 ++-------- crates/project_panel/src/project_panel.rs | 4 -- crates/rpc/proto/zed.proto | 6 -- crates/rpc/src/proto.rs | 3 - 6 files changed, 15 insertions(+), 118 deletions(-) diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index fd27557041..a5be6e7d62 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -225,7 +225,6 @@ impl Server { .add_request_handler(forward_project_request::) .add_request_handler(forward_project_request::) .add_request_handler(forward_project_request::) - .add_request_handler(forward_project_request::) .add_request_handler(forward_project_request::) .add_message_handler(create_buffer_for_peer) .add_request_handler(update_buffer) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 9242168754..79f3e743bd 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -51,7 +51,6 @@ use lsp_command::*; use postage::watch; use project_settings::ProjectSettings; use rand::prelude::*; -use rpc::proto::PeerId; use search::SearchQuery; use serde::Serialize; use settings::SettingsStore; @@ -480,7 +479,6 @@ impl Project { client.add_model_request_handler(Self::handle_copy_project_entry); client.add_model_request_handler(Self::handle_delete_project_entry); client.add_model_request_handler(Self::handle_expand_project_entry); - client.add_model_request_handler(Self::handle_collapse_project_entry); client.add_model_request_handler(Self::handle_apply_additional_edits_for_completion); client.add_model_request_handler(Self::handle_apply_code_action); client.add_model_request_handler(Self::handle_on_type_formatting); @@ -5418,7 +5416,7 @@ impl Project { worktree .as_local_mut() .unwrap() - .mark_entry_expanded(entry_id, true, 0, cx); + .mark_entry_expanded(entry_id, cx); }); } else if let Some(project_id) = self.remote_id() { cx.background() @@ -5431,31 +5429,6 @@ impl Project { Some(()) } - pub fn mark_entry_collapsed( - &mut self, - worktree_id: WorktreeId, - entry_id: ProjectEntryId, - cx: &mut ModelContext, - ) -> Option<()> { - if self.is_local() { - let worktree = self.worktree_for_id(worktree_id, cx)?; - worktree.update(cx, |worktree, cx| { - worktree - .as_local_mut() - .unwrap() - .mark_entry_expanded(entry_id, false, 0, cx); - }); - } else if let Some(project_id) = self.remote_id() { - cx.background() - .spawn(self.client.request(proto::CollapseProjectEntry { - project_id, - entry_id: entry_id.to_proto(), - })) - .log_err(); - } - Some(()) - } - pub fn absolute_path(&self, project_path: &ProjectPath, cx: &AppContext) -> Option { let workspace_root = self .worktree_for_id(project_path.worktree_id, cx)? @@ -5762,58 +5735,17 @@ impl Project { this: ModelHandle, envelope: TypedEnvelope, _: Arc, - cx: AsyncAppContext, - ) -> Result { - Self::handle_expand_or_collapse_project_entry( - this, - envelope.payload.entry_id, - envelope.original_sender_id, - true, - cx, - ) - .await - } - - async fn handle_collapse_project_entry( - this: ModelHandle, - envelope: TypedEnvelope, - _: Arc, - cx: AsyncAppContext, - ) -> Result { - Self::handle_expand_or_collapse_project_entry( - this, - envelope.payload.entry_id, - envelope.original_sender_id, - false, - cx, - ) - .await - } - - async fn handle_expand_or_collapse_project_entry( - this: ModelHandle, - entry_id: u64, - original_sender_id: Option, - is_expanded: bool, mut cx: AsyncAppContext, ) -> Result { - let entry_id = ProjectEntryId::from_proto(entry_id); - let (worktree, replica_id) = this - .read_with(&cx, |this, cx| { - let replica_id = original_sender_id - .and_then(|peer_id| this.collaborators.get(&peer_id))? - .replica_id; - let worktree = this.worktree_for_entry(entry_id, cx)?; - Some((worktree, replica_id)) - }) + let entry_id = ProjectEntryId::from_proto(envelope.payload.entry_id); + let worktree = this + .read_with(&cx, |this, cx| this.worktree_for_entry(entry_id, cx)) .ok_or_else(|| anyhow!("invalid request"))?; worktree.update(&mut cx, |worktree, cx| { - worktree.as_local_mut().unwrap().mark_entry_expanded( - entry_id, - is_expanded, - replica_id, - cx, - ) + worktree + .as_local_mut() + .unwrap() + .mark_entry_expanded(entry_id, cx) }); Ok(proto::Ack {}) } diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 1ce08a9a47..4e5a828165 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -5,7 +5,7 @@ use ::ignore::gitignore::{Gitignore, GitignoreBuilder}; use anyhow::{anyhow, Context, Result}; use client::{proto, Client}; use clock::ReplicaId; -use collections::{BTreeSet, HashMap, VecDeque}; +use collections::{HashMap, HashSet, VecDeque}; use fs::{ repository::{GitFileStatus, GitRepository, RepoPath}, Fs, LineEnding, @@ -89,10 +89,8 @@ enum ScanRequest { paths: Vec, done: barrier::Sender, }, - SetDirExpanded { + ExpandDir { entry_id: ProjectEntryId, - replica_id: ReplicaId, - is_expanded: bool, }, } @@ -226,7 +224,7 @@ pub struct LocalSnapshot { struct BackgroundScannerState { snapshot: LocalSnapshot, - expanded_dirs: BTreeSet<(ProjectEntryId, ReplicaId)>, + expanded_dirs: HashSet, /// The ids of all of the entries that were removed from the snapshot /// as part of the current update. These entry ids may be re-used /// if the same inode is discovered at a new path, or if the given @@ -1154,16 +1152,10 @@ impl LocalWorktree { pub fn mark_entry_expanded( &mut self, entry_id: ProjectEntryId, - is_expanded: bool, - replica_id: ReplicaId, _cx: &mut ModelContext, ) { self.scan_requests_tx - .try_send(ScanRequest::SetDirExpanded { - entry_id, - replica_id, - is_expanded, - }) + .try_send(ScanRequest::ExpandDir { entry_id }) .ok(); } @@ -2210,12 +2202,7 @@ impl LocalSnapshot { impl BackgroundScannerState { fn is_entry_expanded(&self, entry: &Entry) -> bool { - let expanded = self - .expanded_dirs - .range((entry.id, 0)..=(entry.id, ReplicaId::MAX)) - .next() - .is_some(); - expanded + self.expanded_dirs.contains(&entry.id) } fn reuse_entry_id(&mut self, entry: &mut Entry) { @@ -2976,18 +2963,10 @@ impl BackgroundScanner { self.reload_entries_for_paths(paths, None).await; self.send_status_update(false, Some(done)) } - ScanRequest::SetDirExpanded { - entry_id, - replica_id, - is_expanded, - } => { + ScanRequest::ExpandDir { entry_id } => { let path = { let mut state = self.state.lock(); - if is_expanded { - state.expanded_dirs.insert((entry_id, replica_id)); - } else { - state.expanded_dirs.remove(&(entry_id, replica_id)); - } + state.expanded_dirs.insert(entry_id); state .snapshot .entry_for_id(entry_id) diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 78a9fb032f..1291835ae9 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -451,9 +451,6 @@ impl ProjectPanel { Ok(ix) => { expanded_dir_ids.remove(ix); self.update_visible_entries(Some((worktree_id, entry_id)), cx); - self.project.update(cx, |project, cx| { - project.mark_entry_collapsed(worktree_id, entry_id, cx); - }); cx.notify(); break; } @@ -477,7 +474,6 @@ impl ProjectPanel { self.project.update(cx, |project, cx| { match expanded_dir_ids.binary_search(&entry_id) { Ok(ix) => { - project.mark_entry_collapsed(worktree_id, entry_id, cx); expanded_dir_ids.remove(ix); } Err(ix) => { diff --git a/crates/rpc/proto/zed.proto b/crates/rpc/proto/zed.proto index d7e8d16a0e..f3a9f7eab5 100644 --- a/crates/rpc/proto/zed.proto +++ b/crates/rpc/proto/zed.proto @@ -63,7 +63,6 @@ message Envelope { CopyProjectEntry copy_project_entry = 47; DeleteProjectEntry delete_project_entry = 48; ExpandProjectEntry expand_project_entry = 114; - CollapseProjectEntry collapse_project_entry = 115; ProjectEntryResponse project_entry_response = 49; UpdateDiagnosticSummary update_diagnostic_summary = 50; @@ -379,11 +378,6 @@ message ExpandProjectEntry { uint64 entry_id = 2; } -message CollapseProjectEntry { - uint64 project_id = 1; - uint64 entry_id = 2; -} - message ProjectEntryResponse { Entry entry = 1; uint64 worktree_scan_id = 2; diff --git a/crates/rpc/src/proto.rs b/crates/rpc/src/proto.rs index 9f8e942492..6311b043d3 100644 --- a/crates/rpc/src/proto.rs +++ b/crates/rpc/src/proto.rs @@ -151,7 +151,6 @@ messages!( (DeleteProjectEntry, Foreground), (Error, Foreground), (ExpandProjectEntry, Foreground), - (CollapseProjectEntry, Foreground), (Follow, Foreground), (FollowResponse, Foreground), (FormatBuffers, Foreground), @@ -258,7 +257,6 @@ request_messages!( (DeclineCall, Ack), (DeleteProjectEntry, ProjectEntryResponse), (ExpandProjectEntry, Ack), - (CollapseProjectEntry, Ack), (Follow, FollowResponse), (FormatBuffers, FormatBuffersResponse), (GetChannelMessages, GetChannelMessagesResponse), @@ -316,7 +314,6 @@ entity_messages!( CreateProjectEntry, DeleteProjectEntry, ExpandProjectEntry, - CollapseProjectEntry, Follow, FormatBuffers, GetCodeActions, From 205c758e4e5d8c5ef67794023ce61d6ef663d2b1 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 16 Jun 2023 09:42:13 -0700 Subject: [PATCH 122/215] Wait for ignored directory to be expanded in descendant entries test --- crates/project/src/project.rs | 10 ++-------- crates/project/src/worktree.rs | 13 ++++++++----- crates/project/src/worktree_tests.rs | 11 +++++++++++ 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 79f3e743bd..a360e5dd72 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -5413,10 +5413,7 @@ impl Project { if self.is_local() { let worktree = self.worktree_for_id(worktree_id, cx)?; worktree.update(cx, |worktree, cx| { - worktree - .as_local_mut() - .unwrap() - .mark_entry_expanded(entry_id, cx); + worktree.as_local_mut().unwrap().expand_dir(entry_id, cx); }); } else if let Some(project_id) = self.remote_id() { cx.background() @@ -5742,10 +5739,7 @@ impl Project { .read_with(&cx, |this, cx| this.worktree_for_entry(entry_id, cx)) .ok_or_else(|| anyhow!("invalid request"))?; worktree.update(&mut cx, |worktree, cx| { - worktree - .as_local_mut() - .unwrap() - .mark_entry_expanded(entry_id, cx) + worktree.as_local_mut().unwrap().expand_dir(entry_id, cx) }); Ok(proto::Ack {}) } diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 4e5a828165..0480461556 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -91,6 +91,7 @@ enum ScanRequest { }, ExpandDir { entry_id: ProjectEntryId, + done: barrier::Sender, }, } @@ -1149,14 +1150,16 @@ impl LocalWorktree { })) } - pub fn mark_entry_expanded( + pub fn expand_dir( &mut self, entry_id: ProjectEntryId, _cx: &mut ModelContext, - ) { + ) -> barrier::Receiver { + let (tx, rx) = barrier::channel(); self.scan_requests_tx - .try_send(ScanRequest::ExpandDir { entry_id }) + .try_send(ScanRequest::ExpandDir { entry_id, done: tx }) .ok(); + rx } fn refresh_entry( @@ -2963,7 +2966,7 @@ impl BackgroundScanner { self.reload_entries_for_paths(paths, None).await; self.send_status_update(false, Some(done)) } - ScanRequest::ExpandDir { entry_id } => { + ScanRequest::ExpandDir { entry_id, done } => { let path = { let mut state = self.state.lock(); state.expanded_dirs.insert(entry_id); @@ -2978,7 +2981,7 @@ impl BackgroundScanner { .await; if let Some(job) = scan_job_rx.next().await { self.scan_dir(&job).await.log_err(); - self.send_status_update(false, None); + self.send_status_update(false, Some(done)); } } true diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rs index 6468ac9a16..00697d04a2 100644 --- a/crates/project/src/worktree_tests.rs +++ b/crates/project/src/worktree_tests.rs @@ -8,6 +8,7 @@ use fs::{repository::GitFileStatus, FakeFs, Fs, RealFs, RemoveOptions}; use git::GITIGNORE; use gpui::{executor::Deterministic, ModelContext, Task, TestAppContext}; use parking_lot::Mutex; +use postage::stream::Stream; use pretty_assertions::assert_eq; use rand::prelude::*; use serde_json::json; @@ -154,7 +155,17 @@ async fn test_descendent_entries(cx: &mut TestAppContext) { .collect::>(), vec![Path::new("g"), Path::new("g/h"),] ); + }); + // Expand gitignored directory. + tree.update(cx, |tree, cx| { + let tree = tree.as_local_mut().unwrap(); + tree.expand_dir(tree.entry_for_path("i/j").unwrap().id, cx) + }) + .recv() + .await; + + tree.read_with(cx, |tree, _| { assert_eq!( tree.descendent_entries(false, false, Path::new("i")) .map(|entry| entry.path.as_ref()) From 6fe74602ac0e1dce7843bd10635a444700ec3c56 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 16 Jun 2023 09:42:47 -0700 Subject: [PATCH 123/215] Fix detection of when refreshed paths are outside of worktree root --- crates/project/src/worktree.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 0480461556..c508b84f6c 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -3338,7 +3338,19 @@ impl BackgroundScanner { let metadata = futures::future::join_all( abs_paths .iter() - .map(|abs_path| self.fs.metadata(&abs_path)) + .map(|abs_path| async move { + let metadata = self.fs.metadata(&abs_path).await?; + anyhow::Ok(if let Some(metadata) = metadata { + let canonical_path = if metadata.is_symlink { + self.fs.canonicalize(&abs_path).await? + } else { + abs_path.clone() + }; + Some((metadata, canonical_path)) + } else { + None + }) + }) .collect::>(), ) .await; @@ -3376,7 +3388,7 @@ impl BackgroundScanner { let abs_path: Arc = root_abs_path.join(&path).into(); match metadata { - Ok(Some(metadata)) => { + Ok(Some((metadata, canonical_path))) => { let ignore_stack = state .snapshot .ignore_stack_for_abs_path(&abs_path, metadata.is_dir); @@ -3411,7 +3423,7 @@ impl BackgroundScanner { if let Some(scan_queue_tx) = &scan_queue_tx { let mut ancestor_inodes = state.snapshot.ancestor_inodes_for_path(&path); if metadata.is_dir && !ancestor_inodes.contains(&metadata.inode) { - let is_outside_root = !abs_path.starts_with(&root_canonical_path); + let is_outside_root = !canonical_path.starts_with(&root_canonical_path); ancestor_inodes.insert(metadata.inode); smol::block_on(scan_queue_tx.send(ScanJob { abs_path, From 3c06bd056a15499fe410f1d3a8fd7c639df9a1ee Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 16 Jun 2023 10:46:14 -0700 Subject: [PATCH 124/215] Load git repositories when inserting the entry for the .git Don't wait until populating that directory entry, for two reasons: * In the case of submodules, .git is not a directory * We don't eagerly populate .git directories, since their contents are automatically ignored. --- crates/project/src/worktree.rs | 57 +++++++++++++++++----------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index c508b84f6c..1ae0f6067a 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -2218,17 +2218,23 @@ impl BackgroundScannerState { fn insert_entry(&mut self, mut entry: Entry, fs: &dyn Fs) -> Entry { self.reuse_entry_id(&mut entry); - self.snapshot.insert_entry(entry, fs) + let entry = self.snapshot.insert_entry(entry, fs); + if entry.path.file_name() == Some(&DOT_GIT) { + let changed_paths = self.snapshot.build_repo(entry.path.clone(), fs); + if let Some(changed_paths) = changed_paths { + util::extend_sorted(&mut self.changed_paths, changed_paths, usize::MAX, Ord::cmp) + } + } + entry } - #[must_use = "Changed paths must be used for diffing later"] fn populate_dir( &mut self, - parent_path: Arc, + parent_path: &Arc, entries: impl IntoIterator, ignore: Option>, fs: &dyn Fs, - ) -> Option>> { + ) { let mut parent_entry = if let Some(parent_entry) = self .snapshot .entries_by_path @@ -2240,15 +2246,13 @@ impl BackgroundScannerState { "populating a directory {:?} that has been removed", parent_path ); - return None; + return; }; match parent_entry.kind { - EntryKind::PendingDir => { - parent_entry.kind = EntryKind::Dir; - } + EntryKind::PendingDir => parent_entry.kind = EntryKind::Dir, EntryKind::Dir => {} - _ => return None, + _ => return, } if let Some(ignore) = ignore { @@ -2260,8 +2264,13 @@ impl BackgroundScannerState { let mut entries_by_path_edits = vec![Edit::Insert(parent_entry)]; let mut entries_by_id_edits = Vec::new(); + let mut dotgit_path = None; for mut entry in entries { + if entry.path.file_name() == Some(&DOT_GIT) { + dotgit_path = Some(entry.path.clone()); + } + self.reuse_entry_id(&mut entry); entries_by_id_edits.push(Edit::Insert(PathEntry { id: entry.id, @@ -2277,10 +2286,15 @@ impl BackgroundScannerState { .edit(entries_by_path_edits, &()); self.snapshot.entries_by_id.edit(entries_by_id_edits, &()); - if parent_path.file_name() == Some(&DOT_GIT) { - return self.snapshot.build_repo(parent_path, fs); + if let Some(dotgit_path) = dotgit_path { + let changed_paths = self.snapshot.build_repo(dotgit_path, fs); + if let Some(changed_paths) = changed_paths { + util::extend_sorted(&mut self.changed_paths, changed_paths, usize::MAX, Ord::cmp) + } + } + if let Err(ix) = self.changed_paths.binary_search(parent_path) { + self.changed_paths.insert(ix, parent_path.clone()); } - None } fn remove_path(&mut self, path: &Path) { @@ -3297,22 +3311,9 @@ impl BackgroundScanner { new_entries.push(child_entry); } - { - let mut state = self.state.lock(); - let changed_paths = - state.populate_dir(job.path.clone(), new_entries, new_ignore, self.fs.as_ref()); - if let Err(ix) = state.changed_paths.binary_search(&job.path) { - state.changed_paths.insert(ix, job.path.clone()); - } - if let Some(changed_paths) = changed_paths { - util::extend_sorted( - &mut state.changed_paths, - changed_paths, - usize::MAX, - Ord::cmp, - ) - } - } + self.state + .lock() + .populate_dir(&job.path, new_entries, new_ignore, self.fs.as_ref()); for new_job in new_jobs { if let Some(new_job) = new_job { From 1b71589514a047115c66a8601b898defb6c87d0e Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 16 Jun 2023 11:53:05 -0700 Subject: [PATCH 125/215] Fix confusion between canonical vs non-canonical paths when rescanning, expanding paths --- crates/project/src/worktree.rs | 125 +++++++++++++++++---------- crates/project/src/worktree_tests.rs | 9 +- 2 files changed, 87 insertions(+), 47 deletions(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 1ae0f6067a..5693dd8f12 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -86,7 +86,7 @@ pub struct LocalWorktree { enum ScanRequest { RescanPaths { - paths: Vec, + relative_paths: Vec>, done: barrier::Sender, }, ExpandDir { @@ -1051,14 +1051,10 @@ impl LocalWorktree { cx: &mut ModelContext, ) -> Option>> { let entry = self.entry_for_id(entry_id)?.clone(); - let abs_path = self.abs_path.clone(); + let abs_path = self.absolutize(&entry.path); let fs = self.fs.clone(); let delete = cx.background().spawn(async move { - let mut abs_path = fs.canonicalize(&abs_path).await?; - if entry.path.file_name().is_some() { - abs_path = abs_path.join(&entry.path); - } if entry.is_file() { fs.remove_file(&abs_path, Default::default()).await?; } else { @@ -1071,18 +1067,18 @@ impl LocalWorktree { ) .await?; } - anyhow::Ok(abs_path) + anyhow::Ok(entry.path) }); Some(cx.spawn(|this, mut cx| async move { - let abs_path = delete.await?; + let path = delete.await?; let (tx, mut rx) = barrier::channel(); this.update(&mut cx, |this, _| { this.as_local_mut() .unwrap() .scan_requests_tx .try_send(ScanRequest::RescanPaths { - paths: vec![abs_path], + relative_paths: vec![path], done: tx, }) })?; @@ -1168,27 +1164,19 @@ impl LocalWorktree { old_path: Option>, cx: &mut ModelContext, ) -> Task> { - let fs = self.fs.clone(); - let abs_root_path = self.abs_path.clone(); let path_changes_tx = self.scan_requests_tx.clone(); cx.spawn_weak(move |this, mut cx| async move { - let abs_path = fs.canonicalize(&abs_root_path).await?; - let mut paths = Vec::with_capacity(2); - paths.push(if path.file_name().is_some() { - abs_path.join(&path) + let relative_paths = if let Some(old_path) = old_path.as_ref() { + vec![old_path.clone(), path.clone()] } else { - abs_path.clone() - }); - if let Some(old_path) = old_path { - paths.push(if old_path.file_name().is_some() { - abs_path.join(&old_path) - } else { - abs_path.clone() - }); - } + vec![path.clone()] + }; let (tx, mut rx) = barrier::channel(); - path_changes_tx.try_send(ScanRequest::RescanPaths { paths, done: tx })?; + path_changes_tx.try_send(ScanRequest::RescanPaths { + relative_paths, + done: tx, + })?; rx.recv().await; this.upgrade(&cx) .ok_or_else(|| anyhow!("worktree was dropped"))? @@ -2975,38 +2963,81 @@ impl BackgroundScanner { } async fn process_scan_request(&self, request: ScanRequest) -> bool { + let root_path = self.state.lock().snapshot.abs_path.clone(); + let root_canonical_path = match self.fs.canonicalize(&root_path).await { + Ok(path) => path, + Err(err) => { + log::error!("failed to canonicalize root path: {}", err); + return false; + } + }; + match request { - ScanRequest::RescanPaths { paths, done } => { - self.reload_entries_for_paths(paths, None).await; + ScanRequest::RescanPaths { + relative_paths, + done, + } => { + let abs_paths = relative_paths + .into_iter() + .map(|path| { + if path.file_name().is_some() { + root_canonical_path.join(path) + } else { + root_canonical_path.clone() + } + }) + .collect::>(); + self.reload_entries_for_paths(root_path, root_canonical_path, abs_paths, None) + .await; self.send_status_update(false, Some(done)) } ScanRequest::ExpandDir { entry_id, done } => { - let path = { + let abs_path; + { let mut state = self.state.lock(); - state.expanded_dirs.insert(entry_id); - state - .snapshot - .entry_for_id(entry_id) - .map(|e| state.snapshot.absolutize(&e.path)) - }; - if let Some(path) = path { - let (scan_job_tx, mut scan_job_rx) = channel::unbounded(); - self.reload_entries_for_paths(vec![path.clone()], Some(scan_job_tx)) - .await; - if let Some(job) = scan_job_rx.next().await { - self.scan_dir(&job).await.log_err(); - self.send_status_update(false, Some(done)); + if let Some(entry) = state.snapshot.entry_for_id(entry_id) { + abs_path = root_canonical_path.join(&entry.path); + state.expanded_dirs.insert(entry_id); + } else { + return true; } + }; + + let (scan_job_tx, mut scan_job_rx) = channel::unbounded(); + self.reload_entries_for_paths( + root_path, + root_canonical_path, + vec![abs_path], + Some(scan_job_tx), + ) + .await; + if let Some(job) = scan_job_rx.next().await { + self.scan_dir(&job).await.log_err(); + self.send_status_update(false, Some(done)); } true } } } - async fn process_events(&mut self, paths: Vec) { + async fn process_events(&mut self, abs_paths: Vec) { + let root_path = self.state.lock().snapshot.abs_path.clone(); + let root_canonical_path = match self.fs.canonicalize(&root_path).await { + Ok(path) => path, + Err(err) => { + log::error!("failed to canonicalize root path: {}", err); + return; + } + }; + let (scan_job_tx, scan_job_rx) = channel::unbounded(); let paths = self - .reload_entries_for_paths(paths, Some(scan_job_tx.clone())) + .reload_entries_for_paths( + root_path, + root_canonical_path, + abs_paths, + Some(scan_job_tx.clone()), + ) .await; drop(scan_job_tx); self.scan_dirs(false, scan_job_rx).await; @@ -3152,6 +3183,7 @@ impl BackgroundScanner { if job.is_outside_root || job.ignore_stack.is_all() { if let Some(entry) = state.snapshot.entry_for_path(&job.path) { if !state.is_entry_expanded(entry) { + log::debug!("defer scanning directory {:?}", job.path); return Ok(()); } } @@ -3168,6 +3200,8 @@ impl BackgroundScanner { ) }; + log::debug!("scan directory {:?}", job.path); + let mut root_canonical_path = None; let mut child_paths = self.fs.read_dir(&job.abs_path).await?; while let Some(child_abs_path) = child_paths.next().await { @@ -3326,16 +3360,15 @@ impl BackgroundScanner { async fn reload_entries_for_paths( &self, + root_abs_path: Arc, + root_canonical_path: PathBuf, mut abs_paths: Vec, scan_queue_tx: Option>, ) -> Option>> { let doing_recursive_update = scan_queue_tx.is_some(); - abs_paths.sort_unstable(); abs_paths.dedup_by(|a, b| a.starts_with(&b)); - let root_abs_path = self.state.lock().snapshot.abs_path.clone(); - let root_canonical_path = self.fs.canonicalize(&root_abs_path).await.log_err()?; let metadata = futures::future::join_all( abs_paths .iter() diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rs index 00697d04a2..216e14f51c 100644 --- a/crates/project/src/worktree_tests.rs +++ b/crates/project/src/worktree_tests.rs @@ -369,7 +369,14 @@ async fn test_rescan_with_gitignore(cx: &mut TestAppContext) { .unwrap(); cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete()) .await; - tree.flush_fs_events(cx).await; + + tree.update(cx, |tree, cx| { + let tree = tree.as_local_mut().unwrap(); + tree.expand_dir(tree.entry_for_path("ignored-dir").unwrap().id, cx) + }) + .recv() + .await; + cx.read(|cx| { let tree = tree.read(cx); assert!( From cd823ede4d8b714de1ee3fd0e996973c9e4829e3 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 16 Jun 2023 14:19:48 -0700 Subject: [PATCH 126/215] Add a bit to each entry indicating if it's outside of the worktree root --- .../20221109000000_test_schema.sql | 1 + ...35_add_is_external_to_worktree_entries.sql | 2 + crates/collab/src/db.rs | 3 + crates/collab/src/db/worktree_entry.rs | 1 + crates/project/src/worktree.rs | 50 ++++++----- crates/project/src/worktree_tests.rs | 83 ++++++++++++++++--- crates/project_panel/src/project_panel.rs | 1 + crates/rpc/proto/zed.proto | 3 +- 8 files changed, 110 insertions(+), 34 deletions(-) create mode 100644 crates/collab/migrations/20230616134535_add_is_external_to_worktree_entries.sql diff --git a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql index 595d841d07..c690b6148a 100644 --- a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql +++ b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql @@ -74,6 +74,7 @@ CREATE TABLE "worktree_entries" ( "mtime_seconds" INTEGER NOT NULL, "mtime_nanos" INTEGER NOT NULL, "is_symlink" BOOL NOT NULL, + "is_external" BOOL NOT NULL, "is_ignored" BOOL NOT NULL, "is_deleted" BOOL NOT NULL, "git_status" INTEGER, diff --git a/crates/collab/migrations/20230616134535_add_is_external_to_worktree_entries.sql b/crates/collab/migrations/20230616134535_add_is_external_to_worktree_entries.sql new file mode 100644 index 0000000000..e4348af0cc --- /dev/null +++ b/crates/collab/migrations/20230616134535_add_is_external_to_worktree_entries.sql @@ -0,0 +1,2 @@ +ALTER TABLE "worktree_entries" +ADD "is_external" BOOL NOT NULL DEFAULT FALSE; diff --git a/crates/collab/src/db.rs b/crates/collab/src/db.rs index 7e2c376bc2..208da22efe 100644 --- a/crates/collab/src/db.rs +++ b/crates/collab/src/db.rs @@ -1539,6 +1539,7 @@ impl Database { }), is_symlink: db_entry.is_symlink, is_ignored: db_entry.is_ignored, + is_external: db_entry.is_external, git_status: db_entry.git_status.map(|status| status as i32), }); } @@ -2349,6 +2350,7 @@ impl Database { mtime_nanos: ActiveValue::set(mtime.nanos as i32), is_symlink: ActiveValue::set(entry.is_symlink), is_ignored: ActiveValue::set(entry.is_ignored), + is_external: ActiveValue::set(entry.is_external), git_status: ActiveValue::set(entry.git_status.map(|status| status as i64)), is_deleted: ActiveValue::set(false), scan_id: ActiveValue::set(update.scan_id as i64), @@ -2705,6 +2707,7 @@ impl Database { }), is_symlink: db_entry.is_symlink, is_ignored: db_entry.is_ignored, + is_external: db_entry.is_external, git_status: db_entry.git_status.map(|status| status as i32), }); } diff --git a/crates/collab/src/db/worktree_entry.rs b/crates/collab/src/db/worktree_entry.rs index f2df808ee3..cf5090ab6d 100644 --- a/crates/collab/src/db/worktree_entry.rs +++ b/crates/collab/src/db/worktree_entry.rs @@ -18,6 +18,7 @@ pub struct Model { pub git_status: Option, pub is_symlink: bool, pub is_ignored: bool, + pub is_external: bool, pub is_deleted: bool, pub scan_id: i64, } diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 5693dd8f12..6be61e8b9c 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -2604,6 +2604,7 @@ pub struct Entry { pub mtime: SystemTime, pub is_symlink: bool, pub is_ignored: bool, + pub is_external: bool, pub git_status: Option, } @@ -2657,6 +2658,7 @@ impl Entry { mtime: metadata.mtime, is_symlink: metadata.is_symlink, is_ignored: false, + is_external: false, git_status: None, } } @@ -2912,7 +2914,7 @@ impl BackgroundScanner { path: Arc::from(Path::new("")), ignore_stack, ancestor_inodes: TreeSet::from_ordered_entries(root_inode), - is_outside_root: false, + is_external: false, scan_queue: scan_job_tx.clone(), })) .unwrap(); @@ -3180,7 +3182,7 @@ impl BackgroundScanner { let mut new_ignore = None; let (root_abs_path, root_char_bag, next_entry_id, repository) = { let state = self.state.lock(); - if job.is_outside_root || job.ignore_stack.is_all() { + if job.is_external || job.ignore_stack.is_all() { if let Some(entry) = state.snapshot.entry_for_path(&job.path) { if !state.is_entry_expanded(entry) { log::debug!("defer scanning directory {:?}", job.path); @@ -3200,7 +3202,11 @@ impl BackgroundScanner { ) }; - log::debug!("scan directory {:?}", job.path); + log::debug!( + "scan directory {:?}. external: {}", + job.path, + job.is_external + ); let mut root_canonical_path = None; let mut child_paths = self.fs.read_dir(&job.abs_path).await?; @@ -3270,8 +3276,9 @@ impl BackgroundScanner { root_char_bag, ); - let mut is_outside_root = false; - if child_metadata.is_symlink { + if job.is_external { + child_entry.is_external = true; + } else if child_metadata.is_symlink { let canonical_path = match self.fs.canonicalize(&child_abs_path).await { Ok(path) => path, Err(err) => { @@ -3298,13 +3305,12 @@ impl BackgroundScanner { }; if !canonical_path.starts_with(root_canonical_path) { - is_outside_root = true; + child_entry.is_external = true; } } if child_entry.is_dir() { - let is_ignored = ignore_stack.is_abs_path_ignored(&child_abs_path, true); - child_entry.is_ignored = is_ignored; + child_entry.is_ignored = ignore_stack.is_abs_path_ignored(&child_abs_path, true); // Avoid recursing until crash in the case of a recursive symlink if !job.ancestor_inodes.contains(&child_entry.inode) { @@ -3314,8 +3320,8 @@ impl BackgroundScanner { new_jobs.push(Some(ScanJob { abs_path: child_abs_path, path: child_path, - is_outside_root, - ignore_stack: if is_ignored { + is_external: child_entry.is_external, + ignore_stack: if child_entry.is_ignored { IgnoreStack::all() } else { ignore_stack.clone() @@ -3374,16 +3380,12 @@ impl BackgroundScanner { .iter() .map(|abs_path| async move { let metadata = self.fs.metadata(&abs_path).await?; - anyhow::Ok(if let Some(metadata) = metadata { - let canonical_path = if metadata.is_symlink { - self.fs.canonicalize(&abs_path).await? - } else { - abs_path.clone() - }; - Some((metadata, canonical_path)) + if let Some(metadata) = metadata { + let canonical_path = self.fs.canonicalize(&abs_path).await?; + anyhow::Ok(Some((metadata, canonical_path))) } else { - None - }) + Ok(None) + } }) .collect::>(), ) @@ -3434,6 +3436,7 @@ impl BackgroundScanner { state.snapshot.root_char_bag, ); fs_entry.is_ignored = ignore_stack.is_all(); + fs_entry.is_external = !canonical_path.starts_with(&root_canonical_path); if !fs_entry.is_ignored { if !fs_entry.is_dir() { @@ -3452,19 +3455,18 @@ impl BackgroundScanner { } } - state.insert_entry(fs_entry, self.fs.as_ref()); + let fs_entry = state.insert_entry(fs_entry, self.fs.as_ref()); if let Some(scan_queue_tx) = &scan_queue_tx { let mut ancestor_inodes = state.snapshot.ancestor_inodes_for_path(&path); if metadata.is_dir && !ancestor_inodes.contains(&metadata.inode) { - let is_outside_root = !canonical_path.starts_with(&root_canonical_path); ancestor_inodes.insert(metadata.inode); smol::block_on(scan_queue_tx.send(ScanJob { abs_path, path, ignore_stack, ancestor_inodes, - is_outside_root, + is_external: fs_entry.is_external, scan_queue: scan_queue_tx.clone(), })) .unwrap(); @@ -3853,7 +3855,7 @@ struct ScanJob { ignore_stack: Arc, scan_queue: Sender, ancestor_inodes: TreeSet, - is_outside_root: bool, + is_external: bool, } struct UpdateIgnoreStatusJob { @@ -4141,6 +4143,7 @@ impl<'a> From<&'a Entry> for proto::Entry { mtime: Some(entry.mtime.into()), is_symlink: entry.is_symlink, is_ignored: entry.is_ignored, + is_external: entry.is_external, git_status: entry.git_status.map(|status| status.to_proto()), } } @@ -4167,6 +4170,7 @@ impl<'a> TryFrom<(&'a CharBag, proto::Entry)> for Entry { mtime: mtime.into(), is_symlink: entry.is_symlink, is_ignored: entry.is_ignored, + is_external: entry.is_external, git_status: GitFileStatus::from_proto(entry.git_status), }) } else { diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rs index 216e14f51c..83f416d784 100644 --- a/crates/project/src/worktree_tests.rs +++ b/crates/project/src/worktree_tests.rs @@ -267,7 +267,7 @@ async fn test_circular_symlinks(executor: Arc, cx: &mut TestAppCo }); } -#[gpui::test(iterations = 10)] +#[gpui::test] async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { let fs = FakeFs::new(cx.background()); fs.insert_tree( @@ -289,14 +289,17 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { } }, "dir3": { + "deps": {}, "src": { "e.rs": "", "f.rs": "", - } + }, } }), ) .await; + + // These symlinks point to directories outside of the worktree's root, dir1. fs.insert_symlink("/root/dir1/deps/dep-dir2", "../../dir2".into()) .await; fs.insert_symlink("/root/dir1/deps/dep-dir3", "../../dir3".into()) @@ -317,19 +320,79 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete()) .await; + // The symlinked directories are not scanned by default. tree.read_with(cx, |tree, _| { assert_eq!( tree.entries(false) - .map(|entry| entry.path.as_ref()) + .map(|entry| (entry.path.as_ref(), entry.is_external)) .collect::>(), vec![ - Path::new(""), - Path::new("deps"), - Path::new("deps/dep-dir2"), - Path::new("deps/dep-dir3"), - Path::new("src"), - Path::new("src/a.rs"), - Path::new("src/b.rs"), + (Path::new(""), false), + (Path::new("deps"), false), + (Path::new("deps/dep-dir2"), true), + (Path::new("deps/dep-dir3"), true), + (Path::new("src"), false), + (Path::new("src/a.rs"), false), + (Path::new("src/b.rs"), false), + ] + ); + }); + + // Expand one of the symlinked directories. + tree.update(cx, |tree, cx| { + let tree = tree.as_local_mut().unwrap(); + tree.expand_dir(tree.entry_for_path("deps/dep-dir3").unwrap().id, cx) + }) + .recv() + .await; + + // The expanded directory's contents are loaded. Subdirectories are + // not scanned yet. + tree.read_with(cx, |tree, _| { + assert_eq!( + tree.entries(false) + .map(|entry| (entry.path.as_ref(), entry.is_external)) + .collect::>(), + vec![ + (Path::new(""), false), + (Path::new("deps"), false), + (Path::new("deps/dep-dir2"), true), + (Path::new("deps/dep-dir3"), true), + (Path::new("deps/dep-dir3/deps"), true), + (Path::new("deps/dep-dir3/src"), true), + (Path::new("src"), false), + (Path::new("src/a.rs"), false), + (Path::new("src/b.rs"), false), + ] + ); + }); + + // Expand a subdirectory of one of the symlinked directories. + tree.update(cx, |tree, cx| { + let tree = tree.as_local_mut().unwrap(); + tree.expand_dir(tree.entry_for_path("deps/dep-dir3/src").unwrap().id, cx) + }) + .recv() + .await; + + // The expanded subdirectory's contents are loaded. + tree.read_with(cx, |tree, _| { + assert_eq!( + tree.entries(false) + .map(|entry| (entry.path.as_ref(), entry.is_external)) + .collect::>(), + vec![ + (Path::new(""), false), + (Path::new("deps"), false), + (Path::new("deps/dep-dir2"), true), + (Path::new("deps/dep-dir3"), true), + (Path::new("deps/dep-dir3/deps"), true), + (Path::new("deps/dep-dir3/src"), true), + (Path::new("deps/dep-dir3/src/e.rs"), true), + (Path::new("deps/dep-dir3/src/f.rs"), true), + (Path::new("src"), false), + (Path::new("src/a.rs"), false), + (Path::new("src/b.rs"), false), ] ); }); diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 1291835ae9..c8dfb7cb38 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1022,6 +1022,7 @@ impl ProjectPanel { mtime: entry.mtime, is_symlink: false, is_ignored: false, + is_external: false, git_status: entry.git_status, }); } diff --git a/crates/rpc/proto/zed.proto b/crates/rpc/proto/zed.proto index f3a9f7eab5..78aab23a44 100644 --- a/crates/rpc/proto/zed.proto +++ b/crates/rpc/proto/zed.proto @@ -1011,7 +1011,8 @@ message Entry { Timestamp mtime = 5; bool is_symlink = 6; bool is_ignored = 7; - optional GitStatus git_status = 8; + bool is_external = 8; + optional GitStatus git_status = 9; } message RepositoryEntry { From 3e6aedfc694894966ae89b2c85ab338c83b8f7a9 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 16 Jun 2023 15:49:27 -0700 Subject: [PATCH 127/215] Expand dirs on-demand when opening buffers inside unloaded dirs --- crates/project/src/project.rs | 10 +- crates/project/src/worktree.rs | 170 ++++++++++++++++----------- crates/project/src/worktree_tests.rs | 100 +++++++++++++++- 3 files changed, 206 insertions(+), 74 deletions(-) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index a360e5dd72..5c71202956 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -5413,7 +5413,10 @@ impl Project { if self.is_local() { let worktree = self.worktree_for_id(worktree_id, cx)?; worktree.update(cx, |worktree, cx| { - worktree.as_local_mut().unwrap().expand_dir(entry_id, cx); + worktree + .as_local_mut() + .unwrap() + .expand_entry_for_id(entry_id, cx); }); } else if let Some(project_id) = self.remote_id() { cx.background() @@ -5739,7 +5742,10 @@ impl Project { .read_with(&cx, |this, cx| this.worktree_for_entry(entry_id, cx)) .ok_or_else(|| anyhow!("invalid request"))?; worktree.update(&mut cx, |worktree, cx| { - worktree.as_local_mut().unwrap().expand_dir(entry_id, cx) + worktree + .as_local_mut() + .unwrap() + .expand_entry_for_id(entry_id, cx) }); Ok(proto::Ack {}) } diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 6be61e8b9c..bbf63901d1 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -89,8 +89,8 @@ enum ScanRequest { relative_paths: Vec>, done: barrier::Sender, }, - ExpandDir { - entry_id: ProjectEntryId, + ExpandPath { + path: Arc, done: barrier::Sender, }, } @@ -879,26 +879,31 @@ impl LocalWorktree { path: &Path, cx: &mut ModelContext, ) -> Task)>> { - let handle = cx.handle(); let path = Arc::from(path); let abs_path = self.absolutize(&path); let fs = self.fs.clone(); - let snapshot = self.snapshot(); - - let mut index_task = None; - - if let Some(repo) = snapshot.repository_for_path(&path) { - let repo_path = repo.work_directory.relativize(self, &path).unwrap(); - if let Some(repo) = self.git_repositories.get(&*repo.work_directory) { - let repo = repo.repo_ptr.to_owned(); - index_task = Some( - cx.background() - .spawn(async move { repo.lock().load_index_text(&repo_path) }), - ); - } - } + let expand = path + .parent() + .map(|path| self.expand_entry_for_path(path, cx)); cx.spawn(|this, mut cx| async move { + if let Some(mut expand) = expand { + expand.recv().await; + } + + let mut index_task = None; + let snapshot = this.read_with(&cx, |this, _| this.as_local().unwrap().snapshot()); + if let Some(repo) = snapshot.repository_for_path(&path) { + let repo_path = repo.work_directory.relativize(&snapshot, &path).unwrap(); + if let Some(repo) = snapshot.git_repositories.get(&*repo.work_directory) { + let repo = repo.repo_ptr.clone(); + index_task = Some( + cx.background() + .spawn(async move { repo.lock().load_index_text(&repo_path) }), + ); + } + } + let text = fs.load(&abs_path).await?; let diff_base = if let Some(index_task) = index_task { @@ -917,7 +922,7 @@ impl LocalWorktree { Ok(( File { entry_id: entry.id, - worktree: handle, + worktree: this, path: entry.path, mtime: entry.mtime, is_local: true, @@ -1146,14 +1151,34 @@ impl LocalWorktree { })) } - pub fn expand_dir( + pub fn expand_entry_for_id( &mut self, entry_id: ProjectEntryId, _cx: &mut ModelContext, + ) -> barrier::Receiver { + let (tx, rx) = barrier::channel(); + if let Some(entry) = self.entry_for_id(entry_id) { + self.scan_requests_tx + .try_send(ScanRequest::ExpandPath { + path: entry.path.clone(), + done: tx, + }) + .ok(); + } + rx + } + + pub fn expand_entry_for_path( + &self, + path: impl Into>, + _cx: &mut ModelContext, ) -> barrier::Receiver { let (tx, rx) = barrier::channel(); self.scan_requests_tx - .try_send(ScanRequest::ExpandDir { entry_id, done: tx }) + .try_send(ScanRequest::ExpandPath { + path: path.into(), + done: tx, + }) .ok(); rx } @@ -2192,10 +2217,6 @@ impl LocalSnapshot { } impl BackgroundScannerState { - fn is_entry_expanded(&self, entry: &Entry) -> bool { - self.expanded_dirs.contains(&entry.id) - } - fn reuse_entry_id(&mut self, entry: &mut Entry) { if let Some(removed_entry_id) = self.removed_entry_ids.remove(&entry.inode) { entry.id = removed_entry_id; @@ -2989,34 +3010,39 @@ impl BackgroundScanner { } }) .collect::>(); - self.reload_entries_for_paths(root_path, root_canonical_path, abs_paths, None) - .await; - self.send_status_update(false, Some(done)) - } - ScanRequest::ExpandDir { entry_id, done } => { - let abs_path; - { - let mut state = self.state.lock(); - if let Some(entry) = state.snapshot.entry_for_id(entry_id) { - abs_path = root_canonical_path.join(&entry.path); - state.expanded_dirs.insert(entry_id); - } else { - return true; - } - }; - - let (scan_job_tx, mut scan_job_rx) = channel::unbounded(); self.reload_entries_for_paths( root_path, root_canonical_path, - vec![abs_path], - Some(scan_job_tx), + abs_paths, + false, + None, ) .await; - if let Some(job) = scan_job_rx.next().await { - self.scan_dir(&job).await.log_err(); - self.send_status_update(false, Some(done)); + self.send_status_update(false, Some(done)) + } + ScanRequest::ExpandPath { path, done } => { + let (scan_job_tx, mut scan_job_rx) = channel::unbounded(); + let mut abs_path = root_canonical_path.clone(); + for component in path.iter() { + abs_path.push(component); + self.reload_entries_for_paths( + root_path.clone(), + root_canonical_path.clone(), + vec![abs_path.clone()], + true, + Some(scan_job_tx.clone()), + ) + .await; } + drop(scan_job_tx); + + // Scan the expanded directories serially. This is ok, because only + // the direct ancestors of the expanded path need to be scanned. + while let Some(job) = scan_job_rx.next().await { + self.scan_dir(&job).await.log_err(); + } + + self.send_status_update(false, Some(done)); true } } @@ -3038,6 +3064,7 @@ impl BackgroundScanner { root_path, root_canonical_path, abs_paths, + false, Some(scan_job_tx.clone()), ) .await; @@ -3176,22 +3203,18 @@ impl BackgroundScanner { } async fn scan_dir(&self, job: &ScanJob) -> Result<()> { + log::debug!( + "scan directory {:?}. external: {}", + job.path, + job.is_external + ); + let mut new_entries: Vec = Vec::new(); let mut new_jobs: Vec> = Vec::new(); let mut ignore_stack = job.ignore_stack.clone(); let mut new_ignore = None; let (root_abs_path, root_char_bag, next_entry_id, repository) = { - let state = self.state.lock(); - if job.is_external || job.ignore_stack.is_all() { - if let Some(entry) = state.snapshot.entry_for_path(&job.path) { - if !state.is_entry_expanded(entry) { - log::debug!("defer scanning directory {:?}", job.path); - return Ok(()); - } - } - } - - let snapshot = &state.snapshot; + let snapshot = &self.state.lock().snapshot; ( snapshot.abs_path().clone(), snapshot.root_char_bag, @@ -3202,12 +3225,6 @@ impl BackgroundScanner { ) }; - log::debug!( - "scan directory {:?}. external: {}", - job.path, - job.is_external - ); - let mut root_canonical_path = None; let mut child_paths = self.fs.read_dir(&job.abs_path).await?; while let Some(child_abs_path) = child_paths.next().await { @@ -3258,7 +3275,7 @@ impl BackgroundScanner { ignore_stack.is_abs_path_ignored(&entry_abs_path, entry.is_dir()); if entry.is_dir() { - if let Some(job) = new_jobs.next().expect("Missing scan job for entry") { + if let Some(job) = new_jobs.next().expect("missing scan job for entry") { job.ignore_stack = if entry.is_ignored { IgnoreStack::all() } else { @@ -3351,13 +3368,26 @@ impl BackgroundScanner { new_entries.push(child_entry); } - self.state - .lock() - .populate_dir(&job.path, new_entries, new_ignore, self.fs.as_ref()); + let mut state = self.state.lock(); + state.populate_dir(&job.path, new_entries, new_ignore, self.fs.as_ref()); for new_job in new_jobs { if let Some(new_job) = new_job { - job.scan_queue.send(new_job).await.ok(); + // If a subdirectory is ignored, or is external to the worktree, don't scan + // it unless it is marked as expanded. + if (new_job.is_external || new_job.ignore_stack.is_all()) + && !state + .snapshot + .entry_for_path(&new_job.path) + .map_or(true, |entry| state.expanded_dirs.contains(&entry.id)) + { + log::debug!("defer scanning directory {:?}", new_job.path); + continue; + } + + job.scan_queue + .try_send(new_job) + .expect("channel is unbounded"); } } @@ -3369,6 +3399,7 @@ impl BackgroundScanner { root_abs_path: Arc, root_canonical_path: PathBuf, mut abs_paths: Vec, + expand: bool, scan_queue_tx: Option>, ) -> Option>> { let doing_recursive_update = scan_queue_tx.is_some(); @@ -3456,6 +3487,9 @@ impl BackgroundScanner { } let fs_entry = state.insert_entry(fs_entry, self.fs.as_ref()); + if expand { + state.expanded_dirs.insert(fs_entry.id); + } if let Some(scan_queue_tx) = &scan_queue_tx { let mut ancestor_inodes = state.snapshot.ancestor_inodes_for_path(&path); diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rs index 83f416d784..92eded0a99 100644 --- a/crates/project/src/worktree_tests.rs +++ b/crates/project/src/worktree_tests.rs @@ -160,7 +160,7 @@ async fn test_descendent_entries(cx: &mut TestAppContext) { // Expand gitignored directory. tree.update(cx, |tree, cx| { let tree = tree.as_local_mut().unwrap(); - tree.expand_dir(tree.entry_for_path("i/j").unwrap().id, cx) + tree.expand_entry_for_path("i/j".as_ref(), cx) }) .recv() .await; @@ -341,7 +341,7 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { // Expand one of the symlinked directories. tree.update(cx, |tree, cx| { let tree = tree.as_local_mut().unwrap(); - tree.expand_dir(tree.entry_for_path("deps/dep-dir3").unwrap().id, cx) + tree.expand_entry_for_path("deps/dep-dir3".as_ref(), cx) }) .recv() .await; @@ -370,7 +370,7 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { // Expand a subdirectory of one of the symlinked directories. tree.update(cx, |tree, cx| { let tree = tree.as_local_mut().unwrap(); - tree.expand_dir(tree.entry_for_path("deps/dep-dir3/src").unwrap().id, cx) + tree.expand_entry_for_path("deps/dep-dir3/src".as_ref(), cx) }) .recv() .await; @@ -398,6 +398,98 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { }); } +#[gpui::test] +async fn test_open_gitignored_files(cx: &mut TestAppContext) { + let fs = FakeFs::new(cx.background()); + fs.insert_tree( + "/root", + json!({ + ".gitignore": "node_modules\n", + "node_modules": { + "a": { + "a1.js": "a1", + "a2.js": "a2", + }, + "b": { + "b1.js": "b1", + "b2.js": "b2", + }, + }, + "src": { + "x.js": "", + "y.js": "", + }, + }), + ) + .await; + + let client = cx.read(|cx| Client::new(FakeHttpClient::with_404_response(), cx)); + let tree = Worktree::local( + client, + Path::new("/root"), + true, + fs.clone(), + Default::default(), + &mut cx.to_async(), + ) + .await + .unwrap(); + + cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete()) + .await; + + tree.read_with(cx, |tree, _| { + assert_eq!( + tree.entries(true) + .map(|entry| (entry.path.as_ref(), entry.is_ignored)) + .collect::>(), + vec![ + (Path::new(""), false), + (Path::new(".gitignore"), false), + (Path::new("node_modules"), true), + (Path::new("src"), false), + (Path::new("src/x.js"), false), + (Path::new("src/y.js"), false), + ] + ); + }); + + let buffer = tree + .update(cx, |tree, cx| { + tree.as_local_mut() + .unwrap() + .load_buffer(0, "node_modules/b/b1.js".as_ref(), cx) + }) + .await + .unwrap(); + + tree.read_with(cx, |tree, cx| { + assert_eq!( + tree.entries(true) + .map(|entry| (entry.path.as_ref(), entry.is_ignored)) + .collect::>(), + vec![ + (Path::new(""), false), + (Path::new(".gitignore"), false), + (Path::new("node_modules"), true), + (Path::new("node_modules/a"), true), + (Path::new("node_modules/b"), true), + (Path::new("node_modules/b/b1.js"), true), + (Path::new("node_modules/b/b2.js"), true), + (Path::new("src"), false), + (Path::new("src/x.js"), false), + (Path::new("src/y.js"), false), + ] + ); + + let buffer = buffer.read(cx); + assert_eq!( + buffer.file().unwrap().path().as_ref(), + Path::new("node_modules/b/b1.js") + ); + }); +} + #[gpui::test] async fn test_rescan_with_gitignore(cx: &mut TestAppContext) { // .gitignores are handled explicitly by Zed and do not use the git @@ -435,7 +527,7 @@ async fn test_rescan_with_gitignore(cx: &mut TestAppContext) { tree.update(cx, |tree, cx| { let tree = tree.as_local_mut().unwrap(); - tree.expand_dir(tree.entry_for_path("ignored-dir").unwrap().id, cx) + tree.expand_entry_for_path("ignored-dir".as_ref(), cx) }) .recv() .await; From 4424dafcd789ec8dde248c07e6a8666a60265628 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 19 Jun 2023 12:20:54 -0700 Subject: [PATCH 128/215] Fix expansion of ancestor directories when refreshing a path --- crates/fs/src/fs.rs | 9 +- crates/project/src/worktree.rs | 263 +++++++++++++-------------- crates/project/src/worktree_tests.rs | 168 +++++++++++++---- 3 files changed, 265 insertions(+), 175 deletions(-) diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index f5abe35dbd..e487b64c4e 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -388,6 +388,7 @@ struct FakeFsState { event_txs: Vec>>, events_paused: bool, buffered_events: Vec, + read_dir_call_count: usize, } #[cfg(any(test, feature = "test-support"))] @@ -536,6 +537,7 @@ impl FakeFs { event_txs: Default::default(), buffered_events: Vec::new(), events_paused: false, + read_dir_call_count: 0, }), }) } @@ -772,6 +774,10 @@ impl FakeFs { result } + pub fn read_dir_call_count(&self) -> usize { + self.state.lock().read_dir_call_count + } + async fn simulate_random_delay(&self) { self.executor .upgrade() @@ -1146,7 +1152,8 @@ impl Fs for FakeFs { ) -> Result>>>> { self.simulate_random_delay().await; let path = normalize_path(path); - let state = self.state.lock(); + let mut state = self.state.lock(); + state.read_dir_call_count += 1; let entry = state.read_path(&path)?; let mut entry = entry.lock(); let children = entry.dir_entries(&path)?; diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index bbf63901d1..76a1030134 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -84,15 +84,9 @@ pub struct LocalWorktree { visible: bool, } -enum ScanRequest { - RescanPaths { - relative_paths: Vec>, - done: barrier::Sender, - }, - ExpandPath { - path: Arc, - done: barrier::Sender, - }, +struct ScanRequest { + relative_paths: Vec>, + done: barrier::Sender, } pub struct RemoteWorktree { @@ -226,6 +220,7 @@ pub struct LocalSnapshot { struct BackgroundScannerState { snapshot: LocalSnapshot, expanded_dirs: HashSet, + expanded_paths: HashSet>, /// The ids of all of the entries that were removed from the snapshot /// as part of the current update. These entry ids may be re-used /// if the same inode is discovered at a new path, or if the given @@ -882,14 +877,11 @@ impl LocalWorktree { let path = Arc::from(path); let abs_path = self.absolutize(&path); let fs = self.fs.clone(); - let expand = path - .parent() - .map(|path| self.expand_entry_for_path(path, cx)); + let entry = self.refresh_entry(path.clone(), None, cx); - cx.spawn(|this, mut cx| async move { - if let Some(mut expand) = expand { - expand.recv().await; - } + cx.spawn(|this, cx| async move { + let text = fs.load(&abs_path).await?; + let entry = entry.await?; let mut index_task = None; let snapshot = this.read_with(&cx, |this, _| this.as_local().unwrap().snapshot()); @@ -904,21 +896,12 @@ impl LocalWorktree { } } - let text = fs.load(&abs_path).await?; - let diff_base = if let Some(index_task) = index_task { index_task.await } else { None }; - // Eagerly populate the snapshot with an updated entry for the loaded file - let entry = this - .update(&mut cx, |this, cx| { - this.as_local().unwrap().refresh_entry(path, None, cx) - }) - .await?; - Ok(( File { entry_id: entry.id, @@ -1082,7 +1065,7 @@ impl LocalWorktree { this.as_local_mut() .unwrap() .scan_requests_tx - .try_send(ScanRequest::RescanPaths { + .try_send(ScanRequest { relative_paths: vec![path], done: tx, }) @@ -1159,8 +1142,8 @@ impl LocalWorktree { let (tx, rx) = barrier::channel(); if let Some(entry) = self.entry_for_id(entry_id) { self.scan_requests_tx - .try_send(ScanRequest::ExpandPath { - path: entry.path.clone(), + .try_send(ScanRequest { + relative_paths: vec![entry.path.clone()], done: tx, }) .ok(); @@ -1168,15 +1151,11 @@ impl LocalWorktree { rx } - pub fn expand_entry_for_path( - &self, - path: impl Into>, - _cx: &mut ModelContext, - ) -> barrier::Receiver { + pub fn refresh_entries_for_paths(&self, paths: Vec>) -> barrier::Receiver { let (tx, rx) = barrier::channel(); self.scan_requests_tx - .try_send(ScanRequest::ExpandPath { - path: path.into(), + .try_send(ScanRequest { + relative_paths: paths, done: tx, }) .ok(); @@ -1189,20 +1168,14 @@ impl LocalWorktree { old_path: Option>, cx: &mut ModelContext, ) -> Task> { - let path_changes_tx = self.scan_requests_tx.clone(); + let paths = if let Some(old_path) = old_path.as_ref() { + vec![old_path.clone(), path.clone()] + } else { + vec![path.clone()] + }; + let mut refresh = self.refresh_entries_for_paths(paths); cx.spawn_weak(move |this, mut cx| async move { - let relative_paths = if let Some(old_path) = old_path.as_ref() { - vec![old_path.clone(), path.clone()] - } else { - vec![path.clone()] - }; - - let (tx, mut rx) = barrier::channel(); - path_changes_tx.try_send(ScanRequest::RescanPaths { - relative_paths, - done: tx, - })?; - rx.recv().await; + refresh.recv().await; this.upgrade(&cx) .ok_or_else(|| anyhow!("worktree was dropped"))? .update(&mut cx, |this, _| { @@ -2138,9 +2111,14 @@ impl LocalSnapshot { ignore_stack } -} -impl LocalSnapshot { + #[cfg(test)] + pub(crate) fn expanded_entries(&self) -> impl Iterator { + self.entries_by_path + .cursor::<()>() + .filter(|entry| entry.kind == EntryKind::Dir && (entry.is_external || entry.is_ignored)) + } + #[cfg(test)] pub fn check_invariants(&self) { assert_eq!( @@ -2217,6 +2195,14 @@ impl LocalSnapshot { } impl BackgroundScannerState { + fn is_path_expanded(&self, path: &Path) -> bool { + self.expanded_paths.iter().any(|p| p.starts_with(path)) + || self + .snapshot + .entry_for_path(&path) + .map_or(true, |entry| self.expanded_dirs.contains(&entry.id)) + } + fn reuse_entry_id(&mut self, entry: &mut Entry) { if let Some(removed_entry_id) = self.removed_entry_ids.remove(&entry.inode) { entry.id = removed_entry_id; @@ -2271,6 +2257,7 @@ impl BackgroundScannerState { .insert(abs_parent_path, (ignore, false)); } + self.expanded_dirs.insert(parent_entry.id); let mut entries_by_path_edits = vec![Edit::Insert(parent_entry)]; let mut entries_by_id_edits = Vec::new(); let mut dotgit_path = None; @@ -2883,6 +2870,7 @@ impl BackgroundScanner { expanded_dirs: Default::default(), removed_entry_ids: Default::default(), changed_paths: Default::default(), + expanded_paths: Default::default(), }), phase: BackgroundScannerPhase::InitialScan, } @@ -2986,7 +2974,7 @@ impl BackgroundScanner { } async fn process_scan_request(&self, request: ScanRequest) -> bool { - let root_path = self.state.lock().snapshot.abs_path.clone(); + let root_path = self.expand_paths(&request.relative_paths).await; let root_canonical_path = match self.fs.canonicalize(&root_path).await { Ok(path) => path, Err(err) => { @@ -2995,57 +2983,20 @@ impl BackgroundScanner { } }; - match request { - ScanRequest::RescanPaths { - relative_paths, - done, - } => { - let abs_paths = relative_paths - .into_iter() - .map(|path| { - if path.file_name().is_some() { - root_canonical_path.join(path) - } else { - root_canonical_path.clone() - } - }) - .collect::>(); - self.reload_entries_for_paths( - root_path, - root_canonical_path, - abs_paths, - false, - None, - ) - .await; - self.send_status_update(false, Some(done)) - } - ScanRequest::ExpandPath { path, done } => { - let (scan_job_tx, mut scan_job_rx) = channel::unbounded(); - let mut abs_path = root_canonical_path.clone(); - for component in path.iter() { - abs_path.push(component); - self.reload_entries_for_paths( - root_path.clone(), - root_canonical_path.clone(), - vec![abs_path.clone()], - true, - Some(scan_job_tx.clone()), - ) - .await; + let abs_paths = request + .relative_paths + .into_iter() + .map(|path| { + if path.file_name().is_some() { + root_canonical_path.join(path) + } else { + root_canonical_path.clone() } - drop(scan_job_tx); - - // Scan the expanded directories serially. This is ok, because only - // the direct ancestors of the expanded path need to be scanned. - while let Some(job) = scan_job_rx.next().await { - self.scan_dir(&job).await.log_err(); - } - - self.send_status_update(false, Some(done)); - true - } - } + }) + .collect::>(); + self.reload_entries_for_paths(root_path, root_canonical_path, abs_paths, None) + .await; + self.send_status_update(false, Some(request.done)) } async fn process_events(&mut self, abs_paths: Vec) { @@ -3060,15 +3011,8 @@ impl BackgroundScanner { let (scan_job_tx, scan_job_rx) = channel::unbounded(); let paths = self - .reload_entries_for_paths( - root_path, - root_canonical_path, - abs_paths, - false, - Some(scan_job_tx.clone()), - ) + .reload_entries_for_paths(root_path, root_canonical_path, abs_paths, Some(scan_job_tx)) .await; - drop(scan_job_tx); self.scan_dirs(false, scan_job_rx).await; self.update_ignore_statuses().await; @@ -3108,6 +3052,46 @@ impl BackgroundScanner { self.send_status_update(false, None); } + async fn expand_paths(&self, paths: &[Arc]) -> Arc { + let root_path; + let (scan_job_tx, mut scan_job_rx) = channel::unbounded(); + { + let mut state = self.state.lock(); + root_path = state.snapshot.abs_path.clone(); + for path in paths { + for ancestor in path.ancestors() { + if let Some(entry) = state.snapshot.entry_for_path(ancestor) { + if entry.kind == EntryKind::PendingDir { + let abs_path = root_path.join(ancestor); + let ignore_stack = + state.snapshot.ignore_stack_for_abs_path(&abs_path, true); + let ancestor_inodes = + state.snapshot.ancestor_inodes_for_path(&ancestor); + scan_job_tx + .try_send(ScanJob { + abs_path: abs_path.into(), + path: ancestor.into(), + ignore_stack, + scan_queue: scan_job_tx.clone(), + ancestor_inodes, + is_external: entry.is_external, + }) + .unwrap(); + state.expanded_paths.insert(path.clone()); + break; + } + } + } + } + drop(scan_job_tx); + } + while let Some(job) = scan_job_rx.next().await { + self.scan_dir(&job).await.log_err(); + } + self.state.lock().expanded_paths.clear(); + root_path + } + async fn scan_dirs( &self, enable_progress_updates: bool, @@ -3376,10 +3360,7 @@ impl BackgroundScanner { // If a subdirectory is ignored, or is external to the worktree, don't scan // it unless it is marked as expanded. if (new_job.is_external || new_job.ignore_stack.is_all()) - && !state - .snapshot - .entry_for_path(&new_job.path) - .map_or(true, |entry| state.expanded_dirs.contains(&entry.id)) + && !state.is_path_expanded(&new_job.path) { log::debug!("defer scanning directory {:?}", new_job.path); continue; @@ -3399,12 +3380,40 @@ impl BackgroundScanner { root_abs_path: Arc, root_canonical_path: PathBuf, mut abs_paths: Vec, - expand: bool, scan_queue_tx: Option>, ) -> Option>> { - let doing_recursive_update = scan_queue_tx.is_some(); + let mut event_paths = Vec::>::with_capacity(abs_paths.len()); abs_paths.sort_unstable(); abs_paths.dedup_by(|a, b| a.starts_with(&b)); + { + let state = self.state.lock(); + abs_paths.retain(|abs_path| { + let path = if let Ok(path) = abs_path.strip_prefix(&root_canonical_path) { + path + } else { + log::error!( + "unexpected event {:?} for root path {:?}", + abs_path, + root_canonical_path + ); + return false; + }; + + if let Some(parent) = path.parent() { + if state + .snapshot + .entry_for_path(parent) + .map_or(true, |entry| entry.kind != EntryKind::Dir) + { + log::info!("ignoring event within unloaded directory {:?}", parent); + return false; + } + } + + event_paths.push(path.into()); + return true; + }); + } let metadata = futures::future::join_all( abs_paths @@ -3424,6 +3433,7 @@ impl BackgroundScanner { let mut state = self.state.lock(); let snapshot = &mut state.snapshot; + let doing_recursive_update = scan_queue_tx.is_some(); let is_idle = snapshot.completed_scan_id == snapshot.scan_id; snapshot.scan_id += 1; if is_idle && !doing_recursive_update { @@ -3433,25 +3443,13 @@ impl BackgroundScanner { // Remove any entries for paths that no longer exist or are being recursively // refreshed. Do this before adding any new entries, so that renames can be // detected regardless of the order of the paths. - let mut event_paths = Vec::>::with_capacity(abs_paths.len()); - let mut event_metadata = Vec::<_>::with_capacity(abs_paths.len()); - for (abs_path, metadata) in abs_paths.iter().zip(metadata.iter()) { - if let Ok(path) = abs_path.strip_prefix(&root_canonical_path) { - if matches!(metadata, Ok(None)) || doing_recursive_update { - state.remove_path(path); - } - event_paths.push(path.into()); - event_metadata.push(metadata); - } else { - log::error!( - "unexpected event {:?} for root path {:?}", - abs_path, - root_canonical_path - ); + for (path, metadata) in event_paths.iter().zip(metadata.iter()) { + if matches!(metadata, Ok(None)) || doing_recursive_update { + state.remove_path(path); } } - for (path, metadata) in event_paths.iter().cloned().zip(event_metadata.into_iter()) { + for (path, metadata) in event_paths.iter().cloned().zip(metadata.into_iter()) { let abs_path: Arc = root_abs_path.join(&path).into(); match metadata { @@ -3487,9 +3485,6 @@ impl BackgroundScanner { } let fs_entry = state.insert_entry(fs_entry, self.fs.as_ref()); - if expand { - state.expanded_dirs.insert(fs_entry.id); - } if let Some(scan_queue_tx) = &scan_queue_tx { let mut ancestor_inodes = state.snapshot.ancestor_inodes_for_path(&path); diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rs index 92eded0a99..0b8e02dc49 100644 --- a/crates/project/src/worktree_tests.rs +++ b/crates/project/src/worktree_tests.rs @@ -1,6 +1,6 @@ use crate::{ worktree::{Event, Snapshot, WorktreeHandle}, - EntryKind, PathChange, Worktree, + Entry, EntryKind, PathChange, Worktree, }; use anyhow::Result; use client::Client; @@ -158,9 +158,10 @@ async fn test_descendent_entries(cx: &mut TestAppContext) { }); // Expand gitignored directory. - tree.update(cx, |tree, cx| { - let tree = tree.as_local_mut().unwrap(); - tree.expand_entry_for_path("i/j".as_ref(), cx) + tree.read_with(cx, |tree, _| { + tree.as_local() + .unwrap() + .refresh_entries_for_paths(vec![Path::new("i/j").into()]) }) .recv() .await; @@ -336,12 +337,18 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { (Path::new("src/b.rs"), false), ] ); + + assert_eq!( + tree.entry_for_path("deps/dep-dir2").unwrap().kind, + EntryKind::PendingDir + ); }); // Expand one of the symlinked directories. - tree.update(cx, |tree, cx| { - let tree = tree.as_local_mut().unwrap(); - tree.expand_entry_for_path("deps/dep-dir3".as_ref(), cx) + tree.read_with(cx, |tree, _| { + tree.as_local() + .unwrap() + .refresh_entries_for_paths(vec![Path::new("deps/dep-dir3").into()]) }) .recv() .await; @@ -368,9 +375,10 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { }); // Expand a subdirectory of one of the symlinked directories. - tree.update(cx, |tree, cx| { - let tree = tree.as_local_mut().unwrap(); - tree.expand_entry_for_path("deps/dep-dir3/src".as_ref(), cx) + tree.read_with(cx, |tree, _| { + tree.as_local() + .unwrap() + .refresh_entries_for_paths(vec![Path::new("deps/dep-dir3/src").into()]) }) .recv() .await; @@ -405,17 +413,19 @@ async fn test_open_gitignored_files(cx: &mut TestAppContext) { "/root", json!({ ".gitignore": "node_modules\n", - "node_modules": { - "a": { - "a1.js": "a1", - "a2.js": "a2", - }, - "b": { - "b1.js": "b1", - "b2.js": "b2", + "one": { + "node_modules": { + "a": { + "a1.js": "a1", + "a2.js": "a2", + }, + "b": { + "b1.js": "b1", + "b2.js": "b2", + }, }, }, - "src": { + "two": { "x.js": "", "y.js": "", }, @@ -446,19 +456,23 @@ async fn test_open_gitignored_files(cx: &mut TestAppContext) { vec![ (Path::new(""), false), (Path::new(".gitignore"), false), - (Path::new("node_modules"), true), - (Path::new("src"), false), - (Path::new("src/x.js"), false), - (Path::new("src/y.js"), false), + (Path::new("one"), false), + (Path::new("one/node_modules"), true), + (Path::new("two"), false), + (Path::new("two/x.js"), false), + (Path::new("two/y.js"), false), ] ); }); + // Open a file that is nested inside of a gitignored directory that + // has not yet been expanded. + let prev_read_dir_count = fs.read_dir_call_count(); let buffer = tree .update(cx, |tree, cx| { tree.as_local_mut() .unwrap() - .load_buffer(0, "node_modules/b/b1.js".as_ref(), cx) + .load_buffer(0, "one/node_modules/b/b1.js".as_ref(), cx) }) .await .unwrap(); @@ -471,22 +485,68 @@ async fn test_open_gitignored_files(cx: &mut TestAppContext) { vec![ (Path::new(""), false), (Path::new(".gitignore"), false), - (Path::new("node_modules"), true), - (Path::new("node_modules/a"), true), - (Path::new("node_modules/b"), true), - (Path::new("node_modules/b/b1.js"), true), - (Path::new("node_modules/b/b2.js"), true), - (Path::new("src"), false), - (Path::new("src/x.js"), false), - (Path::new("src/y.js"), false), + (Path::new("one"), false), + (Path::new("one/node_modules"), true), + (Path::new("one/node_modules/a"), true), + (Path::new("one/node_modules/b"), true), + (Path::new("one/node_modules/b/b1.js"), true), + (Path::new("one/node_modules/b/b2.js"), true), + (Path::new("two"), false), + (Path::new("two/x.js"), false), + (Path::new("two/y.js"), false), ] ); - let buffer = buffer.read(cx); assert_eq!( - buffer.file().unwrap().path().as_ref(), - Path::new("node_modules/b/b1.js") + buffer.read(cx).file().unwrap().path().as_ref(), + Path::new("one/node_modules/b/b1.js") ); + + // Only the newly-expanded directories are scanned. + assert_eq!(fs.read_dir_call_count() - prev_read_dir_count, 2); + }); + + // Open another file in a different subdirectory of the same + // gitignored directory. + let prev_read_dir_count = fs.read_dir_call_count(); + let buffer = tree + .update(cx, |tree, cx| { + tree.as_local_mut() + .unwrap() + .load_buffer(0, "one/node_modules/a/a2.js".as_ref(), cx) + }) + .await + .unwrap(); + + tree.read_with(cx, |tree, cx| { + assert_eq!( + tree.entries(true) + .map(|entry| (entry.path.as_ref(), entry.is_ignored)) + .collect::>(), + vec![ + (Path::new(""), false), + (Path::new(".gitignore"), false), + (Path::new("one"), false), + (Path::new("one/node_modules"), true), + (Path::new("one/node_modules/a"), true), + (Path::new("one/node_modules/a/a1.js"), true), + (Path::new("one/node_modules/a/a2.js"), true), + (Path::new("one/node_modules/b"), true), + (Path::new("one/node_modules/b/b1.js"), true), + (Path::new("one/node_modules/b/b2.js"), true), + (Path::new("two"), false), + (Path::new("two/x.js"), false), + (Path::new("two/y.js"), false), + ] + ); + + assert_eq!( + buffer.read(cx).file().unwrap().path().as_ref(), + Path::new("one/node_modules/a/a2.js") + ); + + // Only the newly-expanded directory is scanned. + assert_eq!(fs.read_dir_call_count() - prev_read_dir_count, 1); }); } @@ -525,9 +585,10 @@ async fn test_rescan_with_gitignore(cx: &mut TestAppContext) { cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete()) .await; - tree.update(cx, |tree, cx| { - let tree = tree.as_local_mut().unwrap(); - tree.expand_entry_for_path("ignored-dir".as_ref(), cx) + tree.read_with(cx, |tree, _| { + tree.as_local() + .unwrap() + .refresh_entries_for_paths(vec![Path::new("ignored-dir").into()]) }) .recv() .await; @@ -868,8 +929,13 @@ async fn test_random_worktree_changes(cx: &mut TestAppContext, mut rng: StdRng) log::info!("quiescing"); fs.as_fake().flush_events(usize::MAX); cx.foreground().run_until_parked(); + let snapshot = worktree.read_with(cx, |tree, _| tree.as_local().unwrap().snapshot()); snapshot.check_invariants(); + let expanded_paths = snapshot + .expanded_entries() + .map(|e| e.path.clone()) + .collect::>(); { let new_worktree = Worktree::local( @@ -885,6 +951,14 @@ async fn test_random_worktree_changes(cx: &mut TestAppContext, mut rng: StdRng) new_worktree .update(cx, |tree, _| tree.as_local_mut().unwrap().scan_complete()) .await; + new_worktree + .update(cx, |tree, _| { + tree.as_local_mut() + .unwrap() + .refresh_entries_for_paths(expanded_paths) + }) + .recv() + .await; let new_snapshot = new_worktree.read_with(cx, |tree, _| tree.as_local().unwrap().snapshot()); assert_eq!( @@ -901,11 +975,25 @@ async fn test_random_worktree_changes(cx: &mut TestAppContext, mut rng: StdRng) } assert_eq!( - prev_snapshot.entries(true).collect::>(), - snapshot.entries(true).collect::>(), + prev_snapshot + .entries(true) + .map(ignore_pending_dir) + .collect::>(), + snapshot + .entries(true) + .map(ignore_pending_dir) + .collect::>(), "wrong updates after snapshot {i}: {updates:#?}", ); } + + fn ignore_pending_dir(entry: &Entry) -> Entry { + let mut entry = entry.clone(); + if entry.kind == EntryKind::PendingDir { + entry.kind = EntryKind::Dir + } + entry + } } // The worktree's `UpdatedEntries` event can be used to follow along with From d3477f75ac6cce63d7631107b2abd9bc334c12bd Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 20 Jun 2023 16:14:47 -0700 Subject: [PATCH 129/215] Fix reloading of git repositories Also, clean up logic for reloading git repositories. --- crates/project/src/worktree.rs | 372 +++++++++++++++------------------ 1 file changed, 164 insertions(+), 208 deletions(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 76a1030134..d3ff0e93d2 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -239,13 +239,6 @@ pub struct LocalRepositoryEntry { pub(crate) git_dir_path: Arc, } -impl LocalRepositoryEntry { - // Note that this path should be relative to the worktree root. - pub(crate) fn in_dot_git(&self, path: &Path) -> bool { - path.starts_with(self.git_dir_path.as_ref()) - } -} - impl Deref for LocalSnapshot { type Target = Snapshot; @@ -1850,15 +1843,6 @@ impl LocalSnapshot { Some((path, self.git_repositories.get(&repo.work_directory_id())?)) } - pub(crate) fn repo_for_metadata( - &self, - path: &Path, - ) -> Option<(&ProjectEntryId, &LocalRepositoryEntry)> { - self.git_repositories - .iter() - .find(|(_, repo)| repo.in_dot_git(path)) - } - fn build_update( &self, project_id: u64, @@ -1994,57 +1978,6 @@ impl LocalSnapshot { entry } - #[must_use = "Changed paths must be used for diffing later"] - fn build_repo(&mut self, parent_path: Arc, fs: &dyn Fs) -> Option>> { - let abs_path = self.abs_path.join(&parent_path); - let work_dir: Arc = parent_path.parent().unwrap().into(); - - // Guard against repositories inside the repository metadata - if work_dir - .components() - .find(|component| component.as_os_str() == *DOT_GIT) - .is_some() - { - return None; - }; - - let work_dir_id = self - .entry_for_path(work_dir.clone()) - .map(|entry| entry.id)?; - - if self.git_repositories.get(&work_dir_id).is_some() { - return None; - } - - let repo = fs.open_repo(abs_path.as_path())?; - let work_directory = RepositoryWorkDirectory(work_dir.clone()); - - let repo_lock = repo.lock(); - - self.repository_entries.insert( - work_directory.clone(), - RepositoryEntry { - work_directory: work_dir_id.into(), - branch: repo_lock.branch_name().map(Into::into), - }, - ); - - let changed_paths = self.scan_statuses(repo_lock.deref(), &work_directory); - - drop(repo_lock); - - self.git_repositories.insert( - work_dir_id, - LocalRepositoryEntry { - git_dir_scan_id: 0, - repo_ptr: repo, - git_dir_path: parent_path.clone(), - }, - ); - - Some(changed_paths) - } - #[must_use = "Changed paths must be used for diffing later"] fn scan_statuses( &mut self, @@ -2215,10 +2148,7 @@ impl BackgroundScannerState { self.reuse_entry_id(&mut entry); let entry = self.snapshot.insert_entry(entry, fs); if entry.path.file_name() == Some(&DOT_GIT) { - let changed_paths = self.snapshot.build_repo(entry.path.clone(), fs); - if let Some(changed_paths) = changed_paths { - util::extend_sorted(&mut self.changed_paths, changed_paths, usize::MAX, Ord::cmp) - } + self.build_repository(entry.path.clone(), fs); } entry } @@ -2283,10 +2213,7 @@ impl BackgroundScannerState { self.snapshot.entries_by_id.edit(entries_by_id_edits, &()); if let Some(dotgit_path) = dotgit_path { - let changed_paths = self.snapshot.build_repo(dotgit_path, fs); - if let Some(changed_paths) = changed_paths { - util::extend_sorted(&mut self.changed_paths, changed_paths, usize::MAX, Ord::cmp) - } + self.build_repository(dotgit_path, fs); } if let Err(ix) = self.changed_paths.binary_search(parent_path) { self.changed_paths.insert(ix, parent_path.clone()); @@ -2326,6 +2253,134 @@ impl BackgroundScannerState { } } } + + fn reload_repositories(&mut self, changed_paths: &[Arc], fs: &dyn Fs) { + let scan_id = self.snapshot.scan_id; + + // Find each of the .git directories that contain any of the given paths. + let mut prev_dot_git_dir = None; + for changed_path in changed_paths { + let Some(dot_git_dir) = changed_path + .ancestors() + .find(|ancestor| ancestor.file_name() == Some(&*DOT_GIT)) else { + continue; + }; + + // Avoid processing the same repository multiple times, if multiple paths + // within it have changed. + if prev_dot_git_dir == Some(dot_git_dir) { + continue; + } + prev_dot_git_dir = Some(dot_git_dir); + + // If there is already a repository for this .git directory, reload + // the status for all of its files. + let repository = self + .snapshot + .git_repositories + .iter() + .find_map(|(entry_id, repo)| { + (repo.git_dir_path.as_ref() == dot_git_dir).then(|| (*entry_id, repo.clone())) + }); + match repository { + None => { + self.build_repository(dot_git_dir.into(), fs); + } + Some((entry_id, repository)) => { + if repository.git_dir_scan_id == scan_id { + continue; + } + let Some(work_dir) = self + .snapshot + .entry_for_id(entry_id) + .map(|entry| RepositoryWorkDirectory(entry.path.clone())) else { continue }; + + let repository = repository.repo_ptr.lock(); + let branch = repository.branch_name(); + repository.reload_index(); + + self.snapshot + .git_repositories + .update(&entry_id, |entry| entry.git_dir_scan_id = scan_id); + self.snapshot + .snapshot + .repository_entries + .update(&work_dir, |entry| entry.branch = branch.map(Into::into)); + + let changed_paths = self.snapshot.scan_statuses(&*repository, &work_dir); + util::extend_sorted( + &mut self.changed_paths, + changed_paths, + usize::MAX, + Ord::cmp, + ) + } + } + } + + // Remove any git repositories whose .git entry no longer exists. + let mut snapshot = &mut self.snapshot; + let mut repositories = mem::take(&mut snapshot.git_repositories); + let mut repository_entries = mem::take(&mut snapshot.repository_entries); + repositories.retain(|work_directory_id, _| { + snapshot + .entry_for_id(*work_directory_id) + .map_or(false, |entry| { + snapshot.entry_for_path(entry.path.join(*DOT_GIT)).is_some() + }) + }); + repository_entries.retain(|_, entry| repositories.get(&entry.work_directory.0).is_some()); + snapshot.git_repositories = repositories; + snapshot.repository_entries = repository_entries; + } + + fn build_repository(&mut self, dot_git_path: Arc, fs: &dyn Fs) -> Option<()> { + let work_dir_path: Arc = dot_git_path.parent().unwrap().into(); + + // Guard against repositories inside the repository metadata + if work_dir_path.iter().any(|component| component == *DOT_GIT) { + return None; + }; + + let work_dir_id = self + .snapshot + .entry_for_path(work_dir_path.clone()) + .map(|entry| entry.id)?; + + if self.snapshot.git_repositories.get(&work_dir_id).is_some() { + return None; + } + + let abs_path = self.snapshot.abs_path.join(&dot_git_path); + let repository = fs.open_repo(abs_path.as_path())?; + let work_directory = RepositoryWorkDirectory(work_dir_path.clone()); + + let repo_lock = repository.lock(); + self.snapshot.repository_entries.insert( + work_directory.clone(), + RepositoryEntry { + work_directory: work_dir_id.into(), + branch: repo_lock.branch_name().map(Into::into), + }, + ); + + let changed_paths = self + .snapshot + .scan_statuses(repo_lock.deref(), &work_directory); + drop(repo_lock); + + self.snapshot.git_repositories.insert( + work_dir_id, + LocalRepositoryEntry { + git_dir_scan_id: 0, + repo_ptr: repository, + git_dir_path: dot_git_path.clone(), + }, + ); + + util::extend_sorted(&mut self.changed_paths, changed_paths, usize::MAX, Ord::cmp); + Some(()) + } } async fn build_gitignore(abs_path: &Path, fs: &dyn Fs) -> Result { @@ -3019,34 +3074,8 @@ impl BackgroundScanner { { let mut state = self.state.lock(); - - if let Some(paths) = paths { - for path in paths { - self.reload_git_repo(&path, &mut *state, self.fs.as_ref()); - } - } - - let mut snapshot = &mut state.snapshot; - - let mut git_repositories = mem::take(&mut snapshot.git_repositories); - git_repositories.retain(|work_directory_id, _| { - snapshot - .entry_for_id(*work_directory_id) - .map_or(false, |entry| { - snapshot.entry_for_path(entry.path.join(*DOT_GIT)).is_some() - }) - }); - snapshot.git_repositories = git_repositories; - - let mut git_repository_entries = mem::take(&mut snapshot.snapshot.repository_entries); - git_repository_entries.retain(|_, entry| { - snapshot - .git_repositories - .get(&entry.work_directory.0) - .is_some() - }); - snapshot.snapshot.repository_entries = git_repository_entries; - snapshot.completed_scan_id = snapshot.scan_id; + state.reload_repositories(&paths, self.fs.as_ref()); + state.snapshot.completed_scan_id = state.snapshot.scan_id; } self.send_status_update(false, None); @@ -3381,39 +3410,23 @@ impl BackgroundScanner { root_canonical_path: PathBuf, mut abs_paths: Vec, scan_queue_tx: Option>, - ) -> Option>> { + ) -> Vec> { let mut event_paths = Vec::>::with_capacity(abs_paths.len()); abs_paths.sort_unstable(); abs_paths.dedup_by(|a, b| a.starts_with(&b)); - { - let state = self.state.lock(); - abs_paths.retain(|abs_path| { - let path = if let Ok(path) = abs_path.strip_prefix(&root_canonical_path) { - path - } else { - log::error!( - "unexpected event {:?} for root path {:?}", - abs_path, - root_canonical_path - ); - return false; - }; - - if let Some(parent) = path.parent() { - if state - .snapshot - .entry_for_path(parent) - .map_or(true, |entry| entry.kind != EntryKind::Dir) - { - log::info!("ignoring event within unloaded directory {:?}", parent); - return false; - } - } - + abs_paths.retain(|abs_path| { + if let Ok(path) = abs_path.strip_prefix(&root_canonical_path) { event_paths.push(path.into()); - return true; - }); - } + true + } else { + log::error!( + "unexpected event {:?} for root path {:?}", + abs_path, + root_canonical_path + ); + false + } + }); let metadata = futures::future::join_all( abs_paths @@ -3433,8 +3446,8 @@ impl BackgroundScanner { let mut state = self.state.lock(); let snapshot = &mut state.snapshot; - let doing_recursive_update = scan_queue_tx.is_some(); let is_idle = snapshot.completed_scan_id == snapshot.scan_id; + let doing_recursive_update = scan_queue_tx.is_some(); snapshot.scan_id += 1; if is_idle && !doing_recursive_update { snapshot.completed_scan_id = snapshot.scan_id; @@ -3449,7 +3462,21 @@ impl BackgroundScanner { } } - for (path, metadata) in event_paths.iter().cloned().zip(metadata.into_iter()) { + for (path, metadata) in event_paths.iter().zip(metadata.iter()) { + if let (Some(parent), true) = (path.parent(), doing_recursive_update) { + if state + .snapshot + .entry_for_path(parent) + .map_or(true, |entry| entry.kind != EntryKind::Dir) + { + log::debug!( + "ignoring event {path:?} within unloaded directory {:?}", + parent + ); + continue; + } + } + let abs_path: Arc = root_abs_path.join(&path).into(); match metadata { @@ -3460,7 +3487,7 @@ impl BackgroundScanner { let mut fs_entry = Entry::new( path.clone(), - &metadata, + metadata, self.next_entry_id.as_ref(), state.snapshot.root_char_bag, ); @@ -3492,7 +3519,7 @@ impl BackgroundScanner { ancestor_inodes.insert(metadata.inode); smol::block_on(scan_queue_tx.send(ScanJob { abs_path, - path, + path: path.clone(), ignore_stack, ancestor_inodes, is_external: fs_entry.is_external, @@ -3519,7 +3546,7 @@ impl BackgroundScanner { Ord::cmp, ); - Some(event_paths) + event_paths } fn remove_repo_path(&self, path: &Path, snapshot: &mut LocalSnapshot) -> Option<()> { @@ -3544,77 +3571,6 @@ impl BackgroundScanner { Some(()) } - fn reload_git_repo( - &self, - path: &Path, - state: &mut BackgroundScannerState, - fs: &dyn Fs, - ) -> Option<()> { - let scan_id = state.snapshot.scan_id; - - if path - .components() - .any(|component| component.as_os_str() == *DOT_GIT) - { - let (entry_id, repo_ptr) = { - let Some((entry_id, repo)) = state.snapshot.repo_for_metadata(&path) else { - let dot_git_dir = path.ancestors() - .skip_while(|ancestor| ancestor.file_name() != Some(&*DOT_GIT)) - .next()?; - - let changed_paths = state.snapshot.build_repo(dot_git_dir.into(), fs); - if let Some(changed_paths) = changed_paths { - util::extend_sorted( - &mut state.changed_paths, - changed_paths, - usize::MAX, - Ord::cmp, - ); - } - - return None; - }; - if repo.git_dir_scan_id == scan_id { - return None; - } - - (*entry_id, repo.repo_ptr.to_owned()) - }; - - let work_dir = state - .snapshot - .entry_for_id(entry_id) - .map(|entry| RepositoryWorkDirectory(entry.path.clone()))?; - - let repo = repo_ptr.lock(); - repo.reload_index(); - let branch = repo.branch_name(); - - state.snapshot.git_repositories.update(&entry_id, |entry| { - entry.git_dir_scan_id = scan_id; - }); - - state - .snapshot - .snapshot - .repository_entries - .update(&work_dir, |entry| { - entry.branch = branch.map(Into::into); - }); - - let changed_paths = state.snapshot.scan_statuses(repo.deref(), &work_dir); - - util::extend_sorted( - &mut state.changed_paths, - changed_paths, - usize::MAX, - Ord::cmp, - ) - } - - Some(()) - } - async fn update_ignore_statuses(&self) { use futures::FutureExt as _; From bfc90f45020a5ca051a04d289b8794e7ec03855e Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 20 Jun 2023 17:56:27 -0700 Subject: [PATCH 130/215] Add failing test for changing a gitignore so a pending dir is no longer ignored --- crates/project/src/worktree_tests.rs | 182 +++++++++++++++++++++------ 1 file changed, 142 insertions(+), 40 deletions(-) diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rs index 0b8e02dc49..b544181292 100644 --- a/crates/project/src/worktree_tests.rs +++ b/crates/project/src/worktree_tests.rs @@ -35,11 +35,8 @@ async fn test_traversal(cx: &mut TestAppContext) { ) .await; - let http_client = FakeHttpClient::with_404_response(); - let client = cx.read(|cx| Client::new(http_client, cx)); - let tree = Worktree::local( - client, + build_client(cx), Path::new("/root"), true, fs, @@ -108,11 +105,8 @@ async fn test_descendent_entries(cx: &mut TestAppContext) { ) .await; - let http_client = FakeHttpClient::with_404_response(); - let client = cx.read(|cx| Client::new(http_client, cx)); - let tree = Worktree::local( - client, + build_client(cx), Path::new("/root"), true, fs, @@ -208,9 +202,8 @@ async fn test_circular_symlinks(executor: Arc, cx: &mut TestAppCo fs.insert_symlink("/root/lib/a/lib", "..".into()).await; fs.insert_symlink("/root/lib/b/lib", "..".into()).await; - let client = cx.read(|cx| Client::new(FakeHttpClient::with_404_response(), cx)); let tree = Worktree::local( - client, + build_client(cx), Path::new("/root"), true, fs.clone(), @@ -306,9 +299,8 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { fs.insert_symlink("/root/dir1/deps/dep-dir3", "../../dir3".into()) .await; - let client = cx.read(|cx| Client::new(FakeHttpClient::with_404_response(), cx)); let tree = Worktree::local( - client, + build_client(cx), Path::new("/root/dir1"), true, fs.clone(), @@ -433,9 +425,8 @@ async fn test_open_gitignored_files(cx: &mut TestAppContext) { ) .await; - let client = cx.read(|cx| Client::new(FakeHttpClient::with_404_response(), cx)); let tree = Worktree::local( - client, + build_client(cx), Path::new("/root"), true, fs.clone(), @@ -550,6 +541,128 @@ async fn test_open_gitignored_files(cx: &mut TestAppContext) { }); } +#[gpui::test] +async fn test_dirs_no_longer_ignored(cx: &mut TestAppContext) { + let fs = FakeFs::new(cx.background()); + fs.insert_tree( + "/root", + json!({ + ".gitignore": "node_modules\n", + "a": { + "a.js": "", + }, + "b": { + "b.js": "", + }, + "node_modules": { + "c": { + "c.js": "", + }, + "d": { + "d.js": "", + "e": { + "e1.js": "", + "e2.js": "", + }, + "f": { + "f1.js": "", + "f2.js": "", + } + }, + }, + }), + ) + .await; + + let tree = Worktree::local( + build_client(cx), + Path::new("/root"), + true, + fs.clone(), + Default::default(), + &mut cx.to_async(), + ) + .await + .unwrap(); + + cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete()) + .await; + + // Open a file within the gitignored directory, forcing some of its + // subdirectories to be read, but not all. + let read_dir_count_1 = fs.read_dir_call_count(); + tree.read_with(cx, |tree, _| { + tree.as_local() + .unwrap() + .refresh_entries_for_paths(vec![Path::new("node_modules/d/d.js").into()]) + }) + .recv() + .await; + + // Those subdirectories are now loaded. + tree.read_with(cx, |tree, _| { + assert_eq!( + tree.entries(true) + .map(|e| (e.path.as_ref(), e.is_ignored)) + .collect::>(), + &[ + (Path::new(""), false), + (Path::new(".gitignore"), false), + (Path::new("a"), false), + (Path::new("a/a.js"), false), + (Path::new("b"), false), + (Path::new("b/b.js"), false), + (Path::new("node_modules"), true), + (Path::new("node_modules/c"), true), + (Path::new("node_modules/d"), true), + (Path::new("node_modules/d/d.js"), true), + (Path::new("node_modules/d/e"), true), + (Path::new("node_modules/d/f"), true), + ] + ); + }); + let read_dir_count_2 = fs.read_dir_call_count(); + assert_eq!(read_dir_count_2 - read_dir_count_1, 2); + + // Update the gitignore so that node_modules is no longer ignored, + // but a subdirectory is ignored + fs.save("/root/.gitignore".as_ref(), &"e".into(), Default::default()) + .await + .unwrap(); + cx.foreground().run_until_parked(); + + // All of the directories that are no longer ignored are now loaded. + tree.read_with(cx, |tree, _| { + assert_eq!( + tree.entries(true) + .map(|e| (e.path.as_ref(), e.is_ignored)) + .collect::>(), + &[ + (Path::new(""), false), + (Path::new(".gitignore"), false), + (Path::new("a"), false), + (Path::new("a/a.js"), false), + (Path::new("b"), false), + (Path::new("b/b.js"), false), + (Path::new("node_modules"), false), + (Path::new("node_modules/c"), false), + (Path::new("node_modules/c/c.js"), false), + (Path::new("node_modules/d"), false), + (Path::new("node_modules/d/d.js"), false), + // This subdirectory is now ignored + (Path::new("node_modules/d/e"), true), + (Path::new("node_modules/d/f"), false), + (Path::new("node_modules/d/f/f1.js"), false), + (Path::new("node_modules/d/f/f2.js"), false), + ] + ); + }); + + // Each of the newly-loaded directories is scanned only once. + let read_dir_count_3 = fs.read_dir_call_count(); + assert_eq!(read_dir_count_3 - read_dir_count_2, 4); +} + #[gpui::test] async fn test_rescan_with_gitignore(cx: &mut TestAppContext) { // .gitignores are handled explicitly by Zed and do not use the git @@ -570,10 +683,8 @@ async fn test_rescan_with_gitignore(cx: &mut TestAppContext) { })); let dir = parent_dir.path().join("tree"); - let client = cx.read(|cx| Client::new(FakeHttpClient::with_404_response(), cx)); - let tree = Worktree::local( - client, + build_client(cx), dir.as_path(), true, Arc::new(RealFs), @@ -648,10 +759,8 @@ async fn test_write_file(cx: &mut TestAppContext) { "ignored-dir": {} })); - let client = cx.read(|cx| Client::new(FakeHttpClient::with_404_response(), cx)); - let tree = Worktree::local( - client, + build_client(cx), dir.path(), true, Arc::new(RealFs), @@ -695,8 +804,6 @@ async fn test_write_file(cx: &mut TestAppContext) { #[gpui::test(iterations = 30)] async fn test_create_directory_during_initial_scan(cx: &mut TestAppContext) { - let client = cx.read(|cx| Client::new(FakeHttpClient::with_404_response(), cx)); - let fs = FakeFs::new(cx.background()); fs.insert_tree( "/root", @@ -709,7 +816,7 @@ async fn test_create_directory_during_initial_scan(cx: &mut TestAppContext) { .await; let tree = Worktree::local( - client, + build_client(cx), "/root".as_ref(), true, fs, @@ -774,9 +881,8 @@ async fn test_random_worktree_operations_during_initial_scan( } log::info!("generated initial tree"); - let client = cx.read(|cx| Client::new(FakeHttpClient::with_404_response(), cx)); let worktree = Worktree::local( - client.clone(), + build_client(cx), root_dir, true, fs.clone(), @@ -864,9 +970,8 @@ async fn test_random_worktree_changes(cx: &mut TestAppContext, mut rng: StdRng) } log::info!("generated initial tree"); - let client = cx.read(|cx| Client::new(FakeHttpClient::with_404_response(), cx)); let worktree = Worktree::local( - client.clone(), + build_client(cx), root_dir, true, fs.clone(), @@ -939,7 +1044,7 @@ async fn test_random_worktree_changes(cx: &mut TestAppContext, mut rng: StdRng) { let new_worktree = Worktree::local( - client.clone(), + build_client(cx), root_dir, true, fs.clone(), @@ -1276,10 +1381,8 @@ async fn test_rename_work_directory(cx: &mut TestAppContext) { })); let root_path = root.path(); - let http_client = FakeHttpClient::with_404_response(); - let client = cx.read(|cx| Client::new(http_client, cx)); let tree = Worktree::local( - client, + build_client(cx), root_path, true, Arc::new(RealFs), @@ -1355,10 +1458,8 @@ async fn test_git_repository_for_path(cx: &mut TestAppContext) { }, })); - let http_client = FakeHttpClient::with_404_response(); - let client = cx.read(|cx| Client::new(http_client, cx)); let tree = Worktree::local( - client, + build_client(cx), root.path(), true, Arc::new(RealFs), @@ -1479,10 +1580,8 @@ async fn test_git_status(deterministic: Arc, cx: &mut TestAppCont })); - let http_client = FakeHttpClient::with_404_response(); - let client = cx.read(|cx| Client::new(http_client, cx)); let tree = Worktree::local( - client, + build_client(cx), root.path(), true, Arc::new(RealFs), @@ -1686,10 +1785,8 @@ async fn test_propagate_git_statuses(cx: &mut TestAppContext) { ], ); - let http_client = FakeHttpClient::with_404_response(); - let client = cx.read(|cx| Client::new(http_client, cx)); let tree = Worktree::local( - client, + build_client(cx), Path::new("/root"), true, fs.clone(), @@ -1768,6 +1865,11 @@ async fn test_propagate_git_statuses(cx: &mut TestAppContext) { } } +fn build_client(cx: &mut TestAppContext) -> Arc { + let http_client = FakeHttpClient::with_404_response(); + cx.read(|cx| Client::new(http_client, cx)) +} + #[track_caller] fn git_init(path: &Path) -> git2::Repository { git2::Repository::init(path).expect("Failed to initialize git repository") From 400e3cda322086ef8a33ed231807e65947a31268 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 21 Jun 2023 10:07:29 -0700 Subject: [PATCH 131/215] Scan directories when they stop being ignored --- crates/project/src/worktree.rs | 44 ++++++++++++++++++++++++---- crates/project/src/worktree_tests.rs | 3 +- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index d3ff0e93d2..39350f1c8f 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -3066,11 +3066,16 @@ impl BackgroundScanner { let (scan_job_tx, scan_job_rx) = channel::unbounded(); let paths = self - .reload_entries_for_paths(root_path, root_canonical_path, abs_paths, Some(scan_job_tx)) + .reload_entries_for_paths( + root_path, + root_canonical_path, + abs_paths, + Some(scan_job_tx.clone()), + ) .await; - self.scan_dirs(false, scan_job_rx).await; - self.update_ignore_statuses().await; + self.update_ignore_statuses(scan_job_tx).await; + self.scan_dirs(false, scan_job_rx).await; { let mut state = self.state.lock(); @@ -3571,7 +3576,7 @@ impl BackgroundScanner { Some(()) } - async fn update_ignore_statuses(&self) { + async fn update_ignore_statuses(&self, scan_job_tx: Sender) { use futures::FutureExt as _; let mut snapshot = self.state.lock().snapshot.clone(); @@ -3619,6 +3624,7 @@ impl BackgroundScanner { abs_path: parent_abs_path, ignore_stack, ignore_queue: ignore_queue_tx.clone(), + scan_queue: scan_job_tx.clone(), })) .unwrap(); } @@ -3663,7 +3669,7 @@ impl BackgroundScanner { let path = job.abs_path.strip_prefix(&snapshot.abs_path).unwrap(); for mut entry in snapshot.child_entries(path).cloned() { let was_ignored = entry.is_ignored; - let abs_path = snapshot.abs_path().join(&entry.path); + let abs_path: Arc = snapshot.abs_path().join(&entry.path).into(); entry.is_ignored = ignore_stack.is_abs_path_ignored(&abs_path, entry.is_dir()); if entry.is_dir() { let child_ignore_stack = if entry.is_ignored { @@ -3671,11 +3677,36 @@ impl BackgroundScanner { } else { ignore_stack.clone() }; + + // Scan any directories that were previously ignored and weren't + // previously scanned. + if was_ignored + && !entry.is_ignored + && !entry.is_external + && entry.kind == EntryKind::PendingDir + { + job.scan_queue + .try_send(ScanJob { + abs_path: abs_path.clone(), + path: entry.path.clone(), + ignore_stack: child_ignore_stack.clone(), + scan_queue: job.scan_queue.clone(), + ancestor_inodes: self + .state + .lock() + .snapshot + .ancestor_inodes_for_path(&entry.path), + is_external: false, + }) + .unwrap(); + } + job.ignore_queue .send(UpdateIgnoreStatusJob { - abs_path: abs_path.into(), + abs_path: abs_path.clone(), ignore_stack: child_ignore_stack, ignore_queue: job.ignore_queue.clone(), + scan_queue: job.scan_queue.clone(), }) .await .unwrap(); @@ -3847,6 +3878,7 @@ struct UpdateIgnoreStatusJob { abs_path: Arc, ignore_stack: Arc, ignore_queue: Sender, + scan_queue: Sender, } pub trait WorktreeHandle { diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rs index b544181292..5cab52a21a 100644 --- a/crates/project/src/worktree_tests.rs +++ b/crates/project/src/worktree_tests.rs @@ -644,6 +644,7 @@ async fn test_dirs_no_longer_ignored(cx: &mut TestAppContext) { (Path::new("a/a.js"), false), (Path::new("b"), false), (Path::new("b/b.js"), false), + // This directory is no longer ignored (Path::new("node_modules"), false), (Path::new("node_modules/c"), false), (Path::new("node_modules/c/c.js"), false), @@ -660,7 +661,7 @@ async fn test_dirs_no_longer_ignored(cx: &mut TestAppContext) { // Each of the newly-loaded directories is scanned only once. let read_dir_count_3 = fs.read_dir_call_count(); - assert_eq!(read_dir_count_3 - read_dir_count_2, 4); + assert_eq!(read_dir_count_3 - read_dir_count_2, 2); } #[gpui::test] From 5350164db91b1efa2d88534729e83071346ec4cc Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 21 Jun 2023 13:38:30 -0700 Subject: [PATCH 132/215] Get integration test passing. Wait for expand entry on remote projects. --- crates/collab/src/tests/integration_tests.rs | 21 ++++++ crates/project/src/project.rs | 79 ++++++++++++-------- crates/project/src/worktree.rs | 24 +++--- crates/project_panel/src/project_panel.rs | 6 +- crates/rpc/proto/zed.proto | 7 +- crates/rpc/src/proto.rs | 3 +- 6 files changed, 88 insertions(+), 52 deletions(-) diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rs index 92b63478cb..2211e53263 100644 --- a/crates/collab/src/tests/integration_tests.rs +++ b/crates/collab/src/tests/integration_tests.rs @@ -1266,6 +1266,27 @@ async fn test_share_project( let client_b_collaborator = project.collaborators().get(&client_b_peer_id).unwrap(); assert_eq!(client_b_collaborator.replica_id, replica_id_b); }); + project_b.read_with(cx_b, |project, cx| { + let worktree = project.worktrees(cx).next().unwrap().read(cx); + assert_eq!( + worktree.paths().map(AsRef::as_ref).collect::>(), + [ + Path::new(".gitignore"), + Path::new("a.txt"), + Path::new("b.txt"), + Path::new("ignored-dir"), + ] + ); + }); + + project_b + .update(cx_b, |project, cx| { + let worktree = project.worktrees(cx).next().unwrap(); + let entry = worktree.read(cx).entry_for_path("ignored-dir").unwrap(); + project.expand_entry(worktree_id, entry.id, cx).unwrap() + }) + .await + .unwrap(); project_b.read_with(cx_b, |project, cx| { let worktree = project.worktrees(cx).next().unwrap().read(cx); assert_eq!( diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 5c71202956..1c9336e2ae 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -1073,6 +1073,40 @@ impl Project { } } + pub fn expand_entry( + &mut self, + worktree_id: WorktreeId, + entry_id: ProjectEntryId, + cx: &mut ModelContext, + ) -> Option>> { + let worktree = self.worktree_for_id(worktree_id, cx)?; + if self.is_local() { + worktree.update(cx, |worktree, cx| { + worktree.as_local_mut().unwrap().expand_entry(entry_id, cx) + }) + } else { + let worktree = worktree.downgrade(); + let request = self.client.request(proto::ExpandProjectEntry { + project_id: self.remote_id().unwrap(), + entry_id: entry_id.to_proto(), + }); + Some(cx.spawn_weak(|_, mut cx| async move { + let response = request.await?; + if let Some(worktree) = worktree.upgrade(&cx) { + worktree + .update(&mut cx, |worktree, _| { + worktree + .as_remote_mut() + .unwrap() + .wait_for_snapshot(response.worktree_scan_id as usize) + }) + .await?; + } + Ok(()) + })) + } + } + pub fn shared(&mut self, project_id: u64, cx: &mut ModelContext) -> Result<()> { if self.client_state.is_some() { return Err(anyhow!("project was already shared")); @@ -5404,31 +5438,6 @@ impl Project { Some(ProjectPath { worktree_id, path }) } - pub fn mark_entry_expanded( - &mut self, - worktree_id: WorktreeId, - entry_id: ProjectEntryId, - cx: &mut ModelContext, - ) -> Option<()> { - if self.is_local() { - let worktree = self.worktree_for_id(worktree_id, cx)?; - worktree.update(cx, |worktree, cx| { - worktree - .as_local_mut() - .unwrap() - .expand_entry_for_id(entry_id, cx); - }); - } else if let Some(project_id) = self.remote_id() { - cx.background() - .spawn(self.client.request(proto::ExpandProjectEntry { - project_id, - entry_id: entry_id.to_proto(), - })) - .log_err(); - } - Some(()) - } - pub fn absolute_path(&self, project_path: &ProjectPath, cx: &AppContext) -> Option { let workspace_root = self .worktree_for_id(project_path.worktree_id, cx)? @@ -5736,18 +5745,22 @@ impl Project { envelope: TypedEnvelope, _: Arc, mut cx: AsyncAppContext, - ) -> Result { + ) -> Result { let entry_id = ProjectEntryId::from_proto(envelope.payload.entry_id); let worktree = this .read_with(&cx, |this, cx| this.worktree_for_entry(entry_id, cx)) .ok_or_else(|| anyhow!("invalid request"))?; - worktree.update(&mut cx, |worktree, cx| { - worktree - .as_local_mut() - .unwrap() - .expand_entry_for_id(entry_id, cx) - }); - Ok(proto::Ack {}) + worktree + .update(&mut cx, |worktree, cx| { + worktree + .as_local_mut() + .unwrap() + .expand_entry(entry_id, cx) + .ok_or_else(|| anyhow!("invalid entry")) + })? + .await?; + let worktree_scan_id = worktree.read_with(&cx, |worktree, _| worktree.scan_id()) as u64; + Ok(proto::ExpandProjectEntryResponse { worktree_scan_id }) } async fn handle_update_diagnostic_summary( diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 39350f1c8f..2f57b84bba 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -1127,21 +1127,17 @@ impl LocalWorktree { })) } - pub fn expand_entry_for_id( + pub fn expand_entry( &mut self, entry_id: ProjectEntryId, - _cx: &mut ModelContext, - ) -> barrier::Receiver { - let (tx, rx) = barrier::channel(); - if let Some(entry) = self.entry_for_id(entry_id) { - self.scan_requests_tx - .try_send(ScanRequest { - relative_paths: vec![entry.path.clone()], - done: tx, - }) - .ok(); - } - rx + cx: &mut ModelContext, + ) -> Option>> { + let path = self.entry_for_id(entry_id)?.path.clone(); + let mut refresh = self.refresh_entries_for_paths(vec![path]); + Some(cx.background().spawn(async move { + refresh.next().await; + Ok(()) + })) } pub fn refresh_entries_for_paths(&self, paths: Vec>) -> barrier::Receiver { @@ -1337,7 +1333,7 @@ impl RemoteWorktree { self.completed_scan_id >= scan_id } - fn wait_for_snapshot(&mut self, scan_id: usize) -> impl Future> { + pub(crate) fn wait_for_snapshot(&mut self, scan_id: usize) -> impl Future> { let (tx, rx) = oneshot::channel(); if self.observed_snapshot(scan_id) { let _ = tx.send(()); diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index c8dfb7cb38..57934c4adb 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -423,7 +423,7 @@ impl ProjectPanel { Ok(_) => self.select_next(&SelectNext, cx), Err(ix) => { self.project.update(cx, |project, cx| { - project.mark_entry_expanded(worktree_id, entry_id, cx); + project.expand_entry(worktree_id, entry_id, cx); }); expanded_dir_ids.insert(ix, entry_id); @@ -477,7 +477,7 @@ impl ProjectPanel { expanded_dir_ids.remove(ix); } Err(ix) => { - project.mark_entry_expanded(worktree_id, entry_id, cx); + project.expand_entry(worktree_id, entry_id, cx); expanded_dir_ids.insert(ix, entry_id); } } @@ -1084,7 +1084,7 @@ impl ProjectPanel { .worktree_for_id(worktree_id, cx) .zip(self.expanded_dir_ids.get_mut(&worktree_id)) { - project.mark_entry_expanded(worktree_id, entry_id, cx); + project.expand_entry(worktree_id, entry_id, cx); let worktree = worktree.read(cx); if let Some(mut entry) = worktree.entry_for_id(entry_id) { diff --git a/crates/rpc/proto/zed.proto b/crates/rpc/proto/zed.proto index 78aab23a44..2bce1ce1e3 100644 --- a/crates/rpc/proto/zed.proto +++ b/crates/rpc/proto/zed.proto @@ -62,8 +62,9 @@ message Envelope { RenameProjectEntry rename_project_entry = 46; CopyProjectEntry copy_project_entry = 47; DeleteProjectEntry delete_project_entry = 48; - ExpandProjectEntry expand_project_entry = 114; ProjectEntryResponse project_entry_response = 49; + ExpandProjectEntry expand_project_entry = 114; + ExpandProjectEntryResponse expand_project_entry_response = 115; UpdateDiagnosticSummary update_diagnostic_summary = 50; StartLanguageServer start_language_server = 51; @@ -378,6 +379,10 @@ message ExpandProjectEntry { uint64 entry_id = 2; } +message ExpandProjectEntryResponse { + uint64 worktree_scan_id = 1; +} + message ProjectEntryResponse { Entry entry = 1; uint64 worktree_scan_id = 2; diff --git a/crates/rpc/src/proto.rs b/crates/rpc/src/proto.rs index 6311b043d3..4532e798e7 100644 --- a/crates/rpc/src/proto.rs +++ b/crates/rpc/src/proto.rs @@ -201,6 +201,7 @@ messages!( (Ping, Foreground), (PrepareRename, Background), (PrepareRenameResponse, Background), + (ExpandProjectEntryResponse, Foreground), (ProjectEntryResponse, Foreground), (RejoinRoom, Foreground), (RejoinRoomResponse, Foreground), @@ -256,7 +257,7 @@ request_messages!( (CreateRoom, CreateRoomResponse), (DeclineCall, Ack), (DeleteProjectEntry, ProjectEntryResponse), - (ExpandProjectEntry, Ack), + (ExpandProjectEntry, ExpandProjectEntryResponse), (Follow, FollowResponse), (FormatBuffers, FormatBuffersResponse), (GetChannelMessages, GetChannelMessagesResponse), From 16022e9c1a01dd0a95df7d4fdbe401caca53d9ff Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Thu, 22 Jun 2023 10:34:51 -0600 Subject: [PATCH 133/215] Add counts to subsitute (and all) Co-Authored-By: Nathan Sobo --- assets/keymaps/vim.json | 2 +- crates/vim/src/normal.rs | 2 +- crates/vim/src/test.rs | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index eb2d7ecf41..d08b6ddff9 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -131,7 +131,7 @@ } }, { - "context": "Editor && vim_mode == normal && vim_operator == none && !VimWaiting", + "context": "Editor && vim_mode == normal && (vim_operator == none || vim_operator == n) && !VimWaiting", "bindings": { "c": [ "vim::PushOperator", diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index 19d000d397..ecec232104 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -484,7 +484,7 @@ pub fn substitute(vim: &mut Vim, count: usize, cx: &mut WindowContext) { let selections = editor.selections.all::(cx); for selection in selections.into_iter().rev() { let end = if selection.start == selection.end { - selection.start + Point::new(0, 1) + selection.start + Point::new(0, count as u32) } else { selection.end }; diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index 293a4813e6..c7d944bd2a 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -117,4 +117,8 @@ async fn test_substitute(cx: &mut gpui::TestAppContext) { cx.set_state(indoc! {"a«bcˇ»deˇfg\n"}, Mode::Normal); cx.simulate_keystrokes(["s", "x"]); cx.assert_editor_state("axˇdexˇg\n"); + + cx.set_state(indoc! {"ˇabc\n"}, Mode::Normal); + cx.simulate_keystrokes(["2", "s", "x"]); + cx.assert_editor_state("xˇc\n"); } From 8bd9fe1fb087be224bf082ab9ee989d49645570e Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 22 Jun 2023 20:05:06 +0200 Subject: [PATCH 134/215] Deafen now also mutes microphone --- crates/call/src/room.rs | 46 +++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 0c0855fd6c..714a1b19b5 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -1176,24 +1176,31 @@ impl Room { }) }) } - - pub fn toggle_mute(&mut self, cx: &mut ModelContext) -> Result>> { - if let Some(live_kit) = self.live_kit.as_mut() { - match &mut live_kit.microphone_track { - LocalTrack::None => Err(anyhow!("microphone was not shared")), - LocalTrack::Pending { muted, .. } => { - *muted = !*muted; - Ok(Task::Ready(Some(Ok(())))) - } - LocalTrack::Published { - track_publication, - muted, - } => { - *muted = !*muted; - - Ok(cx.background().spawn(track_publication.set_mute(*muted))) - } + fn set_mute( + live_kit: &mut LiveKitRoom, + should_mute: bool, + cx: &mut ModelContext, + ) -> Result>> { + match &mut live_kit.microphone_track { + LocalTrack::None => Err(anyhow!("microphone was not shared")), + LocalTrack::Pending { muted, .. } => { + *muted = should_mute; + Ok(Task::Ready(Some(Ok(())))) } + LocalTrack::Published { + track_publication, + muted, + } => { + *muted = should_mute; + + Ok(cx.background().spawn(track_publication.set_mute(*muted))) + } + } + } + pub fn toggle_mute(&mut self, cx: &mut ModelContext) -> Result>> { + let should_mute = self.is_muted().unwrap_or(false); + if let Some(live_kit) = self.live_kit.as_mut() { + Self::set_mute(live_kit, !should_mute, cx) } else { Err(anyhow!("LiveKit not started")) } @@ -1204,9 +1211,9 @@ impl Room { (*live_kit).deafened = !live_kit.deafened } - if let Some(live_kit) = &self.live_kit { + if let Some(live_kit) = self.live_kit.as_mut() { let mut tasks = Vec::with_capacity(self.remote_participants.len()); - + let _ = Self::set_mute(live_kit, live_kit.deafened, cx)?; // todo (osiewicz): we probably want to schedule it on fg/bg? for participant in self.remote_participants.values() { for track in live_kit .room @@ -1215,7 +1222,6 @@ impl Room { tasks.push(cx.foreground().spawn(track.set_enabled(!live_kit.deafened))); } } - Ok(cx.foreground().spawn(async move { for task in tasks { task.await?; From 0cacf01f907e6c9de9c903b4a308509ad0967e12 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 21 Jun 2023 22:36:48 -0600 Subject: [PATCH 135/215] vim: Fix 1G Before this change code could not distinguish between a user providing a count of 1 and no count at all. Fixes: zed-industries/community#710 --- crates/vim/src/motion.rs | 27 ++++++++++++++++++--------- crates/vim/src/normal.rs | 12 ++++++------ crates/vim/src/normal/change.rs | 9 +++++---- crates/vim/src/normal/delete.rs | 2 +- crates/vim/src/normal/yank.rs | 2 +- crates/vim/src/test.rs | 14 ++++++++++++++ crates/vim/src/vim.rs | 7 +++---- crates/vim/src/visual.rs | 2 +- 8 files changed, 49 insertions(+), 26 deletions(-) diff --git a/crates/vim/src/motion.rs b/crates/vim/src/motion.rs index cc3ec06c47..faf69d9473 100644 --- a/crates/vim/src/motion.rs +++ b/crates/vim/src/motion.rs @@ -209,8 +209,9 @@ impl Motion { map: &DisplaySnapshot, point: DisplayPoint, goal: SelectionGoal, - times: usize, + maybe_times: Option, ) -> Option<(DisplayPoint, SelectionGoal)> { + let times = maybe_times.unwrap_or(1); use Motion::*; let infallible = self.infallible(); let (new_point, goal) = match self { @@ -236,7 +237,10 @@ impl Motion { EndOfLine => (end_of_line(map, point), SelectionGoal::None), CurrentLine => (end_of_line(map, point), SelectionGoal::None), StartOfDocument => (start_of_document(map, point, times), SelectionGoal::None), - EndOfDocument => (end_of_document(map, point, times), SelectionGoal::None), + EndOfDocument => ( + end_of_document(map, point, maybe_times), + SelectionGoal::None, + ), Matching => (matching(map, point), SelectionGoal::None), FindForward { before, text } => ( find_forward(map, point, *before, text.clone(), times), @@ -257,7 +261,7 @@ impl Motion { &self, map: &DisplaySnapshot, selection: &mut Selection, - times: usize, + times: Option, expand_to_surrounding_newline: bool, ) -> bool { if let Some((new_head, goal)) = @@ -473,14 +477,19 @@ fn start_of_document(map: &DisplaySnapshot, point: DisplayPoint, line: usize) -> map.clip_point(new_point, Bias::Left) } -fn end_of_document(map: &DisplaySnapshot, point: DisplayPoint, line: usize) -> DisplayPoint { - let mut new_point = if line == 1 { - map.max_point() +fn end_of_document( + map: &DisplaySnapshot, + point: DisplayPoint, + line: Option, +) -> DisplayPoint { + let new_row = if let Some(line) = line { + (line - 1) as u32 } else { - Point::new((line - 1) as u32, 0).to_display_point(map) + map.max_buffer_row() }; - *new_point.column_mut() = point.column(); - map.clip_point(new_point, Bias::Left) + + let new_point = Point::new(new_row, point.column()); + map.clip_point(new_point.to_display_point(map), Bias::Left) } fn matching(map: &DisplaySnapshot, display_point: DisplayPoint) -> DisplayPoint { diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index 1f90d259d3..2a526880a6 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -93,7 +93,7 @@ pub fn init(cx: &mut AppContext) { pub fn normal_motion( motion: Motion, operator: Option, - times: usize, + times: Option, cx: &mut WindowContext, ) { Vim::update(cx, |vim, cx| { @@ -129,7 +129,7 @@ pub fn normal_object(object: Object, cx: &mut WindowContext) { }) } -fn move_cursor(vim: &mut Vim, motion: Motion, times: usize, cx: &mut WindowContext) { +fn move_cursor(vim: &mut Vim, motion: Motion, times: Option, cx: &mut WindowContext) { vim.update_active_editor(cx, |editor, cx| { editor.change_selections(Some(Autoscroll::fit()), cx, |s| { s.move_cursors_with(|map, cursor, goal| { @@ -147,7 +147,7 @@ fn insert_after(_: &mut Workspace, _: &InsertAfter, cx: &mut ViewContext, cx: &mut WindowContext) { // Some motions ignore failure when switching to normal mode let mut motion_succeeded = matches!( motion, @@ -78,10 +78,10 @@ pub fn change_object(vim: &mut Vim, object: Object, around: bool, cx: &mut Windo fn expand_changed_word_selection( map: &DisplaySnapshot, selection: &mut Selection, - times: usize, + times: Option, ignore_punctuation: bool, ) -> bool { - if times == 1 { + if times.is_none() || times.unwrap() == 1 { let in_word = map .chars_at(selection.head()) .next() @@ -97,7 +97,8 @@ fn expand_changed_word_selection( }); true } else { - Motion::NextWordStart { ignore_punctuation }.expand_selection(map, selection, 1, false) + Motion::NextWordStart { ignore_punctuation } + .expand_selection(map, selection, None, false) } } else { Motion::NextWordStart { ignore_punctuation }.expand_selection(map, selection, times, false) diff --git a/crates/vim/src/normal/delete.rs b/crates/vim/src/normal/delete.rs index cbea65ddaf..56fef78e1d 100644 --- a/crates/vim/src/normal/delete.rs +++ b/crates/vim/src/normal/delete.rs @@ -3,7 +3,7 @@ use collections::{HashMap, HashSet}; use editor::{display_map::ToDisplayPoint, scroll::autoscroll::Autoscroll, Bias}; use gpui::WindowContext; -pub fn delete_motion(vim: &mut Vim, motion: Motion, times: usize, cx: &mut WindowContext) { +pub fn delete_motion(vim: &mut Vim, motion: Motion, times: Option, cx: &mut WindowContext) { vim.update_active_editor(cx, |editor, cx| { editor.transact(cx, |editor, cx| { editor.set_clip_at_line_ends(false, cx); diff --git a/crates/vim/src/normal/yank.rs b/crates/vim/src/normal/yank.rs index aeef333127..7212a865bd 100644 --- a/crates/vim/src/normal/yank.rs +++ b/crates/vim/src/normal/yank.rs @@ -2,7 +2,7 @@ use crate::{motion::Motion, object::Object, utils::copy_selections_content, Vim} use collections::HashMap; use gpui::WindowContext; -pub fn yank_motion(vim: &mut Vim, motion: Motion, times: usize, cx: &mut WindowContext) { +pub fn yank_motion(vim: &mut Vim, motion: Motion, times: Option, cx: &mut WindowContext) { vim.update_active_editor(cx, |editor, cx| { editor.transact(cx, |editor, cx| { editor.set_clip_at_line_ends(false, cx); diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index 2ee3c85435..075229c47f 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -109,3 +109,17 @@ async fn test_count_down(cx: &mut gpui::TestAppContext) { cx.simulate_keystrokes(["9", "down"]); cx.assert_editor_state("aa\nbb\ncc\ndd\neˇe"); } + +#[gpui::test] +async fn test_end_of_document_710(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + // goes to end by default + cx.set_state(indoc! {"aˇa\nbb\ncc"}, Mode::Normal); + cx.simulate_keystrokes(["shift-g"]); + cx.assert_editor_state("aa\nbb\ncˇc"); + + // can go to line 1 (https://github.com/zed-industries/community/issues/710) + cx.simulate_keystrokes(["1", "shift-g"]); + cx.assert_editor_state("aˇa\nbb\ncc"); +} diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index d10ec5e824..eae8643cf3 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -238,13 +238,12 @@ impl Vim { popped_operator } - fn pop_number_operator(&mut self, cx: &mut WindowContext) -> usize { - let mut times = 1; + fn pop_number_operator(&mut self, cx: &mut WindowContext) -> Option { if let Some(Operator::Number(number)) = self.active_operator() { - times = number; self.pop_operator(cx); + return Some(number); } - times + None } fn clear_operator(&mut self, cx: &mut WindowContext) { diff --git a/crates/vim/src/visual.rs b/crates/vim/src/visual.rs index c3728db222..5e22e77bf0 100644 --- a/crates/vim/src/visual.rs +++ b/crates/vim/src/visual.rs @@ -25,7 +25,7 @@ pub fn init(cx: &mut AppContext) { cx.add_action(paste); } -pub fn visual_motion(motion: Motion, times: usize, cx: &mut WindowContext) { +pub fn visual_motion(motion: Motion, times: Option, cx: &mut WindowContext) { Vim::update(cx, |vim, cx| { vim.update_active_editor(cx, |editor, cx| { editor.change_selections(Some(Autoscroll::fit()), cx, |s| { From 926acd6033b1d10758c48d541737adb937c96bca Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Thu, 22 Jun 2023 13:22:19 -0600 Subject: [PATCH 136/215] vim: substitute handles multibyte characters And is now in its own file --- crates/vim/src/normal.rs | 21 +-------- crates/vim/src/normal/substitute.rs | 69 +++++++++++++++++++++++++++++ crates/vim/src/test.rs | 24 ---------- 3 files changed, 71 insertions(+), 43 deletions(-) create mode 100644 crates/vim/src/normal/substitute.rs diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index ecec232104..702f056b75 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -1,5 +1,6 @@ mod change; mod delete; +mod substitute; mod yank; use std::{borrow::Cow, cmp::Ordering, sync::Arc}; @@ -25,6 +26,7 @@ use workspace::Workspace; use self::{ change::{change_motion, change_object}, delete::{delete_motion, delete_object}, + substitute::substitute, yank::{yank_motion, yank_object}, }; @@ -478,25 +480,6 @@ pub(crate) fn normal_replace(text: Arc, cx: &mut WindowContext) { }); } -pub fn substitute(vim: &mut Vim, count: usize, cx: &mut WindowContext) { - vim.update_active_editor(cx, |editor, cx| { - editor.transact(cx, |editor, cx| { - let selections = editor.selections.all::(cx); - for selection in selections.into_iter().rev() { - let end = if selection.start == selection.end { - selection.start + Point::new(0, count as u32) - } else { - selection.end - }; - editor.buffer().update(cx, |buffer, cx| { - buffer.edit([(selection.start..end, "")], None, cx) - }) - } - }) - }); - vim.switch_mode(Mode::Insert, true, cx) -} - #[cfg(test)] mod test { use gpui::TestAppContext; diff --git a/crates/vim/src/normal/substitute.rs b/crates/vim/src/normal/substitute.rs new file mode 100644 index 0000000000..e208983b11 --- /dev/null +++ b/crates/vim/src/normal/substitute.rs @@ -0,0 +1,69 @@ +use gpui::WindowContext; +use language::Point; + +use crate::{motion::Motion, Mode, Vim}; + +pub fn substitute(vim: &mut Vim, count: usize, cx: &mut WindowContext) { + vim.update_active_editor(cx, |editor, cx| { + editor.set_clip_at_line_ends(false, cx); + editor.change_selections(None, cx, |s| { + s.move_with(|map, selection| { + if selection.start == selection.end { + Motion::Right.expand_selection(map, selection, count, true); + } + }) + }); + editor.transact(cx, |editor, cx| { + let selections = editor.selections.all::(cx); + for selection in selections.into_iter().rev() { + editor.buffer().update(cx, |buffer, cx| { + buffer.edit([(selection.start..selection.end, "")], None, cx) + }) + } + }); + editor.set_clip_at_line_ends(true, cx); + }); + vim.switch_mode(Mode::Insert, true, cx) +} + +#[cfg(test)] +mod test { + use crate::{state::Mode, test::VimTestContext}; + use indoc::indoc; + + #[gpui::test] + async fn test_substitute(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + // supports a single cursor + cx.set_state(indoc! {"ˇabc\n"}, Mode::Normal); + cx.simulate_keystrokes(["s", "x"]); + cx.assert_editor_state("xˇbc\n"); + + // supports a selection + cx.set_state(indoc! {"a«bcˇ»\n"}, Mode::Visual { line: false }); + cx.assert_editor_state("a«bcˇ»\n"); + cx.simulate_keystrokes(["s", "x"]); + cx.assert_editor_state("axˇ\n"); + + // supports counts + cx.set_state(indoc! {"ˇabc\n"}, Mode::Normal); + cx.simulate_keystrokes(["2", "s", "x"]); + cx.assert_editor_state("xˇc\n"); + + // supports multiple cursors + cx.set_state(indoc! {"a«bcˇ»deˇffg\n"}, Mode::Normal); + cx.simulate_keystrokes(["2", "s", "x"]); + cx.assert_editor_state("axˇdexˇg\n"); + + // does not read beyond end of line + cx.set_state(indoc! {"ˇabc\n"}, Mode::Normal); + cx.simulate_keystrokes(["5", "s", "x"]); + cx.assert_editor_state("xˇ\n"); + + // it handles multibyte characters + cx.set_state(indoc! {"ˇcàfé\n"}, Mode::Normal); + cx.simulate_keystrokes(["4", "s", "x"]); + cx.assert_editor_state("xˇ\n"); + } +} diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index c7d944bd2a..0214806e11 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -98,27 +98,3 @@ async fn test_buffer_search(cx: &mut gpui::TestAppContext) { assert_eq!(bar.query_editor.read(cx).text(cx), "jumps"); }) } - -#[gpui::test] -async fn test_substitute(cx: &mut gpui::TestAppContext) { - let mut cx = VimTestContext::new(cx, true).await; - - // supports a single cursor - cx.set_state(indoc! {"ˇabc\n"}, Mode::Normal); - cx.simulate_keystrokes(["s", "x"]); - cx.assert_editor_state("xˇbc\n"); - - // supports a selection - cx.set_state(indoc! {"a«bcˇ»\n"}, Mode::Visual { line: false }); - cx.simulate_keystrokes(["s", "x"]); - cx.assert_editor_state("axˇ\n"); - - // supports multiple cursors - cx.set_state(indoc! {"a«bcˇ»deˇfg\n"}, Mode::Normal); - cx.simulate_keystrokes(["s", "x"]); - cx.assert_editor_state("axˇdexˇg\n"); - - cx.set_state(indoc! {"ˇabc\n"}, Mode::Normal); - cx.simulate_keystrokes(["2", "s", "x"]); - cx.assert_editor_state("xˇc\n"); -} From ffb0a215ea1aa7f2c1b5a6c00545a6fb8778780c Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 22 Jun 2023 16:31:04 -0700 Subject: [PATCH 137/215] Fix randomized worktree test failures * Distinguish between unloaded and pending directories via separate entry kind. * Scan directories before updating ignore statuses after fs events. --- crates/project/src/worktree.rs | 110 +++++++++++++++++---------- crates/project/src/worktree_tests.rs | 10 +-- 2 files changed, 73 insertions(+), 47 deletions(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 2f57b84bba..4e72f2d689 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -1053,17 +1053,13 @@ impl LocalWorktree { Some(cx.spawn(|this, mut cx| async move { let path = delete.await?; - let (tx, mut rx) = barrier::channel(); this.update(&mut cx, |this, _| { this.as_local_mut() .unwrap() - .scan_requests_tx - .try_send(ScanRequest { - relative_paths: vec![path], - done: tx, - }) - })?; - rx.recv().await; + .refresh_entries_for_paths(vec![path]) + }) + .recv() + .await; Ok(()) })) } @@ -2049,7 +2045,9 @@ impl LocalSnapshot { } #[cfg(test)] - pub fn check_invariants(&self) { + pub fn check_invariants(&self, git_state: bool) { + use pretty_assertions::assert_eq; + assert_eq!( self.entries_by_path .cursor::<()>() @@ -2079,7 +2077,11 @@ impl LocalSnapshot { assert!(visible_files.next().is_none()); let mut bfs_paths = Vec::new(); - let mut stack = vec![Path::new("")]; + let mut stack = self + .root_entry() + .map(|e| e.path.as_ref()) + .into_iter() + .collect::>(); while let Some(path) = stack.pop() { bfs_paths.push(path); let ix = stack.len(); @@ -2101,12 +2103,15 @@ impl LocalSnapshot { .collect::>(); assert_eq!(dfs_paths_via_traversal, dfs_paths_via_iter); - for ignore_parent_abs_path in self.ignores_by_parent_abs_path.keys() { - let ignore_parent_path = ignore_parent_abs_path.strip_prefix(&self.abs_path).unwrap(); - assert!(self.entry_for_path(&ignore_parent_path).is_some()); - assert!(self - .entry_for_path(ignore_parent_path.join(&*GITIGNORE)) - .is_some()); + if git_state { + for ignore_parent_abs_path in self.ignores_by_parent_abs_path.keys() { + let ignore_parent_path = + ignore_parent_abs_path.strip_prefix(&self.abs_path).unwrap(); + assert!(self.entry_for_path(&ignore_parent_path).is_some()); + assert!(self + .entry_for_path(ignore_parent_path.join(&*GITIGNORE)) + .is_some()); + } } } @@ -2129,7 +2134,7 @@ impl BackgroundScannerState { || self .snapshot .entry_for_path(&path) - .map_or(true, |entry| self.expanded_dirs.contains(&entry.id)) + .map_or(false, |entry| self.expanded_dirs.contains(&entry.id)) } fn reuse_entry_id(&mut self, entry: &mut Entry) { @@ -2146,6 +2151,10 @@ impl BackgroundScannerState { if entry.path.file_name() == Some(&DOT_GIT) { self.build_repository(entry.path.clone(), fs); } + + #[cfg(test)] + self.snapshot.check_invariants(false); + entry } @@ -2171,7 +2180,7 @@ impl BackgroundScannerState { }; match parent_entry.kind { - EntryKind::PendingDir => parent_entry.kind = EntryKind::Dir, + EntryKind::PendingDir | EntryKind::UnloadedDir => parent_entry.kind = EntryKind::Dir, EntryKind::Dir => {} _ => return, } @@ -2214,6 +2223,9 @@ impl BackgroundScannerState { if let Err(ix) = self.changed_paths.binary_search(parent_path) { self.changed_paths.insert(ix, parent_path.clone()); } + + #[cfg(test)] + self.snapshot.check_invariants(false); } fn remove_path(&mut self, path: &Path) { @@ -2248,6 +2260,9 @@ impl BackgroundScannerState { *needs_update = true; } } + + #[cfg(test)] + self.snapshot.check_invariants(false); } fn reload_repositories(&mut self, changed_paths: &[Arc], fs: &dyn Fs) { @@ -2669,6 +2684,7 @@ pub struct Entry { #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum EntryKind { + UnloadedDir, PendingDir, Dir, File(CharBag), @@ -2737,7 +2753,10 @@ impl Entry { impl EntryKind { pub fn is_dir(&self) -> bool { - matches!(self, EntryKind::Dir | EntryKind::PendingDir) + matches!( + self, + EntryKind::Dir | EntryKind::PendingDir | EntryKind::UnloadedDir + ) } pub fn is_file(&self) -> bool { @@ -3025,6 +3044,8 @@ impl BackgroundScanner { } async fn process_scan_request(&self, request: ScanRequest) -> bool { + log::debug!("rescanning paths {:?}", request.relative_paths); + let root_path = self.expand_paths(&request.relative_paths).await; let root_canonical_path = match self.fs.canonicalize(&root_path).await { Ok(path) => path, @@ -3051,6 +3072,8 @@ impl BackgroundScanner { } async fn process_events(&mut self, abs_paths: Vec) { + log::debug!("received fs events {:?}", abs_paths); + let root_path = self.state.lock().snapshot.abs_path.clone(); let root_canonical_path = match self.fs.canonicalize(&root_path).await { Ok(path) => path, @@ -3069,7 +3092,10 @@ impl BackgroundScanner { Some(scan_job_tx.clone()), ) .await; + drop(scan_job_tx); + self.scan_dirs(false, scan_job_rx).await; + let (scan_job_tx, scan_job_rx) = channel::unbounded(); self.update_ignore_statuses(scan_job_tx).await; self.scan_dirs(false, scan_job_rx).await; @@ -3091,7 +3117,7 @@ impl BackgroundScanner { for path in paths { for ancestor in path.ancestors() { if let Some(entry) = state.snapshot.entry_for_path(ancestor) { - if entry.kind == EntryKind::PendingDir { + if entry.kind == EntryKind::UnloadedDir { let abs_path = root_path.join(ancestor); let ignore_stack = state.snapshot.ignore_stack_for_abs_path(&abs_path, true); @@ -3217,14 +3243,8 @@ impl BackgroundScanner { } async fn scan_dir(&self, job: &ScanJob) -> Result<()> { - log::debug!( - "scan directory {:?}. external: {}", - job.path, - job.is_external - ); + log::debug!("scan directory {:?}", job.path); - let mut new_entries: Vec = Vec::new(); - let mut new_jobs: Vec> = Vec::new(); let mut ignore_stack = job.ignore_stack.clone(); let mut new_ignore = None; let (root_abs_path, root_char_bag, next_entry_id, repository) = { @@ -3240,6 +3260,8 @@ impl BackgroundScanner { }; let mut root_canonical_path = None; + let mut new_entries: Vec = Vec::new(); + let mut new_jobs: Vec> = Vec::new(); let mut child_paths = self.fs.read_dir(&job.abs_path).await?; while let Some(child_abs_path) = child_paths.next().await { let child_abs_path: Arc = match child_abs_path { @@ -3383,25 +3405,26 @@ impl BackgroundScanner { } let mut state = self.state.lock(); - state.populate_dir(&job.path, new_entries, new_ignore, self.fs.as_ref()); - - for new_job in new_jobs { - if let Some(new_job) = new_job { - // If a subdirectory is ignored, or is external to the worktree, don't scan - // it unless it is marked as expanded. - if (new_job.is_external || new_job.ignore_stack.is_all()) - && !state.is_path_expanded(&new_job.path) + let mut new_jobs = new_jobs.into_iter(); + for entry in &mut new_entries { + if entry.is_dir() { + let new_job = new_jobs.next().expect("missing scan job for entry"); + if (entry.is_external || entry.is_ignored) + && entry.kind == EntryKind::PendingDir + && !state.is_path_expanded(&entry.path) { - log::debug!("defer scanning directory {:?}", new_job.path); - continue; + log::debug!("defer scanning directory {:?} {:?}", entry.path, entry.kind); + entry.kind = EntryKind::UnloadedDir; + } else if let Some(new_job) = new_job { + job.scan_queue + .try_send(new_job) + .expect("channel is unbounded"); } - - job.scan_queue - .try_send(new_job) - .expect("channel is unbounded"); } } + assert!(new_jobs.next().is_none()); + state.populate_dir(&job.path, new_entries, new_ignore, self.fs.as_ref()); Ok(()) } @@ -3459,6 +3482,7 @@ impl BackgroundScanner { // detected regardless of the order of the paths. for (path, metadata) in event_paths.iter().zip(metadata.iter()) { if matches!(metadata, Ok(None)) || doing_recursive_update { + log::trace!("remove path {:?}", path); state.remove_path(path); } } @@ -3655,6 +3679,8 @@ impl BackgroundScanner { } async fn update_ignore_status(&self, job: UpdateIgnoreStatusJob, snapshot: &LocalSnapshot) { + log::trace!("update ignore status {:?}", job.abs_path); + let mut ignore_stack = job.ignore_stack; if let Some((ignore, _)) = snapshot.ignores_by_parent_abs_path.get(&job.abs_path) { ignore_stack = ignore_stack.append(job.abs_path.clone(), ignore.clone()); @@ -3679,7 +3705,7 @@ impl BackgroundScanner { if was_ignored && !entry.is_ignored && !entry.is_external - && entry.kind == EntryKind::PendingDir + && entry.kind == EntryKind::UnloadedDir { job.scan_queue .try_send(ScanJob { diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rs index 5cab52a21a..0a228c6830 100644 --- a/crates/project/src/worktree_tests.rs +++ b/crates/project/src/worktree_tests.rs @@ -332,7 +332,7 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { assert_eq!( tree.entry_for_path("deps/dep-dir2").unwrap().kind, - EntryKind::PendingDir + EntryKind::UnloadedDir ); }); @@ -915,7 +915,7 @@ async fn test_random_worktree_operations_during_initial_scan( .await .log_err(); worktree.read_with(cx, |tree, _| { - tree.as_local().unwrap().snapshot().check_invariants() + tree.as_local().unwrap().snapshot().check_invariants(true) }); if rng.gen_bool(0.6) { @@ -932,7 +932,7 @@ async fn test_random_worktree_operations_during_initial_scan( let final_snapshot = worktree.read_with(cx, |tree, _| { let tree = tree.as_local().unwrap(); let snapshot = tree.snapshot(); - snapshot.check_invariants(); + snapshot.check_invariants(true); snapshot }); @@ -1037,7 +1037,7 @@ async fn test_random_worktree_changes(cx: &mut TestAppContext, mut rng: StdRng) cx.foreground().run_until_parked(); let snapshot = worktree.read_with(cx, |tree, _| tree.as_local().unwrap().snapshot()); - snapshot.check_invariants(); + snapshot.check_invariants(true); let expanded_paths = snapshot .expanded_entries() .map(|e| e.path.clone()) @@ -1095,7 +1095,7 @@ async fn test_random_worktree_changes(cx: &mut TestAppContext, mut rng: StdRng) fn ignore_pending_dir(entry: &Entry) -> Entry { let mut entry = entry.clone(); - if entry.kind == EntryKind::PendingDir { + if entry.kind.is_dir() { entry.kind = EntryKind::Dir } entry From 9ad1ebf387e0fe31a8a4a898c123dbe43d9d5870 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 22 Jun 2023 17:02:01 -0700 Subject: [PATCH 138/215] Fix project panel test helper --- crates/project_panel/src/project_panel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 57934c4adb..16876106f4 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -2371,7 +2371,7 @@ mod tests { } let indent = " ".repeat(details.depth); - let icon = if matches!(details.kind, EntryKind::Dir | EntryKind::PendingDir) { + let icon = if details.kind.is_dir() { if details.is_expanded { "v " } else { From ff07d0c2ed488bd4c25c62490c80a87f660ac1c4 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 23 Jun 2023 08:58:30 +0200 Subject: [PATCH 139/215] Fix `Conversation::messages_for_offsets` with empty message at the end --- crates/ai/src/assistant.rs | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 5426715bf0..4ca7e7de26 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -1300,21 +1300,21 @@ impl Conversation { ) -> Vec { let mut result = Vec::new(); - let buffer_len = self.buffer.read(cx).len(); let mut messages = self.messages(cx).peekable(); let mut offsets = offsets.into_iter().peekable(); + let mut current_message = messages.next(); while let Some(offset) = offsets.next() { - // Skip messages that start after the offset. - while messages.peek().map_or(false, |message| { - message.range.end < offset || (message.range.end == offset && offset < buffer_len) + // Locate the message that contains the offset. + while current_message.as_ref().map_or(false, |message| { + !message.range.contains(&offset) && messages.peek().is_some() }) { - messages.next(); + current_message = messages.next(); } - let Some(message) = messages.peek() else { continue }; + let Some(message) = current_message.as_ref() else { break }; // Skip offsets that are in the same message. while offsets.peek().map_or(false, |offset| { - message.range.contains(offset) || message.range.end == buffer_len + message.range.contains(offset) || messages.peek().is_none() }) { offsets.next(); } @@ -2360,6 +2360,26 @@ mod tests { [message_1.id, message_3.id] ); + let message_4 = conversation + .update(cx, |conversation, cx| { + conversation.insert_message_after(message_3.id, Role::User, MessageStatus::Done, cx) + }) + .unwrap(); + assert_eq!(buffer.read(cx).text(), "aaa\nbbb\nccc\n"); + assert_eq!( + messages(&conversation, cx), + vec![ + (message_1.id, Role::User, 0..4), + (message_2.id, Role::User, 4..8), + (message_3.id, Role::User, 8..12), + (message_4.id, Role::User, 12..12) + ] + ); + assert_eq!( + message_ids_for_offsets(&conversation, &[0, 4, 8, 12], cx), + [message_1.id, message_2.id, message_3.id, message_4.id] + ); + fn message_ids_for_offsets( conversation: &ModelHandle, offsets: &[usize], From ed88f52619531586aed6697447258dc2c7af7de2 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 23 Jun 2023 09:23:52 +0200 Subject: [PATCH 140/215] Remove double constrained call --- crates/gpui/src/elements/svg.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/gpui/src/elements/svg.rs b/crates/gpui/src/elements/svg.rs index 4ef880b3e1..9792f16cbe 100644 --- a/crates/gpui/src/elements/svg.rs +++ b/crates/gpui/src/elements/svg.rs @@ -30,7 +30,6 @@ impl Svg { Self::new(style.asset) .with_color(style.color) .constrained() - .constrained() .with_width(style.dimensions.width) .with_height(style.dimensions.height) } From 5ea5368c0790ce61b8edfbe4119047871b6f1fe4 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 23 Jun 2023 09:57:31 +0200 Subject: [PATCH 141/215] Re-enable buffer search in assistant --- assets/keymaps/default.json | 7 +++ crates/ai/src/assistant.rs | 92 ++++++++++++++++++++++++++---- crates/search/src/buffer_search.rs | 10 +++- crates/workspace/src/pane.rs | 13 +++-- crates/workspace/src/toolbar.rs | 74 +++++++++++------------- 5 files changed, 134 insertions(+), 62 deletions(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index 635578fdda..853d62f3e4 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -197,6 +197,13 @@ "cmd-alt-enter": "editor::NewlineBelow" } }, + { + "context": "AssistantPanel", + "bindings": { + "cmd-g": "search::SelectNextMatch", + "cmd-shift-g": "search::SelectPrevMatch" + } + }, { "context": "ConversationEditor > Editor", "bindings": { diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 6e10916a3d..b56695d08a 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -24,6 +24,7 @@ use gpui::{ }; use isahc::{http::StatusCode, Request, RequestExt}; use language::{language_settings::SoftWrap, Buffer, LanguageRegistry, ToOffset as _}; +use search::BufferSearchBar; use serde::Deserialize; use settings::SettingsStore; use std::{ @@ -46,7 +47,8 @@ use util::{ use workspace::{ dock::{DockPosition, Panel}, item::Item, - Save, ToggleZoom, Workspace, + searchable::Direction, + Save, ToggleZoom, Toolbar, Workspace, }; const OPENAI_API_URL: &'static str = "https://api.openai.com/v1"; @@ -93,6 +95,10 @@ pub fn init(cx: &mut AppContext) { cx.add_action(AssistantPanel::save_api_key); cx.add_action(AssistantPanel::reset_api_key); cx.add_action(AssistantPanel::toggle_zoom); + cx.add_action(AssistantPanel::deploy); + cx.add_action(AssistantPanel::select_next_match); + cx.add_action(AssistantPanel::select_prev_match); + cx.add_action(AssistantPanel::handle_editor_cancel); cx.add_action( |workspace: &mut Workspace, _: &ToggleFocus, cx: &mut ViewContext| { workspace.toggle_panel_focus::(cx); @@ -118,6 +124,7 @@ pub struct AssistantPanel { saved_conversations_list_state: UniformListState, zoomed: bool, has_focus: bool, + toolbar: ViewHandle, api_key: Rc>>, api_key_editor: Option>, has_read_credentials: bool, @@ -161,6 +168,12 @@ impl AssistantPanel { anyhow::Ok(()) }); + let toolbar = cx.add_view(|cx| { + let mut toolbar = Toolbar::new(None); + toolbar.set_can_navigate(false, cx); + toolbar.add_item(cx.add_view(|cx| BufferSearchBar::new(cx)), cx); + toolbar + }); let mut this = Self { active_editor_index: Default::default(), editors: Default::default(), @@ -168,6 +181,7 @@ impl AssistantPanel { saved_conversations_list_state: Default::default(), zoomed: false, has_focus: false, + toolbar, api_key: Rc::new(RefCell::new(None)), api_key_editor: None, has_read_credentials: false, @@ -220,11 +234,27 @@ impl AssistantPanel { self.subscriptions .push(cx.observe(&conversation, |_, _, cx| cx.notify())); - self.active_editor_index = Some(self.editors.len()); - self.editors.push(editor.clone()); - if self.has_focus(cx) { - cx.focus(&editor); + let index = self.editors.len(); + self.editors.push(editor); + self.set_active_editor_index(Some(index), cx); + } + + fn set_active_editor_index(&mut self, index: Option, cx: &mut ViewContext) { + self.active_editor_index = index; + if let Some(editor) = self.active_editor() { + let editor = editor.read(cx).editor.clone(); + self.toolbar.update(cx, |toolbar, cx| { + toolbar.set_active_item(Some(&editor), cx); + }); + if self.has_focus(cx) { + cx.focus(&editor); + } + } else { + self.toolbar.update(cx, |toolbar, cx| { + toolbar.set_active_item(None, cx); + }); } + cx.notify(); } @@ -275,6 +305,39 @@ impl AssistantPanel { } } + fn deploy(&mut self, action: &search::buffer_search::Deploy, cx: &mut ViewContext) { + if let Some(search_bar) = self.toolbar.read(cx).item_of_type::() { + if search_bar.update(cx, |search_bar, cx| search_bar.show(action.focus, true, cx)) { + return; + } + } + cx.propagate_action(); + } + + fn handle_editor_cancel(&mut self, _: &editor::Cancel, cx: &mut ViewContext) { + if let Some(search_bar) = self.toolbar.read(cx).item_of_type::() { + if !search_bar.read(cx).is_dismissed() { + search_bar.update(cx, |search_bar, cx| { + search_bar.dismiss(&Default::default(), cx) + }); + return; + } + } + cx.propagate_action(); + } + + fn select_next_match(&mut self, _: &search::SelectNextMatch, cx: &mut ViewContext) { + if let Some(search_bar) = self.toolbar.read(cx).item_of_type::() { + search_bar.update(cx, |bar, cx| bar.select_match(Direction::Next, cx)); + } + } + + fn select_prev_match(&mut self, _: &search::SelectPrevMatch, cx: &mut ViewContext) { + if let Some(search_bar) = self.toolbar.read(cx).item_of_type::() { + search_bar.update(cx, |bar, cx| bar.select_match(Direction::Prev, cx)); + } + } + fn active_editor(&self) -> Option<&ViewHandle> { self.editors.get(self.active_editor_index?) } @@ -287,8 +350,7 @@ impl AssistantPanel { .mouse::(0) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, |_, this: &mut Self, cx| { - this.active_editor_index = None; - cx.notify(); + this.set_active_editor_index(None, cx); }) } @@ -425,8 +487,7 @@ impl AssistantPanel { fn open_conversation(&mut self, path: PathBuf, cx: &mut ViewContext) -> Task> { if let Some(ix) = self.editor_index_for_path(&path, cx) { - self.active_editor_index = Some(ix); - cx.notify(); + self.set_active_editor_index(Some(ix), cx); return Task::ready(Ok(())); } @@ -444,7 +505,7 @@ impl AssistantPanel { // If, by the time we've loaded the conversation, the user has already opened // the same conversation, we don't want to open it again. if let Some(ix) = this.editor_index_for_path(&path, cx) { - this.active_editor_index = Some(ix); + this.set_active_editor_index(Some(ix), cx); } else { let editor = cx .add_view(|cx| ConversationEditor::from_conversation(conversation, fs, cx)); @@ -541,6 +602,11 @@ impl View for AssistantPanel { .constrained() .with_height(theme.workspace.tab_bar.height), ) + .with_children(if self.toolbar.read(cx).hidden() { + None + } else { + Some(ChildView::new(&self.toolbar, cx).expanded()) + }) .with_child(if let Some(editor) = self.active_editor() { ChildView::new(editor, cx).flex(1., true).into_any() } else { @@ -563,6 +629,8 @@ impl View for AssistantPanel { fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext) { self.has_focus = true; + self.toolbar + .update(cx, |toolbar, cx| toolbar.focus_changed(true, cx)); if cx.is_self_focused() { if let Some(editor) = self.active_editor() { cx.focus(editor); @@ -572,8 +640,10 @@ impl View for AssistantPanel { } } - fn focus_out(&mut self, _: gpui::AnyViewHandle, _: &mut ViewContext) { + fn focus_out(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext) { self.has_focus = false; + self.toolbar + .update(cx, |toolbar, cx| toolbar.focus_changed(false, cx)); } } diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index c6a86b2f6a..59d25c2659 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -259,7 +259,11 @@ impl BufferSearchBar { } } - fn dismiss(&mut self, _: &Dismiss, cx: &mut ViewContext) { + pub fn is_dismissed(&self) -> bool { + self.dismissed + } + + pub fn dismiss(&mut self, _: &Dismiss, cx: &mut ViewContext) { self.dismissed = true; for searchable_item in self.seachable_items_with_matches.keys() { if let Some(searchable_item) = @@ -275,7 +279,7 @@ impl BufferSearchBar { cx.notify(); } - fn show(&mut self, focus: bool, suggest_query: bool, cx: &mut ViewContext) -> bool { + pub fn show(&mut self, focus: bool, suggest_query: bool, cx: &mut ViewContext) -> bool { let searchable_item = if let Some(searchable_item) = &self.active_searchable_item { SearchableItemHandle::boxed_clone(searchable_item.as_ref()) } else { @@ -484,7 +488,7 @@ impl BufferSearchBar { self.select_match(Direction::Prev, cx); } - fn select_match(&mut self, direction: Direction, cx: &mut ViewContext) { + pub fn select_match(&mut self, direction: Direction, cx: &mut ViewContext) { if let Some(index) = self.active_match_index { if let Some(searchable_item) = self.active_searchable_item.as_ref() { if let Some(matches) = self diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 5136db1d18..54b18ea8b3 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -1,9 +1,10 @@ mod dragged_item_receiver; use super::{ItemHandle, SplitDirection}; +pub use crate::toolbar::Toolbar; use crate::{ - item::WeakItemHandle, notify_of_new_dock, toolbar::Toolbar, AutosaveSetting, Item, - NewCenterTerminal, NewFile, NewSearch, ToggleZoom, Workspace, WorkspaceSettings, + item::WeakItemHandle, notify_of_new_dock, AutosaveSetting, Item, NewCenterTerminal, NewFile, + NewSearch, ToggleZoom, Workspace, WorkspaceSettings, }; use anyhow::Result; use collections::{HashMap, HashSet, VecDeque}; @@ -250,7 +251,7 @@ impl Pane { pane: handle.clone(), next_timestamp, }))), - toolbar: cx.add_view(|_| Toolbar::new(handle)), + toolbar: cx.add_view(|_| Toolbar::new(Some(handle))), tab_bar_context_menu: TabBarContextMenu { kind: TabBarContextMenuKind::New, handle: context_menu, @@ -1112,7 +1113,7 @@ impl Pane { .get(self.active_item_index) .map(|item| item.as_ref()); self.toolbar.update(cx, |toolbar, cx| { - toolbar.set_active_pane_item(active_item, cx); + toolbar.set_active_item(active_item, cx); }); } @@ -1602,7 +1603,7 @@ impl View for Pane { } self.toolbar.update(cx, |toolbar, cx| { - toolbar.pane_focus_update(true, cx); + toolbar.focus_changed(true, cx); }); if let Some(active_item) = self.active_item() { @@ -1631,7 +1632,7 @@ impl View for Pane { fn focus_out(&mut self, _: AnyViewHandle, cx: &mut ViewContext) { self.has_focus = false; self.toolbar.update(cx, |toolbar, cx| { - toolbar.pane_focus_update(false, cx); + toolbar.focus_changed(false, cx); }); cx.notify(); } diff --git a/crates/workspace/src/toolbar.rs b/crates/workspace/src/toolbar.rs index 49f9db12e6..69394b8421 100644 --- a/crates/workspace/src/toolbar.rs +++ b/crates/workspace/src/toolbar.rs @@ -38,7 +38,7 @@ trait ToolbarItemViewHandle { active_pane_item: Option<&dyn ItemHandle>, cx: &mut WindowContext, ) -> ToolbarItemLocation; - fn pane_focus_update(&mut self, pane_focused: bool, cx: &mut WindowContext); + fn focus_changed(&mut self, pane_focused: bool, cx: &mut WindowContext); fn row_count(&self, cx: &WindowContext) -> usize; } @@ -51,10 +51,10 @@ pub enum ToolbarItemLocation { } pub struct Toolbar { - active_pane_item: Option>, + active_item: Option>, hidden: bool, can_navigate: bool, - pane: WeakViewHandle, + pane: Option>, items: Vec<(Box, ToolbarItemLocation)>, } @@ -121,7 +121,7 @@ impl View for Toolbar { let pane = self.pane.clone(); let mut enable_go_backward = false; let mut enable_go_forward = false; - if let Some(pane) = pane.upgrade(cx) { + if let Some(pane) = pane.and_then(|pane| pane.upgrade(cx)) { let pane = pane.read(cx); enable_go_backward = pane.can_navigate_backward(); enable_go_forward = pane.can_navigate_forward(); @@ -143,19 +143,17 @@ impl View for Toolbar { enable_go_backward, spacing, { - let pane = pane.clone(); move |toolbar, cx| { - if let Some(workspace) = toolbar - .pane - .upgrade(cx) - .and_then(|pane| pane.read(cx).workspace().upgrade(cx)) + if let Some(pane) = toolbar.pane.as_ref().and_then(|pane| pane.upgrade(cx)) { - let pane = pane.clone(); - cx.window_context().defer(move |cx| { - workspace.update(cx, |workspace, cx| { - workspace.go_back(pane.clone(), cx).detach_and_log_err(cx); - }); - }) + if let Some(workspace) = pane.read(cx).workspace().upgrade(cx) { + let pane = pane.downgrade(); + cx.window_context().defer(move |cx| { + workspace.update(cx, |workspace, cx| { + workspace.go_back(pane, cx).detach_and_log_err(cx); + }); + }) + } } } }, @@ -171,21 +169,17 @@ impl View for Toolbar { enable_go_forward, spacing, { - let pane = pane.clone(); move |toolbar, cx| { - if let Some(workspace) = toolbar - .pane - .upgrade(cx) - .and_then(|pane| pane.read(cx).workspace().upgrade(cx)) + if let Some(pane) = toolbar.pane.as_ref().and_then(|pane| pane.upgrade(cx)) { - let pane = pane.clone(); - cx.window_context().defer(move |cx| { - workspace.update(cx, |workspace, cx| { - workspace - .go_forward(pane.clone(), cx) - .detach_and_log_err(cx); - }); - }); + if let Some(workspace) = pane.read(cx).workspace().upgrade(cx) { + let pane = pane.downgrade(); + cx.window_context().defer(move |cx| { + workspace.update(cx, |workspace, cx| { + workspace.go_forward(pane, cx).detach_and_log_err(cx); + }); + }) + } } } }, @@ -269,9 +263,9 @@ fn nav_button } impl Toolbar { - pub fn new(pane: WeakViewHandle) -> Self { + pub fn new(pane: Option>) -> Self { Self { - active_pane_item: None, + active_item: None, pane, items: Default::default(), hidden: false, @@ -288,7 +282,7 @@ impl Toolbar { where T: 'static + ToolbarItemView, { - let location = item.set_active_pane_item(self.active_pane_item.as_deref(), cx); + let location = item.set_active_pane_item(self.active_item.as_deref(), cx); cx.subscribe(&item, |this, item, event, cx| { if let Some((_, current_location)) = this.items.iter_mut().find(|(i, _)| i.id() == item.id()) @@ -307,20 +301,16 @@ impl Toolbar { cx.notify(); } - pub fn set_active_pane_item( - &mut self, - pane_item: Option<&dyn ItemHandle>, - cx: &mut ViewContext, - ) { - self.active_pane_item = pane_item.map(|item| item.boxed_clone()); + pub fn set_active_item(&mut self, item: Option<&dyn ItemHandle>, cx: &mut ViewContext) { + self.active_item = item.map(|item| item.boxed_clone()); self.hidden = self - .active_pane_item + .active_item .as_ref() .map(|item| !item.show_toolbar(cx)) .unwrap_or(false); for (toolbar_item, current_location) in self.items.iter_mut() { - let new_location = toolbar_item.set_active_pane_item(pane_item, cx); + let new_location = toolbar_item.set_active_pane_item(item, cx); if new_location != *current_location { *current_location = new_location; cx.notify(); @@ -328,9 +318,9 @@ impl Toolbar { } } - pub fn pane_focus_update(&mut self, pane_focused: bool, cx: &mut ViewContext) { + pub fn focus_changed(&mut self, focused: bool, cx: &mut ViewContext) { for (toolbar_item, _) in self.items.iter_mut() { - toolbar_item.pane_focus_update(pane_focused, cx); + toolbar_item.focus_changed(focused, cx); } } @@ -364,7 +354,7 @@ impl ToolbarItemViewHandle for ViewHandle { }) } - fn pane_focus_update(&mut self, pane_focused: bool, cx: &mut WindowContext) { + fn focus_changed(&mut self, pane_focused: bool, cx: &mut WindowContext) { self.update(cx, |this, cx| { this.pane_focus_update(pane_focused, cx); cx.notify(); From c38bf2de333f1b9602dacd50f566b87ad725c8d4 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 23 Jun 2023 10:05:21 +0200 Subject: [PATCH 142/215] Sort conversations in descending chronological order --- crates/ai/src/ai.rs | 2 ++ styles/src/styleTree/assistant.ts | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ai/src/ai.rs b/crates/ai/src/ai.rs index c1e6a4c569..812fb05121 100644 --- a/crates/ai/src/ai.rs +++ b/crates/ai/src/ai.rs @@ -11,6 +11,7 @@ use gpui::AppContext; use regex::Regex; use serde::{Deserialize, Serialize}; use std::{ + cmp::Reverse, fmt::{self, Display}, path::PathBuf, sync::Arc, @@ -97,6 +98,7 @@ impl SavedConversationMetadata { }); } } + conversations.sort_unstable_by_key(|conversation| Reverse(conversation.mtime)); Ok(conversations) } diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index 942b97a232..abdd55818b 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -75,6 +75,7 @@ export default function assistant(colorScheme: ColorScheme) { container: interactive({ base: { background: background(layer, "on"), + padding: { top: 4, bottom: 4 } }, state: { hovered: { @@ -87,7 +88,7 @@ export default function assistant(colorScheme: ColorScheme) { ...text(layer, "sans", "default", { size: "xs" }), }, title: { - margin: { left: 8 }, + margin: { left: 16 }, ...text(layer, "sans", "default", { size: "sm", weight: "bold" }), } }, From 6c7271c633887ec349bc93680bdbd4dd446c0292 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 23 Jun 2023 10:42:15 +0200 Subject: [PATCH 143/215] Test serialization roundtrip --- crates/ai/src/assistant.rs | 238 +++++++++++++++++++++++-------------- 1 file changed, 146 insertions(+), 92 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index b56695d08a..6e23c1e7a0 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -492,15 +492,14 @@ impl AssistantPanel { } let fs = self.fs.clone(); - let conversation = Conversation::load( - path.clone(), - self.api_key.clone(), - self.languages.clone(), - self.fs.clone(), - cx, - ); + let api_key = self.api_key.clone(); + let languages = self.languages.clone(); cx.spawn(|this, mut cx| async move { - let conversation = conversation.await?; + let saved_conversation = fs.load(&path).await?; + let saved_conversation = serde_json::from_str(&saved_conversation)?; + let conversation = cx.add_model(|cx| { + Conversation::deserialize(saved_conversation, path.clone(), api_key, languages, cx) + }); this.update(&mut cx, |this, cx| { // If, by the time we've loaded the conversation, the user has already opened // the same conversation, we don't want to open it again. @@ -508,7 +507,7 @@ impl AssistantPanel { this.set_active_editor_index(Some(ix), cx); } else { let editor = cx - .add_view(|cx| ConversationEditor::from_conversation(conversation, fs, cx)); + .add_view(|cx| ConversationEditor::for_conversation(conversation, fs, cx)); this.add_conversation(editor, cx); } })?; @@ -861,72 +860,86 @@ impl Conversation { this } - fn load( + fn serialize(&self, cx: &AppContext) -> SavedConversation { + SavedConversation { + zed: "conversation".into(), + version: SavedConversation::VERSION.into(), + text: self.buffer.read(cx).text(), + message_metadata: self.messages_metadata.clone(), + messages: self + .messages(cx) + .map(|message| SavedMessage { + id: message.id, + start: message.range.start, + }) + .collect(), + summary: self + .summary + .as_ref() + .map(|summary| summary.text.clone()) + .unwrap_or_default(), + model: self.model.clone(), + } + } + + fn deserialize( + saved_conversation: SavedConversation, path: PathBuf, api_key: Rc>>, language_registry: Arc, - fs: Arc, - cx: &mut AppContext, - ) -> Task>> { - cx.spawn(|mut cx| async move { - let saved_conversation = fs.load(&path).await?; - let saved_conversation: SavedConversation = serde_json::from_str(&saved_conversation)?; + cx: &mut ModelContext, + ) -> Self { + let model = saved_conversation.model; + let markdown = language_registry.language_for_name("Markdown"); + let mut message_anchors = Vec::new(); + let mut next_message_id = MessageId(0); + let buffer = cx.add_model(|cx| { + let mut buffer = Buffer::new(0, saved_conversation.text, cx); + for message in saved_conversation.messages { + message_anchors.push(MessageAnchor { + id: message.id, + start: buffer.anchor_before(message.start), + }); + next_message_id = cmp::max(next_message_id, MessageId(message.id.0 + 1)); + } + buffer.set_language_registry(language_registry); + cx.spawn_weak(|buffer, mut cx| async move { + let markdown = markdown.await?; + let buffer = buffer + .upgrade(&cx) + .ok_or_else(|| anyhow!("buffer was dropped"))?; + buffer.update(&mut cx, |buffer, cx| { + buffer.set_language(Some(markdown), cx) + }); + anyhow::Ok(()) + }) + .detach_and_log_err(cx); + buffer + }); - let model = saved_conversation.model; - let markdown = language_registry.language_for_name("Markdown"); - let mut message_anchors = Vec::new(); - let mut next_message_id = MessageId(0); - let buffer = cx.add_model(|cx| { - let mut buffer = Buffer::new(0, saved_conversation.text, cx); - for message in saved_conversation.messages { - message_anchors.push(MessageAnchor { - id: message.id, - start: buffer.anchor_before(message.start), - }); - next_message_id = cmp::max(next_message_id, MessageId(message.id.0 + 1)); - } - buffer.set_language_registry(language_registry); - cx.spawn_weak(|buffer, mut cx| async move { - let markdown = markdown.await?; - let buffer = buffer - .upgrade(&cx) - .ok_or_else(|| anyhow!("buffer was dropped"))?; - buffer.update(&mut cx, |buffer, cx| { - buffer.set_language(Some(markdown), cx) - }); - anyhow::Ok(()) - }) - .detach_and_log_err(cx); - buffer - }); - let conversation = cx.add_model(|cx| { - let mut this = Self { - message_anchors, - messages_metadata: saved_conversation.message_metadata, - next_message_id, - summary: Some(Summary { - text: saved_conversation.summary, - done: true, - }), - pending_summary: Task::ready(None), - completion_count: Default::default(), - pending_completions: Default::default(), - token_count: None, - max_token_count: tiktoken_rs::model::get_context_size(&model), - pending_token_count: Task::ready(None), - model, - _subscriptions: vec![cx.subscribe(&buffer, Self::handle_buffer_event)], - pending_save: Task::ready(Ok(())), - path: Some(path), - api_key, - buffer, - }; - - this.count_remaining_tokens(cx); - this - }); - Ok(conversation) - }) + let mut this = Self { + message_anchors, + messages_metadata: saved_conversation.message_metadata, + next_message_id, + summary: Some(Summary { + text: saved_conversation.summary, + done: true, + }), + pending_summary: Task::ready(None), + completion_count: Default::default(), + pending_completions: Default::default(), + token_count: None, + max_token_count: tiktoken_rs::model::get_context_size(&model), + pending_token_count: Task::ready(None), + model, + _subscriptions: vec![cx.subscribe(&buffer, Self::handle_buffer_event)], + pending_save: Task::ready(Ok(())), + path: Some(path), + api_key, + buffer, + }; + this.count_remaining_tokens(cx); + this } fn handle_buffer_event( @@ -1453,23 +1466,7 @@ impl Conversation { }); if let Some(summary) = summary { - let conversation = this.read_with(&cx, |this, cx| SavedConversation { - zed: "conversation".into(), - version: SavedConversation::VERSION.into(), - text: this.buffer.read(cx).text(), - message_metadata: this.messages_metadata.clone(), - messages: this - .message_anchors - .iter() - .map(|message| SavedMessage { - id: message.id, - start: message.start.to_offset(this.buffer.read(cx)), - }) - .collect(), - summary: summary.clone(), - model: this.model.clone(), - }); - + let conversation = this.read_with(&cx, |this, cx| this.serialize(cx)); let path = if let Some(old_path) = old_path { old_path } else { @@ -1533,10 +1530,10 @@ impl ConversationEditor { cx: &mut ViewContext, ) -> Self { let conversation = cx.add_model(|cx| Conversation::new(api_key, language_registry, cx)); - Self::from_conversation(conversation, fs, cx) + Self::for_conversation(conversation, fs, cx) } - fn from_conversation( + fn for_conversation( conversation: ModelHandle, fs: Arc, cx: &mut ViewContext, @@ -2116,9 +2113,8 @@ async fn stream_completion( #[cfg(test)] mod tests { - use crate::MessageId; - use super::*; + use crate::MessageId; use fs::FakeFs; use gpui::{AppContext, TestAppContext}; use project::Project; @@ -2464,6 +2460,64 @@ mod tests { } } + #[gpui::test] + fn test_serialization(cx: &mut AppContext) { + let registry = Arc::new(LanguageRegistry::test()); + let conversation = + cx.add_model(|cx| Conversation::new(Default::default(), registry.clone(), cx)); + let buffer = conversation.read(cx).buffer.clone(); + let message_0 = conversation.read(cx).message_anchors[0].id; + let message_1 = conversation.update(cx, |conversation, cx| { + conversation + .insert_message_after(message_0, Role::Assistant, MessageStatus::Done, cx) + .unwrap() + }); + let message_2 = conversation.update(cx, |conversation, cx| { + conversation + .insert_message_after(message_1.id, Role::System, MessageStatus::Done, cx) + .unwrap() + }); + buffer.update(cx, |buffer, cx| { + buffer.edit([(0..0, "a"), (1..1, "b\nc")], None, cx); + buffer.finalize_last_transaction(); + }); + let _message_3 = conversation.update(cx, |conversation, cx| { + conversation + .insert_message_after(message_2.id, Role::System, MessageStatus::Done, cx) + .unwrap() + }); + buffer.update(cx, |buffer, cx| buffer.undo(cx)); + assert_eq!(buffer.read(cx).text(), "a\nb\nc\n"); + assert_eq!( + messages(&conversation, cx), + [ + (message_0, Role::User, 0..2), + (message_1.id, Role::Assistant, 2..6), + (message_2.id, Role::System, 6..6), + ] + ); + + let deserialized_conversation = cx.add_model(|cx| { + Conversation::deserialize( + conversation.read(cx).serialize(cx), + Default::default(), + Default::default(), + registry.clone(), + cx, + ) + }); + let deserialized_buffer = deserialized_conversation.read(cx).buffer.clone(); + assert_eq!(deserialized_buffer.read(cx).text(), "a\nb\nc\n"); + assert_eq!( + messages(&deserialized_conversation, cx), + [ + (message_0, Role::User, 0..2), + (message_1.id, Role::Assistant, 2..6), + (message_2.id, Role::System, 6..6), + ] + ); + } + fn messages( conversation: &ModelHandle, cx: &AppContext, From 5c5d598623ef33392476fe36787fe08e307ff568 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 23 Jun 2023 11:13:52 +0200 Subject: [PATCH 144/215] Insert new message right before the next valid one --- crates/ai/src/assistant.rs | 143 +++++++++++++++++++++---------------- 1 file changed, 81 insertions(+), 62 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 6e23c1e7a0..d7299ca6b5 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -870,7 +870,7 @@ impl Conversation { .messages(cx) .map(|message| SavedMessage { id: message.id, - start: message.range.start, + start: message.offset_range.start, }) .collect(), summary: self @@ -968,7 +968,11 @@ impl Conversation { Role::Assistant => "assistant".into(), Role::System => "system".into(), }, - content: self.buffer.read(cx).text_for_range(message.range).collect(), + content: self + .buffer + .read(cx) + .text_for_range(message.offset_range) + .collect(), name: None, }) }) @@ -1183,10 +1187,19 @@ impl Conversation { .iter() .position(|message| message.id == message_id) { + // Find the next valid message after the one we were given. + let mut next_message_ix = prev_message_ix + 1; + while let Some(next_message) = self.message_anchors.get(next_message_ix) { + if next_message.start.is_valid(self.buffer.read(cx)) { + break; + } + next_message_ix += 1; + } + let start = self.buffer.update(cx, |buffer, cx| { - let offset = self.message_anchors[prev_message_ix + 1..] - .iter() - .find(|message| message.start.is_valid(buffer)) + let offset = self + .message_anchors + .get(next_message_ix) .map_or(buffer.len(), |message| message.start.to_offset(buffer) - 1); buffer.edit([(offset..offset, "\n")], None, cx); buffer.anchor_before(offset + 1) @@ -1196,7 +1209,7 @@ impl Conversation { start, }; self.message_anchors - .insert(prev_message_ix + 1, message.clone()); + .insert(next_message_ix, message.clone()); self.messages_metadata.insert( message.id, MessageMetadata { @@ -1221,7 +1234,7 @@ impl Conversation { let end_message = self.message_for_offset(range.end, cx); if let Some((start_message, end_message)) = start_message.zip(end_message) { // Prevent splitting when range spans multiple messages. - if start_message.index != end_message.index { + if start_message.id != end_message.id { return (None, None); } @@ -1230,7 +1243,8 @@ impl Conversation { let mut edited_buffer = false; let mut suffix_start = None; - if range.start > message.range.start && range.end < message.range.end - 1 { + if range.start > message.offset_range.start && range.end < message.offset_range.end - 1 + { if self.buffer.read(cx).chars_at(range.end).next() == Some('\n') { suffix_start = Some(range.end + 1); } else if self.buffer.read(cx).reversed_chars_at(range.end).next() == Some('\n') { @@ -1255,7 +1269,7 @@ impl Conversation { }; self.message_anchors - .insert(message.index + 1, suffix.clone()); + .insert(message.index_range.end + 1, suffix.clone()); self.messages_metadata.insert( suffix.id, MessageMetadata { @@ -1265,49 +1279,52 @@ impl Conversation { }, ); - let new_messages = if range.start == range.end || range.start == message.range.start { - (None, Some(suffix)) - } else { - let mut prefix_end = None; - if range.start > message.range.start && range.end < message.range.end - 1 { - if self.buffer.read(cx).chars_at(range.start).next() == Some('\n') { - prefix_end = Some(range.start + 1); - } else if self.buffer.read(cx).reversed_chars_at(range.start).next() - == Some('\n') - { - prefix_end = Some(range.start); - } - } - - let selection = if let Some(prefix_end) = prefix_end { - cx.emit(ConversationEvent::MessagesEdited); - MessageAnchor { - id: MessageId(post_inc(&mut self.next_message_id.0)), - start: self.buffer.read(cx).anchor_before(prefix_end), - } + let new_messages = + if range.start == range.end || range.start == message.offset_range.start { + (None, Some(suffix)) } else { - self.buffer.update(cx, |buffer, cx| { - buffer.edit([(range.start..range.start, "\n")], None, cx) - }); - edited_buffer = true; - MessageAnchor { - id: MessageId(post_inc(&mut self.next_message_id.0)), - start: self.buffer.read(cx).anchor_before(range.end + 1), + let mut prefix_end = None; + if range.start > message.offset_range.start + && range.end < message.offset_range.end - 1 + { + if self.buffer.read(cx).chars_at(range.start).next() == Some('\n') { + prefix_end = Some(range.start + 1); + } else if self.buffer.read(cx).reversed_chars_at(range.start).next() + == Some('\n') + { + prefix_end = Some(range.start); + } } - }; - self.message_anchors - .insert(message.index + 1, selection.clone()); - self.messages_metadata.insert( - selection.id, - MessageMetadata { - role, - sent_at: Local::now(), - status: MessageStatus::Done, - }, - ); - (Some(selection), Some(suffix)) - }; + let selection = if let Some(prefix_end) = prefix_end { + cx.emit(ConversationEvent::MessagesEdited); + MessageAnchor { + id: MessageId(post_inc(&mut self.next_message_id.0)), + start: self.buffer.read(cx).anchor_before(prefix_end), + } + } else { + self.buffer.update(cx, |buffer, cx| { + buffer.edit([(range.start..range.start, "\n")], None, cx) + }); + edited_buffer = true; + MessageAnchor { + id: MessageId(post_inc(&mut self.next_message_id.0)), + start: self.buffer.read(cx).anchor_before(range.end + 1), + } + }; + + self.message_anchors + .insert(message.index_range.end + 1, selection.clone()); + self.messages_metadata.insert( + selection.id, + MessageMetadata { + role, + sent_at: Local::now(), + status: MessageStatus::Done, + }, + ); + (Some(selection), Some(suffix)) + }; if !edited_buffer { cx.emit(ConversationEvent::MessagesEdited); @@ -1389,7 +1406,7 @@ impl Conversation { while let Some(offset) = offsets.next() { // Locate the message that contains the offset. while current_message.as_ref().map_or(false, |message| { - !message.range.contains(&offset) && messages.peek().is_some() + !message.offset_range.contains(&offset) && messages.peek().is_some() }) { current_message = messages.next(); } @@ -1397,7 +1414,7 @@ impl Conversation { // Skip offsets that are in the same message. while offsets.peek().map_or(false, |offset| { - message.range.contains(offset) || messages.peek().is_none() + message.offset_range.contains(offset) || messages.peek().is_none() }) { offsets.next(); } @@ -1411,15 +1428,17 @@ impl Conversation { let buffer = self.buffer.read(cx); let mut message_anchors = self.message_anchors.iter().enumerate().peekable(); iter::from_fn(move || { - while let Some((ix, message_anchor)) = message_anchors.next() { + while let Some((start_ix, message_anchor)) = message_anchors.next() { let metadata = self.messages_metadata.get(&message_anchor.id)?; let message_start = message_anchor.start.to_offset(buffer); let mut message_end = None; + let mut end_ix = start_ix; while let Some((_, next_message)) = message_anchors.peek() { if next_message.start.is_valid(buffer) { message_end = Some(next_message.start); break; } else { + end_ix += 1; message_anchors.next(); } } @@ -1427,8 +1446,8 @@ impl Conversation { .unwrap_or(language::Anchor::MAX) .to_offset(buffer); return Some(Message { - index: ix, - range: message_start..message_end, + index_range: start_ix..end_ix, + offset_range: message_start..message_end, id: message_anchor.id, anchor: message_anchor.start, role: metadata.role, @@ -1885,11 +1904,11 @@ impl ConversationEditor { let mut copied_text = String::new(); let mut spanned_messages = 0; for message in conversation.messages(cx) { - if message.range.start >= selection.range().end { + if message.offset_range.start >= selection.range().end { break; - } else if message.range.end >= selection.range().start { - let range = cmp::max(message.range.start, selection.range().start) - ..cmp::min(message.range.end, selection.range().end); + } else if message.offset_range.end >= selection.range().start { + let range = cmp::max(message.offset_range.start, selection.range().start) + ..cmp::min(message.offset_range.end, selection.range().end); if !range.is_empty() { spanned_messages += 1; write!(&mut copied_text, "## {}\n\n", message.role).unwrap(); @@ -2005,8 +2024,8 @@ struct MessageAnchor { #[derive(Clone, Debug)] pub struct Message { - range: Range, - index: usize, + offset_range: Range, + index_range: Range, id: MessageId, anchor: language::Anchor, role: Role, @@ -2017,7 +2036,7 @@ pub struct Message { impl Message { fn to_open_ai_message(&self, buffer: &Buffer) -> RequestMessage { let mut content = format!("[Message {}]\n", self.id.0).to_string(); - content.extend(buffer.text_for_range(self.range.clone())); + content.extend(buffer.text_for_range(self.offset_range.clone())); RequestMessage { role: self.role, content: content.trim_end().into(), @@ -2525,7 +2544,7 @@ mod tests { conversation .read(cx) .messages(cx) - .map(|message| (message.id, message.role, message.range)) + .map(|message| (message.id, message.role, message.offset_range)) .collect() } } From 437e41f99d9d712cbe8e2a886c6619fc05cf610b Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 23 Jun 2023 11:52:06 +0200 Subject: [PATCH 145/215] Add styles for microphone and speakers buttons --- crates/collab_ui/src/collab_titlebar_item.rs | 29 ++++++--- crates/theme/src/theme.rs | 2 + styles/src/styleTree/workspace.ts | 64 ++++++++++++++++++++ 3 files changed, 85 insertions(+), 10 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 1cfa18f432..17f4f06ff9 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -451,21 +451,22 @@ impl CollabTitlebarItem { ) -> AnyElement { let icon; let tooltip; - let background; - if room.read(cx).is_muted().unwrap_or(false) { + let is_muted = room.read(cx).is_muted().unwrap_or(false); + if is_muted { icon = "icons/radix/mic-mute.svg"; tooltip = "Unmute microphone\nRight click for options"; - background = Color::red(); } else { icon = "icons/radix/mic.svg"; tooltip = "Mute microphone\nRight click for options"; - background = Color::transparent_black(); } let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.call_control.style_for(state); - Svg::new(icon) + let style = titlebar + .toggle_microphone_button + .in_state(is_muted) + .style_for(state); + let image = Svg::new(icon) .with_color(style.color) .constrained() .with_width(style.icon_width) @@ -474,8 +475,12 @@ impl CollabTitlebarItem { .with_width(style.button_width) .with_height(style.button_width) .contained() - .with_style(style.container) - .with_background_color(background) + .with_style(style.container); + if let Some(color) = style.container.background_color { + image.with_background_color(color) + } else { + image + } }) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, move |_, _, cx| { @@ -499,7 +504,8 @@ impl CollabTitlebarItem { ) -> AnyElement { let icon; let tooltip; - if room.read(cx).is_deafened().unwrap_or(false) { + let is_deafened = room.read(cx).is_deafened().unwrap_or(false); + if is_deafened { icon = "icons/radix/speaker-off.svg"; tooltip = "Unmute speakers\nRight click for options"; } else { @@ -509,7 +515,10 @@ impl CollabTitlebarItem { let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.call_control.style_for(state); + let style = titlebar + .toggle_speakers_button + .in_state(is_deafened) + .style_for(state); Svg::new(icon) .with_color(style.color) .constrained() diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 69c06c85ad..bccb74a7ac 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -133,6 +133,8 @@ pub struct Titlebar { pub share_button: Toggleable>, pub call_control: Interactive, pub toggle_contacts_button: Toggleable>, + pub toggle_microphone_button: Toggleable>, + pub toggle_speakers_button: Toggleable>, pub user_menu_button: Toggleable>, pub toggle_contacts_badge: ContainerStyle, } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index d7f994d98e..0e00f6f5bc 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -343,6 +343,70 @@ export default function workspace(colorScheme: ColorScheme) { }, }, }), + toggleMicrophoneButton: toggleable({ + base: interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { + clicked: { + background: background(layer, "variant", "pressed"), + }, + hovered: { + background: background(layer, "variant", "hovered"), + }, + }, + }), + state: { + active: { + default: { + background: background(layer, "on", "default"), + }, + hovered: { + background: background(layer, "on", "hovered"), + }, + clicked: { + background: background(layer, "on", "pressed"), + }, + }, + }, + }), + toggleSpeakersButton: toggleable({ + base: interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { + clicked: { + background: background(layer, "variant", "pressed"), + }, + hovered: { + background: background(layer, "variant", "hovered"), + }, + }, + }), + state: { + active: { + default: { + background: background(layer, "on", "default"), + }, + hovered: { + background: background(layer, "on", "hovered"), + }, + clicked: { + background: background(layer, "on", "pressed"), + }, + }, + }, + }), userMenuButton: merge(titlebarButton, { inactive: { default: { From 62786cd508c62beb63309d4c2843f4d52fa0a78f Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 23 Jun 2023 13:15:25 +0200 Subject: [PATCH 146/215] Add button --- crates/collab_ui/src/collab_titlebar_item.rs | 41 +++++++++++++++++++- crates/collab_ui/src/collab_ui.rs | 1 + 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 17f4f06ff9..81e2736164 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -1,6 +1,6 @@ use crate::{ contact_notification::ContactNotification, contacts_popover, face_pile::FacePile, - toggle_deafen, toggle_mute, toggle_screen_sharing, ToggleDeafen, ToggleMute, + toggle_deafen, toggle_mute, toggle_screen_sharing, LeaveCall, ToggleDeafen, ToggleMute, ToggleScreenSharing, }; use call::{ActiveCall, ParticipantLocation, Room}; @@ -85,7 +85,7 @@ impl View for CollabTitlebarItem { { right_container .add_children(self.render_in_call_share_unshare_button(&workspace, &theme, cx)); - + right_container.add_child(self.render_leave_call(&theme, cx)); left_container .add_child(self.render_current_user(&workspace, &theme, &user, peer_id, cx)); left_container.add_children(self.render_collaborators(&workspace, &theme, &room, cx)); @@ -544,6 +544,43 @@ impl CollabTitlebarItem { .aligned() .into_any() } + fn render_leave_call(&self, theme: &Theme, cx: &mut ViewContext) -> AnyElement { + let icon = "icons/radix/exit.svg"; + let tooltip = "Leave call"; + + let titlebar = &theme.workspace.titlebar; + MouseEventHandler::::new(0, cx, |state, _| { + let style = titlebar + .toggle_speakers_button + .in_state(false) + .style_for(state); + Svg::new(icon) + .with_color(style.color) + .constrained() + .with_width(style.icon_width) + .aligned() + .constrained() + .with_width(style.button_width) + .with_height(style.button_width) + .contained() + .with_style(style.container) + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, move |_, _, cx| { + ActiveCall::global(cx) + .update(cx, |call, cx| call.hang_up(cx)) + .detach_and_log_err(cx); + }) + .with_tooltip::( + 0, + tooltip.into(), + Some(Box::new(LeaveCall)), + theme.tooltip.clone(), + cx, + ) + .aligned() + .into_any() + } fn render_in_call_share_unshare_button( &self, workspace: &ViewHandle, diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rs index 38a39762f4..a809b9c7e6 100644 --- a/crates/collab_ui/src/collab_ui.rs +++ b/crates/collab_ui/src/collab_ui.rs @@ -22,6 +22,7 @@ actions!( ToggleScreenSharing, ToggleMute, ToggleDeafen, + LeaveCall, ShareMicrophone ] ); From 6c676121f286fc85a7ca652a3b8c5d7d3aa6db85 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 23 Jun 2023 13:22:33 +0200 Subject: [PATCH 147/215] Fixed mic's state not being updated in titlebar if user mutes a mic via command palette --- crates/call/src/room.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 714a1b19b5..00c6b43eb3 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -1185,6 +1185,7 @@ impl Room { LocalTrack::None => Err(anyhow!("microphone was not shared")), LocalTrack::Pending { muted, .. } => { *muted = should_mute; + cx.notify(); Ok(Task::Ready(Some(Ok(())))) } LocalTrack::Published { @@ -1192,7 +1193,7 @@ impl Room { muted, } => { *muted = should_mute; - + cx.notify(); Ok(cx.background().spawn(track_publication.set_mute(*muted))) } } @@ -1207,11 +1208,9 @@ impl Room { } pub fn toggle_deafen(&mut self, cx: &mut ModelContext) -> Result>> { - if let Some(live_kit) = &mut self.live_kit { - (*live_kit).deafened = !live_kit.deafened - } - if let Some(live_kit) = self.live_kit.as_mut() { + (*live_kit).deafened = !live_kit.deafened; + cx.notify(); let mut tasks = Vec::with_capacity(self.remote_participants.len()); let _ = Self::set_mute(live_kit, live_kit.deafened, cx)?; // todo (osiewicz): we probably want to schedule it on fg/bg? for participant in self.remote_participants.values() { From 4b52ff65c138042a6b23ee0de9f94f8f71574a8a Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 23 Jun 2023 13:30:40 +0200 Subject: [PATCH 148/215] Add styles for button --- crates/collab_ui/src/collab_titlebar_item.rs | 5 +---- crates/theme/src/theme.rs | 1 + styles/src/styleTree/workspace.ts | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 81e2736164..cb696dab9d 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -550,10 +550,7 @@ impl CollabTitlebarItem { let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar - .toggle_speakers_button - .in_state(false) - .style_for(state); + let style = titlebar.leave_call_button.style_for(state); Svg::new(icon) .with_color(style.color) .constrained() diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index bccb74a7ac..b4a4ba69fd 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -135,6 +135,7 @@ pub struct Titlebar { pub toggle_contacts_button: Toggleable>, pub toggle_microphone_button: Toggleable>, pub toggle_speakers_button: Toggleable>, + pub leave_call_button: Interactive, pub user_menu_button: Toggleable>, pub toggle_contacts_badge: ContainerStyle, } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index 0e00f6f5bc..abc237468a 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -407,6 +407,24 @@ export default function workspace(colorScheme: ColorScheme) { }, }, }), + leaveCallButton: interactive({ + base: { + margin: { left: itemSpacing }, + cornerRadius: 6, + color: foreground(layer, "variant"), + iconWidth: 14, + buttonWidth: 20, + }, + state: { + clicked: { + background: background(layer, "variant", "pressed"), + }, + hovered: { + background: background(layer, "variant", "hovered"), + }, + }, + }), + userMenuButton: merge(titlebarButton, { inactive: { default: { From b22a18345e2745b4c1f0a52223d80efc8df9162b Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 23 Jun 2023 09:39:37 -0700 Subject: [PATCH 149/215] Emit loaded events for lazily loaded paths in worktree --- crates/project/src/worktree.rs | 30 ++++++++++++++++---- crates/project/src/worktree_tests.rs | 42 ++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 4e72f2d689..811098540f 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -2759,6 +2759,10 @@ impl EntryKind { ) } + pub fn is_unloaded(&self) -> bool { + matches!(self, EntryKind::UnloadedDir) + } + pub fn is_file(&self) -> bool { matches!(self, EntryKind::File(_)) } @@ -3773,6 +3777,7 @@ impl BackgroundScanner { let mut changes = Vec::new(); let mut old_paths = old_snapshot.entries_by_path.cursor::(); let mut new_paths = new_snapshot.entries_by_path.cursor::(); + let mut last_newly_loaded_dir_path = None; old_paths.next(&()); new_paths.next(&()); for path in event_paths { @@ -3820,20 +3825,33 @@ impl BackgroundScanner { changes.push((old_entry.path.clone(), old_entry.id, Removed)); changes.push((new_entry.path.clone(), new_entry.id, Added)); } else if old_entry != new_entry { - changes.push((new_entry.path.clone(), new_entry.id, Updated)); + if old_entry.kind.is_unloaded() { + last_newly_loaded_dir_path = Some(&new_entry.path); + changes.push(( + new_entry.path.clone(), + new_entry.id, + Loaded, + )); + } else { + changes.push(( + new_entry.path.clone(), + new_entry.id, + Updated, + )); + } } old_paths.next(&()); new_paths.next(&()); } Ordering::Greater => { + let is_newly_loaded = self.phase == InitialScan + || last_newly_loaded_dir_path + .as_ref() + .map_or(false, |dir| new_entry.path.starts_with(&dir)); changes.push(( new_entry.path.clone(), new_entry.id, - if self.phase == InitialScan { - Loaded - } else { - Added - }, + if is_newly_loaded { Loaded } else { Added }, )); new_paths.next(&()); } diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rs index 0a228c6830..a539e138bf 100644 --- a/crates/project/src/worktree_tests.rs +++ b/crates/project/src/worktree_tests.rs @@ -15,6 +15,7 @@ use serde_json::json; use std::{ env, fmt::Write, + mem, path::{Path, PathBuf}, sync::Arc, }; @@ -313,6 +314,21 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete()) .await; + let tree_updates = Arc::new(Mutex::new(Vec::new())); + tree.update(cx, |_, cx| { + let tree_updates = tree_updates.clone(); + cx.subscribe(&tree, move |_, _, event, _| { + if let Event::UpdatedEntries(update) = event { + tree_updates.lock().extend( + update + .iter() + .map(|(path, _, change)| (path.clone(), *change)), + ); + } + }) + .detach(); + }); + // The symlinked directories are not scanned by default. tree.read_with(cx, |tree, _| { assert_eq!( @@ -365,6 +381,14 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { ] ); }); + assert_eq!( + mem::take(&mut *tree_updates.lock()), + &[ + (Path::new("deps/dep-dir3").into(), PathChange::Loaded), + (Path::new("deps/dep-dir3/deps").into(), PathChange::Loaded), + (Path::new("deps/dep-dir3/src").into(), PathChange::Loaded) + ] + ); // Expand a subdirectory of one of the symlinked directories. tree.read_with(cx, |tree, _| { @@ -396,6 +420,21 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { ] ); }); + + assert_eq!( + mem::take(&mut *tree_updates.lock()), + &[ + (Path::new("deps/dep-dir3/src").into(), PathChange::Loaded), + ( + Path::new("deps/dep-dir3/src/e.rs").into(), + PathChange::Loaded + ), + ( + Path::new("deps/dep-dir3/src/f.rs").into(), + PathChange::Loaded + ) + ] + ); } #[gpui::test] @@ -1114,7 +1153,6 @@ fn check_worktree_change_events(tree: &mut Worktree, cx: &mut ModelContext ix, }; match change_type { - PathChange::Loaded => entries.insert(ix, entry.unwrap()), PathChange::Added => entries.insert(ix, entry.unwrap()), PathChange::Removed => drop(entries.remove(ix)), PathChange::Updated => { @@ -1123,7 +1161,7 @@ fn check_worktree_change_events(tree: &mut Worktree, cx: &mut ModelContext { + PathChange::AddedOrUpdated | PathChange::Loaded => { let entry = entry.unwrap(); if entries.get(ix).map(|e| &e.path) == Some(&entry.path) { *entries.get_mut(ix).unwrap() = entry; From 27b74e9ea151aa2df801d669948ec250c978a64f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 23 Jun 2023 10:23:21 -0700 Subject: [PATCH 150/215] Prune the set of expanded dir ids as entries are removed --- crates/project/src/worktree.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 811098540f..b627c644a7 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -3030,7 +3030,7 @@ impl BackgroundScanner { // these before handling changes reported by the filesystem. request = self.scan_requests_rx.recv().fuse() => { let Ok(request) = request else { break }; - if !self.process_scan_request(request).await { + if !self.process_scan_request(request, false).await { return; } } @@ -3047,7 +3047,7 @@ impl BackgroundScanner { } } - async fn process_scan_request(&self, request: ScanRequest) -> bool { + async fn process_scan_request(&self, request: ScanRequest, scanning: bool) -> bool { log::debug!("rescanning paths {:?}", request.relative_paths); let root_path = self.expand_paths(&request.relative_paths).await; @@ -3072,7 +3072,7 @@ impl BackgroundScanner { .collect::>(); self.reload_entries_for_paths(root_path, root_canonical_path, abs_paths, None) .await; - self.send_status_update(false, Some(request.done)) + self.send_status_update(scanning, Some(request.done)) } async fn process_events(&mut self, abs_paths: Vec) { @@ -3107,6 +3107,9 @@ impl BackgroundScanner { let mut state = self.state.lock(); state.reload_repositories(&paths, self.fs.as_ref()); state.snapshot.completed_scan_id = state.snapshot.scan_id; + for (_, entry_id) in mem::take(&mut state.removed_entry_ids) { + state.expanded_dirs.remove(&entry_id); + } } self.send_status_update(false, None); @@ -3182,7 +3185,7 @@ impl BackgroundScanner { // the scan queue, so that user operations are prioritized. request = self.scan_requests_rx.recv().fuse() => { let Ok(request) = request else { break }; - if !self.process_scan_request(request).await { + if !self.process_scan_request(request, true).await { return; } } @@ -3664,7 +3667,7 @@ impl BackgroundScanner { // the queue of ignore statuses. request = self.scan_requests_rx.recv().fuse() => { let Ok(request) = request else { break }; - if !self.process_scan_request(request).await { + if !self.process_scan_request(request, true).await { return; } } From 91f87bb31fb01d5effa0c50655c8dded5a3a8329 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 23 Jun 2023 12:53:25 -0700 Subject: [PATCH 151/215] Scan any external/ignored directories needed for LSP watchers Also, don't include "external" files in project searches. Treat them the same as ignored files. Co-authored-by: Nathan Sobo --- crates/project/src/project.rs | 69 ++++++++--- crates/project/src/project_tests.rs | 124 +++++++++++++++++--- crates/project/src/worktree.rs | 165 ++++++++++++++++++--------- crates/project/src/worktree_tests.rs | 6 +- 4 files changed, 273 insertions(+), 91 deletions(-) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 1c9336e2ae..91c92edb6a 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -64,7 +64,7 @@ use std::{ mem, num::NonZeroU32, ops::Range, - path::{Component, Path, PathBuf}, + path::{self, Component, Path, PathBuf}, rc::Rc, str, sync::{ @@ -3116,23 +3116,44 @@ impl Project { for watcher in params.watchers { for worktree in &self.worktrees { if let Some(worktree) = worktree.upgrade(cx) { - let worktree = worktree.read(cx); - if let Some(abs_path) = worktree.abs_path().to_str() { - if let Some(suffix) = match &watcher.glob_pattern { - lsp::GlobPattern::String(s) => s, - lsp::GlobPattern::Relative(rp) => &rp.pattern, - } - .strip_prefix(abs_path) - .and_then(|s| s.strip_prefix(std::path::MAIN_SEPARATOR)) - { - if let Some(glob) = Glob::new(suffix).log_err() { - builders - .entry(worktree.id()) - .or_insert_with(|| GlobSetBuilder::new()) - .add(glob); + let glob_is_inside_worktree = worktree.update(cx, |tree, _| { + if let Some(abs_path) = tree.abs_path().to_str() { + let relative_glob_pattern = match &watcher.glob_pattern { + lsp::GlobPattern::String(s) => s + .strip_prefix(abs_path) + .and_then(|s| s.strip_prefix(std::path::MAIN_SEPARATOR)), + lsp::GlobPattern::Relative(rp) => { + let base_uri = match &rp.base_uri { + lsp::OneOf::Left(workspace_folder) => { + &workspace_folder.uri + } + lsp::OneOf::Right(base_uri) => base_uri, + }; + base_uri.to_file_path().ok().and_then(|file_path| { + (file_path.to_str() == Some(abs_path)) + .then_some(rp.pattern.as_str()) + }) + } + }; + if let Some(relative_glob_pattern) = relative_glob_pattern { + let literal_prefix = + glob_literal_prefix(&relative_glob_pattern); + tree.as_local_mut() + .unwrap() + .add_path_prefix_to_scan(Path::new(literal_prefix).into()); + if let Some(glob) = Glob::new(relative_glob_pattern).log_err() { + builders + .entry(tree.id()) + .or_insert_with(|| GlobSetBuilder::new()) + .add(glob); + } + return true; } - break; } + false + }); + if glob_is_inside_worktree { + break; } } } @@ -7105,6 +7126,22 @@ impl Project { } } +fn glob_literal_prefix<'a>(glob: &'a str) -> &'a str { + let mut literal_end = 0; + for (i, part) in glob.split(path::MAIN_SEPARATOR).enumerate() { + if part.contains(&['*', '?', '{', '}']) { + break; + } else { + if i > 0 { + // Acount for separator prior to this part + literal_end += path::MAIN_SEPARATOR.len_utf8(); + } + literal_end += part.len(); + } + } + &glob[..literal_end] +} + impl WorktreeHandle { pub fn upgrade(&self, cx: &AppContext) -> Option> { match self { diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rs index 3c23c30ab9..478fad74a9 100644 --- a/crates/project/src/project_tests.rs +++ b/crates/project/src/project_tests.rs @@ -535,8 +535,28 @@ async fn test_reporting_fs_changes_to_language_servers(cx: &mut gpui::TestAppCon fs.insert_tree( "/the-root", json!({ - "a.rs": "", - "b.rs": "", + ".gitignore": "target\n", + "src": { + "a.rs": "", + "b.rs": "", + }, + "target": { + "x": { + "out": { + "x.rs": "" + } + }, + "y": { + "out": { + "y.rs": "", + } + }, + "z": { + "out": { + "z.rs": "" + } + } + } }), ) .await; @@ -550,11 +570,32 @@ async fn test_reporting_fs_changes_to_language_servers(cx: &mut gpui::TestAppCon // Start the language server by opening a buffer with a compatible file extension. let _buffer = project .update(cx, |project, cx| { - project.open_local_buffer("/the-root/a.rs", cx) + project.open_local_buffer("/the-root/src/a.rs", cx) }) .await .unwrap(); + // Initially, we don't load ignored files because the language server has not explicitly asked us to watch them. + project.read_with(cx, |project, cx| { + let worktree = project.worktrees(cx).next().unwrap(); + assert_eq!( + worktree + .read(cx) + .snapshot() + .entries(true) + .map(|entry| (entry.path.as_ref(), entry.is_ignored)) + .collect::>(), + &[ + (Path::new(""), false), + (Path::new(".gitignore"), false), + (Path::new("src"), false), + (Path::new("src/a.rs"), false), + (Path::new("src/b.rs"), false), + (Path::new("target"), true), + ] + ); + }); + // Keep track of the FS events reported to the language server. let fake_server = fake_servers.next().await.unwrap(); let file_changes = Arc::new(Mutex::new(Vec::new())); @@ -565,12 +606,20 @@ async fn test_reporting_fs_changes_to_language_servers(cx: &mut gpui::TestAppCon method: "workspace/didChangeWatchedFiles".to_string(), register_options: serde_json::to_value( lsp::DidChangeWatchedFilesRegistrationOptions { - watchers: vec![lsp::FileSystemWatcher { - glob_pattern: lsp::GlobPattern::String( - "/the-root/*.{rs,c}".to_string(), - ), - kind: None, - }], + watchers: vec![ + lsp::FileSystemWatcher { + glob_pattern: lsp::GlobPattern::String( + "/the-root/src/*.{rs,c}".to_string(), + ), + kind: None, + }, + lsp::FileSystemWatcher { + glob_pattern: lsp::GlobPattern::String( + "/the-root/target/y/**/*.rs".to_string(), + ), + kind: None, + }, + ], }, ) .ok(), @@ -588,17 +637,50 @@ async fn test_reporting_fs_changes_to_language_servers(cx: &mut gpui::TestAppCon }); cx.foreground().run_until_parked(); - assert_eq!(file_changes.lock().len(), 0); + assert_eq!(mem::take(&mut *file_changes.lock()), &[]); + + // Now the language server has asked us to watch an ignored directory path, + // so we recursively load it. + project.read_with(cx, |project, cx| { + let worktree = project.worktrees(cx).next().unwrap(); + assert_eq!( + worktree + .read(cx) + .snapshot() + .entries(true) + .map(|entry| (entry.path.as_ref(), entry.is_ignored)) + .collect::>(), + &[ + (Path::new(""), false), + (Path::new(".gitignore"), false), + (Path::new("src"), false), + (Path::new("src/a.rs"), false), + (Path::new("src/b.rs"), false), + (Path::new("target"), true), + (Path::new("target/x"), true), + (Path::new("target/y"), true), + (Path::new("target/y/out"), true), + (Path::new("target/y/out/y.rs"), true), + (Path::new("target/z"), true), + ] + ); + }); // Perform some file system mutations, two of which match the watched patterns, // and one of which does not. - fs.create_file("/the-root/c.rs".as_ref(), Default::default()) + fs.create_file("/the-root/src/c.rs".as_ref(), Default::default()) .await .unwrap(); - fs.create_file("/the-root/d.txt".as_ref(), Default::default()) + fs.create_file("/the-root/src/d.txt".as_ref(), Default::default()) .await .unwrap(); - fs.remove_file("/the-root/b.rs".as_ref(), Default::default()) + fs.remove_file("/the-root/src/b.rs".as_ref(), Default::default()) + .await + .unwrap(); + fs.create_file("/the-root/target/x/out/x2.rs".as_ref(), Default::default()) + .await + .unwrap(); + fs.create_file("/the-root/target/y/out/y2.rs".as_ref(), Default::default()) .await .unwrap(); @@ -608,11 +690,15 @@ async fn test_reporting_fs_changes_to_language_servers(cx: &mut gpui::TestAppCon &*file_changes.lock(), &[ lsp::FileEvent { - uri: lsp::Url::from_file_path("/the-root/b.rs").unwrap(), + uri: lsp::Url::from_file_path("/the-root/src/b.rs").unwrap(), typ: lsp::FileChangeType::DELETED, }, lsp::FileEvent { - uri: lsp::Url::from_file_path("/the-root/c.rs").unwrap(), + uri: lsp::Url::from_file_path("/the-root/src/c.rs").unwrap(), + typ: lsp::FileChangeType::CREATED, + }, + lsp::FileEvent { + uri: lsp::Url::from_file_path("/the-root/target/y/out/y2.rs").unwrap(), typ: lsp::FileChangeType::CREATED, }, ] @@ -3846,6 +3932,14 @@ async fn test_search_with_exclusions_and_inclusions(cx: &mut gpui::TestAppContex ); } +#[test] +fn test_glob_literal_prefix() { + assert_eq!(glob_literal_prefix("**/*.js"), ""); + assert_eq!(glob_literal_prefix("node_modules/**/*.js"), "node_modules"); + assert_eq!(glob_literal_prefix("foo/{bar,baz}.js"), "foo"); + assert_eq!(glob_literal_prefix("foo/bar/baz.js"), "foo/bar/baz.js"); +} + async fn search( project: &ModelHandle, query: SearchQuery, diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index b627c644a7..be3bcd05fa 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -68,6 +68,7 @@ pub enum Worktree { pub struct LocalWorktree { snapshot: LocalSnapshot, scan_requests_tx: channel::Sender, + path_prefixes_to_scan_tx: channel::Sender>, is_scanning: (watch::Sender, watch::Receiver), _background_scanner_task: Task<()>, share: Option, @@ -219,8 +220,9 @@ pub struct LocalSnapshot { struct BackgroundScannerState { snapshot: LocalSnapshot, - expanded_dirs: HashSet, - expanded_paths: HashSet>, + scanned_dirs: HashSet, + path_prefixes_to_scan: HashSet>, + paths_to_scan: HashSet>, /// The ids of all of the entries that were removed from the snapshot /// as part of the current update. These entry ids may be re-used /// if the same inode is discovered at a new path, or if the given @@ -331,6 +333,7 @@ impl Worktree { } let (scan_requests_tx, scan_requests_rx) = channel::unbounded(); + let (path_prefixes_to_scan_tx, path_prefixes_to_scan_rx) = channel::unbounded(); let (scan_states_tx, mut scan_states_rx) = mpsc::unbounded(); cx.spawn_weak(|this, mut cx| async move { @@ -371,6 +374,7 @@ impl Worktree { scan_states_tx, background, scan_requests_rx, + path_prefixes_to_scan_rx, ) .run(events) .await; @@ -382,6 +386,7 @@ impl Worktree { is_scanning: watch::channel_with(true), share: None, scan_requests_tx, + path_prefixes_to_scan_tx, _background_scanner_task: background_scanner_task, diagnostics: Default::default(), diagnostic_summaries: Default::default(), @@ -1147,6 +1152,10 @@ impl LocalWorktree { rx } + pub fn add_path_prefix_to_scan(&self, path_prefix: Arc) { + self.path_prefixes_to_scan_tx.try_send(path_prefix).ok(); + } + fn refresh_entry( &self, path: Arc, @@ -1566,7 +1575,7 @@ impl Snapshot { } pub fn visible_file_count(&self) -> usize { - self.entries_by_path.summary().visible_file_count + self.entries_by_path.summary().non_ignored_file_count } fn traverse_from_offset( @@ -2067,7 +2076,7 @@ impl LocalSnapshot { for entry in self.entries_by_path.cursor::<()>() { if entry.is_file() { assert_eq!(files.next().unwrap().inode, entry.inode); - if !entry.is_ignored { + if !entry.is_ignored && !entry.is_external { assert_eq!(visible_files.next().unwrap().inode, entry.inode); } } @@ -2129,12 +2138,17 @@ impl LocalSnapshot { } impl BackgroundScannerState { - fn is_path_expanded(&self, path: &Path) -> bool { - self.expanded_paths.iter().any(|p| p.starts_with(path)) + fn should_scan_directory(&self, entry: &Entry) -> bool { + (!entry.is_external && !entry.is_ignored) + || self.scanned_dirs.contains(&entry.id) // If we've ever scanned it, keep scanning || self - .snapshot - .entry_for_path(&path) - .map_or(false, |entry| self.expanded_dirs.contains(&entry.id)) + .paths_to_scan + .iter() + .any(|p| p.starts_with(&entry.path)) + || self + .path_prefixes_to_scan + .iter() + .any(|p| entry.path.starts_with(p)) } fn reuse_entry_id(&mut self, entry: &mut Entry) { @@ -2192,17 +2206,16 @@ impl BackgroundScannerState { .insert(abs_parent_path, (ignore, false)); } - self.expanded_dirs.insert(parent_entry.id); + self.scanned_dirs.insert(parent_entry.id); let mut entries_by_path_edits = vec![Edit::Insert(parent_entry)]; let mut entries_by_id_edits = Vec::new(); let mut dotgit_path = None; - for mut entry in entries { + for entry in entries { if entry.path.file_name() == Some(&DOT_GIT) { dotgit_path = Some(entry.path.clone()); } - self.reuse_entry_id(&mut entry); entries_by_id_edits.push(Edit::Insert(PathEntry { id: entry.id, path: entry.path.clone(), @@ -2677,7 +2690,20 @@ pub struct Entry { pub inode: u64, pub mtime: SystemTime, pub is_symlink: bool, + + /// Whether this entry is ignored by Git. + /// + /// We only scan ignored entries once the directory is expanded and + /// exclude them from searches. pub is_ignored: bool, + + /// Whether this entry's canonical path is outside of the worktree. + /// This means the entry is only accessible from the worktree root via a + /// symlink. + /// + /// We only scan entries outside of the worktree once the symlinked + /// directory is expanded. External entries are treated like gitignored + /// entries in that they are not included in searches. pub is_external: bool, pub git_status: Option, } @@ -2772,15 +2798,19 @@ impl sum_tree::Item for Entry { type Summary = EntrySummary; fn summary(&self) -> Self::Summary { - let visible_count = if self.is_ignored { 0 } else { 1 }; + let non_ignored_count = if self.is_ignored || self.is_external { + 0 + } else { + 1 + }; let file_count; - let visible_file_count; + let non_ignored_file_count; if self.is_file() { file_count = 1; - visible_file_count = visible_count; + non_ignored_file_count = non_ignored_count; } else { file_count = 0; - visible_file_count = 0; + non_ignored_file_count = 0; } let mut statuses = GitStatuses::default(); @@ -2796,9 +2826,9 @@ impl sum_tree::Item for Entry { EntrySummary { max_path: self.path.clone(), count: 1, - visible_count, + non_ignored_count, file_count, - visible_file_count, + non_ignored_file_count, statuses, } } @@ -2816,9 +2846,9 @@ impl sum_tree::KeyedItem for Entry { pub struct EntrySummary { max_path: Arc, count: usize, - visible_count: usize, + non_ignored_count: usize, file_count: usize, - visible_file_count: usize, + non_ignored_file_count: usize, statuses: GitStatuses, } @@ -2827,9 +2857,9 @@ impl Default for EntrySummary { Self { max_path: Arc::from(Path::new("")), count: 0, - visible_count: 0, + non_ignored_count: 0, file_count: 0, - visible_file_count: 0, + non_ignored_file_count: 0, statuses: Default::default(), } } @@ -2841,9 +2871,9 @@ impl sum_tree::Summary for EntrySummary { fn add_summary(&mut self, rhs: &Self, _: &()) { self.max_path = rhs.max_path.clone(); self.count += rhs.count; - self.visible_count += rhs.visible_count; + self.non_ignored_count += rhs.non_ignored_count; self.file_count += rhs.file_count; - self.visible_file_count += rhs.visible_file_count; + self.non_ignored_file_count += rhs.non_ignored_file_count; self.statuses += rhs.statuses; } } @@ -2912,6 +2942,7 @@ struct BackgroundScanner { status_updates_tx: UnboundedSender, executor: Arc, scan_requests_rx: channel::Receiver, + path_prefixes_to_scan_rx: channel::Receiver>, next_entry_id: Arc, phase: BackgroundScannerPhase, } @@ -2931,20 +2962,23 @@ impl BackgroundScanner { status_updates_tx: UnboundedSender, executor: Arc, scan_requests_rx: channel::Receiver, + path_prefixes_to_scan_rx: channel::Receiver>, ) -> Self { Self { fs, status_updates_tx, executor, scan_requests_rx, + path_prefixes_to_scan_rx, next_entry_id, state: Mutex::new(BackgroundScannerState { prev_snapshot: snapshot.snapshot.clone(), snapshot, - expanded_dirs: Default::default(), + scanned_dirs: Default::default(), + path_prefixes_to_scan: Default::default(), + paths_to_scan: Default::default(), removed_entry_ids: Default::default(), changed_paths: Default::default(), - expanded_paths: Default::default(), }), phase: BackgroundScannerPhase::InitialScan, } @@ -2952,7 +2986,7 @@ impl BackgroundScanner { async fn run( &mut self, - mut events_rx: Pin>>>, + mut fs_events_rx: Pin>>>, ) { use futures::FutureExt as _; @@ -3014,9 +3048,9 @@ impl BackgroundScanner { // For these events, update events cannot be as precise, because we didn't // have the previous state loaded yet. self.phase = BackgroundScannerPhase::EventsReceivedDuringInitialScan; - if let Poll::Ready(Some(events)) = futures::poll!(events_rx.next()) { + if let Poll::Ready(Some(events)) = futures::poll!(fs_events_rx.next()) { let mut paths = events.into_iter().map(|e| e.path).collect::>(); - while let Poll::Ready(Some(more_events)) = futures::poll!(events_rx.next()) { + while let Poll::Ready(Some(more_events)) = futures::poll!(fs_events_rx.next()) { paths.extend(more_events.into_iter().map(|e| e.path)); } self.process_events(paths).await; @@ -3035,10 +3069,26 @@ impl BackgroundScanner { } } - events = events_rx.next().fuse() => { + path_prefix = self.path_prefixes_to_scan_rx.recv().fuse() => { + let Ok(path_prefix) = path_prefix else { break }; + + self.forcibly_load_paths(&[path_prefix.clone()]).await; + + let abs_path = + { + let mut state = self.state.lock(); + state.path_prefixes_to_scan.insert(path_prefix.clone()); + state.snapshot.abs_path.join(path_prefix) + }; + if let Some(abs_path) = self.fs.canonicalize(&abs_path).await.log_err() { + self.process_events(vec![abs_path]).await; + } + } + + events = fs_events_rx.next().fuse() => { let Some(events) = events else { break }; let mut paths = events.into_iter().map(|e| e.path).collect::>(); - while let Poll::Ready(Some(more_events)) = futures::poll!(events_rx.next()) { + while let Poll::Ready(Some(more_events)) = futures::poll!(fs_events_rx.next()) { paths.extend(more_events.into_iter().map(|e| e.path)); } self.process_events(paths.clone()).await; @@ -3050,7 +3100,7 @@ impl BackgroundScanner { async fn process_scan_request(&self, request: ScanRequest, scanning: bool) -> bool { log::debug!("rescanning paths {:?}", request.relative_paths); - let root_path = self.expand_paths(&request.relative_paths).await; + let root_path = self.forcibly_load_paths(&request.relative_paths).await; let root_canonical_path = match self.fs.canonicalize(&root_path).await { Ok(path) => path, Err(err) => { @@ -3108,14 +3158,14 @@ impl BackgroundScanner { state.reload_repositories(&paths, self.fs.as_ref()); state.snapshot.completed_scan_id = state.snapshot.scan_id; for (_, entry_id) in mem::take(&mut state.removed_entry_ids) { - state.expanded_dirs.remove(&entry_id); + state.scanned_dirs.remove(&entry_id); } } self.send_status_update(false, None); } - async fn expand_paths(&self, paths: &[Arc]) -> Arc { + async fn forcibly_load_paths(&self, paths: &[Arc]) -> Arc { let root_path; let (scan_job_tx, mut scan_job_rx) = channel::unbounded(); { @@ -3140,7 +3190,7 @@ impl BackgroundScanner { is_external: entry.is_external, }) .unwrap(); - state.expanded_paths.insert(path.clone()); + state.paths_to_scan.insert(path.clone()); break; } } @@ -3151,7 +3201,7 @@ impl BackgroundScanner { while let Some(job) = scan_job_rx.next().await { self.scan_dir(&job).await.log_err(); } - self.state.lock().expanded_paths.clear(); + self.state.lock().paths_to_scan.clear(); root_path } @@ -3414,18 +3464,19 @@ impl BackgroundScanner { let mut state = self.state.lock(); let mut new_jobs = new_jobs.into_iter(); for entry in &mut new_entries { + state.reuse_entry_id(entry); + if entry.is_dir() { let new_job = new_jobs.next().expect("missing scan job for entry"); - if (entry.is_external || entry.is_ignored) - && entry.kind == EntryKind::PendingDir - && !state.is_path_expanded(&entry.path) - { + if state.should_scan_directory(&entry) { + if let Some(new_job) = new_job { + job.scan_queue + .try_send(new_job) + .expect("channel is unbounded"); + } + } else { log::debug!("defer scanning directory {:?} {:?}", entry.path, entry.kind); entry.kind = EntryKind::UnloadedDir; - } else if let Some(new_job) = new_job { - job.scan_queue - .try_send(new_job) - .expect("channel is unbounded"); } } } @@ -3865,14 +3916,14 @@ impl BackgroundScanner { old_paths.next(&()); } (None, Some(new_entry)) => { + let is_newly_loaded = self.phase == InitialScan + || last_newly_loaded_dir_path + .as_ref() + .map_or(false, |dir| new_entry.path.starts_with(&dir)); changes.push(( new_entry.path.clone(), new_entry.id, - if self.phase == InitialScan { - Loaded - } else { - Added - }, + if is_newly_loaded { Loaded } else { Added }, )); new_paths.next(&()); } @@ -3975,9 +4026,9 @@ impl WorktreeHandle for ModelHandle { struct TraversalProgress<'a> { max_path: &'a Path, count: usize, - visible_count: usize, + non_ignored_count: usize, file_count: usize, - visible_file_count: usize, + non_ignored_file_count: usize, } impl<'a> TraversalProgress<'a> { @@ -3985,8 +4036,8 @@ impl<'a> TraversalProgress<'a> { match (include_ignored, include_dirs) { (true, true) => self.count, (true, false) => self.file_count, - (false, true) => self.visible_count, - (false, false) => self.visible_file_count, + (false, true) => self.non_ignored_count, + (false, false) => self.non_ignored_file_count, } } } @@ -3995,9 +4046,9 @@ impl<'a> sum_tree::Dimension<'a, EntrySummary> for TraversalProgress<'a> { fn add_summary(&mut self, summary: &'a EntrySummary, _: &()) { self.max_path = summary.max_path.as_ref(); self.count += summary.count; - self.visible_count += summary.visible_count; + self.non_ignored_count += summary.non_ignored_count; self.file_count += summary.file_count; - self.visible_file_count += summary.visible_file_count; + self.non_ignored_file_count += summary.non_ignored_file_count; } } @@ -4006,9 +4057,9 @@ impl<'a> Default for TraversalProgress<'a> { Self { max_path: Path::new(""), count: 0, - visible_count: 0, + non_ignored_count: 0, file_count: 0, - visible_file_count: 0, + non_ignored_file_count: 0, } } } diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rs index a539e138bf..39c6e19d56 100644 --- a/crates/project/src/worktree_tests.rs +++ b/crates/project/src/worktree_tests.rs @@ -332,7 +332,7 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { // The symlinked directories are not scanned by default. tree.read_with(cx, |tree, _| { assert_eq!( - tree.entries(false) + tree.entries(true) .map(|entry| (entry.path.as_ref(), entry.is_external)) .collect::>(), vec![ @@ -365,7 +365,7 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { // not scanned yet. tree.read_with(cx, |tree, _| { assert_eq!( - tree.entries(false) + tree.entries(true) .map(|entry| (entry.path.as_ref(), entry.is_external)) .collect::>(), vec![ @@ -402,7 +402,7 @@ async fn test_symlinks_pointing_outside(cx: &mut TestAppContext) { // The expanded subdirectory's contents are loaded. tree.read_with(cx, |tree, _| { assert_eq!( - tree.entries(false) + tree.entries(true) .map(|entry| (entry.path.as_ref(), entry.is_external)) .collect::>(), vec![ From 7d065fa14e8c54b989af8815b55e593ee7456ce8 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Fri, 23 Jun 2023 21:02:01 -0400 Subject: [PATCH 152/215] Add installation_id to panic events Co-Authored-By: Julia <30666851+ForLoveOfCats@users.noreply.github.com> --- crates/client/src/telemetry.rs | 42 +++++++--------------------------- crates/zed/src/main.rs | 25 +++++++++++++++++--- 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index 6a6a91b485..9c4e187dbc 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -1,5 +1,4 @@ use crate::{TelemetrySettings, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL}; -use db::kvp::KEY_VALUE_STORE; use gpui::{executor::Background, serde_json, AppContext, Task}; use lazy_static::lazy_static; use parking_lot::Mutex; @@ -8,7 +7,6 @@ use std::{env, io::Write, mem, path::PathBuf, sync::Arc, time::Duration}; use tempfile::NamedTempFile; use util::http::HttpClient; use util::{channel::ReleaseChannel, TryFutureExt}; -use uuid::Uuid; pub struct Telemetry { http_client: Arc, @@ -120,39 +118,15 @@ impl Telemetry { Some(self.state.lock().log_file.as_ref()?.path().to_path_buf()) } - pub fn start(self: &Arc) { - let this = self.clone(); - self.executor - .spawn( - async move { - let installation_id = - if let Ok(Some(installation_id)) = KEY_VALUE_STORE.read_kvp("device_id") { - installation_id - } else { - let installation_id = Uuid::new_v4().to_string(); - KEY_VALUE_STORE - .write_kvp("device_id".to_string(), installation_id.clone()) - .await?; - installation_id - }; + pub fn start(self: &Arc, installation_id: Option) { + let mut state = self.state.lock(); + state.installation_id = installation_id.map(|id| id.into()); + let has_clickhouse_events = !state.clickhouse_events_queue.is_empty(); + drop(state); - let installation_id: Arc = installation_id.into(); - let mut state = this.state.lock(); - state.installation_id = Some(installation_id.clone()); - - let has_clickhouse_events = !state.clickhouse_events_queue.is_empty(); - - drop(state); - - if has_clickhouse_events { - this.flush_clickhouse_events(); - } - - anyhow::Ok(()) - } - .log_err(), - ) - .detach(); + if has_clickhouse_events { + self.flush_clickhouse_events(); + } } /// This method takes the entire TelemetrySettings struct in order to force client code diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index dcdf5c1ea5..4f9ed7628b 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -48,6 +48,7 @@ use util::{ http::{self, HttpClient}, paths::PathLikeWithPosition, }; +use uuid::Uuid; use welcome::{show_welcome_experience, FIRST_OPEN}; use fs::RealFs; @@ -68,7 +69,8 @@ fn main() { log::info!("========== starting zed =========="); let mut app = gpui::App::new(Assets).unwrap(); - init_panic_hook(&app); + let installation_id = app.background().block(installation_id()).ok(); + init_panic_hook(&app, installation_id.clone()); app.background(); @@ -169,7 +171,7 @@ fn main() { }) .detach(); - client.telemetry().start(); + client.telemetry().start(installation_id); let app_state = Arc::new(AppState { languages, @@ -269,6 +271,20 @@ fn main() { }); } +async fn installation_id() -> Result { + if let Ok(Some(installation_id)) = KEY_VALUE_STORE.read_kvp("device_id") { + Ok(installation_id) + } else { + let installation_id = Uuid::new_v4().to_string(); + + KEY_VALUE_STORE + .write_kvp("device_id".to_string(), installation_id.clone()) + .await?; + + Ok(installation_id) + } +} + fn open_urls( urls: Vec, cli_connections_tx: &mpsc::UnboundedSender<( @@ -372,6 +388,8 @@ struct Panic { os_version: Option, architecture: String, panicked_on: u128, + #[serde(skip_serializing_if = "Option::is_none")] + installation_id: Option, } #[derive(Serialize)] @@ -380,7 +398,7 @@ struct PanicRequest { token: String, } -fn init_panic_hook(app: &App) { +fn init_panic_hook(app: &App, installation_id: Option) { let is_pty = stdout_is_a_pty(); let platform = app.platform(); @@ -433,6 +451,7 @@ fn init_panic_hook(app: &App) { .unwrap() .as_millis(), backtrace, + installation_id: installation_id.clone(), }; if is_pty { From 82bd5fb56405eb782f2ebb9658f72ca962f52b9a Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 25 Jun 2023 01:43:58 +0300 Subject: [PATCH 153/215] Fix main compilation --- crates/vim/src/normal/substitute.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/vim/src/normal/substitute.rs b/crates/vim/src/normal/substitute.rs index e208983b11..87648f8b88 100644 --- a/crates/vim/src/normal/substitute.rs +++ b/crates/vim/src/normal/substitute.rs @@ -3,7 +3,7 @@ use language::Point; use crate::{motion::Motion, Mode, Vim}; -pub fn substitute(vim: &mut Vim, count: usize, cx: &mut WindowContext) { +pub fn substitute(vim: &mut Vim, count: Option, cx: &mut WindowContext) { vim.update_active_editor(cx, |editor, cx| { editor.set_clip_at_line_ends(false, cx); editor.change_selections(None, cx, |s| { From bede668b14e66f591ca2928b18d398d800e68a4e Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Sun, 25 Jun 2023 07:51:50 -0600 Subject: [PATCH 154/215] Add a derive macro for Element To turn any struct into a composite element, you can implement a render method with the following signature: fn render(&mut self, view: &mut V, cx: &mut ViewContext) -> AnyElement; Then add #[derive(Element)] to the struct definition. This will make it easier to introduce higher-level components that are expressed in terms of other elements. --- crates/gpui/src/elements.rs | 92 +-------------------------- crates/gpui/src/gpui.rs | 2 +- crates/gpui_macros/src/gpui_macros.rs | 69 +++++++++++++++++++- 3 files changed, 69 insertions(+), 94 deletions(-) diff --git a/crates/gpui/src/elements.rs b/crates/gpui/src/elements.rs index 779f4b6ec3..78403444ff 100644 --- a/crates/gpui/src/elements.rs +++ b/crates/gpui/src/elements.rs @@ -41,13 +41,7 @@ use collections::HashMap; use core::panic; use json::ToJson; use smallvec::SmallVec; -use std::{ - any::Any, - borrow::Cow, - marker::PhantomData, - mem, - ops::{Deref, DerefMut, Range}, -}; +use std::{any::Any, borrow::Cow, mem, ops::Range}; pub trait Element: 'static { type LayoutState; @@ -567,90 +561,6 @@ impl RootElement { } } -pub trait Component: 'static { - fn render(&self, view: &mut V, cx: &mut ViewContext) -> AnyElement; -} - -pub struct ComponentHost> { - component: C, - view_type: PhantomData, -} - -impl> ComponentHost { - pub fn new(c: C) -> Self { - Self { - component: c, - view_type: PhantomData, - } - } -} - -impl> Deref for ComponentHost { - type Target = C; - - fn deref(&self) -> &Self::Target { - &self.component - } -} - -impl> DerefMut for ComponentHost { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.component - } -} - -impl> Element for ComponentHost { - type LayoutState = AnyElement; - type PaintState = (); - - fn layout( - &mut self, - constraint: SizeConstraint, - view: &mut V, - cx: &mut LayoutContext, - ) -> (Vector2F, AnyElement) { - let mut element = self.component.render(view, cx); - let size = element.layout(constraint, view, cx); - (size, element) - } - - fn paint( - &mut self, - scene: &mut SceneBuilder, - bounds: RectF, - visible_bounds: RectF, - element: &mut AnyElement, - view: &mut V, - cx: &mut ViewContext, - ) { - element.paint(scene, bounds.origin(), visible_bounds, view, cx); - } - - fn rect_for_text_range( - &self, - range_utf16: Range, - _: RectF, - _: RectF, - element: &AnyElement, - _: &(), - view: &V, - cx: &ViewContext, - ) -> Option { - element.rect_for_text_range(range_utf16, view, cx) - } - - fn debug( - &self, - _: RectF, - element: &AnyElement, - _: &(), - view: &V, - cx: &ViewContext, - ) -> serde_json::Value { - element.debug(view, cx) - } -} - pub trait AnyRootElement { fn layout( &mut self, diff --git a/crates/gpui/src/gpui.rs b/crates/gpui/src/gpui.rs index a172667fb9..25d022d8ed 100644 --- a/crates/gpui/src/gpui.rs +++ b/crates/gpui/src/gpui.rs @@ -26,7 +26,7 @@ pub mod color; pub mod json; pub mod keymap_matcher; pub mod platform; -pub use gpui_macros::test; +pub use gpui_macros::{test, Element}; pub use window::{Axis, SizeConstraint, Vector2FExt, WindowContext}; pub use anyhow; diff --git a/crates/gpui_macros/src/gpui_macros.rs b/crates/gpui_macros/src/gpui_macros.rs index e976245e06..dbf57b83e5 100644 --- a/crates/gpui_macros/src/gpui_macros.rs +++ b/crates/gpui_macros/src/gpui_macros.rs @@ -3,8 +3,8 @@ use proc_macro2::Ident; use quote::{format_ident, quote}; use std::mem; use syn::{ - parse_macro_input, parse_quote, spanned::Spanned as _, AttributeArgs, FnArg, ItemFn, Lit, Meta, - NestedMeta, Type, + parse_macro_input, parse_quote, spanned::Spanned as _, AttributeArgs, DeriveInput, FnArg, + ItemFn, Lit, Meta, NestedMeta, Type, }; #[proc_macro_attribute] @@ -275,3 +275,68 @@ fn parse_bool(literal: &Lit) -> Result { result.map_err(|err| TokenStream::from(err.into_compile_error())) } + +#[proc_macro_derive(Element)] +pub fn element_derive(input: TokenStream) -> TokenStream { + // Parse the input tokens into a syntax tree + let input = parse_macro_input!(input as DeriveInput); + + // The name of the struct/enum + let name = input.ident; + + let expanded = quote! { + impl gpui::elements::Element for #name { + type LayoutState = gpui::elements::AnyElement; + type PaintState = (); + + fn layout( + &mut self, + constraint: gpui::SizeConstraint, + view: &mut V, + cx: &mut gpui::LayoutContext, + ) -> (gpui::geometry::vector::Vector2F, gpui::elements::AnyElement) { + let mut element = self.render(view, cx); + let size = element.layout(constraint, view, cx); + (size, element) + } + + fn paint( + &mut self, + scene: &mut gpui::SceneBuilder, + bounds: gpui::geometry::rect::RectF, + visible_bounds: gpui::geometry::rect::RectF, + element: &mut gpui::elements::AnyElement, + view: &mut V, + cx: &mut gpui::ViewContext, + ) { + element.paint(scene, bounds.origin(), visible_bounds, view, cx); + } + + fn rect_for_text_range( + &self, + range_utf16: std::ops::Range, + _: gpui::geometry::rect::RectF, + _: gpui::geometry::rect::RectF, + element: &gpui::elements::AnyElement, + _: &(), + view: &V, + cx: &gpui::ViewContext, + ) -> Option { + element.rect_for_text_range(range_utf16, view, cx) + } + + fn debug( + &self, + _: gpui::geometry::rect::RectF, + element: &gpui::elements::AnyElement, + _: &(), + view: &V, + cx: &gpui::ViewContext, + ) -> serde_json::Value { + element.debug(view, cx) + } + } + }; + // Return generated code + TokenStream::from(expanded) +} From a9b5c1d867b35531d1c15b888401609b86dee657 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 26 Jun 2023 12:45:50 +0200 Subject: [PATCH 155/215] Remove unnecessary call to context.notify --- crates/call/src/room.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 00c6b43eb3..48a35b29f6 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -1210,8 +1210,9 @@ impl Room { pub fn toggle_deafen(&mut self, cx: &mut ModelContext) -> Result>> { if let Some(live_kit) = self.live_kit.as_mut() { (*live_kit).deafened = !live_kit.deafened; - cx.notify(); + let mut tasks = Vec::with_capacity(self.remote_participants.len()); + // Context notification is sent within set_mute itself. let _ = Self::set_mute(live_kit, live_kit.deafened, cx)?; // todo (osiewicz): we probably want to schedule it on fg/bg? for participant in self.remote_participants.values() { for track in live_kit From 55f06dcdb54914c2d8570d5a091cc846be597bce Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 26 Jun 2023 13:31:46 +0200 Subject: [PATCH 156/215] Add headers and footers to file finder --- crates/picker/src/picker.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/picker/src/picker.rs b/crates/picker/src/picker.rs index 69f16e4949..ee1eaf3bc9 100644 --- a/crates/picker/src/picker.rs +++ b/crates/picker/src/picker.rs @@ -45,6 +45,12 @@ pub trait PickerDelegate: Sized + 'static { fn center_selection_after_match_updates(&self) -> bool { false } + fn render_header(&self, cx: &AppContext) -> Option>> { + None + } + fn render_footer(&self, cx: &AppContext) -> Option>> { + None + } } impl Entity for Picker { @@ -77,6 +83,7 @@ impl View for Picker { .contained() .with_style(editor_style), ) + .with_children(self.delegate.render_header(cx)) .with_children(if match_count == 0 { if query.is_empty() { None @@ -118,6 +125,7 @@ impl View for Picker { .into_any(), ) }) + .with_children(self.delegate.render_footer(cx)) .contained() .with_style(container_style) .constrained() From 92d7b6aa3b4fa2f4121c3390f1bcc5d883af3d72 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 26 Jun 2023 15:43:21 +0200 Subject: [PATCH 157/215] Allow toggling back and forth between conversation list and editor Co-Authored-By: Nathan Sobo --- crates/ai/src/assistant.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index d7299ca6b5..11a82aac4b 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -119,6 +119,7 @@ pub struct AssistantPanel { width: Option, height: Option, active_editor_index: Option, + prev_active_editor_index: Option, editors: Vec>, saved_conversations: Vec, saved_conversations_list_state: UniformListState, @@ -176,6 +177,7 @@ impl AssistantPanel { }); let mut this = Self { active_editor_index: Default::default(), + prev_active_editor_index: Default::default(), editors: Default::default(), saved_conversations, saved_conversations_list_state: Default::default(), @@ -240,6 +242,7 @@ impl AssistantPanel { } fn set_active_editor_index(&mut self, index: Option, cx: &mut ViewContext) { + self.prev_active_editor_index = self.active_editor_index; self.active_editor_index = index; if let Some(editor) = self.active_editor() { let editor = editor.read(cx).editor.clone(); @@ -350,7 +353,11 @@ impl AssistantPanel { .mouse::(0) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, |_, this: &mut Self, cx| { - this.set_active_editor_index(None, cx); + if this.active_editor().is_some() { + this.set_active_editor_index(None, cx); + } else { + this.set_active_editor_index(this.prev_active_editor_index, cx); + } }) } From 9d4dd5c42b76d4f894d13ab739eff5141e531377 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 26 Jun 2023 15:57:36 +0200 Subject: [PATCH 158/215] Insert empty user message when assisting with the current last message Co-Authored-By: Nathan Sobo --- crates/ai/src/assistant.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 11a82aac4b..7dcd8830ed 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -1023,6 +1023,14 @@ impl Conversation { ) -> Vec { let mut user_messages = Vec::new(); let mut tasks = Vec::new(); + + let last_message_id = self.message_anchors.iter().rev().find_map(|message| { + message + .start + .is_valid(self.buffer.read(cx)) + .then_some(message.id) + }); + for selected_message_id in selected_messages { let selected_message_role = if let Some(metadata) = self.messages_metadata.get(&selected_message_id) { @@ -1085,6 +1093,19 @@ impl Conversation { ) .unwrap(); + // Queue up the user's next reply + if Some(selected_message_id) == last_message_id { + let user_message = self + .insert_message_after( + assistant_message.id, + Role::User, + MessageStatus::Done, + cx, + ) + .unwrap(); + user_messages.push(user_message); + } + tasks.push(cx.spawn_weak({ |this, mut cx| async move { let assistant_message_id = assistant_message.id; From c5b3785be5a29c8442b205411d914c57f3fa42fd Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 26 Jun 2023 16:03:19 +0200 Subject: [PATCH 159/215] Revert "Panic in debug if global settings can't be deserialized from defaults" This reverts commit 7a051a0dcbafd467203bcaeec773c269abcd02cd. --- crates/settings/src/settings_store.rs | 31 ++++++++++++--------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/crates/settings/src/settings_store.rs b/crates/settings/src/settings_store.rs index 5e2be5a881..1188018cd8 100644 --- a/crates/settings/src/settings_store.rs +++ b/crates/settings/src/settings_store.rs @@ -147,28 +147,25 @@ impl SettingsStore { local_values: Vec::new(), })); - let default_settings = setting_value + if let Some(default_settings) = setting_value .deserialize_setting(&self.raw_default_settings) - .expect("can't deserialize default settings"); - - let mut user_values_stack = Vec::new(); - if let Some(user_settings) = setting_value - .deserialize_setting(&self.raw_user_settings) .log_err() { - user_values_stack = vec![user_settings]; - } + let mut user_values_stack = Vec::new(); - #[cfg(debug_assertions)] - setting_value - .load_setting(&default_settings, &[], cx) - .expect("can't deserialize settings from defaults"); + if let Some(user_settings) = setting_value + .deserialize_setting(&self.raw_user_settings) + .log_err() + { + user_values_stack = vec![user_settings]; + } - if let Some(setting) = setting_value - .load_setting(&default_settings, &user_values_stack, cx) - .log_err() - { - setting_value.set_global_value(setting); + if let Some(setting) = setting_value + .load_setting(&default_settings, &user_values_stack, cx) + .log_err() + { + setting_value.set_global_value(setting); + } } } From edc7f306603deb4fa7579d8d2dc148e771796267 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 26 Jun 2023 16:49:33 +0200 Subject: [PATCH 160/215] Add assistant icons to the toolbar Co-Authored-By: Nathan Sobo --- assets/icons/assist_15.svg | 1 + assets/icons/split_message_15.svg | 1 + crates/ai/src/assistant.rs | 187 +++++++++++++++--------------- crates/gpui/src/elements/label.rs | 1 + crates/theme/src/theme.rs | 3 +- styles/src/styleTree/assistant.ts | 41 ++++++- 6 files changed, 132 insertions(+), 102 deletions(-) create mode 100644 assets/icons/assist_15.svg create mode 100644 assets/icons/split_message_15.svg diff --git a/assets/icons/assist_15.svg b/assets/icons/assist_15.svg new file mode 100644 index 0000000000..3baf8df3e9 --- /dev/null +++ b/assets/icons/assist_15.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/split_message_15.svg b/assets/icons/split_message_15.svg new file mode 100644 index 0000000000..54d9e81224 --- /dev/null +++ b/assets/icons/split_message_15.svg @@ -0,0 +1 @@ + diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 7dcd8830ed..929b54fded 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -28,7 +28,6 @@ use search::BufferSearchBar; use serde::Deserialize; use settings::SettingsStore; use std::{ - borrow::Cow, cell::RefCell, cmp, env, fmt::Write, @@ -40,13 +39,9 @@ use std::{ time::Duration, }; use theme::{ui::IconStyle, AssistantStyle}; -use util::{ - channel::ReleaseChannel, paths::CONVERSATIONS_DIR, post_inc, truncate_and_trailoff, ResultExt, - TryFutureExt, -}; +use util::{channel::ReleaseChannel, paths::CONVERSATIONS_DIR, post_inc, ResultExt, TryFutureExt}; use workspace::{ dock::{DockPosition, Panel}, - item::Item, searchable::Direction, Save, ToggleZoom, Toolbar, Workspace, }; @@ -361,64 +356,43 @@ impl AssistantPanel { }) } - fn render_current_model( - &self, - style: &AssistantStyle, - cx: &mut ViewContext, - ) -> Option> { - enum Model {} - - let model = self - .active_editor()? - .read(cx) - .conversation - .read(cx) - .model - .clone(); - - Some( - MouseEventHandler::::new(0, cx, |state, _| { - let style = style.model.style_for(state); - Label::new(model, style.text.clone()) - .contained() - .with_style(style.container) - }) - .with_cursor_style(CursorStyle::PointingHand) - .on_click(MouseButton::Left, |_, this, cx| { - if let Some(editor) = this.active_editor() { - editor.update(cx, |editor, cx| { - editor.cycle_model(cx); - }); - } - }), - ) + fn render_editor_tools(&self, style: &AssistantStyle) -> Vec> { + if self.active_editor().is_some() { + vec![ + Self::render_split_button(&style.split_button).into_any(), + Self::render_assist_button(&style.assist_button).into_any(), + ] + } else { + Default::default() + } } - fn render_remaining_tokens( - &self, - style: &AssistantStyle, - cx: &mut ViewContext, - ) -> Option> { - self.active_editor().and_then(|editor| { - editor - .read(cx) - .conversation - .read(cx) - .remaining_tokens() - .map(|remaining_tokens| { - let remaining_tokens_style = if remaining_tokens <= 0 { - &style.no_remaining_tokens - } else { - &style.remaining_tokens - }; - Label::new( - remaining_tokens.to_string(), - remaining_tokens_style.text.clone(), - ) - .contained() - .with_style(remaining_tokens_style.container) - }) - }) + fn render_split_button(style: &IconStyle) -> impl Element { + enum SplitMessage {} + Svg::for_style(style.icon.clone()) + .contained() + .with_style(style.container) + .mouse::(0) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this: &mut Self, cx| { + if let Some(active_editor) = this.active_editor() { + active_editor.update(cx, |editor, cx| editor.split(&Default::default(), cx)); + } + }) + } + + fn render_assist_button(style: &IconStyle) -> impl Element { + enum Assist {} + Svg::for_style(style.icon.clone()) + .contained() + .with_style(style.container) + .mouse::(0) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this: &mut Self, cx| { + if let Some(active_editor) = this.active_editor() { + active_editor.update(cx, |editor, cx| editor.assist(&Default::default(), cx)); + } + }) } fn render_plus_button(style: &IconStyle) -> impl Element { @@ -589,19 +563,16 @@ impl View for AssistantPanel { ) .with_children(title) .with_children( - self.render_current_model(&style, cx) - .map(|current_model| current_model.aligned().flex_float()), - ) - .with_children( - self.render_remaining_tokens(&style, cx) - .map(|remaining_tokens| remaining_tokens.aligned().flex_float()), + self.render_editor_tools(&style) + .into_iter() + .map(|tool| tool.aligned().flex_float()), ) .with_child( Self::render_plus_button(&style.plus_button) .aligned() .flex_float(), ) - .with_child(self.render_zoom_button(&style, cx).aligned().flex_float()) + .with_child(self.render_zoom_button(&style, cx).aligned()) .contained() .with_style(theme.workspace.tab_bar.container) .expanded() @@ -1995,6 +1966,44 @@ impl ConversationEditor { .map(|summary| summary.text.clone()) .unwrap_or_else(|| "New Conversation".into()) } + + fn render_current_model( + &self, + style: &AssistantStyle, + cx: &mut ViewContext, + ) -> impl Element { + enum Model {} + + MouseEventHandler::::new(0, cx, |state, cx| { + let style = style.model.style_for(state); + Label::new(self.conversation.read(cx).model.clone(), style.text.clone()) + .contained() + .with_style(style.container) + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this, cx| this.cycle_model(cx)) + } + + fn render_remaining_tokens( + &self, + style: &AssistantStyle, + cx: &mut ViewContext, + ) -> Option> { + let remaining_tokens = self.conversation.read(cx).remaining_tokens()?; + let remaining_tokens_style = if remaining_tokens <= 0 { + &style.no_remaining_tokens + } else { + &style.remaining_tokens + }; + Some( + Label::new( + remaining_tokens.to_string(), + remaining_tokens_style.text.clone(), + ) + .contained() + .with_style(remaining_tokens_style.container), + ) + } } impl Entity for ConversationEditor { @@ -2008,9 +2017,20 @@ impl View for ConversationEditor { fn render(&mut self, cx: &mut ViewContext) -> AnyElement { let theme = &theme::current(cx).assistant; - ChildView::new(&self.editor, cx) - .contained() - .with_style(theme.container) + Stack::new() + .with_child( + ChildView::new(&self.editor, cx) + .contained() + .with_style(theme.container), + ) + .with_child( + Flex::row() + .with_child(self.render_current_model(theme, cx)) + .with_children(self.render_remaining_tokens(theme, cx)) + .aligned() + .top() + .right(), + ) .into_any() } @@ -2021,29 +2041,6 @@ impl View for ConversationEditor { } } -impl Item for ConversationEditor { - fn tab_content( - &self, - _: Option, - style: &theme::Tab, - cx: &gpui::AppContext, - ) -> AnyElement { - let title = truncate_and_trailoff(&self.title(cx), editor::MAX_TAB_TITLE_LEN); - Label::new(title, style.label.clone()).into_any() - } - - fn tab_tooltip_text(&self, cx: &AppContext) -> Option> { - Some(self.title(cx).into()) - } - - fn as_searchable( - &self, - _: &ViewHandle, - ) -> Option> { - Some(Box::new(self.editor.clone())) - } -} - #[derive(Clone, Debug)] struct MessageAnchor { id: MessageId, diff --git a/crates/gpui/src/elements/label.rs b/crates/gpui/src/elements/label.rs index 57aeba2886..d9cf537333 100644 --- a/crates/gpui/src/elements/label.rs +++ b/crates/gpui/src/elements/label.rs @@ -165,6 +165,7 @@ impl Element for Label { _: &mut V, cx: &mut ViewContext, ) -> Self::PaintState { + let visible_bounds = bounds.intersection(visible_bounds).unwrap_or_default(); line.paint( scene, bounds.origin(), diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index c012e04807..7a6b554247 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -994,6 +994,8 @@ pub struct TerminalStyle { pub struct AssistantStyle { pub container: ContainerStyle, pub hamburger_button: IconStyle, + pub split_button: IconStyle, + pub assist_button: IconStyle, pub zoom_in_button: IconStyle, pub zoom_out_button: IconStyle, pub plus_button: IconStyle, @@ -1003,7 +1005,6 @@ pub struct AssistantStyle { pub user_sender: Interactive, pub assistant_sender: Interactive, pub system_sender: Interactive, - pub model_info_container: ContainerStyle, pub model: Interactive, pub remaining_tokens: ContainedText, pub no_remaining_tokens: ContainedText, diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index abdd55818b..153b2f9e42 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -28,6 +28,32 @@ export default function assistant(colorScheme: ColorScheme) { margin: { left: 12 }, } }, + splitButton: { + icon: { + color: text(layer, "sans", "default", { size: "sm" }).color, + asset: "icons/split_message_15.svg", + dimensions: { + width: 15, + height: 15, + }, + }, + container: { + margin: { left: 12 }, + } + }, + assistButton: { + icon: { + color: text(layer, "sans", "default", { size: "sm" }).color, + asset: "icons/assist_15.svg", + dimensions: { + width: 15, + height: 15, + }, + }, + container: { + margin: { left: 12, right: 12 }, + } + }, zoomInButton: { icon: { color: text(layer, "sans", "default", { size: "sm" }).color, @@ -120,13 +146,10 @@ export default function assistant(colorScheme: ColorScheme) { margin: { top: 2, left: 8 }, ...text(layer, "sans", "default", { size: "2xs" }), }, - modelInfoContainer: { - margin: { right: 16, top: 4 }, - }, model: interactive({ base: { background: background(layer, "on"), - margin: { right: 8 }, + margin: { left: 12, right: 12, top: 12 }, padding: 4, cornerRadius: 4, ...text(layer, "sans", "default", { size: "xs" }), @@ -139,11 +162,17 @@ export default function assistant(colorScheme: ColorScheme) { }, }), remainingTokens: { - margin: { right: 12 }, + background: background(layer, "on"), + margin: { top: 12, right: 12 }, + padding: 4, + cornerRadius: 4, ...text(layer, "sans", "positive", { size: "xs" }), }, noRemainingTokens: { - margin: { right: 12 }, + background: background(layer, "on"), + margin: { top: 12, right: 12 }, + padding: 4, + cornerRadius: 4, ...text(layer, "sans", "negative", { size: "xs" }), }, errorIcon: { From f6edc6861397c07c166bd6d074fb928663b248e6 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 26 Jun 2023 17:07:33 +0200 Subject: [PATCH 161/215] picker: fix warnings --- crates/picker/src/picker.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/picker/src/picker.rs b/crates/picker/src/picker.rs index ee1eaf3bc9..33d6e84241 100644 --- a/crates/picker/src/picker.rs +++ b/crates/picker/src/picker.rs @@ -45,10 +45,10 @@ pub trait PickerDelegate: Sized + 'static { fn center_selection_after_match_updates(&self) -> bool { false } - fn render_header(&self, cx: &AppContext) -> Option>> { + fn render_header(&self, _cx: &AppContext) -> Option>> { None } - fn render_footer(&self, cx: &AppContext) -> Option>> { + fn render_footer(&self, _cx: &AppContext) -> Option>> { None } } From e723686b72545cb23fcab453e12c07ee2467d515 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 26 Jun 2023 17:17:45 +0200 Subject: [PATCH 162/215] Shwo tooltips for assistant buttons --- crates/ai/src/assistant.rs | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 929b54fded..354599cf5b 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -85,7 +85,7 @@ pub fn init(cx: &mut AppContext) { cx.capture_action(ConversationEditor::save); cx.add_action(ConversationEditor::quote_selection); cx.capture_action(ConversationEditor::copy); - cx.capture_action(ConversationEditor::split); + cx.add_action(ConversationEditor::split); cx.capture_action(ConversationEditor::cycle_message_role); cx.add_action(AssistantPanel::save_api_key); cx.add_action(AssistantPanel::reset_api_key); @@ -356,33 +356,44 @@ impl AssistantPanel { }) } - fn render_editor_tools(&self, style: &AssistantStyle) -> Vec> { + fn render_editor_tools( + &self, + style: &AssistantStyle, + cx: &mut ViewContext, + ) -> Vec> { if self.active_editor().is_some() { vec![ - Self::render_split_button(&style.split_button).into_any(), - Self::render_assist_button(&style.assist_button).into_any(), + Self::render_split_button(&style.split_button, cx).into_any(), + Self::render_assist_button(&style.assist_button, cx).into_any(), ] } else { Default::default() } } - fn render_split_button(style: &IconStyle) -> impl Element { - enum SplitMessage {} + fn render_split_button(style: &IconStyle, cx: &mut ViewContext) -> impl Element { + let tooltip_style = theme::current(cx).tooltip.clone(); Svg::for_style(style.icon.clone()) .contained() .with_style(style.container) - .mouse::(0) + .mouse::(0) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, |_, this: &mut Self, cx| { if let Some(active_editor) = this.active_editor() { active_editor.update(cx, |editor, cx| editor.split(&Default::default(), cx)); } }) + .with_tooltip::( + 1, + "Split Message".into(), + Some(Box::new(Split)), + tooltip_style, + cx, + ) } - fn render_assist_button(style: &IconStyle) -> impl Element { - enum Assist {} + fn render_assist_button(style: &IconStyle, cx: &mut ViewContext) -> impl Element { + let tooltip_style = theme::current(cx).tooltip.clone(); Svg::for_style(style.icon.clone()) .contained() .with_style(style.container) @@ -393,6 +404,13 @@ impl AssistantPanel { active_editor.update(cx, |editor, cx| editor.assist(&Default::default(), cx)); } }) + .with_tooltip::( + 1, + "Assist".into(), + Some(Box::new(Assist)), + tooltip_style, + cx, + ) } fn render_plus_button(style: &IconStyle) -> impl Element { @@ -563,7 +581,7 @@ impl View for AssistantPanel { ) .with_children(title) .with_children( - self.render_editor_tools(&style) + self.render_editor_tools(&style, cx) .into_iter() .map(|tool| tool.aligned().flex_float()), ) From 723c8b98b30b9c20537d352a34ec69a734571b76 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 26 Jun 2023 17:24:31 +0200 Subject: [PATCH 163/215] Show quote selection button --- assets/icons/quote_15.svg | 1 + crates/ai/src/assistant.rs | 29 +++++++++++++++++++++++++++++ crates/theme/src/theme.rs | 1 + styles/src/styleTree/assistant.ts | 15 ++++++++++++++- 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 assets/icons/quote_15.svg diff --git a/assets/icons/quote_15.svg b/assets/icons/quote_15.svg new file mode 100644 index 0000000000..be5eabd9b0 --- /dev/null +++ b/assets/icons/quote_15.svg @@ -0,0 +1 @@ + diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 354599cf5b..78ab13fbb1 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -111,6 +111,7 @@ pub enum AssistantPanelEvent { } pub struct AssistantPanel { + workspace: WeakViewHandle, width: Option, height: Option, active_editor_index: Option, @@ -143,6 +144,7 @@ impl AssistantPanel { .unwrap_or_default(); // TODO: deserialize state. + let workspace_handle = workspace.clone(); workspace.update(&mut cx, |workspace, cx| { cx.add_view::(|cx| { const CONVERSATION_WATCH_DURATION: Duration = Duration::from_millis(100); @@ -171,6 +173,7 @@ impl AssistantPanel { toolbar }); let mut this = Self { + workspace: workspace_handle, active_editor_index: Default::default(), prev_active_editor_index: Default::default(), editors: Default::default(), @@ -364,6 +367,7 @@ impl AssistantPanel { if self.active_editor().is_some() { vec![ Self::render_split_button(&style.split_button, cx).into_any(), + Self::render_quote_button(&style.quote_button, cx).into_any(), Self::render_assist_button(&style.assist_button, cx).into_any(), ] } else { @@ -413,6 +417,31 @@ impl AssistantPanel { ) } + fn render_quote_button(style: &IconStyle, cx: &mut ViewContext) -> impl Element { + let tooltip_style = theme::current(cx).tooltip.clone(); + Svg::for_style(style.icon.clone()) + .contained() + .with_style(style.container) + .mouse::(0) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this: &mut Self, cx| { + if let Some(workspace) = this.workspace.upgrade(cx) { + cx.window_context().defer(move |cx| { + workspace.update(cx, |workspace, cx| { + ConversationEditor::quote_selection(workspace, &Default::default(), cx) + }); + }); + } + }) + .with_tooltip::( + 1, + "Assist".into(), + Some(Box::new(QuoteSelection)), + tooltip_style, + cx, + ) + } + fn render_plus_button(style: &IconStyle) -> impl Element { enum AddConversation {} Svg::for_style(style.icon.clone()) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 7a6b554247..e828f8ba97 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -996,6 +996,7 @@ pub struct AssistantStyle { pub hamburger_button: IconStyle, pub split_button: IconStyle, pub assist_button: IconStyle, + pub quote_button: IconStyle, pub zoom_in_button: IconStyle, pub zoom_out_button: IconStyle, pub plus_button: IconStyle, diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index 153b2f9e42..db3f419b14 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -41,6 +41,19 @@ export default function assistant(colorScheme: ColorScheme) { margin: { left: 12 }, } }, + quoteButton: { + icon: { + color: text(layer, "sans", "default", { size: "sm" }).color, + asset: "icons/quote_15.svg", + dimensions: { + width: 15, + height: 15, + }, + }, + container: { + margin: { left: 12 }, + } + }, assistButton: { icon: { color: text(layer, "sans", "default", { size: "sm" }).color, @@ -51,7 +64,7 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - margin: { left: 12, right: 12 }, + margin: { left: 12, right: 24 }, } }, zoomInButton: { From e77abbf64f3d5f0309f6f149f333d8dbcb2b4c3d Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 26 Jun 2023 17:48:43 +0200 Subject: [PATCH 164/215] Add hover state to assistant buttons --- crates/ai/src/assistant.rs | 215 +++++++++++++++--------------- crates/theme/src/theme.rs | 14 +- styles/src/styleTree/assistant.ts | 203 ++++++++++++++++++---------- 3 files changed, 249 insertions(+), 183 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 78ab13fbb1..2d3c21ba31 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -38,7 +38,7 @@ use std::{ sync::Arc, time::Duration, }; -use theme::{ui::IconStyle, AssistantStyle}; +use theme::AssistantStyle; use util::{channel::ReleaseChannel, paths::CONVERSATIONS_DIR, post_inc, ResultExt, TryFutureExt}; use workspace::{ dock::{DockPosition, Panel}, @@ -343,131 +343,140 @@ impl AssistantPanel { self.editors.get(self.active_editor_index?) } - fn render_hamburger_button(style: &IconStyle) -> impl Element { + fn render_hamburger_button(cx: &mut ViewContext) -> impl Element { enum ListConversations {} - Svg::for_style(style.icon.clone()) - .contained() - .with_style(style.container) - .mouse::(0) - .with_cursor_style(CursorStyle::PointingHand) - .on_click(MouseButton::Left, |_, this: &mut Self, cx| { - if this.active_editor().is_some() { - this.set_active_editor_index(None, cx); - } else { - this.set_active_editor_index(this.prev_active_editor_index, cx); - } - }) + let theme = theme::current(cx); + MouseEventHandler::::new(0, cx, |state, _| { + let style = theme.assistant.hamburger_button.style_for(state); + Svg::for_style(style.icon.clone()) + .contained() + .with_style(style.container) + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this: &mut Self, cx| { + if this.active_editor().is_some() { + this.set_active_editor_index(None, cx); + } else { + this.set_active_editor_index(this.prev_active_editor_index, cx); + } + }) } - fn render_editor_tools( - &self, - style: &AssistantStyle, - cx: &mut ViewContext, - ) -> Vec> { + fn render_editor_tools(&self, cx: &mut ViewContext) -> Vec> { if self.active_editor().is_some() { vec![ - Self::render_split_button(&style.split_button, cx).into_any(), - Self::render_quote_button(&style.quote_button, cx).into_any(), - Self::render_assist_button(&style.assist_button, cx).into_any(), + Self::render_split_button(cx).into_any(), + Self::render_quote_button(cx).into_any(), + Self::render_assist_button(cx).into_any(), ] } else { Default::default() } } - fn render_split_button(style: &IconStyle, cx: &mut ViewContext) -> impl Element { + fn render_split_button(cx: &mut ViewContext) -> impl Element { + let theme = theme::current(cx); let tooltip_style = theme::current(cx).tooltip.clone(); - Svg::for_style(style.icon.clone()) - .contained() - .with_style(style.container) - .mouse::(0) - .with_cursor_style(CursorStyle::PointingHand) - .on_click(MouseButton::Left, |_, this: &mut Self, cx| { - if let Some(active_editor) = this.active_editor() { - active_editor.update(cx, |editor, cx| editor.split(&Default::default(), cx)); - } - }) - .with_tooltip::( - 1, - "Split Message".into(), - Some(Box::new(Split)), - tooltip_style, - cx, - ) + MouseEventHandler::::new(0, cx, |state, _| { + let style = theme.assistant.split_button.style_for(state); + Svg::for_style(style.icon.clone()) + .contained() + .with_style(style.container) + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this: &mut Self, cx| { + if let Some(active_editor) = this.active_editor() { + active_editor.update(cx, |editor, cx| editor.split(&Default::default(), cx)); + } + }) + .with_tooltip::( + 1, + "Split Message".into(), + Some(Box::new(Split)), + tooltip_style, + cx, + ) } - fn render_assist_button(style: &IconStyle, cx: &mut ViewContext) -> impl Element { + fn render_assist_button(cx: &mut ViewContext) -> impl Element { + let theme = theme::current(cx); let tooltip_style = theme::current(cx).tooltip.clone(); - Svg::for_style(style.icon.clone()) - .contained() - .with_style(style.container) - .mouse::(0) - .with_cursor_style(CursorStyle::PointingHand) - .on_click(MouseButton::Left, |_, this: &mut Self, cx| { - if let Some(active_editor) = this.active_editor() { - active_editor.update(cx, |editor, cx| editor.assist(&Default::default(), cx)); - } - }) - .with_tooltip::( - 1, - "Assist".into(), - Some(Box::new(Assist)), - tooltip_style, - cx, - ) + MouseEventHandler::::new(0, cx, |state, _| { + let style = theme.assistant.assist_button.style_for(state); + Svg::for_style(style.icon.clone()) + .contained() + .with_style(style.container) + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this: &mut Self, cx| { + if let Some(active_editor) = this.active_editor() { + active_editor.update(cx, |editor, cx| editor.assist(&Default::default(), cx)); + } + }) + .with_tooltip::( + 1, + "Assist".into(), + Some(Box::new(Assist)), + tooltip_style, + cx, + ) } - fn render_quote_button(style: &IconStyle, cx: &mut ViewContext) -> impl Element { + fn render_quote_button(cx: &mut ViewContext) -> impl Element { + let theme = theme::current(cx); let tooltip_style = theme::current(cx).tooltip.clone(); - Svg::for_style(style.icon.clone()) - .contained() - .with_style(style.container) - .mouse::(0) - .with_cursor_style(CursorStyle::PointingHand) - .on_click(MouseButton::Left, |_, this: &mut Self, cx| { - if let Some(workspace) = this.workspace.upgrade(cx) { - cx.window_context().defer(move |cx| { - workspace.update(cx, |workspace, cx| { - ConversationEditor::quote_selection(workspace, &Default::default(), cx) - }); + MouseEventHandler::::new(0, cx, |state, _| { + let style = theme.assistant.quote_button.style_for(state); + Svg::for_style(style.icon.clone()) + .contained() + .with_style(style.container) + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this: &mut Self, cx| { + if let Some(workspace) = this.workspace.upgrade(cx) { + cx.window_context().defer(move |cx| { + workspace.update(cx, |workspace, cx| { + ConversationEditor::quote_selection(workspace, &Default::default(), cx) }); - } - }) - .with_tooltip::( - 1, - "Assist".into(), - Some(Box::new(QuoteSelection)), - tooltip_style, - cx, - ) + }); + } + }) + .with_tooltip::( + 1, + "Assist".into(), + Some(Box::new(QuoteSelection)), + tooltip_style, + cx, + ) } - fn render_plus_button(style: &IconStyle) -> impl Element { + fn render_plus_button(cx: &mut ViewContext) -> impl Element { enum AddConversation {} - Svg::for_style(style.icon.clone()) - .contained() - .with_style(style.container) - .mouse::(0) - .with_cursor_style(CursorStyle::PointingHand) - .on_click(MouseButton::Left, |_, this: &mut Self, cx| { - this.new_conversation(cx); - }) + let theme = theme::current(cx); + MouseEventHandler::::new(0, cx, |state, _| { + let style = theme.assistant.plus_button.style_for(state); + Svg::for_style(style.icon.clone()) + .contained() + .with_style(style.container) + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, this: &mut Self, cx| { + this.new_conversation(cx); + }) } - fn render_zoom_button( - &self, - style: &AssistantStyle, - cx: &mut ViewContext, - ) -> impl Element { + fn render_zoom_button(&self, cx: &mut ViewContext) -> impl Element { enum ToggleZoomButton {} + let theme = theme::current(cx); let style = if self.zoomed { - &style.zoom_out_button + &theme.assistant.zoom_out_button } else { - &style.zoom_in_button + &theme.assistant.zoom_in_button }; - MouseEventHandler::::new(0, cx, |_, _| { + MouseEventHandler::::new(0, cx, |state, _| { + let style = style.style_for(state); Svg::for_style(style.icon.clone()) .contained() .with_style(style.container) @@ -605,21 +614,15 @@ impl View for AssistantPanel { Flex::column() .with_child( Flex::row() - .with_child( - Self::render_hamburger_button(&style.hamburger_button).aligned(), - ) + .with_child(Self::render_hamburger_button(cx).aligned()) .with_children(title) .with_children( - self.render_editor_tools(&style, cx) + self.render_editor_tools(cx) .into_iter() .map(|tool| tool.aligned().flex_float()), ) - .with_child( - Self::render_plus_button(&style.plus_button) - .aligned() - .flex_float(), - ) - .with_child(self.render_zoom_button(&style, cx).aligned()) + .with_child(Self::render_plus_button(cx).aligned().flex_float()) + .with_child(self.render_zoom_button(cx).aligned()) .contained() .with_style(theme.workspace.tab_bar.container) .expanded() diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index e828f8ba97..f93063be2e 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -993,13 +993,13 @@ pub struct TerminalStyle { #[derive(Clone, Deserialize, Default, JsonSchema)] pub struct AssistantStyle { pub container: ContainerStyle, - pub hamburger_button: IconStyle, - pub split_button: IconStyle, - pub assist_button: IconStyle, - pub quote_button: IconStyle, - pub zoom_in_button: IconStyle, - pub zoom_out_button: IconStyle, - pub plus_button: IconStyle, + pub hamburger_button: Interactive, + pub split_button: Interactive, + pub assist_button: Interactive, + pub quote_button: Interactive, + pub zoom_in_button: Interactive, + pub zoom_out_button: Interactive, + pub plus_button: Interactive, pub title: ContainedText, pub message_header: ContainerStyle, pub sent_at: ContainedText, diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index db3f419b14..91b52f20ad 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -15,97 +15,160 @@ export default function assistant(colorScheme: ColorScheme) { margin: { bottom: 6, top: 6 }, background: editor(colorScheme).background, }, - hamburgerButton: { - icon: { - color: text(layer, "sans", "default", { size: "sm" }).color, - asset: "icons/hamburger_15.svg", - dimensions: { - width: 15, - height: 15, + hamburgerButton: interactive({ + base: { + icon: { + color: foreground(layer, "variant"), + asset: "icons/hamburger_15.svg", + dimensions: { + width: 15, + height: 15, + }, }, + container: { + margin: { left: 12 }, + } }, - container: { - margin: { left: 12 }, + state: { + hovered: { + icon: { + color: foreground(layer, "hovered") + } + } } - }, - splitButton: { - icon: { - color: text(layer, "sans", "default", { size: "sm" }).color, - asset: "icons/split_message_15.svg", - dimensions: { - width: 15, - height: 15, + }), + splitButton: interactive({ + base: { + icon: { + color: foreground(layer, "variant"), + asset: "icons/split_message_15.svg", + dimensions: { + width: 15, + height: 15, + }, }, + container: { + margin: { left: 12 }, + } }, - container: { - margin: { left: 12 }, + state: { + hovered: { + icon: { + color: foreground(layer, "hovered") + } + } } - }, - quoteButton: { - icon: { - color: text(layer, "sans", "default", { size: "sm" }).color, - asset: "icons/quote_15.svg", - dimensions: { - width: 15, - height: 15, + }), + quoteButton: interactive({ + base: { + icon: { + color: foreground(layer, "variant"), + asset: "icons/quote_15.svg", + dimensions: { + width: 15, + height: 15, + }, }, + container: { + margin: { left: 12 }, + } }, - container: { - margin: { left: 12 }, + state: { + hovered: { + icon: { + color: foreground(layer, "hovered") + } + } } - }, - assistButton: { - icon: { - color: text(layer, "sans", "default", { size: "sm" }).color, - asset: "icons/assist_15.svg", - dimensions: { - width: 15, - height: 15, + }), + assistButton: interactive({ + base: { + icon: { + color: foreground(layer, "variant"), + asset: "icons/assist_15.svg", + dimensions: { + width: 15, + height: 15, + }, }, + container: { + margin: { left: 12, right: 24 }, + } }, - container: { - margin: { left: 12, right: 24 }, + state: { + hovered: { + icon: { + color: foreground(layer, "hovered") + } + } } - }, - zoomInButton: { - icon: { - color: text(layer, "sans", "default", { size: "sm" }).color, - asset: "icons/maximize_8.svg", - dimensions: { - width: 12, - height: 12, + }), + zoomInButton: interactive({ + base: { + icon: { + color: foreground(layer, "variant"), + asset: "icons/maximize_8.svg", + dimensions: { + width: 12, + height: 12, + }, }, + container: { + margin: { right: 12 }, + } }, - container: { - margin: { right: 12 }, + state: { + hovered: { + icon: { + color: foreground(layer, "hovered") + } + } } - }, - zoomOutButton: { - icon: { - color: text(layer, "sans", "default", { size: "sm" }).color, - asset: "icons/minimize_8.svg", - dimensions: { - width: 12, - height: 12, + }), + zoomOutButton: interactive({ + base: { + icon: { + color: foreground(layer, "variant"), + asset: "icons/minimize_8.svg", + dimensions: { + width: 12, + height: 12, + }, }, + container: { + margin: { right: 12 }, + } }, - container: { - margin: { right: 12 }, + state: { + hovered: { + icon: { + color: foreground(layer, "hovered") + } + } } - }, - plusButton: { - icon: { - color: text(layer, "sans", "default", { size: "sm" }).color, - asset: "icons/plus_12.svg", - dimensions: { - width: 12, - height: 12, + }), + plusButton: interactive({ + base: { + icon: { + color: foreground(layer, "variant"), + asset: "icons/plus_12.svg", + dimensions: { + width: 12, + height: 12, + }, }, + container: { + margin: { right: 12 }, + } }, - container: { - margin: { right: 12 }, + state: { + hovered: { + icon: { + color: foreground(layer, "hovered") + } + } } - }, + }), title: { margin: { left: 12 }, ...text(layer, "sans", "default", { size: "sm" }) From c3e8cae20f7248748541e447a8d782e8c3392c74 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 26 Jun 2023 10:08:34 -0600 Subject: [PATCH 165/215] vim: indent/outdent Fixes: zed-industries/community#832 --- assets/keymaps/vim.json | 8 ++++++-- crates/vim/src/test.rs | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 43b778d9b8..d621bd0e49 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -221,7 +221,9 @@ "vim::PushOperator", "Replace" ], - "s": "vim::Substitute" + "s": "vim::Substitute", + "> >": "editor::Indent", + "< <": "editor::Outdent" } }, { @@ -312,7 +314,9 @@ "r": [ "vim::PushOperator", "Replace" - ] + ], + "> >": "editor::Indent", + "< <": "editor::Outdent" } }, { diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index 075229c47f..b6c5b7ca51 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -123,3 +123,19 @@ async fn test_end_of_document_710(cx: &mut gpui::TestAppContext) { cx.simulate_keystrokes(["1", "shift-g"]); cx.assert_editor_state("aˇa\nbb\ncc"); } + +#[gpui::test] +async fn test_indent_outdent(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + // works in normal mode + cx.set_state(indoc! {"aa\nbˇb\ncc"}, Mode::Normal); + cx.simulate_keystrokes([">", ">"]); + cx.assert_editor_state("aa\n bˇb\ncc"); + cx.simulate_keystrokes(["<", "<"]); + cx.assert_editor_state("aa\nbˇb\ncc"); + + // works in visuial mode + cx.simulate_keystrokes(["shift-v", "down", ">", ">"]); + cx.assert_editor_state("aa\n b«b\n cˇ»c"); +} From d46d3e6d15ec641e6d0895a3bf2801e5ccc0dec8 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 26 Jun 2023 18:18:22 +0200 Subject: [PATCH 166/215] Try fixing test on CI --- crates/ai/src/assistant.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 2d3c21ba31..770aff954d 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -2244,11 +2244,10 @@ mod tests { workspace.add_panel(panel.clone(), cx); workspace.toggle_dock(DockPosition::Right, cx); assert!(workspace.right_dock().read(cx).is_open()); - cx.focus(&panel); }); + panel.update(cx, |_, cx| cx.focus_self()); cx.dispatch_action(window_id, workspace::ToggleZoom); - workspace.read_with(cx, |workspace, cx| { assert_eq!(workspace.zoomed_view(cx).unwrap(), panel); }) From 1dc52c7547686b6286552cd43073e00e2c88f920 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Mon, 26 Jun 2023 13:07:33 -0400 Subject: [PATCH 167/215] Fix incorrect ThemeAppearance --- styles/src/themes/atelier/atelier-forest-light.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles/src/themes/atelier/atelier-forest-light.ts b/styles/src/themes/atelier/atelier-forest-light.ts index 17d3b63d88..e12baf9904 100644 --- a/styles/src/themes/atelier/atelier-forest-light.ts +++ b/styles/src/themes/atelier/atelier-forest-light.ts @@ -30,7 +30,7 @@ const getTheme = (variant: Variant): ThemeConfig => { return { name: `${meta.name} Forest Light`, author: meta.author, - appearance: ThemeAppearance.Dark, + appearance: ThemeAppearance.Light, licenseType: meta.licenseType, licenseUrl: meta.licenseUrl, licenseFile: `${__dirname}/LICENSE`, From 43723168fce66c120b0c0b577e0f9d6c2d57e05c Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 26 Jun 2023 19:10:59 +0200 Subject: [PATCH 168/215] Remove assistant panel zoom test The test was testing pretty straightforward logic, but for some strange reason it was failing on CI (but passed locally). I think it's fine to delete it and make progress, if zooming regresses we'll find out pretty quickly. --- crates/ai/src/assistant.rs | 44 +------------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 770aff954d..01693425fb 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -2209,49 +2209,7 @@ async fn stream_completion( mod tests { use super::*; use crate::MessageId; - use fs::FakeFs; - use gpui::{AppContext, TestAppContext}; - use project::Project; - - fn init_test(cx: &mut TestAppContext) { - cx.foreground().forbid_parking(); - cx.update(|cx| { - cx.set_global(SettingsStore::test(cx)); - theme::init((), cx); - language::init(cx); - editor::init_settings(cx); - crate::init(cx); - workspace::init_settings(cx); - Project::init_settings(cx); - }); - } - - #[gpui::test] - async fn test_panel(cx: &mut TestAppContext) { - init_test(cx); - - let fs = FakeFs::new(cx.background()); - let project = Project::test(fs, [], cx).await; - let (window_id, workspace) = cx.add_window(|cx| Workspace::test_new(project.clone(), cx)); - let weak_workspace = workspace.downgrade(); - - let panel = cx - .spawn(|cx| async move { AssistantPanel::load(weak_workspace, cx).await }) - .await - .unwrap(); - - workspace.update(cx, |workspace, cx| { - workspace.add_panel(panel.clone(), cx); - workspace.toggle_dock(DockPosition::Right, cx); - assert!(workspace.right_dock().read(cx).is_open()); - }); - - panel.update(cx, |_, cx| cx.focus_self()); - cx.dispatch_action(window_id, workspace::ToggleZoom); - workspace.read_with(cx, |workspace, cx| { - assert_eq!(workspace.zoomed_view(cx).unwrap(), panel); - }) - } + use gpui::AppContext; #[gpui::test] fn test_inserting_and_removing_messages(cx: &mut AppContext) { From c0fb98cb3fee28b251b353bebb7d353610fefeb5 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Mon, 26 Jun 2023 13:31:16 -0400 Subject: [PATCH 169/215] Factor out key name --- crates/zed/src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 5f362d1d31..5d94622d47 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -271,13 +271,15 @@ fn main() { } async fn installation_id() -> Result { - if let Ok(Some(installation_id)) = KEY_VALUE_STORE.read_kvp("device_id") { + let legacy_key_name = "device_id"; + + if let Ok(Some(installation_id)) = KEY_VALUE_STORE.read_kvp(legacy_key_name) { Ok(installation_id) } else { let installation_id = Uuid::new_v4().to_string(); KEY_VALUE_STORE - .write_kvp("device_id".to_string(), installation_id.clone()) + .write_kvp(legacy_key_name.to_string(), installation_id.clone()) .await?; Ok(installation_id) From 02fc5dd6c92cb059324cbcae1358607fe51ebea6 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 26 Jun 2023 12:23:58 -0600 Subject: [PATCH 170/215] vim: Fix scrolling After #2641 we noticed that scrolling didn't take a count parameter. The PageDown/PageUp logic was also broken by an additional -1 (for both vim mode and not). --- assets/keymaps/vim.json | 32 ++---- crates/editor/src/editor_tests.rs | 38 +++++++ crates/editor/src/scroll.rs | 2 +- crates/editor/src/scroll/actions.rs | 12 +-- crates/editor/src/scroll/scroll_amount.rs | 32 +++--- crates/vim/src/normal.rs | 65 ++---------- crates/vim/src/normal/scroll.rs | 120 ++++++++++++++++++++++ 7 files changed, 195 insertions(+), 106 deletions(-) create mode 100644 crates/vim/src/normal/scroll.rs diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 43b778d9b8..ddda37e5fa 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -58,10 +58,6 @@ } ], "%": "vim::Matching", - "ctrl-y": [ - "vim::Scroll", - "LineUp" - ], "f": [ "vim::PushOperator", { @@ -197,26 +193,14 @@ "focus": true } ], - "ctrl-f": [ - "vim::Scroll", - "PageDown" - ], - "ctrl-b": [ - "vim::Scroll", - "PageUp" - ], - "ctrl-d": [ - "vim::Scroll", - "HalfPageDown" - ], - "ctrl-u": [ - "vim::Scroll", - "HalfPageUp" - ], - "ctrl-e": [ - "vim::Scroll", - "LineDown" - ], + "ctrl-f": "vim::PageDown", + "pagedown": "vim::PageDown", + "ctrl-b": "vim::PageUp", + "pageup": "vim::PageUp", + "ctrl-d": "vim::ScrollDown", + "ctrl-u": "vim::ScrollUp", + "ctrl-e": "vim::LineDown", + "ctrl-y": "vim::LineUp", "r": [ "vim::PushOperator", "Replace" diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 6fcb6f778f..657a7a744e 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -1,5 +1,6 @@ use super::*; use crate::{ + scroll::scroll_amount::ScrollAmount, test::{ assert_text_with_selections, build_editor, editor_lsp_test_context::EditorLspTestContext, editor_test_context::EditorTestContext, select_ranges, @@ -1359,6 +1360,43 @@ async fn test_move_start_of_paragraph_end_of_paragraph(cx: &mut gpui::TestAppCon ); } +#[gpui::test] +async fn test_scroll_page_up_page_down(cx: &mut gpui::TestAppContext) { + init_test(cx, |_| {}); + let mut cx = EditorTestContext::new(cx).await; + let line_height = cx.editor(|editor, cx| editor.style(cx).text.line_height(cx.font_cache())); + cx.simulate_window_resize(cx.window_id, vec2f(1000., 4. * line_height + 0.5)); + + cx.set_state( + &r#"ˇone + two + three + four + five + six + seven + eight + nine + ten + "#, + ); + + cx.update_editor(|editor, cx| { + assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 0.)); + editor.scroll_screen(&ScrollAmount::Page(1.), cx); + assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 3.)); + editor.scroll_screen(&ScrollAmount::Page(1.), cx); + assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 6.)); + editor.scroll_screen(&ScrollAmount::Page(-1.), cx); + assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 3.)); + + editor.scroll_screen(&ScrollAmount::Page(-0.5), cx); + assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 2.)); + editor.scroll_screen(&ScrollAmount::Page(0.5), cx); + assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 3.)); + }); +} + #[gpui::test] async fn test_move_page_up_page_down(cx: &mut gpui::TestAppContext) { init_test(cx, |_| {}); diff --git a/crates/editor/src/scroll.rs b/crates/editor/src/scroll.rs index a13619a82a..09b75bc680 100644 --- a/crates/editor/src/scroll.rs +++ b/crates/editor/src/scroll.rs @@ -368,7 +368,7 @@ impl Editor { } let cur_position = self.scroll_position(cx); - let new_pos = cur_position + vec2f(0., amount.lines(self) - 1.); + let new_pos = cur_position + vec2f(0., amount.lines(self)); self.set_scroll_position(new_pos, cx); } diff --git a/crates/editor/src/scroll/actions.rs b/crates/editor/src/scroll/actions.rs index da5e3603e7..82c2e10589 100644 --- a/crates/editor/src/scroll/actions.rs +++ b/crates/editor/src/scroll/actions.rs @@ -27,22 +27,22 @@ pub fn init(cx: &mut AppContext) { cx.add_action(Editor::scroll_cursor_center); cx.add_action(Editor::scroll_cursor_bottom); cx.add_action(|this: &mut Editor, _: &LineDown, cx| { - this.scroll_screen(&ScrollAmount::LineDown, cx) + this.scroll_screen(&ScrollAmount::Line(1.), cx) }); cx.add_action(|this: &mut Editor, _: &LineUp, cx| { - this.scroll_screen(&ScrollAmount::LineUp, cx) + this.scroll_screen(&ScrollAmount::Line(-1.), cx) }); cx.add_action(|this: &mut Editor, _: &HalfPageDown, cx| { - this.scroll_screen(&ScrollAmount::HalfPageDown, cx) + this.scroll_screen(&ScrollAmount::Page(0.5), cx) }); cx.add_action(|this: &mut Editor, _: &HalfPageUp, cx| { - this.scroll_screen(&ScrollAmount::HalfPageUp, cx) + this.scroll_screen(&ScrollAmount::Page(-0.5), cx) }); cx.add_action(|this: &mut Editor, _: &PageDown, cx| { - this.scroll_screen(&ScrollAmount::PageDown, cx) + this.scroll_screen(&ScrollAmount::Page(1.), cx) }); cx.add_action(|this: &mut Editor, _: &PageUp, cx| { - this.scroll_screen(&ScrollAmount::PageUp, cx) + this.scroll_screen(&ScrollAmount::Page(-1.), cx) }); } diff --git a/crates/editor/src/scroll/scroll_amount.rs b/crates/editor/src/scroll/scroll_amount.rs index 6f6c21f0d4..f9d09adcf5 100644 --- a/crates/editor/src/scroll/scroll_amount.rs +++ b/crates/editor/src/scroll/scroll_amount.rs @@ -6,12 +6,10 @@ use crate::Editor; #[derive(Clone, PartialEq, Deserialize)] pub enum ScrollAmount { - LineUp, - LineDown, - HalfPageUp, - HalfPageDown, - PageUp, - PageDown, + // Scroll N lines (positive is towards the end of the document) + Line(f32), + // Scroll N pages (positive is towards the end of the document) + Page(f32), } impl ScrollAmount { @@ -24,10 +22,10 @@ impl ScrollAmount { let context_menu = editor.context_menu.as_mut()?; match self { - Self::LineDown | Self::HalfPageDown => context_menu.select_next(cx), - Self::LineUp | Self::HalfPageUp => context_menu.select_prev(cx), - Self::PageDown => context_menu.select_last(cx), - Self::PageUp => context_menu.select_first(cx), + Self::Line(c) if *c > 0. => context_menu.select_next(cx), + Self::Line(_) => context_menu.select_prev(cx), + Self::Page(c) if *c > 0. => context_menu.select_last(cx), + Self::Page(_) => context_menu.select_first(cx), } .then_some(()) }) @@ -36,13 +34,13 @@ impl ScrollAmount { pub fn lines(&self, editor: &mut Editor) -> f32 { match self { - Self::LineDown => 1., - Self::LineUp => -1., - Self::HalfPageDown => editor.visible_line_count().map(|l| l / 2.).unwrap_or(1.), - Self::HalfPageUp => -editor.visible_line_count().map(|l| l / 2.).unwrap_or(1.), - // Minus 1. here so that there is a pivot line that stays on the screen - Self::PageDown => editor.visible_line_count().unwrap_or(1.) - 1., - Self::PageUp => -editor.visible_line_count().unwrap_or(1.) - 1., + Self::Line(count) => *count, + Self::Page(count) => editor + .visible_line_count() + // subtract one to leave an anchor line + // round towards zero (so page-up and page-down are symmetric) + .map(|l| ((l - 1.) * count).trunc()) + .unwrap_or(0.), } } } diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index c54f739628..8c414d306b 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -1,9 +1,10 @@ mod change; mod delete; +mod scroll; mod substitute; mod yank; -use std::{borrow::Cow, cmp::Ordering, sync::Arc}; +use std::{borrow::Cow, sync::Arc}; use crate::{ motion::Motion, @@ -13,14 +14,12 @@ use crate::{ }; use collections::{HashMap, HashSet}; use editor::{ - display_map::ToDisplayPoint, - scroll::{autoscroll::Autoscroll, scroll_amount::ScrollAmount}, - Anchor, Bias, ClipboardSelection, DisplayPoint, Editor, + display_map::ToDisplayPoint, scroll::autoscroll::Autoscroll, Anchor, Bias, ClipboardSelection, + DisplayPoint, }; -use gpui::{actions, impl_actions, AppContext, ViewContext, WindowContext}; +use gpui::{actions, AppContext, ViewContext, WindowContext}; use language::{AutoindentMode, Point, SelectionGoal}; use log::error; -use serde::Deserialize; use workspace::Workspace; use self::{ @@ -30,9 +29,6 @@ use self::{ yank::{yank_motion, yank_object}, }; -#[derive(Clone, PartialEq, Deserialize)] -struct Scroll(ScrollAmount); - actions!( vim, [ @@ -51,8 +47,6 @@ actions!( ] ); -impl_actions!(vim, [Scroll]); - pub fn init(cx: &mut AppContext) { cx.add_action(insert_after); cx.add_action(insert_first_non_whitespace); @@ -90,13 +84,8 @@ pub fn init(cx: &mut AppContext) { }) }); cx.add_action(paste); - cx.add_action(|_: &mut Workspace, Scroll(amount): &Scroll, cx| { - Vim::update(cx, |vim, cx| { - vim.update_active_editor(cx, |editor, cx| { - scroll(editor, amount, cx); - }) - }) - }); + + scroll::init(cx); } pub fn normal_motion( @@ -393,46 +382,6 @@ fn paste(_: &mut Workspace, _: &Paste, cx: &mut ViewContext) { }); } -fn scroll(editor: &mut Editor, amount: &ScrollAmount, cx: &mut ViewContext) { - let should_move_cursor = editor.newest_selection_on_screen(cx).is_eq(); - editor.scroll_screen(amount, cx); - if should_move_cursor { - let selection_ordering = editor.newest_selection_on_screen(cx); - if selection_ordering.is_eq() { - return; - } - - let visible_rows = if let Some(visible_rows) = editor.visible_line_count() { - visible_rows as u32 - } else { - return; - }; - - let scroll_margin_rows = editor.vertical_scroll_margin() as u32; - let top_anchor = editor.scroll_manager.anchor().anchor; - - editor.change_selections(None, cx, |s| { - s.replace_cursors_with(|snapshot| { - let mut new_point = top_anchor.to_display_point(&snapshot); - - match selection_ordering { - Ordering::Less => { - *new_point.row_mut() += scroll_margin_rows; - new_point = snapshot.clip_point(new_point, Bias::Right); - } - Ordering::Greater => { - *new_point.row_mut() += visible_rows - scroll_margin_rows as u32; - new_point = snapshot.clip_point(new_point, Bias::Left); - } - Ordering::Equal => unreachable!(), - } - - vec![new_point] - }) - }); - } -} - pub(crate) fn normal_replace(text: Arc, cx: &mut WindowContext) { Vim::update(cx, |vim, cx| { vim.update_active_editor(cx, |editor, cx| { diff --git a/crates/vim/src/normal/scroll.rs b/crates/vim/src/normal/scroll.rs new file mode 100644 index 0000000000..7b068cd793 --- /dev/null +++ b/crates/vim/src/normal/scroll.rs @@ -0,0 +1,120 @@ +use std::cmp::Ordering; + +use crate::Vim; +use editor::{display_map::ToDisplayPoint, scroll::scroll_amount::ScrollAmount, Editor}; +use gpui::{actions, AppContext, ViewContext}; +use language::Bias; +use workspace::Workspace; + +actions!( + vim, + [LineUp, LineDown, ScrollUp, ScrollDown, PageUp, PageDown,] +); + +pub fn init(cx: &mut AppContext) { + cx.add_action(|_: &mut Workspace, _: &LineDown, cx| { + scroll(cx, |c| ScrollAmount::Line(c.unwrap_or(1.))) + }); + cx.add_action(|_: &mut Workspace, _: &LineUp, cx| { + scroll(cx, |c| ScrollAmount::Line(-c.unwrap_or(1.))) + }); + cx.add_action(|_: &mut Workspace, _: &PageDown, cx| { + scroll(cx, |c| ScrollAmount::Page(c.unwrap_or(1.))) + }); + cx.add_action(|_: &mut Workspace, _: &PageUp, cx| { + scroll(cx, |c| ScrollAmount::Page(-c.unwrap_or(1.))) + }); + cx.add_action(|_: &mut Workspace, _: &ScrollDown, cx| { + scroll(cx, |c| { + if let Some(c) = c { + ScrollAmount::Line(c) + } else { + ScrollAmount::Page(0.5) + } + }) + }); + cx.add_action(|_: &mut Workspace, _: &ScrollUp, cx| { + scroll(cx, |c| { + if let Some(c) = c { + ScrollAmount::Line(-c) + } else { + ScrollAmount::Page(-0.5) + } + }) + }); +} + +fn scroll(cx: &mut ViewContext, by: fn(c: Option) -> ScrollAmount) { + Vim::update(cx, |vim, cx| { + let amount = by(vim.pop_number_operator(cx).map(|c| c as f32)); + vim.update_active_editor(cx, |editor, cx| scroll_editor(editor, &amount, cx)); + }) +} + +fn scroll_editor(editor: &mut Editor, amount: &ScrollAmount, cx: &mut ViewContext) { + let should_move_cursor = editor.newest_selection_on_screen(cx).is_eq(); + editor.scroll_screen(amount, cx); + if should_move_cursor { + let selection_ordering = editor.newest_selection_on_screen(cx); + if selection_ordering.is_eq() { + return; + } + + let visible_rows = if let Some(visible_rows) = editor.visible_line_count() { + visible_rows as u32 + } else { + return; + }; + + let top_anchor = editor.scroll_manager.anchor().anchor; + + editor.change_selections(None, cx, |s| { + s.replace_cursors_with(|snapshot| { + let mut new_point = top_anchor.to_display_point(&snapshot); + + match selection_ordering { + Ordering::Less => { + new_point = snapshot.clip_point(new_point, Bias::Right); + } + Ordering::Greater => { + *new_point.row_mut() += visible_rows - 1; + new_point = snapshot.clip_point(new_point, Bias::Left); + } + Ordering::Equal => unreachable!(), + } + + vec![new_point] + }) + }); + } +} + +#[cfg(test)] +mod test { + use crate::{state::Mode, test::VimTestContext}; + use gpui::geometry::vector::vec2f; + use indoc::indoc; + + #[gpui::test] + async fn test_scroll(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + cx.set_state(indoc! {"ˇa\nb\nc\nd\ne\n"}, Mode::Normal); + + cx.update_editor(|editor, cx| { + assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 0.)) + }); + cx.simulate_keystrokes(["ctrl-e"]); + cx.update_editor(|editor, cx| { + assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 1.)) + }); + cx.simulate_keystrokes(["2", "ctrl-e"]); + cx.update_editor(|editor, cx| { + assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 3.)) + }); + cx.simulate_keystrokes(["ctrl-y"]); + cx.update_editor(|editor, cx| { + assert_eq!(editor.snapshot(cx).scroll_position(), vec2f(0., 2.)) + }); + } +} From 73920807a9f91e5f7244f5dcf72ae86885d4b127 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 26 Jun 2023 14:42:47 -0600 Subject: [PATCH 171/215] vim: shortcuts for tab navigation --- assets/keymaps/vim.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 43b778d9b8..5656b73be4 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -221,7 +221,9 @@ "vim::PushOperator", "Replace" ], - "s": "vim::Substitute" + "s": "vim::Substitute", + "ctrl-pagedown": "pane::ActivateNextItem", + "ctrl-pageup": "pane::ActivatePrevItem" } }, { @@ -238,6 +240,8 @@ "bindings": { "g": "vim::StartOfDocument", "h": "editor::Hover", + "t": "pane::ActivateNextItem", + "shift-t": "pane::ActivatePrevItem", "escape": [ "vim::SwitchMode", "Normal" @@ -330,4 +334,4 @@ "escape": "editor::Cancel" } } -] +] \ No newline at end of file From 77dc22bff65d87f0b486c1cd231d70ff885f8141 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 26 Jun 2023 20:20:47 -0600 Subject: [PATCH 172/215] vim: Fix cursor restoration when undoing substitute --- crates/vim/src/normal/substitute.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/vim/src/normal/substitute.rs b/crates/vim/src/normal/substitute.rs index 87648f8b88..ef72baae31 100644 --- a/crates/vim/src/normal/substitute.rs +++ b/crates/vim/src/normal/substitute.rs @@ -6,14 +6,14 @@ use crate::{motion::Motion, Mode, Vim}; pub fn substitute(vim: &mut Vim, count: Option, cx: &mut WindowContext) { vim.update_active_editor(cx, |editor, cx| { editor.set_clip_at_line_ends(false, cx); - editor.change_selections(None, cx, |s| { - s.move_with(|map, selection| { - if selection.start == selection.end { - Motion::Right.expand_selection(map, selection, count, true); - } - }) - }); editor.transact(cx, |editor, cx| { + editor.change_selections(None, cx, |s| { + s.move_with(|map, selection| { + if selection.start == selection.end { + Motion::Right.expand_selection(map, selection, count, true); + } + }) + }); let selections = editor.selections.all::(cx); for selection in selections.into_iter().rev() { editor.buffer().update(cx, |buffer, cx| { @@ -63,7 +63,11 @@ mod test { // it handles multibyte characters cx.set_state(indoc! {"ˇcàfé\n"}, Mode::Normal); - cx.simulate_keystrokes(["4", "s", "x"]); - cx.assert_editor_state("xˇ\n"); + cx.simulate_keystrokes(["4", "s"]); + cx.assert_editor_state("ˇ\n"); + + // should transactionally undo selection changes + cx.simulate_keystrokes(["escape", "u"]); + cx.assert_editor_state("ˇcàfé\n"); } } From a9aa5e5196e0b7e2abc67c6a567f1bfa90e893de Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 26 Jun 2023 20:19:28 -0600 Subject: [PATCH 173/215] vim: Add ~ to change case Fixes: zed-industries/community#1410 --- assets/keymaps/vim.json | 2 ++ crates/vim/src/normal.rs | 4 +++ crates/vim/src/normal/case.rs | 64 +++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 crates/vim/src/normal/case.rs diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 43b778d9b8..871ad13319 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -172,6 +172,7 @@ "^": "vim::FirstNonWhitespace", "o": "vim::InsertLineBelow", "shift-o": "vim::InsertLineAbove", + "~": "vim::ChangeCase", "v": [ "vim::SwitchMode", { @@ -309,6 +310,7 @@ "y": "vim::VisualYank", "p": "vim::VisualPaste", "s": "vim::Substitute", + "~": "vim::ChangeCase", "r": [ "vim::PushOperator", "Replace" diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index c54f739628..10251201c2 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -1,3 +1,4 @@ +mod case; mod change; mod delete; mod substitute; @@ -24,6 +25,7 @@ use serde::Deserialize; use workspace::Workspace; use self::{ + case::change_case, change::{change_motion, change_object}, delete::{delete_motion, delete_object}, substitute::substitute, @@ -48,6 +50,7 @@ actions!( Paste, Yank, Substitute, + ChangeCase, ] ); @@ -59,6 +62,7 @@ pub fn init(cx: &mut AppContext) { cx.add_action(insert_end_of_line); cx.add_action(insert_line_above); cx.add_action(insert_line_below); + cx.add_action(change_case); cx.add_action(|_: &mut Workspace, _: &Substitute, cx| { Vim::update(cx, |vim, cx| { let times = vim.pop_number_operator(cx); diff --git a/crates/vim/src/normal/case.rs b/crates/vim/src/normal/case.rs new file mode 100644 index 0000000000..ba527af0bb --- /dev/null +++ b/crates/vim/src/normal/case.rs @@ -0,0 +1,64 @@ +use gpui::ViewContext; +use language::Point; +use workspace::Workspace; + +use crate::{motion::Motion, normal::ChangeCase, Vim}; + +pub fn change_case(_: &mut Workspace, _: &ChangeCase, cx: &mut ViewContext) { + Vim::update(cx, |vim, cx| { + let count = vim.pop_number_operator(cx); + vim.update_active_editor(cx, |editor, cx| { + editor.set_clip_at_line_ends(false, cx); + editor.transact(cx, |editor, cx| { + editor.change_selections(None, cx, |s| { + s.move_with(|map, selection| { + if selection.start == selection.end { + Motion::Right.expand_selection(map, selection, count, true); + } + }) + }); + let selections = editor.selections.all::(cx); + for selection in selections.into_iter().rev() { + let snapshot = editor.buffer().read(cx).snapshot(cx); + editor.buffer().update(cx, |buffer, cx| { + let range = selection.start..selection.end; + let text = snapshot + .text_for_range(selection.start..selection.end) + .flat_map(|s| s.chars()) + .flat_map(|c| { + if c.is_lowercase() { + c.to_uppercase().collect::>() + } else { + c.to_lowercase().collect::>() + } + }) + .collect::(); + + buffer.edit([(range, text)], None, cx) + }) + } + }); + editor.set_clip_at_line_ends(true, cx); + }); + }) +} + +#[cfg(test)] +mod test { + use crate::{state::Mode, test::VimTestContext}; + use indoc::indoc; + + #[gpui::test] + async fn test_change_case(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + cx.set_state(indoc! {"ˇabC\n"}, Mode::Normal); + cx.simulate_keystrokes(["~"]); + cx.assert_editor_state("AˇbC\n"); + cx.simulate_keystrokes(["2", "~"]); + cx.assert_editor_state("ABcˇ\n"); + + cx.set_state(indoc! {"a😀C«dÉ1*fˇ»\n"}, Mode::Normal); + cx.simulate_keystrokes(["~"]); + cx.assert_editor_state("a😀CDé1*Fˇ\n"); + } +} From a1343f0d2c44cb9f4123e8c12f98e21354658c13 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 26 Jun 2023 21:46:06 -0600 Subject: [PATCH 174/215] vim: Fix code actions menu Fixes: zed-industries/community#1690 --- assets/keymaps/vim.json | 2 +- crates/editor/src/editor.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 43b778d9b8..76b6653c81 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -1,6 +1,6 @@ [ { - "context": "Editor && VimControl && !VimWaiting", + "context": "Editor && VimControl && !VimWaiting && !menu", "bindings": { "g": [ "vim::PushOperator", diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index c1e38614ef..8adf98f1bc 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -7641,8 +7641,14 @@ impl View for Editor { keymap.add_identifier("renaming"); } match self.context_menu.as_ref() { - Some(ContextMenu::Completions(_)) => keymap.add_identifier("showing_completions"), - Some(ContextMenu::CodeActions(_)) => keymap.add_identifier("showing_code_actions"), + Some(ContextMenu::Completions(_)) => { + keymap.add_identifier("menu"); + keymap.add_identifier("showing_completions") + } + Some(ContextMenu::CodeActions(_)) => { + keymap.add_identifier("menu"); + keymap.add_identifier("showing_code_actions") + } None => {} } for layer in self.keymap_context_layers.values() { From 71c0b7d74ded6f93c96830c71e653c5639d5a391 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 26 Jun 2023 18:56:30 +0200 Subject: [PATCH 175/215] Add styles for user menu --- crates/collab_ui/src/collab_titlebar_item.rs | 22 +++--- crates/theme/src/theme.rs | 11 +++ styles/src/styleTree/app.ts | 2 + styles/src/styleTree/titlebar.ts | 81 ++++++++++++++++++++ 4 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 styles/src/styleTree/titlebar.ts diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index cb696dab9d..52f0bc7d61 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -639,12 +639,17 @@ impl CollabTitlebarItem { avatar: Option>, cx: &mut ViewContext, ) -> AnyElement { - let titlebar = &theme.workspace.titlebar; - let avatar_style = &theme.workspace.titlebar.follower_avatar; + let tooltip = theme.tooltip.clone(); + let user_menu_button = &theme.titlebar; + let avatar_style = &user_menu_button.user_menu_button.avatar; Stack::new() .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.call_control.style_for(state); + let style = user_menu_button + .user_menu_button + .user_menu + .inactive_state() + .style_for(state); let mut dropdown = Flex::row().align_children_center(); @@ -658,15 +663,15 @@ impl CollabTitlebarItem { dropdown .with_child( Svg::new("icons/caret_down_8.svg") - .with_color(style.color) + .with_color(theme.titlebar.user_menu_button.icon.color) .constrained() - .with_width(style.icon_width) + .with_width(theme.titlebar.user_menu_button.icon.width) .contained() .into_any(), ) .aligned() .constrained() - .with_height(style.button_width) + .with_height(style.width) .contained() .with_style(style.container) .into_any() @@ -679,11 +684,10 @@ impl CollabTitlebarItem { 0, "Toggle user menu".to_owned(), Some(Box::new(ToggleUserMenu)), - theme.tooltip.clone(), + tooltip, cx, ) - .contained() - .with_margin_left(theme.workspace.titlebar.item_spacing), + .contained(), ) .with_child( ChildView::new(&self.user_menu, cx) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index b4a4ba69fd..7de10db6c5 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -65,6 +65,7 @@ pub struct Theme { pub feedback: FeedbackStyle, pub welcome: WelcomeStyle, pub color_scheme: ColorScheme, + pub titlebar: UserMenu, } #[derive(Deserialize, Default, Clone)] @@ -140,6 +141,16 @@ pub struct Titlebar { pub toggle_contacts_badge: ContainerStyle, } +#[derive(Clone, Deserialize, Default)] +pub struct UserMenu { + pub user_menu_button: UserMenuButton, +} +#[derive(Clone, Deserialize, Default)] +pub struct UserMenuButton { + pub user_menu: Toggleable>, + pub avatar: AvatarStyle, + pub icon: Icon, +} #[derive(Copy, Clone, Deserialize, Default)] pub struct AvatarStyle { #[serde(flatten)] diff --git a/styles/src/styleTree/app.ts b/styles/src/styleTree/app.ts index 754443cc5f..d98e00383f 100644 --- a/styles/src/styleTree/app.ts +++ b/styles/src/styleTree/app.ts @@ -23,6 +23,7 @@ import feedback from "./feedback" import welcome from "./welcome" import copilot from "./copilot" import assistant from "./assistant" +import { titlebar } from "./titlebar" export default function app(colorScheme: ColorScheme): Object { return { @@ -36,6 +37,7 @@ export default function app(colorScheme: ColorScheme): Object { incomingCallNotification: incomingCallNotification(colorScheme), picker: picker(colorScheme), workspace: workspace(colorScheme), + titlebar: titlebar(colorScheme), copilot: copilot(colorScheme), welcome: welcome(colorScheme), contextMenu: contextMenu(colorScheme), diff --git a/styles/src/styleTree/titlebar.ts b/styles/src/styleTree/titlebar.ts new file mode 100644 index 0000000000..4c2c2147f8 --- /dev/null +++ b/styles/src/styleTree/titlebar.ts @@ -0,0 +1,81 @@ +import { ColorScheme } from "../common"; +import { interactive, toggleable } from "../element" +import { background, foreground, text } from "./components"; + +const titlebarButton = (theme: ColorScheme) => toggleable({ + base: interactive({ + base: { + cornerRadius: 6, + height: 24, + width: 24, + padding: { + top: 4, + bottom: 4, + left: 4, + right: 4, + }, + ...text(theme.lowest, "sans", { size: "xs" }), + background: background(theme.lowest), + }, + state: { + hovered: { + ...text(theme.lowest, "sans", "hovered", { + size: "xs", + }), + background: background(theme.lowest, "hovered"), + }, + clicked: { + ...text(theme.lowest, "sans", "pressed", { + size: "xs", + }), + background: background(theme.lowest, "pressed"), + }, + }, + }), + state: { + active: { + default: { + ...text(theme.lowest, "sans", "active", { size: "xs" }), + background: background(theme.middle), + }, + hovered: { + ...text(theme.lowest, "sans", "active", { size: "xs" }), + background: background(theme.middle, "hovered"), + }, + clicked: { + ...text(theme.lowest, "sans", "active", { size: "xs" }), + background: background(theme.middle, "pressed"), + }, + }, + } +}); + +/** +* Opens the User Menu when toggled +* +* When logged in shows the user's avatar and a chevron, +* When logged out only shows a chevron. +*/ +function userMenuButton(theme: ColorScheme) { + return { + userMenu: titlebarButton(theme), + avatar: { + icon_width: 16, + icon_height: 16, + cornerRadius: 4, + outerWidth: 10, + outerCornerRadius: 10 + }, + icon: { + width: 11, + height: 11, + color: foreground(theme.lowest) + } + } +} + +export function titlebar(theme: ColorScheme) { + return { + userMenuButton: userMenuButton(theme) + } +} From a67eba9fedb82b894e9ea98802d50a9385274923 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Tue, 27 Jun 2023 09:51:30 -0400 Subject: [PATCH 176/215] Create local-collaboration.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I forget how to do this every single time 😅 --- docs/local-collaboration.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 docs/local-collaboration.md diff --git a/docs/local-collaboration.md b/docs/local-collaboration.md new file mode 100644 index 0000000000..bedaa1f7f1 --- /dev/null +++ b/docs/local-collaboration.md @@ -0,0 +1,20 @@ +# Local Collaboration + +## Setting up the local collaboration server + +### Setting up for the first time? + +Install [Postgres](https://postgresapp.com) and run it. + +Then, from the root of the repo, run `script/bootstrap`. + +### Have a db that is out of date? / Need to migrate? + +Try `cd crates/collab && cargo run -- migrate` from the root of the repo. + +## Testing collab locally + +1. Run `foreman start` from the root of the repo. +1. In another terminal run `script/start-local-collaboration`. +1. Two copies of Zed will open. Add yourself as a contact in the one that is not you. +1. Start a collaboration session as normal with any open project. From 0548df09d9460e2ede4f016bde325ec5c6871117 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Tue, 27 Jun 2023 10:05:37 -0400 Subject: [PATCH 177/215] Update local-collaboration.md --- docs/local-collaboration.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/local-collaboration.md b/docs/local-collaboration.md index bedaa1f7f1..f16df2b3e0 100644 --- a/docs/local-collaboration.md +++ b/docs/local-collaboration.md @@ -10,7 +10,8 @@ Then, from the root of the repo, run `script/bootstrap`. ### Have a db that is out of date? / Need to migrate? -Try `cd crates/collab && cargo run -- migrate` from the root of the repo. +1. Try `cd crates/collab && cargo run -- migrate` from the root of the repo. +2. Run `script/seed-db` ## Testing collab locally From 9389b506461d0800334a64861c3ec17e0140f9b9 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Tue, 27 Jun 2023 10:52:38 -0400 Subject: [PATCH 178/215] Update local-collaboration.md Add missing livekit info --- docs/local-collaboration.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/local-collaboration.md b/docs/local-collaboration.md index f16df2b3e0..7d8054af67 100644 --- a/docs/local-collaboration.md +++ b/docs/local-collaboration.md @@ -4,14 +4,15 @@ ### Setting up for the first time? -Install [Postgres](https://postgresapp.com) and run it. - -Then, from the root of the repo, run `script/bootstrap`. +1. Make sure you have livekit installed (`brew install livekit`) +1. Install [Postgres](https://postgresapp.com) and run it. +1. Then, from the root of the repo, run `script/bootstrap`. ### Have a db that is out of date? / Need to migrate? +1. Make sure you have livekit installed (`brew install livekit`) 1. Try `cd crates/collab && cargo run -- migrate` from the root of the repo. -2. Run `script/seed-db` +1. Run `script/seed-db` ## Testing collab locally From 3104275d87af9b4abd9cd8a927d3c389e8583249 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Tue, 27 Jun 2023 17:19:18 +0200 Subject: [PATCH 179/215] Keep users muted once they undeafen themselves --- crates/call/src/room.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 48a35b29f6..3c94feae4c 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -1213,7 +1213,11 @@ impl Room { let mut tasks = Vec::with_capacity(self.remote_participants.len()); // Context notification is sent within set_mute itself. - let _ = Self::set_mute(live_kit, live_kit.deafened, cx)?; // todo (osiewicz): we probably want to schedule it on fg/bg? + if live_kit.deafened { + // Unmute microphone only if we're going from unmuted -> muted state. + // We don't want to unmute user automatically. + let _ = Self::set_mute(live_kit, live_kit.deafened, cx)?; // todo (osiewicz): we probably want to schedule it on fg/bg? + } for participant in self.remote_participants.values() { for track in live_kit .room From 331800c14d174a3a54848a79a81890b294180a07 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Tue, 27 Jun 2023 11:34:12 -0400 Subject: [PATCH 180/215] Use `icon_button` for leave call --- styles/src/component/icon_button.ts | 54 +++++++++++++++++++++++++++++ styles/src/element/index.ts | 4 +-- styles/src/element/interactive.ts | 2 +- styles/src/styleTree/titlebar.ts | 4 ++- styles/src/styleTree/workspace.ts | 22 +++--------- 5 files changed, 65 insertions(+), 21 deletions(-) create mode 100644 styles/src/component/icon_button.ts diff --git a/styles/src/component/icon_button.ts b/styles/src/component/icon_button.ts new file mode 100644 index 0000000000..d71996042b --- /dev/null +++ b/styles/src/component/icon_button.ts @@ -0,0 +1,54 @@ +import { ColorScheme } from "../common"; +import { interactive } from "../element"; +import { background, foreground } from "../styleTree/components"; +import { Margin } from "../types/zed"; + +interface IconButtonOptions { + color?: keyof ColorScheme['lowest']; + margin?: Partial; +} + +export function icon_button(theme: ColorScheme, { color, margin }: IconButtonOptions) { + if (!color) + color = "base"; + + const m = { + top: margin?.top ?? 0, + bottom: margin?.bottom ?? 0, + left: margin?.left ?? 0, + right: margin?.right ?? 0, + } + + return interactive({ + base: { + corner_radius: 4, + padding: { + top: 2, + bottom: 2, + left: 4, + right: 4, + }, + margin: m, + icon_width: 15, + icon_height: 15, + button_width: 23, + button_height: 19, + }, + state: { + default: { + background: background(theme.lowest, color), + color: foreground(theme.lowest, color), + }, + hovered: { + background: background(theme.lowest, color, "hovered"), + color: foreground(theme.lowest, color, "hovered"), + + }, + clicked: { + background: background(theme.lowest, color, "pressed"), + color: foreground(theme.lowest, color, "pressed"), + + }, + }, + }); +} diff --git a/styles/src/element/index.ts b/styles/src/element/index.ts index b1e3cfe415..81c911c7bd 100644 --- a/styles/src/element/index.ts +++ b/styles/src/element/index.ts @@ -1,4 +1,4 @@ -import { interactive } from "./interactive" +import { interactive, Interactive } from "./interactive" import { toggleable } from "./toggle" -export { interactive, toggleable } +export { interactive, Interactive, toggleable } diff --git a/styles/src/element/interactive.ts b/styles/src/element/interactive.ts index 1c0f393cff..79fee70cb9 100644 --- a/styles/src/element/interactive.ts +++ b/styles/src/element/interactive.ts @@ -8,7 +8,7 @@ type InteractiveState = | "selected" | "disabled" -type Interactive = { +export type Interactive = { default: T hovered?: T clicked?: T diff --git a/styles/src/styleTree/titlebar.ts b/styles/src/styleTree/titlebar.ts index 4c2c2147f8..3aa41359fa 100644 --- a/styles/src/styleTree/titlebar.ts +++ b/styles/src/styleTree/titlebar.ts @@ -58,11 +58,13 @@ const titlebarButton = (theme: ColorScheme) => toggleable({ */ function userMenuButton(theme: ColorScheme) { return { - userMenu: titlebarButton(theme), + user_menu: titlebarButton(theme), avatar: { icon_width: 16, icon_height: 16, cornerRadius: 4, + outer_corner_radius: 0, + outer_width: 0, outerWidth: 10, outerCornerRadius: 10 }, diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index abc237468a..a500988bf7 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -13,6 +13,7 @@ import statusBar from "./statusBar" import tabBar from "./tabBar" import { interactive } from "../element" import merge from "ts-deepmerge" +import { icon_button } from "../component/icon_button" export default function workspace(colorScheme: ColorScheme) { const layer = colorScheme.lowest const isLight = colorScheme.isLight @@ -252,7 +253,7 @@ export default function workspace(colorScheme: ColorScheme) { }, avatarRibbon: { height: 3, - width: 12, + width: 11, // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. }, @@ -407,22 +408,9 @@ export default function workspace(colorScheme: ColorScheme) { }, }, }), - leaveCallButton: interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, - }, - state: { - clicked: { - background: background(layer, "variant", "pressed"), - }, - hovered: { - background: background(layer, "variant", "hovered"), - }, - }, + + leaveCallButton: icon_button(colorScheme, { + margin: { left: itemSpacing }, }), userMenuButton: merge(titlebarButton, { From 5af33407f03c2b311f6db604707132899ded3cb7 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Tue, 27 Jun 2023 11:34:26 -0400 Subject: [PATCH 181/215] Add script for building theme types --- script/build-theme-types | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 script/build-theme-types diff --git a/script/build-theme-types b/script/build-theme-types new file mode 100755 index 0000000000..b78631f3d1 --- /dev/null +++ b/script/build-theme-types @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "running xtask" +(cd crates/theme && cargo xtask build-theme-types) + +echo "updating theme packages" +(cd styles && npm install) + +echo "building theme types" +(cd styles && npm run build-types) From b4f9faee3bca19a35577686cc5c335223f1a0c45 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Tue, 27 Jun 2023 12:24:19 -0400 Subject: [PATCH 182/215] Update share, call control buttons --- styles/src/component/icon_button.ts | 33 ++++-- styles/src/component/text_button.ts | 74 +++++++++++++ styles/src/styleTree/workspace.ts | 165 ++++++---------------------- 3 files changed, 134 insertions(+), 138 deletions(-) create mode 100644 styles/src/component/text_button.ts diff --git a/styles/src/component/icon_button.ts b/styles/src/component/icon_button.ts index d71996042b..47953a56d3 100644 --- a/styles/src/component/icon_button.ts +++ b/styles/src/component/icon_button.ts @@ -1,14 +1,17 @@ import { ColorScheme } from "../common"; -import { interactive } from "../element"; +import { interactive, toggleable } from "../element"; import { background, foreground } from "../styleTree/components"; import { Margin } from "../types/zed"; interface IconButtonOptions { + layer?: ColorScheme['lowest'] | ColorScheme['middle'] | ColorScheme['highest']; color?: keyof ColorScheme['lowest']; margin?: Partial; } -export function icon_button(theme: ColorScheme, { color, margin }: IconButtonOptions) { +type ToggleableIconButtonOptions = IconButtonOptions & { active_color?: keyof ColorScheme['lowest'] }; + +export function icon_button(theme: ColorScheme, { color, margin, layer }: IconButtonOptions) { if (!color) color = "base"; @@ -21,7 +24,7 @@ export function icon_button(theme: ColorScheme, { color, margin }: IconButtonOpt return interactive({ base: { - corner_radius: 4, + corner_radius: 6, padding: { top: 2, bottom: 2, @@ -36,19 +39,31 @@ export function icon_button(theme: ColorScheme, { color, margin }: IconButtonOpt }, state: { default: { - background: background(theme.lowest, color), - color: foreground(theme.lowest, color), + background: background(layer ?? theme.lowest, color), + color: foreground(layer ?? theme.lowest, color), }, hovered: { - background: background(theme.lowest, color, "hovered"), - color: foreground(theme.lowest, color, "hovered"), + background: background(layer ?? theme.lowest, color, "hovered"), + color: foreground(layer ?? theme.lowest, color, "hovered"), }, clicked: { - background: background(theme.lowest, color, "pressed"), - color: foreground(theme.lowest, color, "pressed"), + background: background(layer ?? theme.lowest, color, "pressed"), + color: foreground(layer ?? theme.lowest, color, "pressed"), }, }, }); } + +export function toggleable_icon_button(theme: ColorScheme, { color, active_color, margin }: ToggleableIconButtonOptions) { + if (!color) + color = "base"; + + return toggleable({ + state: { + inactive: icon_button(theme, { color, margin }), + active: icon_button(theme, { color: active_color ? active_color : color, margin, layer: theme.middle }), + } + }) +} diff --git a/styles/src/component/text_button.ts b/styles/src/component/text_button.ts new file mode 100644 index 0000000000..921ecc639f --- /dev/null +++ b/styles/src/component/text_button.ts @@ -0,0 +1,74 @@ +import { ColorScheme } from "../common"; +import { interactive, toggleable } from "../element"; +import { TextProperties, background, foreground, text } from "../styleTree/components"; +import { Margin } from "../types/zed"; + +interface TextButtonOptions { + layer?: ColorScheme['lowest'] | ColorScheme['middle'] | ColorScheme['highest']; + color?: keyof ColorScheme['lowest']; + margin?: Partial; + text_properties?: TextProperties; +} + +type ToggleableTextButtonOptions = TextButtonOptions & { active_color?: keyof ColorScheme['lowest'] }; + +export function text_button(theme: ColorScheme, { color, layer, margin, text_properties }: TextButtonOptions) { + if (!color) + color = "base"; + + const text_options: TextProperties = { + size: "xs", + weight: "normal", + ...text_properties + } + + const m = { + top: margin?.top ?? 0, + bottom: margin?.bottom ?? 0, + left: margin?.left ?? 0, + right: margin?.right ?? 0, + } + + return interactive({ + base: { + corner_radius: 6, + padding: { + top: 1, + bottom: 1, + left: 6, + right: 6, + }, + margin: m, + button_height: 22, + ...text(layer ?? theme.lowest, "sans", color, text_options) + }, + state: { + default: { + background: background(layer ?? theme.lowest, color), + color: foreground(layer ?? theme.lowest, color), + }, + hovered: { + background: background(layer ?? theme.lowest, color, "hovered"), + color: foreground(layer ?? theme.lowest, color, "hovered"), + + }, + clicked: { + background: background(layer ?? theme.lowest, color, "pressed"), + color: foreground(layer ?? theme.lowest, color, "pressed"), + + }, + }, + }); +} + +export function toggleable_text_button(theme: ColorScheme, { color, active_color, margin }: ToggleableTextButtonOptions) { + if (!color) + color = "base"; + + return toggleable({ + state: { + inactive: text_button(theme, { color, margin }), + active: text_button(theme, { color: active_color ? active_color : color, margin, layer: theme.middle }), + } + }) +} diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index a500988bf7..da1ad1fe18 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -13,7 +13,8 @@ import statusBar from "./statusBar" import tabBar from "./tabBar" import { interactive } from "../element" import merge from "ts-deepmerge" -import { icon_button } from "../component/icon_button" +import { icon_button, toggleable_icon_button } from "../component/icon_button" +import { text_button, toggleable_text_button } from "../component/text_button" export default function workspace(colorScheme: ColorScheme) { const layer = colorScheme.lowest const isLight = colorScheme.isLight @@ -298,137 +299,45 @@ export default function workspace(colorScheme: ColorScheme) { }, cornerRadius: 6, }, - callControl: interactive({ - base: { - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 20, - }, - state: { - hovered: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), - }, - }, - }), - toggleContactsButton: toggleable({ - base: interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, - }, - state: { - clicked: { - background: background(layer, "variant", "pressed"), - }, - hovered: { - background: background(layer, "variant", "hovered"), - }, - }, - }), - state: { - active: { - default: { - background: background(layer, "on", "default"), - }, - hovered: { - background: background(layer, "on", "hovered"), - }, - clicked: { - background: background(layer, "on", "pressed"), - }, - }, - }, - }), - toggleMicrophoneButton: toggleable({ - base: interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, - }, - state: { - clicked: { - background: background(layer, "variant", "pressed"), - }, - hovered: { - background: background(layer, "variant", "hovered"), - }, - }, - }), - state: { - active: { - default: { - background: background(layer, "on", "default"), - }, - hovered: { - background: background(layer, "on", "hovered"), - }, - clicked: { - background: background(layer, "on", "pressed"), - }, - }, - }, - }), - toggleSpeakersButton: toggleable({ - base: interactive({ - base: { - margin: { left: itemSpacing }, - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 14, - buttonWidth: 20, - }, - state: { - clicked: { - background: background(layer, "variant", "pressed"), - }, - hovered: { - background: background(layer, "variant", "hovered"), - }, - }, - }), - state: { - active: { - default: { - background: background(layer, "on", "default"), - }, - hovered: { - background: background(layer, "on", "hovered"), - }, - clicked: { - background: background(layer, "on", "pressed"), - }, - }, - }, + + call_control: icon_button(colorScheme, { + margin: { left: itemSpacing / 2 }, }), - leaveCallButton: icon_button(colorScheme, { + toggle_contacts_button: toggleable_icon_button(colorScheme, { + margin: { left: itemSpacing } + }), + + toggle_microphone_button: toggleable_icon_button(colorScheme, { + margin: { left: itemSpacing }, + active_color: 'negative' + }), + + toggle_speakers_button: toggleable_icon_button(colorScheme, { + margin: { left: itemSpacing / 2 }, + }), + + leave_call_button: icon_button(colorScheme, { margin: { left: itemSpacing }, }), - userMenuButton: merge(titlebarButton, { - inactive: { - default: { - buttonWidth: 20, - iconWidth: 12, + user_menu_button: + merge(titlebarButton, { + inactive: { + default: { + buttonWidth: 20, + iconWidth: 12, + }, }, - }, - active: { - default: { - iconWidth: 12, - button_width: 20, - background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active"), - } - }, - }), + active: { + default: { + iconWidth: 12, + button_width: 20, + background: background(layer, "variant", "active"), + color: foreground(layer, "variant", "active"), + } + }, + }), toggleContactsBadge: { cornerRadius: 3, @@ -437,9 +346,7 @@ export default function workspace(colorScheme: ColorScheme) { border: border(layer), background: foreground(layer, "accent"), }, - shareButton: { - ...titlebarButton, - }, + shareButton: toggleable_text_button(colorScheme, {}), }, toolbar: { From 37cb202c9337fce50a482e63f8963c66eaba5bb6 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 27 Jun 2023 09:56:41 -0700 Subject: [PATCH 183/215] Rename and toggle screenshare --- crates/collab_ui/src/collab_titlebar_item.rs | 2 +- crates/theme/src/theme.rs | 2 +- styles/package.json | 2 +- styles/src/styleTree/workspace.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 52f0bc7d61..0a91a488ed 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -417,7 +417,7 @@ impl CollabTitlebarItem { let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.call_control.style_for(state); + let style = titlebar.screen_share_button.style_for(state); Svg::new(icon) .with_color(style.color) .constrained() diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 3fda62ced9..f2e9c4aa3e 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -133,7 +133,7 @@ pub struct Titlebar { pub sign_in_prompt: Toggleable>, pub outdated_warning: ContainedText, pub share_button: Toggleable>, - pub call_control: Interactive, + pub screen_share_button: Toggleable>, pub toggle_contacts_button: Toggleable>, pub toggle_microphone_button: Toggleable>, pub toggle_speakers_button: Toggleable>, diff --git a/styles/package.json b/styles/package.json index 8820259e86..b14fb5f527 100644 --- a/styles/package.json +++ b/styles/package.json @@ -7,7 +7,7 @@ "build": "ts-node ./src/buildThemes.ts", "build-licenses": "ts-node ./src/buildLicenses.ts", "build-tokens": "ts-node ./src/buildTokens.ts", - "build-types": "cd ../crates/theme && cargo test && cd ../../styles && ts-node ./src/buildTypes.ts", + "build-types": "ts-node ./src/buildTypes.ts", "test": "vitest" }, "author": "", diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index da1ad1fe18..ec3776dcb0 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -300,7 +300,7 @@ export default function workspace(colorScheme: ColorScheme) { cornerRadius: 6, }, - call_control: icon_button(colorScheme, { + screen_share_button: icon_button(colorScheme, { margin: { left: itemSpacing / 2 }, }), From 60ce58442768efdfbc63dcfd1249825fb97b5697 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 27 Jun 2023 13:12:52 -0700 Subject: [PATCH 184/215] WIP: Add mute icons --- crates/call/src/participant.rs | 1 + crates/call/src/room.rs | 25 +++++++++++++++++++++++-- crates/live_kit_client/src/prod.rs | 1 + crates/live_kit_client/src/test.rs | 1 + 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/crates/call/src/participant.rs b/crates/call/src/participant.rs index 90f256489d..9773e837c3 100644 --- a/crates/call/src/participant.rs +++ b/crates/call/src/participant.rs @@ -43,6 +43,7 @@ pub struct RemoteParticipant { pub peer_id: proto::PeerId, pub projects: Vec, pub location: ParticipantLocation, + pub muted: bool, pub video_tracks: HashMap>, pub audio_tracks: HashMap>, } diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 3c94feae4c..7b7ec89a5e 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -647,6 +647,7 @@ impl Room { peer_id, projects: participant.projects, location, + muted: false, video_tracks: Default::default(), audio_tracks: Default::default(), }, @@ -781,6 +782,21 @@ impl Room { cx: &mut ModelContext, ) -> Result<()> { match change { + RemoteAudioTrackUpdate::MuteChanged { track_id, muted } => { + for participant in &mut self.remote_participants.values_mut() { + let mut found = false; + for track in participant.audio_tracks.values() { + if track.sid() == track_id { + found = true; + break; + } + } + if found { + participant.muted = muted; + break; + } + } + } RemoteAudioTrackUpdate::Subscribed(track) => { let user_id = track.publisher_id().parse()?; let track_id = track.sid().to_string(); @@ -1213,11 +1229,12 @@ impl Room { let mut tasks = Vec::with_capacity(self.remote_participants.len()); // Context notification is sent within set_mute itself. + let mut mute_task = None; if live_kit.deafened { // Unmute microphone only if we're going from unmuted -> muted state. // We don't want to unmute user automatically. - let _ = Self::set_mute(live_kit, live_kit.deafened, cx)?; // todo (osiewicz): we probably want to schedule it on fg/bg? - } + mute_task = Some(Self::set_mute(live_kit, live_kit.deafened, cx)?); + }; for participant in self.remote_participants.values() { for track in live_kit .room @@ -1226,7 +1243,11 @@ impl Room { tasks.push(cx.foreground().spawn(track.set_enabled(!live_kit.deafened))); } } + Ok(cx.foreground().spawn(async move { + if let Some(mute_task) = mute_task { + mute_task.await?; + } for task in tasks { task.await?; } diff --git a/crates/live_kit_client/src/prod.rs b/crates/live_kit_client/src/prod.rs index dbd9e1917e..96bf40ca4e 100644 --- a/crates/live_kit_client/src/prod.rs +++ b/crates/live_kit_client/src/prod.rs @@ -761,6 +761,7 @@ pub enum RemoteVideoTrackUpdate { } pub enum RemoteAudioTrackUpdate { + MuteChanged { track_id: Sid, muted: bool}, Subscribed(Arc), Unsubscribed { publisher_id: Sid, track_id: Sid }, } diff --git a/crates/live_kit_client/src/test.rs b/crates/live_kit_client/src/test.rs index 9db57a3294..286c7215e9 100644 --- a/crates/live_kit_client/src/test.rs +++ b/crates/live_kit_client/src/test.rs @@ -580,6 +580,7 @@ pub enum RemoteVideoTrackUpdate { #[derive(Clone)] pub enum RemoteAudioTrackUpdate { + MuteChanged { track_id: Sid, muted: bool}, Subscribed(Arc), Unsubscribed { publisher_id: Sid, track_id: Sid }, } From 825a7cb799bf297ba099ba69004eecff2771c832 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Tue, 27 Jun 2023 16:20:45 -0400 Subject: [PATCH 185/215] Update screenshare toggle, titlebar spacing --- crates/collab_ui/src/collab_titlebar_item.rs | 11 ++++-- crates/theme/src/theme.rs | 2 +- styles/src/component/icon_button.ts | 12 ++++-- styles/src/component/text_button.ts | 2 +- styles/src/styleTree/workspace.ts | 39 ++++++++++++++------ 5 files changed, 47 insertions(+), 19 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 0a91a488ed..08d63dc1b4 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -408,16 +408,21 @@ impl CollabTitlebarItem { let icon; let tooltip; if room.read(cx).is_screen_sharing() { - icon = "icons/radix/desktop-mute.svg"; + icon = "icons/radix/desktop.svg"; tooltip = "Stop Sharing Screen" } else { icon = "icons/radix/desktop.svg"; tooltip = "Share Screen"; } + let active = room.read(cx).is_screen_sharing(); let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.screen_share_button.style_for(state); + let style = titlebar + .screen_share_button + .in_state(active) + .style_for(state); + Svg::new(icon) .with_color(style.color) .constrained() @@ -701,7 +706,7 @@ impl CollabTitlebarItem { fn render_sign_in_button(&self, theme: &Theme, cx: &mut ViewContext) -> AnyElement { let titlebar = &theme.workspace.titlebar; MouseEventHandler::::new(0, cx, |state, _| { - let style = titlebar.sign_in_prompt.inactive_state().style_for(state); + let style = titlebar.sign_in_button.inactive_state().style_for(state); Label::new("Sign In", style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index f2e9c4aa3e..49c93f38f3 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -130,7 +130,7 @@ pub struct Titlebar { pub leader_avatar: AvatarStyle, pub follower_avatar: AvatarStyle, pub inactive_avatar_grayscale: bool, - pub sign_in_prompt: Toggleable>, + pub sign_in_button: Toggleable>, pub outdated_warning: ContainedText, pub share_button: Toggleable>, pub screen_share_button: Toggleable>, diff --git a/styles/src/component/icon_button.ts b/styles/src/component/icon_button.ts index 47953a56d3..850acc62f9 100644 --- a/styles/src/component/icon_button.ts +++ b/styles/src/component/icon_button.ts @@ -1,7 +1,13 @@ import { ColorScheme } from "../common"; import { interactive, toggleable } from "../element"; import { background, foreground } from "../styleTree/components"; -import { Margin } from "../types/zed"; + +export type Margin = { + top: number; + bottom: number; + left: number; + right: number; +} interface IconButtonOptions { layer?: ColorScheme['lowest'] | ColorScheme['middle'] | ColorScheme['highest']; @@ -34,8 +40,8 @@ export function icon_button(theme: ColorScheme, { color, margin, layer }: IconBu margin: m, icon_width: 15, icon_height: 15, - button_width: 23, - button_height: 19, + button_width: 21, + button_height: 17, }, state: { default: { diff --git a/styles/src/component/text_button.ts b/styles/src/component/text_button.ts index 921ecc639f..ae7fede900 100644 --- a/styles/src/component/text_button.ts +++ b/styles/src/component/text_button.ts @@ -1,7 +1,7 @@ import { ColorScheme } from "../common"; import { interactive, toggleable } from "../element"; import { TextProperties, background, foreground, text } from "../styleTree/components"; -import { Margin } from "../types/zed"; +import { Margin } from "./icon_button"; interface TextButtonOptions { layer?: ColorScheme['lowest'] | ColorScheme['middle'] | ColorScheme['highest']; diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index ec3776dcb0..4b3c5f3b51 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -260,7 +260,7 @@ export default function workspace(colorScheme: ColorScheme) { // Sign in buttom // FlatButton, Variant - signInPrompt: merge(titlebarButton, { + sign_in_button: merge(titlebarButton, { inactive: { default: { margin: { @@ -300,25 +300,41 @@ export default function workspace(colorScheme: ColorScheme) { cornerRadius: 6, }, - screen_share_button: icon_button(colorScheme, { - margin: { left: itemSpacing / 2 }, - }), - - toggle_contacts_button: toggleable_icon_button(colorScheme, { - margin: { left: itemSpacing } + leave_call_button: icon_button(colorScheme, { + margin: { + left: itemSpacing / 2, + right: itemSpacing + }, }), toggle_microphone_button: toggleable_icon_button(colorScheme, { - margin: { left: itemSpacing }, + margin: { + left: itemSpacing, + right: itemSpacing / 2 + }, active_color: 'negative' }), toggle_speakers_button: toggleable_icon_button(colorScheme, { - margin: { left: itemSpacing / 2 }, + margin: { + left: itemSpacing / 2, + right: itemSpacing / 2 + }, }), - leave_call_button: icon_button(colorScheme, { - margin: { left: itemSpacing }, + screen_share_button: toggleable_icon_button(colorScheme, { + margin: { + left: itemSpacing / 2, + right: itemSpacing + }, + active_color: 'accent' + }), + + toggle_contacts_button: toggleable_icon_button(colorScheme, { + margin: { + left: itemSpacing, + right: itemSpacing / 2 + }, }), user_menu_button: @@ -339,6 +355,7 @@ export default function workspace(colorScheme: ColorScheme) { }, }), + // Jewel that notifies you that there are new contact requests toggleContactsBadge: { cornerRadius: 3, padding: 2, From 19ca6a88752a1ca991f2c0b7f0d241615529b713 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 27 Jun 2023 13:32:42 -0700 Subject: [PATCH 186/215] Seperate online and offline --- crates/collab_ui/src/collab_titlebar_item.rs | 25 ++++++++++---------- crates/theme/src/theme.rs | 3 ++- styles/src/styleTree/titlebar.ts | 8 ++++--- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 08d63dc1b4..6c900f5a07 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -98,13 +98,7 @@ impl View for CollabTitlebarItem { let status = &*status.borrow(); if matches!(status, client::Status::Connected { .. }) { right_container.add_child(self.render_toggle_contacts_button(&theme, cx)); - let avatar = ActiveCall::global(cx) - .read(cx) - .room() - .is_none() - .then(|| user.as_ref()) - .flatten() - .and_then(|user| user.avatar.clone()); + let avatar = user.as_ref().and_then(|user| user.avatar.clone()); right_container.add_child(self.render_user_menu_button(&theme, avatar, cx)); } else { right_container.add_children(self.render_connection_status(status, cx)); @@ -645,13 +639,17 @@ impl CollabTitlebarItem { cx: &mut ViewContext, ) -> AnyElement { let tooltip = theme.tooltip.clone(); - let user_menu_button = &theme.titlebar; - let avatar_style = &user_menu_button.user_menu_button.avatar; + let user_menu_button_style = if avatar.is_some() { + &theme.titlebar.user_menu_button_online + } else { + &theme.titlebar.user_menu_button_offline + }; + + let avatar_style = &user_menu_button_style.avatar; Stack::new() .with_child( MouseEventHandler::::new(0, cx, |state, _| { - let style = user_menu_button - .user_menu_button + let style = user_menu_button_style .user_menu .inactive_state() .style_for(state); @@ -665,12 +663,13 @@ impl CollabTitlebarItem { Color::transparent_black(), )); }; + dropdown .with_child( Svg::new("icons/caret_down_8.svg") - .with_color(theme.titlebar.user_menu_button.icon.color) + .with_color(user_menu_button_style.icon.color) .constrained() - .with_width(theme.titlebar.user_menu_button.icon.width) + .with_width(user_menu_button_style.icon.width) .contained() .into_any(), ) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 49c93f38f3..4d7f334086 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -144,7 +144,8 @@ pub struct Titlebar { #[derive(Clone, Deserialize, Default, JsonSchema)] pub struct UserMenu { - pub user_menu_button: UserMenuButton, + pub user_menu_button_online: UserMenuButton, + pub user_menu_button_offline: UserMenuButton, } #[derive(Clone, Deserialize, Default, JsonSchema)] pub struct UserMenuButton { diff --git a/styles/src/styleTree/titlebar.ts b/styles/src/styleTree/titlebar.ts index 3aa41359fa..881600d76c 100644 --- a/styles/src/styleTree/titlebar.ts +++ b/styles/src/styleTree/titlebar.ts @@ -56,7 +56,7 @@ const titlebarButton = (theme: ColorScheme) => toggleable({ * When logged in shows the user's avatar and a chevron, * When logged out only shows a chevron. */ -function userMenuButton(theme: ColorScheme) { +function userMenuButton(theme: ColorScheme, online: boolean) { return { user_menu: titlebarButton(theme), avatar: { @@ -71,13 +71,15 @@ function userMenuButton(theme: ColorScheme) { icon: { width: 11, height: 11, - color: foreground(theme.lowest) + color: online ? foreground(theme.lowest) : background(theme.lowest) } } } export function titlebar(theme: ColorScheme) { return { - userMenuButton: userMenuButton(theme) + userMenuButtonOnline: userMenuButton(theme, true), + userMenuButtonOffline: userMenuButton(theme, false) + } } From 8b2732c3aa33c04d126e629b13e84b25cc3f7716 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Tue, 27 Jun 2023 17:27:58 -0400 Subject: [PATCH 187/215] `workspace.titlebar` -> `titlebar` in Theme --- crates/collab_ui/src/collab_titlebar_item.rs | 54 ++-- crates/theme/src/theme.rs | 5 +- crates/workspace/src/workspace.rs | 6 +- styles/src/styleTree/titlebar.ts | 240 +++++++++++++++++- styles/src/styleTree/workspace.ts | 246 +------------------ 5 files changed, 266 insertions(+), 285 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 6c900f5a07..708fb89e86 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -113,7 +113,6 @@ impl View for CollabTitlebarItem { .with_child( right_container.contained().with_background_color( theme - .workspace .titlebar .container .background_color @@ -200,11 +199,11 @@ impl CollabTitlebarItem { .as_ref() .and_then(RepositoryEntry::branch) .map(|branch| format!("/{branch}")); - let text_style = theme.workspace.titlebar.title.clone(); - let item_spacing = theme.workspace.titlebar.item_spacing; + let text_style = theme.titlebar.title.clone(); + let item_spacing = theme.titlebar.item_spacing; let mut highlight = text_style.clone(); - highlight.color = theme.workspace.titlebar.highlight_color; + highlight.color = theme.titlebar.highlight_color; let style = LabelStyle { text: text_style, @@ -325,7 +324,7 @@ impl CollabTitlebarItem { theme: &Theme, cx: &mut ViewContext, ) -> AnyElement { - let titlebar = &theme.workspace.titlebar; + let titlebar = &theme.titlebar; let badge = if self .user_store @@ -410,7 +409,7 @@ impl CollabTitlebarItem { } let active = room.read(cx).is_screen_sharing(); - let titlebar = &theme.workspace.titlebar; + let titlebar = &theme.titlebar; MouseEventHandler::::new(0, cx, |state, _| { let style = titlebar .screen_share_button @@ -459,7 +458,7 @@ impl CollabTitlebarItem { tooltip = "Mute microphone\nRight click for options"; } - let titlebar = &theme.workspace.titlebar; + let titlebar = &theme.titlebar; MouseEventHandler::::new(0, cx, |state, _| { let style = titlebar .toggle_microphone_button @@ -512,7 +511,7 @@ impl CollabTitlebarItem { tooltip = "Mute speakers\nRight click for options"; } - let titlebar = &theme.workspace.titlebar; + let titlebar = &theme.titlebar; MouseEventHandler::::new(0, cx, |state, _| { let style = titlebar .toggle_speakers_button @@ -547,7 +546,7 @@ impl CollabTitlebarItem { let icon = "icons/radix/exit.svg"; let tooltip = "Leave call"; - let titlebar = &theme.workspace.titlebar; + let titlebar = &theme.titlebar; MouseEventHandler::::new(0, cx, |state, _| { let style = titlebar.leave_call_button.style_for(state); Svg::new(icon) @@ -596,7 +595,7 @@ impl CollabTitlebarItem { "Share project with call participants" }; - let titlebar = &theme.workspace.titlebar; + let titlebar = &theme.titlebar; enum ShareUnshare {} Some( @@ -627,7 +626,7 @@ impl CollabTitlebarItem { ) .aligned() .contained() - .with_margin_left(theme.workspace.titlebar.item_spacing) + .with_margin_left(theme.titlebar.item_spacing) .into_any(), ) } @@ -640,9 +639,9 @@ impl CollabTitlebarItem { ) -> AnyElement { let tooltip = theme.tooltip.clone(); let user_menu_button_style = if avatar.is_some() { - &theme.titlebar.user_menu_button_online + &theme.titlebar.user_menu.user_menu_button_online } else { - &theme.titlebar.user_menu_button_offline + &theme.titlebar.user_menu.user_menu_button_offline }; let avatar_style = &user_menu_button_style.avatar; @@ -703,7 +702,7 @@ impl CollabTitlebarItem { } fn render_sign_in_button(&self, theme: &Theme, cx: &mut ViewContext) -> AnyElement { - let titlebar = &theme.workspace.titlebar; + let titlebar = &theme.titlebar; MouseEventHandler::::new(0, cx, |state, _| { let style = titlebar.sign_in_button.inactive_state().style_for(state); Label::new("Sign In", style.text.clone()) @@ -771,7 +770,7 @@ impl CollabTitlebarItem { theme, cx, )) - .with_margin_right(theme.workspace.titlebar.face_pile_spacing), + .with_margin_right(theme.titlebar.face_pile_spacing), ) }) .collect() @@ -795,7 +794,7 @@ impl CollabTitlebarItem { theme, cx, )) - .with_margin_right(theme.workspace.titlebar.item_spacing) + .with_margin_right(theme.titlebar.item_spacing) .into_any() } @@ -827,11 +826,10 @@ impl CollabTitlebarItem { }) .unwrap_or(false); - let leader_style = theme.workspace.titlebar.leader_avatar; - let follower_style = theme.workspace.titlebar.follower_avatar; + let leader_style = theme.titlebar.leader_avatar; + let follower_style = theme.titlebar.follower_avatar; let mut background_color = theme - .workspace .titlebar .container .background_color @@ -846,7 +844,7 @@ impl CollabTitlebarItem { let mut content = Stack::new() .with_children(user.avatar.as_ref().map(|avatar| { - let face_pile = FacePile::new(theme.workspace.titlebar.follower_avatar_overlap) + let face_pile = FacePile::new(theme.titlebar.follower_avatar_overlap) .with_child(Self::render_face( avatar.clone(), Self::location_style(workspace, location, leader_style, cx), @@ -891,7 +889,7 @@ impl CollabTitlebarItem { let mut container = face_pile .contained() - .with_style(theme.workspace.titlebar.leader_selection); + .with_style(theme.titlebar.leader_selection); if let Some(replica_id) = replica_id { if followed_by_self { @@ -908,8 +906,8 @@ impl CollabTitlebarItem { Some( AvatarRibbon::new(color) .constrained() - .with_width(theme.workspace.titlebar.avatar_ribbon.width) - .with_height(theme.workspace.titlebar.avatar_ribbon.height) + .with_width(theme.titlebar.avatar_ribbon.width) + .with_height(theme.titlebar.avatar_ribbon.height) .aligned() .bottom(), ) @@ -1029,22 +1027,22 @@ impl CollabTitlebarItem { | client::Status::Reconnecting { .. } | client::Status::ReconnectionError { .. } => Some( Svg::new("icons/cloud_slash_12.svg") - .with_color(theme.workspace.titlebar.offline_icon.color) + .with_color(theme.titlebar.offline_icon.color) .constrained() - .with_width(theme.workspace.titlebar.offline_icon.width) + .with_width(theme.titlebar.offline_icon.width) .aligned() .contained() - .with_style(theme.workspace.titlebar.offline_icon.container) + .with_style(theme.titlebar.offline_icon.container) .into_any(), ), client::Status::UpgradeRequired => Some( MouseEventHandler::::new(0, cx, |_, _| { Label::new( "Please update Zed to collaborate", - theme.workspace.titlebar.outdated_warning.text.clone(), + theme.titlebar.outdated_warning.text.clone(), ) .contained() - .with_style(theme.workspace.titlebar.outdated_warning.container) + .with_style(theme.titlebar.outdated_warning.container) .aligned() }) .with_cursor_style(CursorStyle::PointingHand) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 4d7f334086..06c6026e3a 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -66,7 +66,7 @@ pub struct Theme { pub feedback: FeedbackStyle, pub welcome: WelcomeStyle, pub color_scheme: ColorScheme, - pub titlebar: UserMenu, + pub titlebar: Titlebar, } #[derive(Deserialize, Default, Clone, JsonSchema)] @@ -81,7 +81,6 @@ pub struct ThemeMeta { pub struct Workspace { pub background: Color, pub blank_pane: BlankPaneStyle, - pub titlebar: Titlebar, pub tab_bar: TabBar, pub pane_divider: Border, pub leader_border_opacity: f32, @@ -138,8 +137,8 @@ pub struct Titlebar { pub toggle_microphone_button: Toggleable>, pub toggle_speakers_button: Toggleable>, pub leave_call_button: Interactive, - pub user_menu_button: Toggleable>, pub toggle_contacts_badge: ContainerStyle, + pub user_menu: UserMenu, } #[derive(Clone, Deserialize, Default, JsonSchema)] diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index dfc2f4f795..066ea5f8a6 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -2296,11 +2296,11 @@ impl Workspace { // (https://github.com/zed-industries/zed/issues/1290) let is_fullscreen = cx.window_is_fullscreen(); let container_theme = if is_fullscreen { - let mut container_theme = theme.workspace.titlebar.container; + let mut container_theme = theme.titlebar.container; container_theme.padding.left = container_theme.padding.right; container_theme } else { - theme.workspace.titlebar.container + theme.titlebar.container }; enum TitleBar {} @@ -2320,7 +2320,7 @@ impl Workspace { } }) .constrained() - .with_height(theme.workspace.titlebar.height) + .with_height(theme.titlebar.height) .into_any_named("titlebar") } diff --git a/styles/src/styleTree/titlebar.ts b/styles/src/styleTree/titlebar.ts index 881600d76c..5f0fc3f528 100644 --- a/styles/src/styleTree/titlebar.ts +++ b/styles/src/styleTree/titlebar.ts @@ -1,6 +1,49 @@ import { ColorScheme } from "../common"; +import { icon_button, toggleable_icon_button } from "../component/icon_button" +import { toggleable_text_button } from "../component/text_button" import { interactive, toggleable } from "../element" -import { background, foreground, text } from "./components"; +import { withOpacity } from "../theme/color"; +import { background, border, foreground, text } from "./components"; + +const ITEM_SPACING = 8 + +interface SpacingProps { + container_height: number; + spacing: number; +} + +function build_spacing( + container_height: number, + element_height: number, + spacing: number +) { + return { + group: spacing * 2, + item: spacing / 2, + marginY: (container_height - element_height) / 2, + marginX: (container_height - element_height) / 2, + } +} + +function mac_os_controls(theme: ColorScheme, { container_height, spacing }: SpacingProps) { + return {} +} + +function project_info(theme: ColorScheme, { container_height, spacing }: SpacingProps) { + return {} +} + +function collaboration_stacks(theme: ColorScheme, { container_height, spacing }: SpacingProps) { + return {} +} + +function sharing_controls(theme: ColorScheme, { container_height, spacing }: SpacingProps) { + return {} +} + +function call_controls(theme: ColorScheme, { container_height, spacing }: SpacingProps) { + return {} +} const titlebarButton = (theme: ColorScheme) => toggleable({ base: interactive({ @@ -57,29 +100,210 @@ const titlebarButton = (theme: ColorScheme) => toggleable({ * When logged out only shows a chevron. */ function userMenuButton(theme: ColorScheme, online: boolean) { + const button = toggleable({ + base: interactive({ + base: { + cornerRadius: 6, + height: 19, + width: online ? 36 : 23, + padding: { + top: 2, + bottom: 2, + left: 6, + right: 6, + }, + ...text(theme.lowest, "sans", { size: "xs" }), + background: background(theme.lowest), + }, + state: { + hovered: { + ...text(theme.lowest, "sans", "hovered", { + size: "xs", + }), + background: background(theme.lowest, "hovered"), + }, + clicked: { + ...text(theme.lowest, "sans", "pressed", { + size: "xs", + }), + background: background(theme.lowest, "pressed"), + }, + }, + }), + state: { + active: { + default: { + ...text(theme.lowest, "sans", "active", { size: "xs" }), + background: background(theme.middle), + }, + hovered: { + ...text(theme.lowest, "sans", "active", { size: "xs" }), + background: background(theme.middle, "hovered"), + }, + clicked: { + ...text(theme.lowest, "sans", "active", { size: "xs" }), + background: background(theme.middle, "pressed"), + }, + }, + } + }); + return { - user_menu: titlebarButton(theme), + user_menu: button, avatar: { icon_width: 16, icon_height: 16, cornerRadius: 4, outer_corner_radius: 0, outer_width: 0, - outerWidth: 10, - outerCornerRadius: 10 + outerWidth: 16, + outerCornerRadius: 16 }, icon: { + margin: { + left: online ? 2 : 0, + }, width: 11, height: 11, - color: online ? foreground(theme.lowest) : background(theme.lowest) + color: foreground(theme.lowest) } } } export function titlebar(theme: ColorScheme) { - return { - userMenuButtonOnline: userMenuButton(theme, true), - userMenuButtonOffline: userMenuButton(theme, false) + const avatarWidth = 18 + const avatarOuterWidth = avatarWidth + 4 + const followerAvatarWidth = 14 + const followerAvatarOuterWidth = followerAvatarWidth + 4 + return { + ITEM_SPACING, + facePileSpacing: 2, + height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. + background: background(theme.lowest), + border: border(theme.lowest, { bottom: true }), + padding: { + left: 80, + right: ITEM_SPACING, + }, + + // Project + title: text(theme.lowest, "sans", "variant"), + highlight_color: text(theme.lowest, "sans", "active").color, + + // Collaborators + leaderAvatar: { + width: avatarWidth, + outerWidth: avatarOuterWidth, + cornerRadius: avatarWidth / 2, + outerCornerRadius: avatarOuterWidth / 2, + }, + followerAvatar: { + width: followerAvatarWidth, + outerWidth: followerAvatarOuterWidth, + cornerRadius: followerAvatarWidth / 2, + outerCornerRadius: followerAvatarOuterWidth / 2, + }, + inactiveAvatarGrayscale: true, + followerAvatarOverlap: 8, + leaderSelection: { + margin: { + top: 4, + bottom: 4, + }, + padding: { + left: 2, + right: 2, + top: 2, + bottom: 2, + }, + cornerRadius: 6, + }, + avatarRibbon: { + height: 3, + width: 11, + // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. + }, + + // Sign in buttom + sign_in_button: toggleable_text_button(theme, {}), + + // Offline Indicator + offlineIcon: { + color: foreground(theme.lowest, "variant"), + width: 16, + margin: { + left: ITEM_SPACING, + }, + padding: { + right: 4, + }, + }, + + // Notice that the collaboration server is out of date + outdatedWarning: { + ...text(theme.lowest, "sans", "warning", { size: "xs" }), + background: withOpacity(background(theme.lowest, "warning"), 0.3), + border: border(theme.lowest, "warning"), + margin: { + left: ITEM_SPACING, + }, + padding: { + left: 8, + right: 8, + }, + cornerRadius: 6, + }, + + leave_call_button: icon_button(theme, { + margin: { + left: ITEM_SPACING / 2, + right: ITEM_SPACING + }, + }), + + toggle_microphone_button: toggleable_icon_button(theme, { + margin: { + left: ITEM_SPACING, + right: ITEM_SPACING / 2 + }, + active_color: 'negative' + }), + + toggle_speakers_button: toggleable_icon_button(theme, { + margin: { + left: ITEM_SPACING / 2, + right: ITEM_SPACING / 2 + }, + }), + + screen_share_button: toggleable_icon_button(theme, { + margin: { + left: ITEM_SPACING / 2, + right: ITEM_SPACING + }, + active_color: 'accent' + }), + + toggle_contacts_button: toggleable_icon_button(theme, { + margin: { + left: ITEM_SPACING, + right: ITEM_SPACING / 2 + }, + }), + + // Jewel that notifies you that there are new contact requests + toggleContactsBadge: { + cornerRadius: 3, + padding: 2, + margin: { top: 3, left: 3 }, + border: border(theme.lowest), + background: foreground(theme.lowest, "accent"), + }, + shareButton: toggleable_text_button(theme, {}), + user_menu: { + userMenuButtonOnline: userMenuButton(theme, true), + userMenuButtonOffline: userMenuButton(theme, false), + } } } diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index 4b3c5f3b51..afc2ea4d98 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -1,6 +1,5 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" -import { toggleable } from "../element" import { background, border, @@ -12,94 +11,11 @@ import { import statusBar from "./statusBar" import tabBar from "./tabBar" import { interactive } from "../element" -import merge from "ts-deepmerge" -import { icon_button, toggleable_icon_button } from "../component/icon_button" -import { text_button, toggleable_text_button } from "../component/text_button" + +import { titlebar } from "./titlebar" export default function workspace(colorScheme: ColorScheme) { const layer = colorScheme.lowest const isLight = colorScheme.isLight - const itemSpacing = 8 - const titlebarButton = toggleable({ - base: interactive({ - base: { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - border: border(layer), - }, - state: { - hovered: { - ...text(layer, "sans", "variant", "hovered", { - size: "xs", - }), - background: background(layer, "variant", "hovered"), - border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { - size: "xs", - }), - background: background(layer, "variant", "pressed"), - border: border(layer, "variant", "pressed"), - }, - }, - }), - state: { - active: { - default: { - ...text(layer, "sans", "variant", "active", { size: "xs" }), - background: background(layer, "variant", "active"), - border: border(layer, "variant", "active"), - }, - }, - } - }); - const signInButton = toggleable({ - base: interactive({ - base: { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 8, - }, - ...text(layer, "sans", "variant", { size: "xs" }), - background: background(layer, "variant"), - }, - state: { - hovered: { - ...text(layer, "sans", "variant", "hovered", { size: "xs" }), - background: background(layer, "variant", "hovered"), - //border: border(layer, "variant", "hovered"), - }, - clicked: { - ...text(layer, "sans", "variant", "pressed", { size: "xs" }), - background: background(layer, "variant", "pressed"), - //border: border(layer, "variant", "pressed"), - } - } - }), - state: { - active: { - default: { - ...text(layer, "sans", "variant", "active", { size: "xs" }), - background: background(layer, "variant", "active"), - //border: border(layer, "variant", "active"), - } - }, - } - }); - const avatarWidth = 18 - const avatarOuterWidth = avatarWidth + 4 - const followerAvatarWidth = 14 - const followerAvatarOuterWidth = followerAvatarWidth + 4 return { background: background(colorScheme.lowest), @@ -209,163 +125,7 @@ export default function workspace(colorScheme: ColorScheme) { width: 1, }, statusBar: statusBar(colorScheme), - titlebar: { - itemSpacing, - facePileSpacing: 2, - height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. - background: background(layer), - border: border(layer, { bottom: true }), - padding: { - left: 80, - right: itemSpacing, - }, - - // Project - title: text(layer, "sans", "variant"), - highlight_color: text(layer, "sans", "active").color, - - // Collaborators - leaderAvatar: { - width: avatarWidth, - outerWidth: avatarOuterWidth, - cornerRadius: avatarWidth / 2, - outerCornerRadius: avatarOuterWidth / 2, - }, - followerAvatar: { - width: followerAvatarWidth, - outerWidth: followerAvatarOuterWidth, - cornerRadius: followerAvatarWidth / 2, - outerCornerRadius: followerAvatarOuterWidth / 2, - }, - inactiveAvatarGrayscale: true, - followerAvatarOverlap: 8, - leaderSelection: { - margin: { - top: 4, - bottom: 4, - }, - padding: { - left: 2, - right: 2, - top: 2, - bottom: 2, - }, - cornerRadius: 6, - }, - avatarRibbon: { - height: 3, - width: 11, - // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. - }, - - // Sign in buttom - // FlatButton, Variant - sign_in_button: merge(titlebarButton, { - inactive: { - default: { - margin: { - left: itemSpacing, - }, - }, - }, - - signInButton, - - }), - - // Offline Indicator - offlineIcon: { - color: foreground(layer, "variant"), - width: 16, - margin: { - left: itemSpacing, - }, - padding: { - right: 4, - }, - }, - - // Notice that the collaboration server is out of date - outdatedWarning: { - ...text(layer, "sans", "warning", { size: "xs" }), - background: withOpacity(background(layer, "warning"), 0.3), - border: border(layer, "warning"), - margin: { - left: itemSpacing, - }, - padding: { - left: 8, - right: 8, - }, - cornerRadius: 6, - }, - - leave_call_button: icon_button(colorScheme, { - margin: { - left: itemSpacing / 2, - right: itemSpacing - }, - }), - - toggle_microphone_button: toggleable_icon_button(colorScheme, { - margin: { - left: itemSpacing, - right: itemSpacing / 2 - }, - active_color: 'negative' - }), - - toggle_speakers_button: toggleable_icon_button(colorScheme, { - margin: { - left: itemSpacing / 2, - right: itemSpacing / 2 - }, - }), - - screen_share_button: toggleable_icon_button(colorScheme, { - margin: { - left: itemSpacing / 2, - right: itemSpacing - }, - active_color: 'accent' - }), - - toggle_contacts_button: toggleable_icon_button(colorScheme, { - margin: { - left: itemSpacing, - right: itemSpacing / 2 - }, - }), - - user_menu_button: - merge(titlebarButton, { - inactive: { - default: { - buttonWidth: 20, - iconWidth: 12, - }, - }, - active: { - default: { - iconWidth: 12, - button_width: 20, - background: background(layer, "variant", "active"), - color: foreground(layer, "variant", "active"), - } - }, - }), - - // Jewel that notifies you that there are new contact requests - toggleContactsBadge: { - cornerRadius: 3, - padding: 2, - margin: { top: 3, left: 3 }, - border: border(layer), - background: foreground(layer, "accent"), - }, - shareButton: toggleable_text_button(colorScheme, {}), - }, - + titlebar: titlebar(colorScheme), toolbar: { height: 34, background: background(colorScheme.highest), From 9a07696240513bee363a14a9d4d5f9e6c3f7ebf1 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Tue, 27 Jun 2023 17:56:44 -0400 Subject: [PATCH 188/215] Update titlebar item spacing --- styles/src/styleTree/titlebar.ts | 273 +++++++++++++------------------ 1 file changed, 112 insertions(+), 161 deletions(-) diff --git a/styles/src/styleTree/titlebar.ts b/styles/src/styleTree/titlebar.ts index 5f0fc3f528..993d421859 100644 --- a/styles/src/styleTree/titlebar.ts +++ b/styles/src/styleTree/titlebar.ts @@ -6,11 +6,7 @@ import { withOpacity } from "../theme/color"; import { background, border, foreground, text } from "./components"; const ITEM_SPACING = 8 - -interface SpacingProps { - container_height: number; - spacing: number; -} +const TITLEBAR_HEIGHT = 32 function build_spacing( container_height: number, @@ -18,80 +14,44 @@ function build_spacing( spacing: number ) { return { - group: spacing * 2, + group: spacing, item: spacing / 2, + half_item: spacing / 4, marginY: (container_height - element_height) / 2, marginX: (container_height - element_height) / 2, } } -function mac_os_controls(theme: ColorScheme, { container_height, spacing }: SpacingProps) { - return {} -} +function call_controls(theme: ColorScheme) { + const button_height = 19 -function project_info(theme: ColorScheme, { container_height, spacing }: SpacingProps) { - return {} -} + const space = build_spacing(TITLEBAR_HEIGHT, button_height, ITEM_SPACING); -function collaboration_stacks(theme: ColorScheme, { container_height, spacing }: SpacingProps) { - return {} -} + return { + toggle_microphone_button: toggleable_icon_button(theme, { + margin: { + left: space.group, + right: space.half_item, + }, + active_color: 'negative' + }), -function sharing_controls(theme: ColorScheme, { container_height, spacing }: SpacingProps) { - return {} -} + toggle_speakers_button: toggleable_icon_button(theme, { + margin: { + left: space.half_item, + right: space.half_item + }, + }), -function call_controls(theme: ColorScheme, { container_height, spacing }: SpacingProps) { - return {} -} - -const titlebarButton = (theme: ColorScheme) => toggleable({ - base: interactive({ - base: { - cornerRadius: 6, - height: 24, - width: 24, - padding: { - top: 4, - bottom: 4, - left: 4, - right: 4, + screen_share_button: toggleable_icon_button(theme, { + margin: { + left: space.half_item, + right: space.group }, - ...text(theme.lowest, "sans", { size: "xs" }), - background: background(theme.lowest), - }, - state: { - hovered: { - ...text(theme.lowest, "sans", "hovered", { - size: "xs", - }), - background: background(theme.lowest, "hovered"), - }, - clicked: { - ...text(theme.lowest, "sans", "pressed", { - size: "xs", - }), - background: background(theme.lowest, "pressed"), - }, - }, - }), - state: { - active: { - default: { - ...text(theme.lowest, "sans", "active", { size: "xs" }), - background: background(theme.middle), - }, - hovered: { - ...text(theme.lowest, "sans", "active", { size: "xs" }), - background: background(theme.middle, "hovered"), - }, - clicked: { - ...text(theme.lowest, "sans", "active", { size: "xs" }), - background: background(theme.middle, "pressed"), - }, - }, + active_color: 'accent' + }), } -}); +} /** * Opens the User Menu when toggled @@ -99,75 +59,90 @@ const titlebarButton = (theme: ColorScheme) => toggleable({ * When logged in shows the user's avatar and a chevron, * When logged out only shows a chevron. */ -function userMenuButton(theme: ColorScheme, online: boolean) { - const button = toggleable({ - base: interactive({ - base: { - cornerRadius: 6, - height: 19, - width: online ? 36 : 23, - padding: { - top: 2, - bottom: 2, - left: 6, - right: 6, - }, - ...text(theme.lowest, "sans", { size: "xs" }), - background: background(theme.lowest), - }, - state: { - hovered: { - ...text(theme.lowest, "sans", "hovered", { - size: "xs", - }), - background: background(theme.lowest, "hovered"), - }, - clicked: { - ...text(theme.lowest, "sans", "pressed", { - size: "xs", - }), - background: background(theme.lowest, "pressed"), - }, - }, - }), - state: { - active: { - default: { - ...text(theme.lowest, "sans", "active", { size: "xs" }), - background: background(theme.middle), - }, - hovered: { - ...text(theme.lowest, "sans", "active", { size: "xs" }), - background: background(theme.middle, "hovered"), - }, - clicked: { - ...text(theme.lowest, "sans", "active", { size: "xs" }), - background: background(theme.middle, "pressed"), - }, - }, - } - }); +function user_menu(theme: ColorScheme) { + const button_height = 19 - return { - user_menu: button, - avatar: { - icon_width: 16, - icon_height: 16, - cornerRadius: 4, - outer_corner_radius: 0, - outer_width: 0, - outerWidth: 16, - outerCornerRadius: 16 - }, - icon: { - margin: { - left: online ? 2 : 0, + const space = build_spacing(TITLEBAR_HEIGHT, button_height, ITEM_SPACING); + + const build_button = ({ online }: { online: boolean }) => { + const button = toggleable({ + base: interactive({ + base: { + cornerRadius: 6, + height: button_height, + width: online ? 36 : 23, + padding: { + top: 2, + bottom: 2, + left: 6, + right: 6, + }, + margin: { + left: space.item, + right: space.item, + }, + ...text(theme.lowest, "sans", { size: "xs" }), + background: background(theme.lowest), + }, + state: { + hovered: { + ...text(theme.lowest, "sans", "hovered", { + size: "xs", + }), + background: background(theme.lowest, "hovered"), + }, + clicked: { + ...text(theme.lowest, "sans", "pressed", { + size: "xs", + }), + background: background(theme.lowest, "pressed"), + }, + }, + }), + state: { + active: { + default: { + ...text(theme.lowest, "sans", "active", { size: "xs" }), + background: background(theme.middle), + }, + hovered: { + ...text(theme.lowest, "sans", "active", { size: "xs" }), + background: background(theme.middle, "hovered"), + }, + clicked: { + ...text(theme.lowest, "sans", "active", { size: "xs" }), + background: background(theme.middle, "pressed"), + }, + }, + } + }); + + return { + user_menu: button, + avatar: { + icon_width: 15, + icon_height: 15, + corner_radius: 4, + outer_width: 15, + outer_corner_radius: 15 }, - width: 11, - height: 11, - color: foreground(theme.lowest) + icon: { + margin: { + top: 2, + left: online ? space.item : 0, + right: space.group, + bottom: 2, + }, + width: 11, + height: 11, + color: foreground(theme.lowest) + } } } + return { + userMenuButtonOnline: build_button({ online: true }), + userMenuButtonOffline: build_button({ online: false }), + } } export function titlebar(theme: ColorScheme) { @@ -177,14 +152,14 @@ export function titlebar(theme: ColorScheme) { const followerAvatarOuterWidth = followerAvatarWidth + 4 return { - ITEM_SPACING, + item_spacing: ITEM_SPACING, facePileSpacing: 2, - height: 33, // 32px + 1px border. It's important the content area of the titlebar is evenly sized to vertically center avatar images. + height: TITLEBAR_HEIGHT, background: background(theme.lowest), border: border(theme.lowest, { bottom: true }), padding: { left: 80, - right: ITEM_SPACING, + right: 0, }, // Project @@ -262,28 +237,7 @@ export function titlebar(theme: ColorScheme) { }, }), - toggle_microphone_button: toggleable_icon_button(theme, { - margin: { - left: ITEM_SPACING, - right: ITEM_SPACING / 2 - }, - active_color: 'negative' - }), - - toggle_speakers_button: toggleable_icon_button(theme, { - margin: { - left: ITEM_SPACING / 2, - right: ITEM_SPACING / 2 - }, - }), - - screen_share_button: toggleable_icon_button(theme, { - margin: { - left: ITEM_SPACING / 2, - right: ITEM_SPACING - }, - active_color: 'accent' - }), + ...call_controls(theme), toggle_contacts_button: toggleable_icon_button(theme, { margin: { @@ -301,9 +255,6 @@ export function titlebar(theme: ColorScheme) { background: foreground(theme.lowest, "accent"), }, shareButton: toggleable_text_button(theme, {}), - user_menu: { - userMenuButtonOnline: userMenuButton(theme, true), - userMenuButtonOffline: userMenuButton(theme, false), - } + user_menu: user_menu(theme) } } From 81c26cfea0d06132aca760bb9610778eb576661b Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 27 Jun 2023 15:08:26 -0700 Subject: [PATCH 189/215] Fix bugs in handling combined injections exposed by HEEx --- crates/language/src/syntax_map.rs | 245 ++++++++++++------ .../src/syntax_map/syntax_map_tests.rs | 33 ++- crates/zed/src/languages/heex/injections.scm | 2 - 3 files changed, 200 insertions(+), 80 deletions(-) diff --git a/crates/language/src/syntax_map.rs b/crates/language/src/syntax_map.rs index c589e37d8a..1570baf185 100644 --- a/crates/language/src/syntax_map.rs +++ b/crates/language/src/syntax_map.rs @@ -11,7 +11,7 @@ use std::{ cell::RefCell, cmp::{self, Ordering, Reverse}, collections::BinaryHeap, - iter, + fmt, iter, ops::{Deref, DerefMut, Range}, sync::Arc, }; @@ -428,6 +428,8 @@ impl SyntaxSnapshot { invalidated_ranges: Vec>, registry: Option<&Arc>, ) { + log::trace!("reparse. invalidated ranges:{:?}", invalidated_ranges); + let max_depth = self.layers.summary().max_depth; let mut cursor = self.layers.cursor::(); cursor.next(&text); @@ -489,6 +491,15 @@ impl SyntaxSnapshot { let Some(layer) = cursor.item() else { break }; if changed_regions.intersects(&layer, text) { + if let SyntaxLayerContent::Parsed { language, .. } = &layer.content { + log::trace!( + "discard layer. language:{}, range:{:?}. changed_regions:{:?}", + language.name(), + LogAnchorRange(&layer.range, text), + LogChangedRegions(&changed_regions, text), + ); + } + changed_regions.insert( ChangedRegion { depth: layer.depth + 1, @@ -541,26 +552,24 @@ impl SyntaxSnapshot { .to_ts_point(); } - if included_ranges.is_empty() { - included_ranges.push(tree_sitter::Range { - start_byte: 0, - end_byte: 0, - start_point: Default::default(), - end_point: Default::default(), - }); - } - - if let Some(SyntaxLayerContent::Parsed { tree: old_tree, .. }) = - old_layer.map(|layer| &layer.content) + if let Some((SyntaxLayerContent::Parsed { tree: old_tree, .. }, layer_start)) = + old_layer.map(|layer| (&layer.content, layer.range.start)) { + log::trace!( + "existing layer. language:{}, start:{:?}, ranges:{:?}", + language.name(), + LogPoint(layer_start.to_point(&text)), + LogIncludedRanges(&old_tree.included_ranges()) + ); + if let ParseMode::Combined { mut parent_layer_changed_ranges, .. } = step.mode { for range in &mut parent_layer_changed_ranges { - range.start -= step_start_byte; - range.end -= step_start_byte; + range.start = range.start.saturating_sub(step_start_byte); + range.end = range.end.saturating_sub(step_start_byte); } included_ranges = splice_included_ranges( @@ -570,6 +579,22 @@ impl SyntaxSnapshot { ); } + if included_ranges.is_empty() { + included_ranges.push(tree_sitter::Range { + start_byte: 0, + end_byte: 0, + start_point: Default::default(), + end_point: Default::default(), + }); + } + + log::trace!( + "update layer. language:{}, start:{:?}, ranges:{:?}", + language.name(), + LogAnchorRange(&step.range, text), + LogIncludedRanges(&included_ranges), + ); + tree = parse_text( grammar, text.as_rope(), @@ -586,6 +611,22 @@ impl SyntaxSnapshot { }), ); } else { + if included_ranges.is_empty() { + included_ranges.push(tree_sitter::Range { + start_byte: 0, + end_byte: 0, + start_point: Default::default(), + end_point: Default::default(), + }); + } + + log::trace!( + "create layer. language:{}, range:{:?}, included_ranges:{:?}", + language.name(), + LogAnchorRange(&step.range, text), + LogIncludedRanges(&included_ranges), + ); + tree = parse_text( grammar, text.as_rope(), @@ -613,6 +654,7 @@ impl SyntaxSnapshot { get_injections( config, text, + step.range.clone(), tree.root_node_with_offset( step_start_byte, step_start_point.to_ts_point(), @@ -1117,6 +1159,7 @@ fn parse_text( fn get_injections( config: &InjectionConfig, text: &BufferSnapshot, + outer_range: Range, node: Node, language_registry: &Arc, depth: usize, @@ -1153,16 +1196,17 @@ fn get_injections( continue; } - // Avoid duplicate matches if two changed ranges intersect the same injection. let content_range = content_ranges.first().unwrap().start_byte..content_ranges.last().unwrap().end_byte; - if let Some((last_pattern_ix, last_range)) = &prev_match { - if mat.pattern_index == *last_pattern_ix && content_range == *last_range { + + // Avoid duplicate matches if two changed ranges intersect the same injection. + if let Some((prev_pattern_ix, prev_range)) = &prev_match { + if mat.pattern_index == *prev_pattern_ix && content_range == *prev_range { continue; } } - prev_match = Some((mat.pattern_index, content_range.clone())); + prev_match = Some((mat.pattern_index, content_range.clone())); let combined = config.patterns[mat.pattern_index].combined; let mut language_name = None; @@ -1218,11 +1262,10 @@ fn get_injections( for (language, mut included_ranges) in combined_injection_ranges.drain() { included_ranges.sort_unstable(); - let range = text.anchor_before(node.start_byte())..text.anchor_after(node.end_byte()); queue.push(ParseStep { depth, language: ParseStepLanguage::Loaded { language }, - range, + range: outer_range.clone(), included_ranges, mode: ParseMode::Combined { parent_layer_range: node.start_byte()..node.end_byte(), @@ -1234,72 +1277,77 @@ fn get_injections( pub(crate) fn splice_included_ranges( mut ranges: Vec, - changed_ranges: &[Range], + removed_ranges: &[Range], new_ranges: &[tree_sitter::Range], ) -> Vec { - let mut changed_ranges = changed_ranges.into_iter().peekable(); - let mut new_ranges = new_ranges.into_iter().peekable(); + let mut removed_ranges = removed_ranges.iter().cloned().peekable(); + let mut new_ranges = new_ranges.into_iter().cloned().peekable(); let mut ranges_ix = 0; loop { - let new_range = new_ranges.peek(); - let mut changed_range = changed_ranges.peek(); + let next_new_range = new_ranges.peek(); + let next_removed_range = removed_ranges.peek(); - // Remove ranges that have changed before inserting any new ranges - // into those ranges. - if let Some((changed, new)) = changed_range.zip(new_range) { - if new.end_byte < changed.start { - changed_range = None; + let (remove, insert) = match (next_removed_range, next_new_range) { + (None, None) => break, + (Some(_), None) => (removed_ranges.next().unwrap(), None), + (Some(next_removed_range), Some(next_new_range)) => { + if next_removed_range.end < next_new_range.start_byte { + (removed_ranges.next().unwrap(), None) + } else { + let mut start = next_new_range.start_byte; + let mut end = next_new_range.end_byte; + + while let Some(next_removed_range) = removed_ranges.peek() { + if next_removed_range.start > next_new_range.end_byte { + break; + } + let next_removed_range = removed_ranges.next().unwrap(); + start = cmp::min(start, next_removed_range.start); + end = cmp::max(end, next_removed_range.end); + } + + (start..end, Some(new_ranges.next().unwrap())) + } + } + (None, Some(next_new_range)) => ( + next_new_range.start_byte..next_new_range.end_byte, + Some(new_ranges.next().unwrap()), + ), + }; + + let mut start_ix = ranges_ix + + match ranges[ranges_ix..].binary_search_by_key(&remove.start, |r| r.end_byte) { + Ok(ix) => ix, + Err(ix) => ix, + }; + let mut end_ix = ranges_ix + + match ranges[ranges_ix..].binary_search_by_key(&remove.end, |r| r.start_byte) { + Ok(ix) => ix + 1, + Err(ix) => ix, + }; + + // If there are empty ranges, then there may be multiple ranges with the same + // start or end. Expand the splice to include any adjacent ranges that touch + // the changed range. + while start_ix > 0 { + if ranges[start_ix - 1].end_byte == remove.start { + start_ix -= 1; + } else { + break; + } + } + while let Some(range) = ranges.get(end_ix) { + if range.start_byte == remove.end { + end_ix += 1; + } else { + break; } } - if let Some(changed) = changed_range { - let mut start_ix = ranges_ix - + match ranges[ranges_ix..].binary_search_by_key(&changed.start, |r| r.end_byte) { - Ok(ix) | Err(ix) => ix, - }; - let mut end_ix = ranges_ix - + match ranges[ranges_ix..].binary_search_by_key(&changed.end, |r| r.start_byte) { - Ok(ix) => ix + 1, - Err(ix) => ix, - }; - - // If there are empty ranges, then there may be multiple ranges with the same - // start or end. Expand the splice to include any adjacent ranges that touch - // the changed range. - while start_ix > 0 { - if ranges[start_ix - 1].end_byte == changed.start { - start_ix -= 1; - } else { - break; - } - } - while let Some(range) = ranges.get(end_ix) { - if range.start_byte == changed.end { - end_ix += 1; - } else { - break; - } - } - - if end_ix > start_ix { - ranges.splice(start_ix..end_ix, []); - } - changed_ranges.next(); - ranges_ix = start_ix; - } else if let Some(new_range) = new_range { - let ix = ranges_ix - + match ranges[ranges_ix..] - .binary_search_by_key(&new_range.start_byte, |r| r.start_byte) - { - Ok(ix) | Err(ix) => ix, - }; - ranges.insert(ix, **new_range); - new_ranges.next(); - ranges_ix = ix + 1; - } else { - break; - } + ranges.splice(start_ix..end_ix, insert); + ranges_ix = start_ix; } + ranges } @@ -1628,3 +1676,46 @@ impl ToTreeSitterPoint for Point { Point::new(point.row as u32, point.column as u32) } } + +struct LogIncludedRanges<'a>(&'a [tree_sitter::Range]); +struct LogPoint(Point); +struct LogAnchorRange<'a>(&'a Range, &'a text::BufferSnapshot); +struct LogChangedRegions<'a>(&'a ChangeRegionSet, &'a text::BufferSnapshot); + +impl<'a> fmt::Debug for LogIncludedRanges<'a> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list() + .entries(self.0.iter().map(|range| { + let start = range.start_point; + let end = range.end_point; + (start.row, start.column)..(end.row, end.column) + })) + .finish() + } +} + +impl<'a> fmt::Debug for LogAnchorRange<'a> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let range = self.0.to_point(self.1); + (LogPoint(range.start)..LogPoint(range.end)).fmt(f) + } +} + +impl<'a> fmt::Debug for LogChangedRegions<'a> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list() + .entries( + self.0 + .0 + .iter() + .map(|region| LogAnchorRange(®ion.range, self.1)), + ) + .finish() + } +} + +impl fmt::Debug for LogPoint { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (self.0.row, self.0.column).fmt(f) + } +} diff --git a/crates/language/src/syntax_map/syntax_map_tests.rs b/crates/language/src/syntax_map/syntax_map_tests.rs index 57b5cd4a8c..272501f2d0 100644 --- a/crates/language/src/syntax_map/syntax_map_tests.rs +++ b/crates/language/src/syntax_map/syntax_map_tests.rs @@ -48,6 +48,13 @@ fn test_splice_included_ranges() { let new_ranges = splice_included_ranges(ranges.clone(), &[30..50], &[ts_range(25..55)]); assert_eq!(new_ranges, &[ts_range(25..55), ts_range(80..90)]); + // does not create overlapping ranges + let new_ranges = splice_included_ranges(ranges.clone(), &[0..18], &[ts_range(20..32)]); + assert_eq!( + new_ranges, + &[ts_range(20..32), ts_range(50..60), ts_range(80..90)] + ); + fn ts_range(range: Range) -> tree_sitter::Range { tree_sitter::Range { start_byte: range.start, @@ -624,6 +631,26 @@ fn test_combined_injections_splitting_some_injections() { ); } +#[gpui::test] +fn test_combined_injections_editing_after_last_injection() { + test_edit_sequence( + "ERB", + &[ + r#" + <% foo %> +
+ <% bar %> + "#, + r#" + <% foo %> +
+ <% bar %>« + more text» + "#, + ], + ); +} + #[gpui::test] fn test_combined_injections_inside_injections() { let (_buffer, _syntax_map) = test_edit_sequence( @@ -974,13 +1001,16 @@ fn test_edit_sequence(language_name: &str, steps: &[&str]) -> (Buffer, SyntaxMap mutated_syntax_map.reparse(language.clone(), &buffer); for (i, marked_string) in steps.into_iter().enumerate() { - buffer.edit_via_marked_text(&marked_string.unindent()); + let marked_string = marked_string.unindent(); + log::info!("incremental parse {i}: {marked_string:?}"); + buffer.edit_via_marked_text(&marked_string); // Reparse the syntax map mutated_syntax_map.interpolate(&buffer); mutated_syntax_map.reparse(language.clone(), &buffer); // Create a second syntax map from scratch + log::info!("fresh parse {i}: {marked_string:?}"); let mut reference_syntax_map = SyntaxMap::new(); reference_syntax_map.set_language_registry(registry.clone()); reference_syntax_map.reparse(language.clone(), &buffer); @@ -1133,6 +1163,7 @@ fn range_for_text(buffer: &Buffer, text: &str) -> Range { start..start + text.len() } +#[track_caller] fn assert_layers_for_range( syntax_map: &SyntaxMap, buffer: &BufferSnapshot, diff --git a/crates/zed/src/languages/heex/injections.scm b/crates/zed/src/languages/heex/injections.scm index 41b65db8ee..b503bcb28d 100644 --- a/crates/zed/src/languages/heex/injections.scm +++ b/crates/zed/src/languages/heex/injections.scm @@ -9,7 +9,5 @@ (#set! combined) ) -; expressions live within HTML tags, and do not need to be combined -; ((expression (expression_value) @content) (#set! language "elixir")) From 201188fdaa284debcd445b1d70d6918d800a3861 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 27 Jun 2023 15:40:36 -0700 Subject: [PATCH 190/215] Use FakeFs in worktree gitignore test --- crates/project/src/worktree_tests.rs | 64 ++++++++++++++++++---------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rs index 39c6e19d56..553c5e2cca 100644 --- a/crates/project/src/worktree_tests.rs +++ b/crates/project/src/worktree_tests.rs @@ -703,31 +703,33 @@ async fn test_dirs_no_longer_ignored(cx: &mut TestAppContext) { assert_eq!(read_dir_count_3 - read_dir_count_2, 2); } -#[gpui::test] +#[gpui::test(iterations = 10)] async fn test_rescan_with_gitignore(cx: &mut TestAppContext) { - // .gitignores are handled explicitly by Zed and do not use the git - // machinery that the git_tests module checks - let parent_dir = temp_tree(json!({ - ".gitignore": "ancestor-ignored-file1\nancestor-ignored-file2\n", - "tree": { - ".git": {}, - ".gitignore": "ignored-dir\n", - "tracked-dir": { - "tracked-file1": "", - "ancestor-ignored-file1": "", - }, - "ignored-dir": { - "ignored-file1": "" + let fs = FakeFs::new(cx.background()); + fs.insert_tree( + "/root", + json!({ + ".gitignore": "ancestor-ignored-file1\nancestor-ignored-file2\n", + "tree": { + ".git": {}, + ".gitignore": "ignored-dir\n", + "tracked-dir": { + "tracked-file1": "", + "ancestor-ignored-file1": "", + }, + "ignored-dir": { + "ignored-file1": "" + } } - } - })); - let dir = parent_dir.path().join("tree"); + }), + ) + .await; let tree = Worktree::local( build_client(cx), - dir.as_path(), + "/root/tree".as_ref(), true, - Arc::new(RealFs), + fs.clone(), Default::default(), &mut cx.to_async(), ) @@ -764,10 +766,26 @@ async fn test_rescan_with_gitignore(cx: &mut TestAppContext) { ); }); - std::fs::write(dir.join("tracked-dir/tracked-file2"), "").unwrap(); - std::fs::write(dir.join("tracked-dir/ancestor-ignored-file2"), "").unwrap(); - std::fs::write(dir.join("ignored-dir/ignored-file2"), "").unwrap(); - tree.flush_fs_events(cx).await; + fs.create_file( + "/root/tree/tracked-dir/tracked-file2".as_ref(), + Default::default(), + ) + .await + .unwrap(); + fs.create_file( + "/root/tree/tracked-dir/ancestor-ignored-file2".as_ref(), + Default::default(), + ) + .await + .unwrap(); + fs.create_file( + "/root/tree/ignored-dir/ignored-file2".as_ref(), + Default::default(), + ) + .await + .unwrap(); + + cx.foreground().run_until_parked(); cx.read(|cx| { let tree = tree.read(cx); assert!( From 5d02b490582f47ebc8641825755ac250d7aad992 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 27 Jun 2023 19:19:08 -0700 Subject: [PATCH 191/215] Added muted and currently speaking tracking --- crates/call/src/participant.rs | 1 + crates/call/src/room.rs | 39 ++++++++++- crates/collab_ui/src/collab_titlebar_item.rs | 31 +++++++-- .../Sources/LiveKitBridge/LiveKitBridge.swift | 21 ++++++ crates/live_kit_client/examples/test_app.rs | 39 ++++++++++- crates/live_kit_client/src/prod.rs | 64 ++++++++++++++++++- crates/live_kit_client/src/test.rs | 1 + script/start-local-collaboration | 2 +- 8 files changed, 185 insertions(+), 13 deletions(-) diff --git a/crates/call/src/participant.rs b/crates/call/src/participant.rs index 9773e837c3..e7858869ce 100644 --- a/crates/call/src/participant.rs +++ b/crates/call/src/participant.rs @@ -44,6 +44,7 @@ pub struct RemoteParticipant { pub projects: Vec, pub location: ParticipantLocation, pub muted: bool, + pub speaking: bool, pub video_tracks: HashMap>, pub audio_tracks: HashMap>, } diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 7b7ec89a5e..e5f000c34b 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -164,6 +164,7 @@ impl Room { microphone_track: LocalTrack::None, next_publish_id: 0, deafened: false, + speaking: false, _maintain_room, _maintain_tracks: [_maintain_video_tracks, _maintain_audio_tracks], }) @@ -648,6 +649,7 @@ impl Room { projects: participant.projects, location, muted: false, + speaking: false, video_tracks: Default::default(), audio_tracks: Default::default(), }, @@ -782,6 +784,30 @@ impl Room { cx: &mut ModelContext, ) -> Result<()> { match change { + RemoteAudioTrackUpdate::ActiveSpeakersChanged { speakers } => { + let mut speaker_ids = speakers + .into_iter() + .filter_map(|speaker_sid| speaker_sid.parse().ok()) + .collect::>(); + speaker_ids.sort_unstable(); + for (sid, participant) in &mut self.remote_participants { + if let Ok(_) = speaker_ids.binary_search(sid) { + participant.speaking = true; + } else { + participant.speaking = false; + } + } + if let Some(id) = self.client.user_id() { + if let Some(room) = &mut self.live_kit { + if let Ok(_) = speaker_ids.binary_search(&id) { + room.speaking = true; + } else { + room.speaking = false; + } + } + } + cx.notify(); + } RemoteAudioTrackUpdate::MuteChanged { track_id, muted } => { for participant in &mut self.remote_participants.values_mut() { let mut found = false; @@ -796,6 +822,7 @@ impl Room { break; } } + cx.notify(); } RemoteAudioTrackUpdate::Subscribed(track) => { let user_id = track.publisher_id().parse()?; @@ -1011,7 +1038,7 @@ impl Room { }) } - pub fn is_muted(&self) -> Option { + pub fn is_muted(&self) -> bool { self.live_kit .as_ref() .and_then(|live_kit| match &live_kit.microphone_track { @@ -1019,6 +1046,13 @@ impl Room { LocalTrack::Pending { muted, .. } => Some(*muted), LocalTrack::Published { muted, .. } => Some(*muted), }) + .unwrap_or(false) + } + + pub fn is_speaking(&self) -> bool { + self.live_kit + .as_ref() + .map_or(false, |live_kit| live_kit.speaking) } pub fn is_deafened(&self) -> Option { @@ -1215,7 +1249,7 @@ impl Room { } } pub fn toggle_mute(&mut self, cx: &mut ModelContext) -> Result>> { - let should_mute = self.is_muted().unwrap_or(false); + let should_mute = self.is_muted(); if let Some(live_kit) = self.live_kit.as_mut() { Self::set_mute(live_kit, !should_mute, cx) } else { @@ -1298,6 +1332,7 @@ struct LiveKitRoom { screen_track: LocalTrack, microphone_track: LocalTrack, deafened: bool, + speaking: bool, next_publish_id: usize, _maintain_room: Task<()>, _maintain_tracks: [Task<()>; 2], diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 708fb89e86..e23320f827 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -86,8 +86,10 @@ impl View for CollabTitlebarItem { right_container .add_children(self.render_in_call_share_unshare_button(&workspace, &theme, cx)); right_container.add_child(self.render_leave_call(&theme, cx)); + let muted = room.read(cx).is_muted(); + let speaking = room.read(cx).is_speaking(); left_container - .add_child(self.render_current_user(&workspace, &theme, &user, peer_id, cx)); + .add_child(self.render_current_user(&workspace, &theme, &user, peer_id, muted, speaking, cx)); left_container.add_children(self.render_collaborators(&workspace, &theme, &room, cx)); right_container.add_child(self.render_toggle_mute(&theme, &room, cx)); right_container.add_child(self.render_toggle_deafen(&theme, &room, cx)); @@ -449,7 +451,7 @@ impl CollabTitlebarItem { ) -> AnyElement { let icon; let tooltip; - let is_muted = room.read(cx).is_muted().unwrap_or(false); + let is_muted = room.read(cx).is_muted(); if is_muted { icon = "icons/radix/mic-mute.svg"; tooltip = "Unmute microphone\nRight click for options"; @@ -766,6 +768,8 @@ impl CollabTitlebarItem { replica_id, participant.peer_id, Some(participant.location), + participant.muted, + participant.speaking, workspace, theme, cx, @@ -782,14 +786,19 @@ impl CollabTitlebarItem { theme: &Theme, user: &Arc, peer_id: PeerId, + muted: bool, + speaking: bool, cx: &mut ViewContext, ) -> AnyElement { let replica_id = workspace.read(cx).project().read(cx).replica_id(); + Container::new(self.render_face_pile( user, Some(replica_id), peer_id, None, + muted, + speaking, workspace, theme, cx, @@ -804,6 +813,8 @@ impl CollabTitlebarItem { replica_id: Option, peer_id: PeerId, location: Option, + muted: bool, + speaking: bool, workspace: &ViewHandle, theme: &Theme, cx: &mut ViewContext, @@ -829,11 +840,17 @@ impl CollabTitlebarItem { let leader_style = theme.titlebar.leader_avatar; let follower_style = theme.titlebar.follower_avatar; - let mut background_color = theme - .titlebar - .container - .background_color - .unwrap_or_default(); + let mut background_color = if muted { + gpui::color::Color::red() + } else if speaking { + gpui::color::Color::green() + } else { + theme + .titlebar + .container + .background_color + .unwrap_or_default() + }; if let Some(replica_id) = replica_id { if followed_by_self { let selection = theme.editor.replica_selection_style(replica_id).selection; diff --git a/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift b/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift index 74d43d7865..40d3641db2 100644 --- a/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift +++ b/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift @@ -8,6 +8,8 @@ class LKRoomDelegate: RoomDelegate { var onDidDisconnect: @convention(c) (UnsafeRawPointer) -> Void var onDidSubscribeToRemoteAudioTrack: @convention(c) (UnsafeRawPointer, CFString, CFString, UnsafeRawPointer) -> Void var onDidUnsubscribeFromRemoteAudioTrack: @convention(c) (UnsafeRawPointer, CFString, CFString) -> Void + var onMuteChangedFromRemoteAudioTrack: @convention(c) (UnsafeRawPointer, CFString, Bool) -> Void + var onActiveSpeakersChanged: @convention(c) (UnsafeRawPointer, CFArray) -> Void var onDidSubscribeToRemoteVideoTrack: @convention(c) (UnsafeRawPointer, CFString, CFString, UnsafeRawPointer) -> Void var onDidUnsubscribeFromRemoteVideoTrack: @convention(c) (UnsafeRawPointer, CFString, CFString) -> Void @@ -16,6 +18,8 @@ class LKRoomDelegate: RoomDelegate { onDidDisconnect: @escaping @convention(c) (UnsafeRawPointer) -> Void, onDidSubscribeToRemoteAudioTrack: @escaping @convention(c) (UnsafeRawPointer, CFString, CFString, UnsafeRawPointer) -> Void, onDidUnsubscribeFromRemoteAudioTrack: @escaping @convention(c) (UnsafeRawPointer, CFString, CFString) -> Void, + onMuteChangedFromRemoteAudioTrack: @escaping @convention(c) (UnsafeRawPointer, CFString, Bool) -> Void, + onActiveSpeakersChanged: @convention(c) (UnsafeRawPointer, CFArray) -> Void, onDidSubscribeToRemoteVideoTrack: @escaping @convention(c) (UnsafeRawPointer, CFString, CFString, UnsafeRawPointer) -> Void, onDidUnsubscribeFromRemoteVideoTrack: @escaping @convention(c) (UnsafeRawPointer, CFString, CFString) -> Void) { @@ -25,6 +29,8 @@ class LKRoomDelegate: RoomDelegate { self.onDidUnsubscribeFromRemoteAudioTrack = onDidUnsubscribeFromRemoteAudioTrack self.onDidSubscribeToRemoteVideoTrack = onDidSubscribeToRemoteVideoTrack self.onDidUnsubscribeFromRemoteVideoTrack = onDidUnsubscribeFromRemoteVideoTrack + self.onMuteChangedFromRemoteAudioTrack = onMuteChangedFromRemoteAudioTrack + self.onActiveSpeakersChanged = onActiveSpeakersChanged } func room(_ room: Room, didUpdate connectionState: ConnectionState, oldValue: ConnectionState) { @@ -41,6 +47,17 @@ class LKRoomDelegate: RoomDelegate { } } + func room(_ room: Room, participant: Participant, didUpdate publication: TrackPublication, muted: Bool) { + if publication.kind == .audio { + self.onMuteChangedFromRemoteAudioTrack(self.data, publication.sid as CFString, muted) + } + } + + func room(_ room: Room, didUpdate speakers: [Participant]) { + guard let speaker_ids = speakers.compactMap({ $0.identity as CFString }) as CFArray? else { return } + self.onActiveSpeakersChanged(self.data, speaker_ids) + } + func room(_ room: Room, participant: RemoteParticipant, didUnsubscribe publication: RemoteTrackPublication, track: Track) { if track.kind == .video { self.onDidUnsubscribeFromRemoteVideoTrack(self.data, participant.identity as CFString, track.sid! as CFString) @@ -89,6 +106,8 @@ public func LKRoomDelegateCreate( onDidDisconnect: @escaping @convention(c) (UnsafeRawPointer) -> Void, onDidSubscribeToRemoteAudioTrack: @escaping @convention(c) (UnsafeRawPointer, CFString, CFString, UnsafeRawPointer) -> Void, onDidUnsubscribeFromRemoteAudioTrack: @escaping @convention(c) (UnsafeRawPointer, CFString, CFString) -> Void, + onMuteChangedFromRemoteAudioTrack: @escaping @convention(c) (UnsafeRawPointer, CFString, Bool) -> Void, + onActiveSpeakerChanged: @escaping @convention(c) (UnsafeRawPointer, CFArray) -> Void, onDidSubscribeToRemoteVideoTrack: @escaping @convention(c) (UnsafeRawPointer, CFString, CFString, UnsafeRawPointer) -> Void, onDidUnsubscribeFromRemoteVideoTrack: @escaping @convention(c) (UnsafeRawPointer, CFString, CFString) -> Void ) -> UnsafeMutableRawPointer { @@ -97,6 +116,8 @@ public func LKRoomDelegateCreate( onDidDisconnect: onDidDisconnect, onDidSubscribeToRemoteAudioTrack: onDidSubscribeToRemoteAudioTrack, onDidUnsubscribeFromRemoteAudioTrack: onDidUnsubscribeFromRemoteAudioTrack, + onMuteChangedFromRemoteAudioTrack: onMuteChangedFromRemoteAudioTrack, + onActiveSpeakersChanged: onActiveSpeakerChanged, onDidSubscribeToRemoteVideoTrack: onDidSubscribeToRemoteVideoTrack, onDidUnsubscribeFromRemoteVideoTrack: onDidUnsubscribeFromRemoteVideoTrack ) diff --git a/crates/live_kit_client/examples/test_app.rs b/crates/live_kit_client/examples/test_app.rs index faf1b54798..4fc02d9a9d 100644 --- a/crates/live_kit_client/examples/test_app.rs +++ b/crates/live_kit_client/examples/test_app.rs @@ -74,19 +74,54 @@ fn main() { panic!("unexpected message"); } + audio_track_publication.set_mute(true).await.unwrap(); + + println!("waiting for mute changed!"); + if let RemoteAudioTrackUpdate::MuteChanged { track_id, muted } = + audio_track_updates.next().await.unwrap() + { + let remote_tracks = room_b.remote_audio_tracks("test-participant-1"); + assert_eq!(remote_tracks[0].sid(), track_id); + assert_eq!(muted, true); + } else { + panic!("unexpected message"); + } + + audio_track_publication.set_mute(false).await.unwrap(); + + if let RemoteAudioTrackUpdate::MuteChanged { track_id, muted } = + audio_track_updates.next().await.unwrap() + { + let remote_tracks = room_b.remote_audio_tracks("test-participant-1"); + assert_eq!(remote_tracks[0].sid(), track_id); + assert_eq!(muted, false); + } else { + panic!("unexpected message"); + } + println!("Pausing for 5 seconds to test audio, make some noise!"); let timer = cx.background().timer(Duration::from_secs(5)); timer.await; - let remote_audio_track = room_b .remote_audio_tracks("test-participant-1") .pop() .unwrap(); room_a.unpublish_track(audio_track_publication); + + // Clear out any active speakers changed messages + let mut next = audio_track_updates.next().await.unwrap(); + while let RemoteAudioTrackUpdate::ActiveSpeakersChanged { + speakers + } = next + { + println!("Speakers changed: {:?}", speakers); + next = audio_track_updates.next().await.unwrap(); + } + if let RemoteAudioTrackUpdate::Unsubscribed { publisher_id, track_id, - } = audio_track_updates.next().await.unwrap() + } = next { assert_eq!(publisher_id, "test-participant-1"); assert_eq!(remote_audio_track.sid(), track_id); diff --git a/crates/live_kit_client/src/prod.rs b/crates/live_kit_client/src/prod.rs index 96bf40ca4e..bdbba87b51 100644 --- a/crates/live_kit_client/src/prod.rs +++ b/crates/live_kit_client/src/prod.rs @@ -32,6 +32,15 @@ extern "C" { publisher_id: CFStringRef, track_id: CFStringRef, ), + on_mute_changed_from_remote_audio_track: extern "C" fn( + callback_data: *mut c_void, + track_id: CFStringRef, + muted: bool, + ), + on_active_speakers_changed: extern "C" fn( + callback_data: *mut c_void, + participants: CFArrayRef, + ), on_did_subscribe_to_remote_video_track: extern "C" fn( callback_data: *mut c_void, publisher_id: CFStringRef, @@ -381,6 +390,24 @@ impl Room { }); } + fn mute_changed_from_remote_audio_track(&self, track_id: String, muted: bool) { + self.remote_audio_track_subscribers.lock().retain(|tx| { + tx.unbounded_send(RemoteAudioTrackUpdate::MuteChanged { + track_id: track_id.clone(), + muted, + }) + .is_ok() + }); + } + + // A vec of publisher IDs + fn active_speakers_changed(&self, speakers: Vec) { + self.remote_audio_track_subscribers.lock().retain(move |tx| { + tx.unbounded_send(RemoteAudioTrackUpdate::ActiveSpeakersChanged { speakers: speakers.clone() }) + .is_ok() + }); + } + fn did_subscribe_to_remote_video_track(&self, track: RemoteVideoTrack) { let track = Arc::new(track); self.remote_video_track_subscribers.lock().retain(|tx| { @@ -445,6 +472,8 @@ impl RoomDelegate { Self::on_did_disconnect, Self::on_did_subscribe_to_remote_audio_track, Self::on_did_unsubscribe_from_remote_audio_track, + Self::on_mute_change_from_remote_audio_track, + Self::on_active_speakers_changed, Self::on_did_subscribe_to_remote_video_track, Self::on_did_unsubscribe_from_remote_video_track, ) @@ -493,6 +522,38 @@ impl RoomDelegate { let _ = Weak::into_raw(room); } + extern "C" fn on_mute_change_from_remote_audio_track( + room: *mut c_void, + track_id: CFStringRef, + muted: bool, + ) { + let room = unsafe { Weak::from_raw(room as *mut Room) }; + let track_id = unsafe { CFString::wrap_under_get_rule(track_id).to_string() }; + if let Some(room) = room.upgrade() { + room.mute_changed_from_remote_audio_track(track_id, muted); + } + let _ = Weak::into_raw(room); + } + + extern "C" fn on_active_speakers_changed(room: *mut c_void, participants: CFArrayRef) { + if participants.is_null() { + return; + } + + let room = unsafe { Weak::from_raw(room as *mut Room) }; + let speakers = unsafe { + CFArray::wrap_under_get_rule(participants) + .into_iter() + .map(|speaker: core_foundation::base::ItemRef<'_, *const c_void>| CFString::wrap_under_get_rule(*speaker as CFStringRef).to_string()) + .collect() + }; + + if let Some(room) = room.upgrade() { + room.active_speakers_changed(speakers); + } + let _ = Weak::into_raw(room); + } + extern "C" fn on_did_subscribe_to_remote_video_track( room: *mut c_void, publisher_id: CFStringRef, @@ -761,7 +822,8 @@ pub enum RemoteVideoTrackUpdate { } pub enum RemoteAudioTrackUpdate { - MuteChanged { track_id: Sid, muted: bool}, + ActiveSpeakersChanged { speakers: Vec }, + MuteChanged { track_id: Sid, muted: bool }, Subscribed(Arc), Unsubscribed { publisher_id: Sid, track_id: Sid }, } diff --git a/crates/live_kit_client/src/test.rs b/crates/live_kit_client/src/test.rs index 286c7215e9..809a1f5d29 100644 --- a/crates/live_kit_client/src/test.rs +++ b/crates/live_kit_client/src/test.rs @@ -580,6 +580,7 @@ pub enum RemoteVideoTrackUpdate { #[derive(Clone)] pub enum RemoteAudioTrackUpdate { + ActiveSpeakersChanged { speakers: Vec }, MuteChanged { track_id: Sid, muted: bool}, Subscribed(Arc), Unsubscribed { publisher_id: Sid, track_id: Sid }, diff --git a/script/start-local-collaboration b/script/start-local-collaboration index b8632c4c22..b702fb4e02 100755 --- a/script/start-local-collaboration +++ b/script/start-local-collaboration @@ -54,5 +54,5 @@ sleep 0.5 # Start the two Zed child processes. Open the given paths with the first instance. trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT ZED_IMPERSONATE=${username_1} ZED_WINDOW_POSITION=${position_1} target/debug/Zed $@ & -ZED_IMPERSONATE=${username_2} ZED_WINDOW_POSITION=${position_2} target/debug/Zed & +SECOND=true ZED_IMPERSONATE=${username_2} ZED_WINDOW_POSITION=${position_2} target/debug/Zed & wait From 749f60ba8199f64b12fe877082f7f4263d234cf5 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 27 Jun 2023 19:25:46 -0700 Subject: [PATCH 192/215] fmt --- crates/collab_ui/src/collab_titlebar_item.rs | 5 +++-- crates/live_kit_client/examples/test_app.rs | 5 +---- crates/live_kit_client/src/prod.rs | 16 ++++++++++++---- crates/live_kit_client/src/test.rs | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index e23320f827..ae80e59f22 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -88,8 +88,9 @@ impl View for CollabTitlebarItem { right_container.add_child(self.render_leave_call(&theme, cx)); let muted = room.read(cx).is_muted(); let speaking = room.read(cx).is_speaking(); - left_container - .add_child(self.render_current_user(&workspace, &theme, &user, peer_id, muted, speaking, cx)); + left_container.add_child( + self.render_current_user(&workspace, &theme, &user, peer_id, muted, speaking, cx), + ); left_container.add_children(self.render_collaborators(&workspace, &theme, &room, cx)); right_container.add_child(self.render_toggle_mute(&theme, &room, cx)); right_container.add_child(self.render_toggle_deafen(&theme, &room, cx)); diff --git a/crates/live_kit_client/examples/test_app.rs b/crates/live_kit_client/examples/test_app.rs index 4fc02d9a9d..f5f6d0e46f 100644 --- a/crates/live_kit_client/examples/test_app.rs +++ b/crates/live_kit_client/examples/test_app.rs @@ -110,10 +110,7 @@ fn main() { // Clear out any active speakers changed messages let mut next = audio_track_updates.next().await.unwrap(); - while let RemoteAudioTrackUpdate::ActiveSpeakersChanged { - speakers - } = next - { + while let RemoteAudioTrackUpdate::ActiveSpeakersChanged { speakers } = next { println!("Speakers changed: {:?}", speakers); next = audio_track_updates.next().await.unwrap(); } diff --git a/crates/live_kit_client/src/prod.rs b/crates/live_kit_client/src/prod.rs index bdbba87b51..6daa0601ca 100644 --- a/crates/live_kit_client/src/prod.rs +++ b/crates/live_kit_client/src/prod.rs @@ -402,10 +402,14 @@ impl Room { // A vec of publisher IDs fn active_speakers_changed(&self, speakers: Vec) { - self.remote_audio_track_subscribers.lock().retain(move |tx| { - tx.unbounded_send(RemoteAudioTrackUpdate::ActiveSpeakersChanged { speakers: speakers.clone() }) + self.remote_audio_track_subscribers + .lock() + .retain(move |tx| { + tx.unbounded_send(RemoteAudioTrackUpdate::ActiveSpeakersChanged { + speakers: speakers.clone(), + }) .is_ok() - }); + }); } fn did_subscribe_to_remote_video_track(&self, track: RemoteVideoTrack) { @@ -544,7 +548,11 @@ impl RoomDelegate { let speakers = unsafe { CFArray::wrap_under_get_rule(participants) .into_iter() - .map(|speaker: core_foundation::base::ItemRef<'_, *const c_void>| CFString::wrap_under_get_rule(*speaker as CFStringRef).to_string()) + .map( + |speaker: core_foundation::base::ItemRef<'_, *const c_void>| { + CFString::wrap_under_get_rule(*speaker as CFStringRef).to_string() + }, + ) .collect() }; diff --git a/crates/live_kit_client/src/test.rs b/crates/live_kit_client/src/test.rs index 809a1f5d29..3fc046c5a2 100644 --- a/crates/live_kit_client/src/test.rs +++ b/crates/live_kit_client/src/test.rs @@ -581,7 +581,7 @@ pub enum RemoteVideoTrackUpdate { #[derive(Clone)] pub enum RemoteAudioTrackUpdate { ActiveSpeakersChanged { speakers: Vec }, - MuteChanged { track_id: Sid, muted: bool}, + MuteChanged { track_id: Sid, muted: bool }, Subscribed(Arc), Unsubscribed { publisher_id: Sid, track_id: Sid }, } From d41a7f41fb9684632db0a127b1478d10fc05507a Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 28 Jun 2023 10:00:28 +0200 Subject: [PATCH 193/215] Space out assistant icons to match pane icons Co-Authored-By: Antonio Scandurra --- styles/src/styleTree/assistant.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index 91b52f20ad..d61c73ec53 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -26,7 +26,7 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - margin: { left: 12 }, + padding: { left: 8.5, right: 8.5 }, } }, state: { @@ -48,7 +48,7 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - margin: { left: 12 }, + padding: { left: 8.5, right: 8.5 }, } }, state: { @@ -70,7 +70,7 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - margin: { left: 12 }, + padding: { left: 8.5, right: 8.5 }, } }, state: { @@ -92,7 +92,7 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - margin: { left: 12, right: 24 }, + padding: { left: 8.5, right: 8.5 }, } }, state: { @@ -114,7 +114,7 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - margin: { right: 12 }, + padding: { left: 10, right: 10 }, } }, state: { @@ -136,7 +136,7 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - margin: { right: 12 }, + padding: { left: 10, right: 10 }, } }, state: { @@ -158,7 +158,7 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - margin: { right: 12 }, + padding: { left: 10, right: 10 }, } }, state: { From f52d3ea5ef3fa57d043be9d3ccebaa7933f6819d Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 28 Jun 2023 10:27:29 +0200 Subject: [PATCH 194/215] Clean up tooltips, create conversation on cmd-n Co-Authored-By: Antonio Scandurra --- assets/keymaps/default.json | 4 +- crates/ai/src/assistant.rs | 70 ++++++++++++++++++++----------- crates/workspace/src/pane.rs | 30 ++++++++----- styles/src/styleTree/assistant.ts | 3 +- 4 files changed, 68 insertions(+), 39 deletions(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index 853d62f3e4..d08df1f391 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -200,8 +200,8 @@ { "context": "AssistantPanel", "bindings": { - "cmd-g": "search::SelectNextMatch", - "cmd-shift-g": "search::SelectPrevMatch" + "cmd-g": "search::SelectNextMatch", + "cmd-shift-g": "search::SelectPrevMatch" } }, { diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 01693425fb..dde527d89c 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -51,7 +51,7 @@ const OPENAI_API_URL: &'static str = "https://api.openai.com/v1"; actions!( assistant, [ - NewContext, + NewConversation, Assist, Split, CycleMessageRole, @@ -70,14 +70,10 @@ pub fn init(cx: &mut AppContext) { settings::register::(cx); cx.add_action( - |workspace: &mut Workspace, _: &NewContext, cx: &mut ViewContext| { - if let Some(this) = workspace.panel::(cx) { - this.update(cx, |this, cx| { - this.new_conversation(cx); - }) - } - - workspace.focus_panel::(cx); + |this: &mut AssistantPanel, + _: &workspace::NewFile, + cx: &mut ViewContext| { + this.new_conversation(cx); }, ); cx.add_action(ConversationEditor::assist); @@ -344,9 +340,10 @@ impl AssistantPanel { } fn render_hamburger_button(cx: &mut ViewContext) -> impl Element { - enum ListConversations {} + enum History {} let theme = theme::current(cx); - MouseEventHandler::::new(0, cx, |state, _| { + let tooltip_style = theme::current(cx).tooltip.clone(); + MouseEventHandler::::new(0, cx, |state, _| { let style = theme.assistant.hamburger_button.style_for(state); Svg::for_style(style.icon.clone()) .contained() @@ -360,6 +357,7 @@ impl AssistantPanel { this.set_active_editor_index(this.prev_active_editor_index, cx); } }) + .with_tooltip::(1, "History".into(), None, tooltip_style, cx) } fn render_editor_tools(&self, cx: &mut ViewContext) -> Vec> { @@ -443,7 +441,7 @@ impl AssistantPanel { }) .with_tooltip::( 1, - "Assist".into(), + "Quote Selection".into(), Some(Box::new(QuoteSelection)), tooltip_style, cx, @@ -451,9 +449,9 @@ impl AssistantPanel { } fn render_plus_button(cx: &mut ViewContext) -> impl Element { - enum AddConversation {} let theme = theme::current(cx); - MouseEventHandler::::new(0, cx, |state, _| { + let tooltip_style = theme::current(cx).tooltip.clone(); + MouseEventHandler::::new(0, cx, |state, _| { let style = theme.assistant.plus_button.style_for(state); Svg::for_style(style.icon.clone()) .contained() @@ -463,12 +461,20 @@ impl AssistantPanel { .on_click(MouseButton::Left, |_, this: &mut Self, cx| { this.new_conversation(cx); }) + .with_tooltip::( + 1, + "New Conversation".into(), + Some(Box::new(NewConversation)), + tooltip_style, + cx, + ) } fn render_zoom_button(&self, cx: &mut ViewContext) -> impl Element { enum ToggleZoomButton {} let theme = theme::current(cx); + let tooltip_style = theme::current(cx).tooltip.clone(); let style = if self.zoomed { &theme.assistant.zoom_out_button } else { @@ -485,6 +491,17 @@ impl AssistantPanel { .on_click(MouseButton::Left, |_, this, cx| { this.toggle_zoom(&ToggleZoom, cx); }) + .with_tooltip::( + 0, + if self.zoomed { + "Zoom Out".into() + } else { + "Zoom In".into() + }, + Some(Box::new(ToggleZoom)), + tooltip_style, + cx, + ) } fn render_saved_conversation( @@ -610,19 +627,22 @@ impl View for AssistantPanel { .left() .flex(1., false) }); + let mut header = Flex::row() + .with_child(Self::render_hamburger_button(cx).aligned()) + .with_children(title); + if self.has_focus { + header.add_children( + self.render_editor_tools(cx) + .into_iter() + .map(|tool| tool.aligned().flex_float()), + ); + header.add_child(Self::render_plus_button(cx).aligned().flex_float()); + header.add_child(self.render_zoom_button(cx).aligned()); + } Flex::column() .with_child( - Flex::row() - .with_child(Self::render_hamburger_button(cx).aligned()) - .with_children(title) - .with_children( - self.render_editor_tools(cx) - .into_iter() - .map(|tool| tool.aligned().flex_float()), - ) - .with_child(Self::render_plus_button(cx).aligned().flex_float()) - .with_child(self.render_zoom_button(cx).aligned()) + header .contained() .with_style(theme.workspace.tab_bar.container) .expanded() @@ -658,6 +678,7 @@ impl View for AssistantPanel { self.has_focus = true; self.toolbar .update(cx, |toolbar, cx| toolbar.focus_changed(true, cx)); + cx.notify(); if cx.is_self_focused() { if let Some(editor) = self.active_editor() { cx.focus(editor); @@ -671,6 +692,7 @@ impl View for AssistantPanel { self.has_focus = false; self.toolbar .update(cx, |toolbar, cx| toolbar.focus_changed(false, cx)); + cx.notify(); } } diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 54b18ea8b3..9776fede2c 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -286,19 +286,27 @@ impl Pane { pane.tab_bar_context_menu .handle_if_kind(TabBarContextMenuKind::Split), )) - .with_child(Pane::render_tab_bar_button( - 2, + .with_child({ + let icon_path; + let tooltip_label; if pane.is_zoomed() { - "icons/minimize_8.svg" + icon_path = "icons/minimize_8.svg"; + tooltip_label = "Zoom In".into(); } else { - "icons/maximize_8.svg" - }, - pane.is_zoomed(), - Some(("Toggle Zoom".into(), Some(Box::new(ToggleZoom)))), - cx, - move |pane, cx| pane.toggle_zoom(&Default::default(), cx), - None, - )) + icon_path = "icons/maximize_8.svg"; + tooltip_label = "Zoom In".into(); + } + + Pane::render_tab_bar_button( + 2, + icon_path, + pane.is_zoomed(), + Some((tooltip_label, Some(Box::new(ToggleZoom)))), + cx, + move |pane, cx| pane.toggle_zoom(&Default::default(), cx), + None, + ) + }) .into_any() }), } diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index d61c73ec53..e3c8e455ea 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -26,7 +26,7 @@ export default function assistant(colorScheme: ColorScheme) { }, }, container: { - padding: { left: 8.5, right: 8.5 }, + padding: { left: 12, right: 8.5 }, } }, state: { @@ -170,7 +170,6 @@ export default function assistant(colorScheme: ColorScheme) { } }), title: { - margin: { left: 12 }, ...text(layer, "sans", "default", { size: "sm" }) }, savedConversation: { From 83fc7b9b7c77ffb31692a191cf10da192f6f559b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 28 Jun 2023 10:32:06 +0200 Subject: [PATCH 195/215] Avoid scrolling to the new cursor position so the assistant's output is stable Co-Authored-By: Antonio Scandurra --- crates/ai/src/assistant.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index dde527d89c..7631381273 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -1681,6 +1681,8 @@ impl ConversationEditor { |selections| selections.select_ranges(new_selections), ); }); + // Avoid scrolling to the new cursor position so the assistant's output is stable. + cx.defer(|this, _| this.scroll_position = None); } } From 7efcd6060864d63cbebbb603053052818cfb43e1 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 28 Jun 2023 10:54:44 +0200 Subject: [PATCH 196/215] Remove border from assistant message header Also: Increase right margin on token count to space it from the scrollbar. Co-Authored-By: Antonio Scandurra --- styles/src/styleTree/assistant.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index e3c8e455ea..b6e97303f2 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -11,7 +11,6 @@ export default function assistant(colorScheme: ColorScheme) { padding: { left: 12 }, }, messageHeader: { - border: border(layer, "default", { bottom: true, top: true }), margin: { bottom: 6, top: 6 }, background: editor(colorScheme).background, }, @@ -238,14 +237,14 @@ export default function assistant(colorScheme: ColorScheme) { }), remainingTokens: { background: background(layer, "on"), - margin: { top: 12, right: 12 }, + margin: { top: 12, right: 24 }, padding: 4, cornerRadius: 4, ...text(layer, "sans", "positive", { size: "xs" }), }, noRemainingTokens: { background: background(layer, "on"), - margin: { top: 12, right: 12 }, + margin: { top: 12, right: 24 }, padding: 4, cornerRadius: 4, ...text(layer, "sans", "negative", { size: "xs" }), From 2ddf0e12bfd214d46efca8d36e8ea4fede4e7a35 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 28 Jun 2023 11:10:56 +0200 Subject: [PATCH 197/215] Undeafen: unmute if user was not muted prior to deafening --- crates/call/src/room.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index e5f000c34b..da298f9ca2 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -163,6 +163,7 @@ impl Room { screen_track: LocalTrack::None, microphone_track: LocalTrack::None, next_publish_id: 0, + muted_by_user: false, deafened: false, speaking: false, _maintain_room, @@ -1231,6 +1232,10 @@ impl Room { should_mute: bool, cx: &mut ModelContext, ) -> Result>> { + if !should_mute { + // clear user muting state. + live_kit.muted_by_user = false; + } match &mut live_kit.microphone_track { LocalTrack::None => Err(anyhow!("microphone was not shared")), LocalTrack::Pending { muted, .. } => { @@ -1249,9 +1254,11 @@ impl Room { } } pub fn toggle_mute(&mut self, cx: &mut ModelContext) -> Result>> { - let should_mute = self.is_muted(); + let should_mute = !self.is_muted(); if let Some(live_kit) = self.live_kit.as_mut() { - Self::set_mute(live_kit, !should_mute, cx) + let ret = Self::set_mute(live_kit, should_mute, cx); + live_kit.muted_by_user = should_mute; + ret } else { Err(anyhow!("LiveKit not started")) } @@ -1264,9 +1271,9 @@ impl Room { let mut tasks = Vec::with_capacity(self.remote_participants.len()); // Context notification is sent within set_mute itself. let mut mute_task = None; - if live_kit.deafened { - // Unmute microphone only if we're going from unmuted -> muted state. - // We don't want to unmute user automatically. + // When deafening, mute user's mic as well. + // When undeafening, unmute user's mic unless it was manually muted prior to deafening. + if live_kit.deafened || !live_kit.muted_by_user { mute_task = Some(Self::set_mute(live_kit, live_kit.deafened, cx)?); }; for participant in self.remote_participants.values() { @@ -1331,6 +1338,8 @@ struct LiveKitRoom { room: Arc, screen_track: LocalTrack, microphone_track: LocalTrack, + /// Tracks whether we're currently in a muted state due to auto-mute from deafening or manual mute performed by user. + muted_by_user: bool, deafened: bool, speaking: bool, next_publish_id: usize, From 8f8a99d7886de6543a0f21d03024d3862d5cbbb4 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 28 Jun 2023 11:43:24 +0200 Subject: [PATCH 198/215] Bind cmd-? to assistant::toggle_focus Bypass system help menu shortcut at the app delegate level to achieve this. Co-Authored-By: Antonio Scandurra --- assets/keymaps/default.json | 1 + crates/gpui/src/app.rs | 23 +++++++++++++++++++++++ crates/gpui/src/platform/mac/platform.rs | 1 - crates/zed/src/main.rs | 2 -- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index d08df1f391..6fc06198fe 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -408,6 +408,7 @@ "cmd-shift-p": "command_palette::Toggle", "cmd-shift-m": "diagnostics::Deploy", "cmd-shift-e": "project_panel::ToggleFocus", + "cmd-?": "assistant::ToggleFocus", "cmd-alt-s": "workspace::SaveAll", "cmd-k m": "language_selector::Toggle" } diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 41684f3226..20043a9093 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -152,6 +152,29 @@ impl App { asset_source, )))); + foreground_platform.on_event(Box::new({ + let cx = app.0.clone(); + move |event| { + if let Event::KeyDown(KeyDownEvent { keystroke, .. }) = &event { + // Allow system menu "cmd-?" shortcut to be overridden + if keystroke.cmd + && !keystroke.shift + && !keystroke.alt + && !keystroke.function + && keystroke.key == "?" + { + if cx + .borrow_mut() + .update_active_window(|cx| cx.dispatch_keystroke(keystroke)) + .unwrap_or(false) + { + return true; + } + } + } + false + } + })); foreground_platform.on_quit(Box::new({ let cx = app.0.clone(); move || { diff --git a/crates/gpui/src/platform/mac/platform.rs b/crates/gpui/src/platform/mac/platform.rs index ea415cc6a6..e1d80fe25c 100644 --- a/crates/gpui/src/platform/mac/platform.rs +++ b/crates/gpui/src/platform/mac/platform.rs @@ -939,7 +939,6 @@ extern "C" fn send_event(this: &mut Object, _sel: Sel, native_event: id) { } } } - msg_send![super(this, class!(NSApplication)), sendEvent: native_event] } } diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 5d94622d47..58229d3951 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -72,8 +72,6 @@ fn main() { let installation_id = app.background().block(installation_id()).ok(); init_panic_hook(&app, installation_id.clone()); - app.background(); - load_embedded_fonts(&app); let fs = Arc::new(RealFs); From 2cb4616609aaa8fc6940530aa3cefb03fe294243 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 28 Jun 2023 12:09:49 +0200 Subject: [PATCH 199/215] Enable assistant on stable Co-Authored-By: Nathan Sobo --- crates/ai/src/assistant.rs | 8 +------- crates/zed/src/zed.rs | 18 ++++++------------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 7631381273..9ca54e661a 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -39,7 +39,7 @@ use std::{ time::Duration, }; use theme::AssistantStyle; -use util::{channel::ReleaseChannel, paths::CONVERSATIONS_DIR, post_inc, ResultExt, TryFutureExt}; +use util::{paths::CONVERSATIONS_DIR, post_inc, ResultExt, TryFutureExt}; use workspace::{ dock::{DockPosition, Panel}, searchable::Direction, @@ -62,12 +62,6 @@ actions!( ); pub fn init(cx: &mut AppContext) { - if *util::channel::RELEASE_CHANNEL == ReleaseChannel::Stable { - cx.update_default_global::(move |filter, _cx| { - filter.filtered_namespaces.insert("assistant"); - }); - } - settings::register::(cx); cx.add_action( |this: &mut AssistantPanel, diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index bcdfe57a46..cbd67a84cf 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -361,15 +361,15 @@ pub fn initialize_workspace( let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone()); let terminal_panel = TerminalPanel::load(workspace_handle.clone(), cx.clone()); - let assistant_panel = if *util::channel::RELEASE_CHANNEL == ReleaseChannel::Stable { - None - } else { - Some(AssistantPanel::load(workspace_handle.clone(), cx.clone()).await?) - }; - let (project_panel, terminal_panel) = futures::try_join!(project_panel, terminal_panel)?; + let assistant_panel = AssistantPanel::load(workspace_handle.clone(), cx.clone()); + let (project_panel, terminal_panel, assistant_panel) = + futures::try_join!(project_panel, terminal_panel, assistant_panel)?; workspace_handle.update(&mut cx, |workspace, cx| { let project_panel_position = project_panel.position(cx); workspace.add_panel(project_panel, cx); + workspace.add_panel(terminal_panel, cx); + workspace.add_panel(assistant_panel, cx); + if !was_deserialized && workspace .project() @@ -383,13 +383,7 @@ pub fn initialize_workspace( { workspace.toggle_dock(project_panel_position, cx); } - cx.focus_self(); - - workspace.add_panel(terminal_panel, cx); - if let Some(assistant_panel) = assistant_panel { - workspace.add_panel(assistant_panel, cx); - } })?; Ok(()) }) From dddff644ca8d198677a1bdc21b7c156ee915e46f Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:00:43 +0200 Subject: [PATCH 200/215] tests: Test 'db' package sequentially (#2654) /cc @as-cii @nathansobo Release Notes: - N/A --- .config/nextest.toml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .config/nextest.toml diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 0000000000..b05d68911f --- /dev/null +++ b/.config/nextest.toml @@ -0,0 +1,6 @@ +[test-groups] +sequential-db-tests = { max-threads = 1 } + +[[profile.default.overrides]] +filter = 'package(db)' +test-group = 'sequential-db-tests' From 456be1f86e5415e43090dc39b4f4e0dde0427841 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:19:32 +0200 Subject: [PATCH 201/215] Hide user menu on second click --- crates/collab_ui/src/collab_titlebar_item.rs | 77 ++++++++++---------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index ae80e59f22..6621aed875 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -49,7 +49,7 @@ pub struct CollabTitlebarItem { client: Arc, workspace: WeakViewHandle, contacts_popover: Option>, - user_menu: ViewHandle, + user_menu: Option>, _subscriptions: Vec, } @@ -170,18 +170,13 @@ impl CollabTitlebarItem { }), ); - let view_id = cx.view_id(); Self { workspace: workspace.weak_handle(), project, user_store, client, contacts_popover: None, - user_menu: cx.add_view(|cx| { - let mut menu = ContextMenu::new(view_id, cx); - menu.set_position_mode(OverlayPositionMode::Local); - menu - }), + user_menu: None, _subscriptions: subscriptions, } } @@ -294,32 +289,41 @@ impl CollabTitlebarItem { } pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext) { - self.user_menu.update(cx, |user_menu, cx| { - let items = if let Some(_) = self.user_store.read(cx).current_user() { - vec![ - ContextMenuItem::action("Settings", zed_actions::OpenSettings), - ContextMenuItem::action("Theme", theme_selector::Toggle), - ContextMenuItem::separator(), - ContextMenuItem::action( - "Share Feedback", - feedback::feedback_editor::GiveFeedback, - ), - ContextMenuItem::action("Sign out", SignOut), - ] - } else { - vec![ - ContextMenuItem::action("Settings", zed_actions::OpenSettings), - ContextMenuItem::action("Theme", theme_selector::Toggle), - ContextMenuItem::separator(), - ContextMenuItem::action( - "Share Feedback", - feedback::feedback_editor::GiveFeedback, - ), - ] - }; + if self.user_menu.take().is_none() { + let mut user_menu = cx.add_view(|cx| { + let view_id = cx.view_id(); + let mut menu = ContextMenu::new(view_id, cx); + menu.set_position_mode(OverlayPositionMode::Local); + menu + }); + user_menu.update(cx, |user_menu, cx| { + let items = if let Some(_) = self.user_store.read(cx).current_user() { + vec![ + ContextMenuItem::action("Settings", zed_actions::OpenSettings), + ContextMenuItem::action("Theme", theme_selector::Toggle), + ContextMenuItem::separator(), + ContextMenuItem::action( + "Share Feedback", + feedback::feedback_editor::GiveFeedback, + ), + ContextMenuItem::action("Sign out", SignOut), + ] + } else { + vec![ + ContextMenuItem::action("Settings", zed_actions::OpenSettings), + ContextMenuItem::action("Theme", theme_selector::Toggle), + ContextMenuItem::separator(), + ContextMenuItem::action( + "Share Feedback", + feedback::feedback_editor::GiveFeedback, + ), + ] + }; - user_menu.show(Default::default(), AnchorCorner::TopRight, items, cx); - }); + user_menu.show(Default::default(), AnchorCorner::TopRight, items, cx); + }); + self.user_menu = Some(user_menu); + } } fn render_toggle_contacts_button( @@ -695,11 +699,10 @@ impl CollabTitlebarItem { ) .contained(), ) - .with_child( - ChildView::new(&self.user_menu, cx) - .aligned() - .bottom() - .right(), + .with_children( + self.user_menu + .as_ref() + .map(|menu| ChildView::new(&menu, cx).aligned().bottom().right()), ) .into_any() } From c2f5855fdc21158f28ecebba7cce8146682128cd Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:22:17 +0200 Subject: [PATCH 202/215] Fix warning --- crates/collab_ui/src/collab_titlebar_item.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 6621aed875..e5837330a4 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -290,7 +290,7 @@ impl CollabTitlebarItem { pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext) { if self.user_menu.take().is_none() { - let mut user_menu = cx.add_view(|cx| { + let user_menu = cx.add_view(|cx| { let view_id = cx.view_id(); let mut menu = ContextMenu::new(view_id, cx); menu.set_position_mode(OverlayPositionMode::Local); From 49ce1977e3409740f29b4d5565345c557c0938e0 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:27:38 +0200 Subject: [PATCH 203/215] Optimize user menu trigger --- crates/collab_ui/src/collab_titlebar_item.rs | 34 +++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index e5837330a4..76d1741c14 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -49,7 +49,8 @@ pub struct CollabTitlebarItem { client: Arc, workspace: WeakViewHandle, contacts_popover: Option>, - user_menu: Option>, + user_menu: ViewHandle, + user_menu_is_visible: bool, _subscriptions: Vec, } @@ -176,7 +177,13 @@ impl CollabTitlebarItem { user_store, client, contacts_popover: None, - user_menu: None, + user_menu: cx.add_view(|cx| { + let view_id = cx.view_id(); + let mut menu = ContextMenu::new(view_id, cx); + menu.set_position_mode(OverlayPositionMode::Local); + menu + }), + user_menu_is_visible: false, _subscriptions: subscriptions, } } @@ -289,14 +296,8 @@ impl CollabTitlebarItem { } pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext) { - if self.user_menu.take().is_none() { - let user_menu = cx.add_view(|cx| { - let view_id = cx.view_id(); - let mut menu = ContextMenu::new(view_id, cx); - menu.set_position_mode(OverlayPositionMode::Local); - menu - }); - user_menu.update(cx, |user_menu, cx| { + if !self.user_menu_is_visible { + self.user_menu.update(cx, |user_menu, cx| { let items = if let Some(_) = self.user_store.read(cx).current_user() { vec![ ContextMenuItem::action("Settings", zed_actions::OpenSettings), @@ -322,8 +323,8 @@ impl CollabTitlebarItem { user_menu.show(Default::default(), AnchorCorner::TopRight, items, cx); }); - self.user_menu = Some(user_menu); } + self.user_menu_is_visible = !self.user_menu_is_visible; } fn render_toggle_contacts_button( @@ -699,11 +700,12 @@ impl CollabTitlebarItem { ) .contained(), ) - .with_children( - self.user_menu - .as_ref() - .map(|menu| ChildView::new(&menu, cx).aligned().bottom().right()), - ) + .with_children(self.user_menu_is_visible.then(|| { + ChildView::new(&self.user_menu, cx) + .aligned() + .bottom() + .right() + })) .into_any() } From a889f3db54866ae690516cde8bbf967a99a56383 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 28 Jun 2023 10:06:12 -0400 Subject: [PATCH 204/215] Reduce the right spacing of the contacts menu --- styles/src/styleTree/titlebar.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/styles/src/styleTree/titlebar.ts b/styles/src/styleTree/titlebar.ts index 993d421859..b1971a2e8d 100644 --- a/styles/src/styleTree/titlebar.ts +++ b/styles/src/styleTree/titlebar.ts @@ -200,10 +200,7 @@ export function titlebar(theme: ColorScheme) { // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. }, - // Sign in buttom sign_in_button: toggleable_text_button(theme, {}), - - // Offline Indicator offlineIcon: { color: foreground(theme.lowest, "variant"), width: 16, @@ -215,7 +212,7 @@ export function titlebar(theme: ColorScheme) { }, }, - // Notice that the collaboration server is out of date + // When the collaboration server is out of date, show a warning outdatedWarning: { ...text(theme.lowest, "sans", "warning", { size: "xs" }), background: withOpacity(background(theme.lowest, "warning"), 0.3), @@ -242,7 +239,6 @@ export function titlebar(theme: ColorScheme) { toggle_contacts_button: toggleable_icon_button(theme, { margin: { left: ITEM_SPACING, - right: ITEM_SPACING / 2 }, }), From c381e8821ce68e887a2ae92ae798960fb15a84aa Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 28 Jun 2023 10:19:30 -0400 Subject: [PATCH 205/215] Update icon sizes --- styles/src/component/icon_button.ts | 8 ++++---- styles/src/styleTree/titlebar.ts | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/styles/src/component/icon_button.ts b/styles/src/component/icon_button.ts index 850acc62f9..43f8d0f9c4 100644 --- a/styles/src/component/icon_button.ts +++ b/styles/src/component/icon_button.ts @@ -38,10 +38,10 @@ export function icon_button(theme: ColorScheme, { color, margin, layer }: IconBu right: 4, }, margin: m, - icon_width: 15, - icon_height: 15, - button_width: 21, - button_height: 17, + icon_width: 14, + icon_height: 14, + button_width: 20, + button_height: 16, }, state: { default: { diff --git a/styles/src/styleTree/titlebar.ts b/styles/src/styleTree/titlebar.ts index b1971a2e8d..f27c301433 100644 --- a/styles/src/styleTree/titlebar.ts +++ b/styles/src/styleTree/titlebar.ts @@ -23,13 +23,18 @@ function build_spacing( } function call_controls(theme: ColorScheme) { - const button_height = 19 + const button_height = 18 const space = build_spacing(TITLEBAR_HEIGHT, button_height, ITEM_SPACING); + const marginY = { + top: space.marginY, + bottom: space.marginY, + } return { toggle_microphone_button: toggleable_icon_button(theme, { margin: { + ...marginY, left: space.group, right: space.half_item, }, @@ -38,6 +43,7 @@ function call_controls(theme: ColorScheme) { toggle_speakers_button: toggleable_icon_button(theme, { margin: { + ...marginY, left: space.half_item, right: space.half_item }, @@ -45,6 +51,7 @@ function call_controls(theme: ColorScheme) { screen_share_button: toggleable_icon_button(theme, { margin: { + ...marginY, left: space.half_item, right: space.group }, @@ -60,7 +67,7 @@ function call_controls(theme: ColorScheme) { * When logged out only shows a chevron. */ function user_menu(theme: ColorScheme) { - const button_height = 19 + const button_height = 18 const space = build_spacing(TITLEBAR_HEIGHT, button_height, ITEM_SPACING); @@ -70,7 +77,7 @@ function user_menu(theme: ColorScheme) { base: { cornerRadius: 6, height: button_height, - width: online ? 36 : 23, + width: online ? 37 : 24, padding: { top: 2, bottom: 2, @@ -120,11 +127,11 @@ function user_menu(theme: ColorScheme) { return { user_menu: button, avatar: { - icon_width: 15, - icon_height: 15, + icon_width: 16, + icon_height: 16, corner_radius: 4, - outer_width: 15, - outer_corner_radius: 15 + outer_width: 16, + outer_corner_radius: 16 }, icon: { margin: { @@ -196,7 +203,7 @@ export function titlebar(theme: ColorScheme) { }, avatarRibbon: { height: 3, - width: 11, + width: 14, // TODO: Chore: Make avatarRibbon colors driven by the theme rather than being hard coded. }, From 1882ce48be02ec68430683a29436ca618dd629a4 Mon Sep 17 00:00:00 2001 From: Julia Date: Mon, 26 Jun 2023 10:18:30 -0400 Subject: [PATCH 206/215] Handle new elixir-ls release zip name --- crates/zed/src/languages/elixir.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/zed/src/languages/elixir.rs b/crates/zed/src/languages/elixir.rs index 22aaedc069..d07faae0cd 100644 --- a/crates/zed/src/languages/elixir.rs +++ b/crates/zed/src/languages/elixir.rs @@ -62,16 +62,23 @@ impl LspAdapter for ElixirLspAdapter { &self, delegate: &dyn LspAdapterDelegate, ) -> Result> { - let release = - latest_github_release("elixir-lsp/elixir-ls", false, delegate.http_client()).await?; - let asset_name = "elixir-ls.zip"; + let http = delegate.http_client(); + let release = latest_github_release("elixir-lsp/elixir-ls", false, http).await?; + let version_name = release + .name + .strip_prefix("Release ") + .context("Elixir-ls release name does not start with prefix")? + .to_owned(); + + let asset_name = format!("elixir-ls-{}.zip", &version_name); let asset = release .assets .iter() .find(|asset| asset.name == asset_name) .ok_or_else(|| anyhow!("no asset found matching {:?}", asset_name))?; + let version = GitHubLspBinaryVersion { - name: release.name, + name: version_name, url: asset.browser_download_url.clone(), }; Ok(Box::new(version) as Box<_>) @@ -116,7 +123,7 @@ impl LspAdapter for ElixirLspAdapter { .await? .status; if !unzip_status.success() { - Err(anyhow!("failed to unzip clangd archive"))?; + Err(anyhow!("failed to unzip elixir-ls archive"))?; } remove_matching(&container_dir, |entry| entry != version_dir).await; From 9ab0efa1f80714fa50aab6001d64c543f6fa25f5 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 28 Jun 2023 08:41:31 -0700 Subject: [PATCH 207/215] Fix microphone and speaking styles --- crates/collab_ui/src/collab_titlebar_item.rs | 25 +++++++++++++------- crates/theme/src/theme.rs | 3 +++ styles/src/styleTree/titlebar.ts | 5 +++- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 76d1741c14..72aa247f35 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -668,6 +668,7 @@ impl CollabTitlebarItem { avatar_img, *avatar_style, Color::transparent_black(), + None )); }; @@ -846,17 +847,20 @@ impl CollabTitlebarItem { let leader_style = theme.titlebar.leader_avatar; let follower_style = theme.titlebar.follower_avatar; - let mut background_color = if muted { - gpui::color::Color::red() + let microphone_state = if muted { + Some(theme.titlebar.muted) } else if speaking { - gpui::color::Color::green() + Some(theme.titlebar.speaking) } else { - theme - .titlebar - .container - .background_color - .unwrap_or_default() + None }; + + let mut background_color = theme + .titlebar + .container + .background_color + .unwrap_or_default(); + if let Some(replica_id) = replica_id { if followed_by_self { let selection = theme.editor.replica_selection_style(replica_id).selection; @@ -872,6 +876,7 @@ impl CollabTitlebarItem { avatar.clone(), Self::location_style(workspace, location, leader_style, cx), background_color, + microphone_state )) .with_children( (|| { @@ -903,6 +908,7 @@ impl CollabTitlebarItem { avatar.clone(), follower_style, background_color, + None )) })) })() @@ -1021,12 +1027,13 @@ impl CollabTitlebarItem { avatar: Arc, avatar_style: AvatarStyle, background_color: Color, + microphone_state: Option ) -> AnyElement { Image::from_data(avatar) .with_style(avatar_style.image) .aligned() .contained() - .with_background_color(background_color) + .with_background_color(microphone_state.unwrap_or(background_color)) .with_corner_radius(avatar_style.outer_corner_radius) .constrained() .with_width(avatar_style.outer_width) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 06c6026e3a..0a62459a3a 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -132,6 +132,8 @@ pub struct Titlebar { pub sign_in_button: Toggleable>, pub outdated_warning: ContainedText, pub share_button: Toggleable>, + pub muted: Color, + pub speaking: Color, pub screen_share_button: Toggleable>, pub toggle_contacts_button: Toggleable>, pub toggle_microphone_button: Toggleable>, @@ -146,6 +148,7 @@ pub struct UserMenu { pub user_menu_button_online: UserMenuButton, pub user_menu_button_offline: UserMenuButton, } + #[derive(Clone, Deserialize, Default, JsonSchema)] pub struct UserMenuButton { pub user_menu: Toggleable>, diff --git a/styles/src/styleTree/titlebar.ts b/styles/src/styleTree/titlebar.ts index f27c301433..fe0885c8e7 100644 --- a/styles/src/styleTree/titlebar.ts +++ b/styles/src/styleTree/titlebar.ts @@ -57,6 +57,9 @@ function call_controls(theme: ColorScheme) { }, active_color: 'accent' }), + + muted: foreground(theme.lowest, "negative"), + speaking: foreground(theme.lowest, "accent"), } } @@ -153,7 +156,7 @@ function user_menu(theme: ColorScheme) { } export function titlebar(theme: ColorScheme) { - const avatarWidth = 18 + const avatarWidth = 15 const avatarOuterWidth = avatarWidth + 4 const followerAvatarWidth = 14 const followerAvatarOuterWidth = followerAvatarWidth + 4 From 88b30dea100137538c86e35ca941fff3b9ff2102 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 28 Jun 2023 08:44:17 -0700 Subject: [PATCH 208/215] fmt --- crates/collab_ui/src/collab_titlebar_item.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 72aa247f35..e76778b2cd 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -668,7 +668,7 @@ impl CollabTitlebarItem { avatar_img, *avatar_style, Color::transparent_black(), - None + None, )); }; @@ -876,7 +876,7 @@ impl CollabTitlebarItem { avatar.clone(), Self::location_style(workspace, location, leader_style, cx), background_color, - microphone_state + microphone_state, )) .with_children( (|| { @@ -908,7 +908,7 @@ impl CollabTitlebarItem { avatar.clone(), follower_style, background_color, - None + None, )) })) })() @@ -1027,7 +1027,7 @@ impl CollabTitlebarItem { avatar: Arc, avatar_style: AvatarStyle, background_color: Color, - microphone_state: Option + microphone_state: Option, ) -> AnyElement { Image::from_data(avatar) .with_style(avatar_style.image) From 34b81e2aab45c369b37fd7ab47e764d0564a59a7 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 28 Jun 2023 09:01:07 -0700 Subject: [PATCH 209/215] collab 0.15.0 --- Cargo.lock | 2 +- crates/collab/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3732653a15..bc586381c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1333,7 +1333,7 @@ dependencies = [ [[package]] name = "collab" -version = "0.14.2" +version = "0.15.0" dependencies = [ "anyhow", "async-tungstenite", diff --git a/crates/collab/Cargo.toml b/crates/collab/Cargo.toml index 27545a652d..a87234ded7 100644 --- a/crates/collab/Cargo.toml +++ b/crates/collab/Cargo.toml @@ -3,7 +3,7 @@ authors = ["Nathan Sobo "] default-run = "collab" edition = "2021" name = "collab" -version = "0.14.2" +version = "0.15.0" publish = false [[bin]] From cb782c5a7b0c306056c76734f72997592210248a Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 28 Jun 2023 09:06:06 -0700 Subject: [PATCH 210/215] Remove menu tracking state --- crates/collab_ui/src/collab_titlebar_item.rs | 62 +++++++++----------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index e76778b2cd..2ab8928166 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -50,7 +50,6 @@ pub struct CollabTitlebarItem { workspace: WeakViewHandle, contacts_popover: Option>, user_menu: ViewHandle, - user_menu_is_visible: bool, _subscriptions: Vec, } @@ -183,7 +182,6 @@ impl CollabTitlebarItem { menu.set_position_mode(OverlayPositionMode::Local); menu }), - user_menu_is_visible: false, _subscriptions: subscriptions, } } @@ -296,35 +294,31 @@ impl CollabTitlebarItem { } pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext) { - if !self.user_menu_is_visible { - self.user_menu.update(cx, |user_menu, cx| { - let items = if let Some(_) = self.user_store.read(cx).current_user() { - vec![ - ContextMenuItem::action("Settings", zed_actions::OpenSettings), - ContextMenuItem::action("Theme", theme_selector::Toggle), - ContextMenuItem::separator(), - ContextMenuItem::action( - "Share Feedback", - feedback::feedback_editor::GiveFeedback, - ), - ContextMenuItem::action("Sign out", SignOut), - ] - } else { - vec![ - ContextMenuItem::action("Settings", zed_actions::OpenSettings), - ContextMenuItem::action("Theme", theme_selector::Toggle), - ContextMenuItem::separator(), - ContextMenuItem::action( - "Share Feedback", - feedback::feedback_editor::GiveFeedback, - ), - ] - }; - - user_menu.show(Default::default(), AnchorCorner::TopRight, items, cx); - }); - } - self.user_menu_is_visible = !self.user_menu_is_visible; + self.user_menu.update(cx, |user_menu, cx| { + let items = if let Some(_) = self.user_store.read(cx).current_user() { + vec![ + ContextMenuItem::action("Settings", zed_actions::OpenSettings), + ContextMenuItem::action("Theme", theme_selector::Toggle), + ContextMenuItem::separator(), + ContextMenuItem::action( + "Share Feedback", + feedback::feedback_editor::GiveFeedback, + ), + ContextMenuItem::action("Sign out", SignOut), + ] + } else { + vec![ + ContextMenuItem::action("Settings", zed_actions::OpenSettings), + ContextMenuItem::action("Theme", theme_selector::Toggle), + ContextMenuItem::separator(), + ContextMenuItem::action( + "Share Feedback", + feedback::feedback_editor::GiveFeedback, + ), + ] + }; + user_menu.show(Default::default(), AnchorCorner::TopRight, items, cx); + }); } fn render_toggle_contacts_button( @@ -701,12 +695,12 @@ impl CollabTitlebarItem { ) .contained(), ) - .with_children(self.user_menu_is_visible.then(|| { + .with_child( ChildView::new(&self.user_menu, cx) .aligned() .bottom() - .right() - })) + .right(), + ) .into_any() } From 6c53653831d1d0cd1e26349a5febb6bb32cfcc4e Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Wed, 28 Jun 2023 12:23:42 -0400 Subject: [PATCH 211/215] v0.94.x dev --- Cargo.lock | 2 +- crates/zed/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 029f9e5ce2..c4b0755fcd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8909,7 +8909,7 @@ dependencies = [ [[package]] name = "zed" -version = "0.93.0" +version = "0.94.0" dependencies = [ "activity_indicator", "ai", diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index f00346510d..6434d36951 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -3,7 +3,7 @@ authors = ["Nathan Sobo "] description = "The fast, collaborative code editor." edition = "2021" name = "zed" -version = "0.93.0" +version = "0.94.0" publish = false [lib] From 4659c34d46e16d12901f6fcf11fdbcdef0bb74e8 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 28 Jun 2023 09:55:25 -0700 Subject: [PATCH 212/215] WIP: Fix style overwriting in project panel --- styles/src/element/interactive.ts | 2 +- styles/src/styleTree/projectPanel.ts | 107 +++++++++++++++++++++------ 2 files changed, 84 insertions(+), 25 deletions(-) diff --git a/styles/src/element/interactive.ts b/styles/src/element/interactive.ts index 79fee70cb9..03a1f7f5ce 100644 --- a/styles/src/element/interactive.ts +++ b/styles/src/element/interactive.ts @@ -1,7 +1,7 @@ import merge from "ts-deepmerge" import { DeepPartial } from "utility-types" -type InteractiveState = +export type InteractiveState = | "default" | "hovered" | "clicked" diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 6bec951288..25606d8ca6 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -1,37 +1,16 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" -import { background, border, foreground, text } from "./components" +import { Border, TextProperties, background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" +import { InteractiveState } from "../element/interactive" export default function projectPanel(colorScheme: ColorScheme) { const { isLight } = colorScheme let layer = colorScheme.middle - let baseEntry = { - height: 22, - iconColor: foreground(layer, "variant"), - iconSize: 7, - iconSpacing: 5, - } - - let status = { - git: { - modified: isLight - ? colorScheme.ramps.yellow(0.6).hex() - : colorScheme.ramps.yellow(0.5).hex(), - inserted: isLight - ? colorScheme.ramps.green(0.45).hex() - : colorScheme.ramps.green(0.5).hex(), - conflict: isLight - ? colorScheme.ramps.red(0.6).hex() - : colorScheme.ramps.red(0.5).hex(), - }, - } - const default_entry = interactive({ base: { ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), status, }, state: { @@ -47,7 +26,7 @@ export default function projectPanel(colorScheme: ColorScheme) { }, }) - let entry = toggleable({ + let base_entry = toggleable({ base: default_entry, state: { active: interactive({ @@ -69,6 +48,86 @@ export default function projectPanel(colorScheme: ColorScheme) { }, }) + type EntryStateProps = { + background?: string, + border: Border, + text: TextProperties, + iconColor: string, + } + + type EntryState = Record, EntryStateProps> + + const entry = (base: object, unselected: EntryState, selected: EntryState) => { + const git_status = { + git: { + modified: isLight + ? colorScheme.ramps.yellow(0.6).hex() + : colorScheme.ramps.yellow(0.5).hex(), + inserted: isLight + ? colorScheme.ramps.green(0.45).hex() + : colorScheme.ramps.green(0.5).hex(), + conflict: isLight + ? colorScheme.ramps.red(0.6).hex() + : colorScheme.ramps.red(0.5).hex(), + }, + } + + const base_properties = { + height: 22, + iconColor: foreground(layer, "variant"), + iconSize: 7, + iconSpacing: 5, + text: text(layer, "mono", "variant", { size: "sm" }), + status: { + ...git_status + } + } + + const unselected_i = interactive({ + base: base_properties, + state: { + default: { + background: background(layer), + ...unselected.default ?? {}, + }, + hovered: { + background: background(layer, "variant", "hovered"), + ...unselected.hovered ?? {}, + }, + clicked: { + background: background(layer, "variant", "pressed"), + ...unselected.clicked ?? {}, + }, + }, + }) + + const selected_i = interactive({ + base: base, + state: { + default: { + ...base_entry, + ...(selected.default ?? {}), + }, + hovered: { + ...base_entry, + ...selected.hovered ?? {}, + }, + clicked: { + ...base_entry, + ...selected.clicked ?? {}, + }, + } + }) + + return toggleable({ + state: { + inactive: unselected_i, + active: selected_i, + } + }) + + } + return { openProjectButton: interactive({ base: { From cf8e0befc86f51b41a675ba6b08f579e7c8cb135 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 28 Jun 2023 13:27:41 -0400 Subject: [PATCH 213/215] Update --- styles/src/styleTree/components.ts | 8 ++ styles/src/styleTree/projectPanel.ts | 171 ++++++++++----------------- 2 files changed, 69 insertions(+), 110 deletions(-) diff --git a/styles/src/styleTree/components.ts b/styles/src/styleTree/components.ts index bfd1f75cb0..3b6f26066b 100644 --- a/styles/src/styleTree/components.ts +++ b/styles/src/styleTree/components.ts @@ -93,6 +93,14 @@ interface Text extends Object { underline?: boolean } +export interface TextStyle extends Object { + family: keyof typeof fontFamilies + color: string + size: number + weight?: FontWeight + underline?: boolean +} + export interface TextProperties { size?: keyof typeof fontSizes weight?: FontWeight diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 25606d8ca6..eada2444f4 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -1,63 +1,28 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" -import { Border, TextProperties, background, border, foreground, text } from "./components" +import { Border, TextStyle, background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" -import { InteractiveState } from "../element/interactive" +import merge from "ts-deepmerge" export default function projectPanel(colorScheme: ColorScheme) { const { isLight } = colorScheme let layer = colorScheme.middle - const default_entry = interactive({ - base: { - ...baseEntry, - status, - }, - state: { - default: { - background: background(layer), - }, - hovered: { - background: background(layer, "variant", "hovered"), - }, - clicked: { - background: background(layer, "variant", "pressed"), - }, - }, - }) - - let base_entry = toggleable({ - base: default_entry, - state: { - active: interactive({ - base: { - ...default_entry, - }, - state: { - default: { - background: background(colorScheme.lowest), - }, - hovered: { - background: background(colorScheme.lowest, "hovered"), - }, - clicked: { - background: background(colorScheme.lowest, "pressed"), - }, - }, - }), - }, - }) - type EntryStateProps = { background?: string, - border: Border, - text: TextProperties, - iconColor: string, + border?: Border, + text?: TextStyle, + iconColor?: string, } - type EntryState = Record, EntryStateProps> + type EntryState = { + default: EntryStateProps, + hovered?: EntryStateProps, + clicked?: EntryStateProps, + } + + const entry = (unselected?: EntryState, selected?: EntryState) => { - const entry = (base: object, unselected: EntryState, selected: EntryState) => { const git_status = { git: { modified: isLight @@ -74,6 +39,7 @@ export default function projectPanel(colorScheme: ColorScheme) { const base_properties = { height: 22, + background: background(layer), iconColor: foreground(layer, "variant"), iconSize: 7, iconSpacing: 5, @@ -83,51 +49,38 @@ export default function projectPanel(colorScheme: ColorScheme) { } } - const unselected_i = interactive({ - base: base_properties, - state: { - default: { - background: background(layer), - ...unselected.default ?? {}, - }, - hovered: { - background: background(layer, "variant", "hovered"), - ...unselected.hovered ?? {}, - }, - clicked: { - background: background(layer, "variant", "pressed"), - ...unselected.clicked ?? {}, - }, - }, - }) + const selectedStyle: EntryState | undefined = selected ? selected : unselected - const selected_i = interactive({ - base: base, - state: { - default: { - ...base_entry, - ...(selected.default ?? {}), - }, - hovered: { - ...base_entry, - ...selected.hovered ?? {}, - }, - clicked: { - ...base_entry, - ...selected.clicked ?? {}, - }, - } - }) + const unselected_default_style = merge(base_properties, unselected?.default ?? {}, {}) + const unselected_hovered_style = merge(base_properties, unselected?.hovered ?? {}, { background: background(layer, "variant", "hovered") }) + const unselected_clicked_style = merge(base_properties, unselected?.clicked ?? {}, { background: background(layer, "variant", "pressed") }) + const selected_default_style = merge(base_properties, selectedStyle?.default ?? {}, { background: background(layer) }) + const selected_hovered_style = merge(base_properties, selectedStyle?.hovered ?? {}, { background: background(layer, "variant", "hovered") }) + const selected_clicked_style = merge(base_properties, selectedStyle?.clicked ?? {}, { background: background(layer, "variant", "pressed") }) return toggleable({ state: { - inactive: unselected_i, - active: selected_i, + inactive: interactive({ + state: { + default: unselected_default_style, + hovered: unselected_hovered_style, + clicked: unselected_clicked_style, + }, + }), + active: interactive({ + state: { + default: selected_default_style, + hovered: selected_hovered_style, + clicked: selected_clicked_style, + }, + }), } }) } + const defaultEntry = entry() + return { openProjectButton: interactive({ base: { @@ -163,35 +116,33 @@ export default function projectPanel(colorScheme: ColorScheme) { background: background(layer), padding: { left: 6, right: 6, top: 0, bottom: 6 }, indentWidth: 12, - entry, - draggedEntry: { - ...baseEntry, - text: text(layer, "mono", "on", { size: "sm" }), - background: withOpacity(background(layer, "on"), 0.9), - border: border(layer), - status, - }, - ignoredEntry: { - ...entry, - iconColor: foreground(layer, "disabled"), - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, + defaultEntry, + draggedEntry: entry({ + default: { + text: text(layer, "mono", "on", { size: "sm" }), + background: withOpacity(background(layer, "on"), 0.9), + border: border(layer), + } + }), + ignoredEntry: entry({ + default: { + text: text(layer, "mono", "disabled"), + }, + }, { + default: { iconColor: foreground(layer, "variant"), + } + }), + cutEntry: entry({ + default: { + text: text(layer, "mono", "disabled"), }, - }, - cutEntry: { - ...entry, - text: text(layer, "mono", "disabled"), - active: { - ...entry.active, - default: { - ...entry.active.default, - background: background(layer, "active"), - text: text(layer, "mono", "disabled", { size: "sm" }), - }, - }, - }, + }, { + default: { + background: background(layer, "active"), + text: text(layer, "mono", "disabled", { size: "sm" }), + } + }), filenameEditor: { background: background(layer, "on"), text: text(layer, "mono", "on", { size: "sm" }), From bf2c2fe2421935ed52fe468a05bf99797c8695ac Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 28 Jun 2023 10:34:47 -0700 Subject: [PATCH 214/215] fix bug with dragged entry --- styles/src/styleTree/projectPanel.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index eada2444f4..5d98073d54 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -116,14 +116,13 @@ export default function projectPanel(colorScheme: ColorScheme) { background: background(layer), padding: { left: 6, right: 6, top: 0, bottom: 6 }, indentWidth: 12, - defaultEntry, - draggedEntry: entry({ - default: { - text: text(layer, "mono", "on", { size: "sm" }), - background: withOpacity(background(layer, "on"), 0.9), - border: border(layer), - } - }), + entry: defaultEntry, + draggedEntry: { + ...defaultEntry.inactive.default, + text: text(layer, "mono", "on", { size: "sm" }), + background: withOpacity(background(layer, "on"), 0.9), + border: border(layer), + }, ignoredEntry: entry({ default: { text: text(layer, "mono", "disabled"), From 1d4a92218525c94525757c45f8ad92c5aee60d7d Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 28 Jun 2023 10:35:28 -0700 Subject: [PATCH 215/215] prettier format --- styles/src/component/icon_button.ts | 55 +++++---- styles/src/component/text_button.ts | 60 ++++++---- styles/src/styleTree/assistant.ts | 83 +++++++------- styles/src/styleTree/projectPanel.ts | 107 ++++++++++++------ styles/src/styleTree/titlebar.ts | 42 +++---- styles/src/themes/rose-pine/common.ts | 66 +++++------ styles/src/themes/rose-pine/rose-pine-dawn.ts | 24 +++- styles/src/themes/rose-pine/rose-pine-moon.ts | 22 +++- styles/src/themes/rose-pine/rose-pine.ts | 20 +++- 9 files changed, 288 insertions(+), 191 deletions(-) diff --git a/styles/src/component/icon_button.ts b/styles/src/component/icon_button.ts index 43f8d0f9c4..39c1adb5e5 100644 --- a/styles/src/component/icon_button.ts +++ b/styles/src/component/icon_button.ts @@ -1,25 +1,32 @@ -import { ColorScheme } from "../common"; -import { interactive, toggleable } from "../element"; -import { background, foreground } from "../styleTree/components"; +import { ColorScheme } from "../common" +import { interactive, toggleable } from "../element" +import { background, foreground } from "../styleTree/components" export type Margin = { - top: number; - bottom: number; - left: number; - right: number; + top: number + bottom: number + left: number + right: number } interface IconButtonOptions { - layer?: ColorScheme['lowest'] | ColorScheme['middle'] | ColorScheme['highest']; - color?: keyof ColorScheme['lowest']; - margin?: Partial; + layer?: + | ColorScheme["lowest"] + | ColorScheme["middle"] + | ColorScheme["highest"] + color?: keyof ColorScheme["lowest"] + margin?: Partial } -type ToggleableIconButtonOptions = IconButtonOptions & { active_color?: keyof ColorScheme['lowest'] }; +type ToggleableIconButtonOptions = IconButtonOptions & { + active_color?: keyof ColorScheme["lowest"] +} -export function icon_button(theme: ColorScheme, { color, margin, layer }: IconButtonOptions) { - if (!color) - color = "base"; +export function icon_button( + theme: ColorScheme, + { color, margin, layer }: IconButtonOptions +) { + if (!color) color = "base" const m = { top: margin?.top ?? 0, @@ -51,25 +58,29 @@ export function icon_button(theme: ColorScheme, { color, margin, layer }: IconBu hovered: { background: background(layer ?? theme.lowest, color, "hovered"), color: foreground(layer ?? theme.lowest, color, "hovered"), - }, clicked: { background: background(layer ?? theme.lowest, color, "pressed"), color: foreground(layer ?? theme.lowest, color, "pressed"), - }, }, - }); + }) } -export function toggleable_icon_button(theme: ColorScheme, { color, active_color, margin }: ToggleableIconButtonOptions) { - if (!color) - color = "base"; +export function toggleable_icon_button( + theme: ColorScheme, + { color, active_color, margin }: ToggleableIconButtonOptions +) { + if (!color) color = "base" return toggleable({ state: { inactive: icon_button(theme, { color, margin }), - active: icon_button(theme, { color: active_color ? active_color : color, margin, layer: theme.middle }), - } + active: icon_button(theme, { + color: active_color ? active_color : color, + margin, + layer: theme.middle, + }), + }, }) } diff --git a/styles/src/component/text_button.ts b/styles/src/component/text_button.ts index ae7fede900..b8a2272cd3 100644 --- a/styles/src/component/text_button.ts +++ b/styles/src/component/text_button.ts @@ -1,25 +1,37 @@ -import { ColorScheme } from "../common"; -import { interactive, toggleable } from "../element"; -import { TextProperties, background, foreground, text } from "../styleTree/components"; -import { Margin } from "./icon_button"; +import { ColorScheme } from "../common" +import { interactive, toggleable } from "../element" +import { + TextProperties, + background, + foreground, + text, +} from "../styleTree/components" +import { Margin } from "./icon_button" interface TextButtonOptions { - layer?: ColorScheme['lowest'] | ColorScheme['middle'] | ColorScheme['highest']; - color?: keyof ColorScheme['lowest']; - margin?: Partial; - text_properties?: TextProperties; + layer?: + | ColorScheme["lowest"] + | ColorScheme["middle"] + | ColorScheme["highest"] + color?: keyof ColorScheme["lowest"] + margin?: Partial + text_properties?: TextProperties } -type ToggleableTextButtonOptions = TextButtonOptions & { active_color?: keyof ColorScheme['lowest'] }; +type ToggleableTextButtonOptions = TextButtonOptions & { + active_color?: keyof ColorScheme["lowest"] +} -export function text_button(theme: ColorScheme, { color, layer, margin, text_properties }: TextButtonOptions) { - if (!color) - color = "base"; +export function text_button( + theme: ColorScheme, + { color, layer, margin, text_properties }: TextButtonOptions +) { + if (!color) color = "base" const text_options: TextProperties = { size: "xs", weight: "normal", - ...text_properties + ...text_properties, } const m = { @@ -40,7 +52,7 @@ export function text_button(theme: ColorScheme, { color, layer, margin, text_pro }, margin: m, button_height: 22, - ...text(layer ?? theme.lowest, "sans", color, text_options) + ...text(layer ?? theme.lowest, "sans", color, text_options), }, state: { default: { @@ -50,25 +62,29 @@ export function text_button(theme: ColorScheme, { color, layer, margin, text_pro hovered: { background: background(layer ?? theme.lowest, color, "hovered"), color: foreground(layer ?? theme.lowest, color, "hovered"), - }, clicked: { background: background(layer ?? theme.lowest, color, "pressed"), color: foreground(layer ?? theme.lowest, color, "pressed"), - }, }, - }); + }) } -export function toggleable_text_button(theme: ColorScheme, { color, active_color, margin }: ToggleableTextButtonOptions) { - if (!color) - color = "base"; +export function toggleable_text_button( + theme: ColorScheme, + { color, active_color, margin }: ToggleableTextButtonOptions +) { + if (!color) color = "base" return toggleable({ state: { inactive: text_button(theme, { color, margin }), - active: text_button(theme, { color: active_color ? active_color : color, margin, layer: theme.middle }), - } + active: text_button(theme, { + color: active_color ? active_color : color, + margin, + layer: theme.middle, + }), + }, }) } diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.ts index b6e97303f2..30e109df1a 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -26,15 +26,15 @@ export default function assistant(colorScheme: ColorScheme) { }, container: { padding: { left: 12, right: 8.5 }, - } + }, }, state: { hovered: { icon: { - color: foreground(layer, "hovered") - } - } - } + color: foreground(layer, "hovered"), + }, + }, + }, }), splitButton: interactive({ base: { @@ -48,15 +48,15 @@ export default function assistant(colorScheme: ColorScheme) { }, container: { padding: { left: 8.5, right: 8.5 }, - } + }, }, state: { hovered: { icon: { - color: foreground(layer, "hovered") - } - } - } + color: foreground(layer, "hovered"), + }, + }, + }, }), quoteButton: interactive({ base: { @@ -70,15 +70,15 @@ export default function assistant(colorScheme: ColorScheme) { }, container: { padding: { left: 8.5, right: 8.5 }, - } + }, }, state: { hovered: { icon: { - color: foreground(layer, "hovered") - } - } - } + color: foreground(layer, "hovered"), + }, + }, + }, }), assistButton: interactive({ base: { @@ -92,15 +92,15 @@ export default function assistant(colorScheme: ColorScheme) { }, container: { padding: { left: 8.5, right: 8.5 }, - } + }, }, state: { hovered: { icon: { - color: foreground(layer, "hovered") - } - } - } + color: foreground(layer, "hovered"), + }, + }, + }, }), zoomInButton: interactive({ base: { @@ -114,15 +114,15 @@ export default function assistant(colorScheme: ColorScheme) { }, container: { padding: { left: 10, right: 10 }, - } + }, }, state: { hovered: { icon: { - color: foreground(layer, "hovered") - } - } - } + color: foreground(layer, "hovered"), + }, + }, + }, }), zoomOutButton: interactive({ base: { @@ -136,15 +136,15 @@ export default function assistant(colorScheme: ColorScheme) { }, container: { padding: { left: 10, right: 10 }, - } + }, }, state: { hovered: { icon: { - color: foreground(layer, "hovered") - } - } - } + color: foreground(layer, "hovered"), + }, + }, + }, }), plusButton: interactive({ base: { @@ -158,29 +158,29 @@ export default function assistant(colorScheme: ColorScheme) { }, container: { padding: { left: 10, right: 10 }, - } + }, }, state: { hovered: { icon: { - color: foreground(layer, "hovered") - } - } - } + color: foreground(layer, "hovered"), + }, + }, + }, }), title: { - ...text(layer, "sans", "default", { size: "sm" }) + ...text(layer, "sans", "default", { size: "sm" }), }, savedConversation: { container: interactive({ base: { background: background(layer, "on"), - padding: { top: 4, bottom: 4 } + padding: { top: 4, bottom: 4 }, }, state: { hovered: { background: background(layer, "on", "hovered"), - } + }, }, }), savedAt: { @@ -189,8 +189,11 @@ export default function assistant(colorScheme: ColorScheme) { }, title: { margin: { left: 16 }, - ...text(layer, "sans", "default", { size: "sm", weight: "bold" }), - } + ...text(layer, "sans", "default", { + size: "sm", + weight: "bold", + }), + }, }, userSender: { default: { diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index 5d98073d54..3727c1916c 100644 --- a/styles/src/styleTree/projectPanel.ts +++ b/styles/src/styleTree/projectPanel.ts @@ -1,6 +1,13 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" -import { Border, TextStyle, background, border, foreground, text } from "./components" +import { + Border, + TextStyle, + background, + border, + foreground, + text, +} from "./components" import { interactive, toggleable } from "../element" import merge from "ts-deepmerge" export default function projectPanel(colorScheme: ColorScheme) { @@ -9,20 +16,19 @@ export default function projectPanel(colorScheme: ColorScheme) { let layer = colorScheme.middle type EntryStateProps = { - background?: string, - border?: Border, - text?: TextStyle, - iconColor?: string, + background?: string + border?: Border + text?: TextStyle + iconColor?: string } type EntryState = { - default: EntryStateProps, - hovered?: EntryStateProps, - clicked?: EntryStateProps, + default: EntryStateProps + hovered?: EntryStateProps + clicked?: EntryStateProps } const entry = (unselected?: EntryState, selected?: EntryState) => { - const git_status = { git: { modified: isLight @@ -45,18 +51,44 @@ export default function projectPanel(colorScheme: ColorScheme) { iconSpacing: 5, text: text(layer, "mono", "variant", { size: "sm" }), status: { - ...git_status - } + ...git_status, + }, } - const selectedStyle: EntryState | undefined = selected ? selected : unselected + const selectedStyle: EntryState | undefined = selected + ? selected + : unselected - const unselected_default_style = merge(base_properties, unselected?.default ?? {}, {}) - const unselected_hovered_style = merge(base_properties, unselected?.hovered ?? {}, { background: background(layer, "variant", "hovered") }) - const unselected_clicked_style = merge(base_properties, unselected?.clicked ?? {}, { background: background(layer, "variant", "pressed") }) - const selected_default_style = merge(base_properties, selectedStyle?.default ?? {}, { background: background(layer) }) - const selected_hovered_style = merge(base_properties, selectedStyle?.hovered ?? {}, { background: background(layer, "variant", "hovered") }) - const selected_clicked_style = merge(base_properties, selectedStyle?.clicked ?? {}, { background: background(layer, "variant", "pressed") }) + const unselected_default_style = merge( + base_properties, + unselected?.default ?? {}, + {} + ) + const unselected_hovered_style = merge( + base_properties, + unselected?.hovered ?? {}, + { background: background(layer, "variant", "hovered") } + ) + const unselected_clicked_style = merge( + base_properties, + unselected?.clicked ?? {}, + { background: background(layer, "variant", "pressed") } + ) + const selected_default_style = merge( + base_properties, + selectedStyle?.default ?? {}, + { background: background(layer) } + ) + const selected_hovered_style = merge( + base_properties, + selectedStyle?.hovered ?? {}, + { background: background(layer, "variant", "hovered") } + ) + const selected_clicked_style = merge( + base_properties, + selectedStyle?.clicked ?? {}, + { background: background(layer, "variant", "pressed") } + ) return toggleable({ state: { @@ -74,9 +106,8 @@ export default function projectPanel(colorScheme: ColorScheme) { clicked: selected_clicked_style, }, }), - } + }, }) - } const defaultEntry = entry() @@ -123,25 +154,31 @@ export default function projectPanel(colorScheme: ColorScheme) { background: withOpacity(background(layer, "on"), 0.9), border: border(layer), }, - ignoredEntry: entry({ - default: { - text: text(layer, "mono", "disabled"), + ignoredEntry: entry( + { + default: { + text: text(layer, "mono", "disabled"), + }, }, - }, { - default: { - iconColor: foreground(layer, "variant"), + { + default: { + iconColor: foreground(layer, "variant"), + }, } - }), - cutEntry: entry({ - default: { - text: text(layer, "mono", "disabled"), + ), + cutEntry: entry( + { + default: { + text: text(layer, "mono", "disabled"), + }, }, - }, { - default: { - background: background(layer, "active"), - text: text(layer, "mono", "disabled", { size: "sm" }), + { + default: { + background: background(layer, "active"), + text: text(layer, "mono", "disabled", { size: "sm" }), + }, } - }), + ), filenameEditor: { background: background(layer, "on"), text: text(layer, "mono", "on", { size: "sm" }), diff --git a/styles/src/styleTree/titlebar.ts b/styles/src/styleTree/titlebar.ts index fe0885c8e7..3c7318a56e 100644 --- a/styles/src/styleTree/titlebar.ts +++ b/styles/src/styleTree/titlebar.ts @@ -1,9 +1,9 @@ -import { ColorScheme } from "../common"; +import { ColorScheme } from "../common" import { icon_button, toggleable_icon_button } from "../component/icon_button" import { toggleable_text_button } from "../component/text_button" import { interactive, toggleable } from "../element" -import { withOpacity } from "../theme/color"; -import { background, border, foreground, text } from "./components"; +import { withOpacity } from "../theme/color" +import { background, border, foreground, text } from "./components" const ITEM_SPACING = 8 const TITLEBAR_HEIGHT = 32 @@ -25,7 +25,7 @@ function build_spacing( function call_controls(theme: ColorScheme) { const button_height = 18 - const space = build_spacing(TITLEBAR_HEIGHT, button_height, ITEM_SPACING); + const space = build_spacing(TITLEBAR_HEIGHT, button_height, ITEM_SPACING) const marginY = { top: space.marginY, bottom: space.marginY, @@ -38,14 +38,14 @@ function call_controls(theme: ColorScheme) { left: space.group, right: space.half_item, }, - active_color: 'negative' + active_color: "negative", }), toggle_speakers_button: toggleable_icon_button(theme, { margin: { ...marginY, left: space.half_item, - right: space.half_item + right: space.half_item, }, }), @@ -53,9 +53,9 @@ function call_controls(theme: ColorScheme) { margin: { ...marginY, left: space.half_item, - right: space.group + right: space.group, }, - active_color: 'accent' + active_color: "accent", }), muted: foreground(theme.lowest, "negative"), @@ -64,15 +64,15 @@ function call_controls(theme: ColorScheme) { } /** -* Opens the User Menu when toggled -* -* When logged in shows the user's avatar and a chevron, -* When logged out only shows a chevron. -*/ + * Opens the User Menu when toggled + * + * When logged in shows the user's avatar and a chevron, + * When logged out only shows a chevron. + */ function user_menu(theme: ColorScheme) { const button_height = 18 - const space = build_spacing(TITLEBAR_HEIGHT, button_height, ITEM_SPACING); + const space = build_spacing(TITLEBAR_HEIGHT, button_height, ITEM_SPACING) const build_button = ({ online }: { online: boolean }) => { const button = toggleable({ @@ -124,8 +124,8 @@ function user_menu(theme: ColorScheme) { background: background(theme.middle, "pressed"), }, }, - } - }); + }, + }) return { user_menu: button, @@ -134,7 +134,7 @@ function user_menu(theme: ColorScheme) { icon_height: 16, corner_radius: 4, outer_width: 16, - outer_corner_radius: 16 + outer_corner_radius: 16, }, icon: { margin: { @@ -145,8 +145,8 @@ function user_menu(theme: ColorScheme) { }, width: 11, height: 11, - color: foreground(theme.lowest) - } + color: foreground(theme.lowest), + }, } } return { @@ -240,7 +240,7 @@ export function titlebar(theme: ColorScheme) { leave_call_button: icon_button(theme, { margin: { left: ITEM_SPACING / 2, - right: ITEM_SPACING + right: ITEM_SPACING, }, }), @@ -261,6 +261,6 @@ export function titlebar(theme: ColorScheme) { background: foreground(theme.lowest, "accent"), }, shareButton: toggleable_text_button(theme, {}), - user_menu: user_menu(theme) + user_menu: user_menu(theme), } } diff --git a/styles/src/themes/rose-pine/common.ts b/styles/src/themes/rose-pine/common.ts index 8b3b3b7000..146305890b 100644 --- a/styles/src/themes/rose-pine/common.ts +++ b/styles/src/themes/rose-pine/common.ts @@ -1,39 +1,39 @@ -import { ThemeSyntax } from "../../common"; +import { ThemeSyntax } from "../../common" export const color = { default: { - base: '#191724', - surface: '#1f1d2e', - overlay: '#26233a', - muted: '#6e6a86', - subtle: '#908caa', - text: '#e0def4', - love: '#eb6f92', - gold: '#f6c177', - rose: '#ebbcba', - pine: '#31748f', - foam: '#9ccfd8', - iris: '#c4a7e7', - highlightLow: '#21202e', - highlightMed: '#403d52', - highlightHigh: '#524f67', + base: "#191724", + surface: "#1f1d2e", + overlay: "#26233a", + muted: "#6e6a86", + subtle: "#908caa", + text: "#e0def4", + love: "#eb6f92", + gold: "#f6c177", + rose: "#ebbcba", + pine: "#31748f", + foam: "#9ccfd8", + iris: "#c4a7e7", + highlightLow: "#21202e", + highlightMed: "#403d52", + highlightHigh: "#524f67", }, moon: { - base: '#232136', - surface: '#2a273f', - overlay: '#393552', - muted: '#6e6a86', - subtle: '#908caa', - text: '#e0def4', - love: '#eb6f92', - gold: '#f6c177', - rose: '#ea9a97', - pine: '#3e8fb0', - foam: '#9ccfd8', - iris: '#c4a7e7', - highlightLow: '#2a283e', - highlightMed: '#44415a', - highlightHigh: '#56526e', + base: "#232136", + surface: "#2a273f", + overlay: "#393552", + muted: "#6e6a86", + subtle: "#908caa", + text: "#e0def4", + love: "#eb6f92", + gold: "#f6c177", + rose: "#ea9a97", + pine: "#3e8fb0", + foam: "#9ccfd8", + iris: "#c4a7e7", + highlightLow: "#2a283e", + highlightMed: "#44415a", + highlightHigh: "#56526e", }, dawn: { base: "#faf4ed", @@ -51,8 +51,8 @@ export const color = { highlightLow: "#f4ede8", highlightMed: "#dfdad9", highlightHigh: "#cecacd", - } -}; + }, +} export const syntax = (c: typeof color.default): Partial => { return { diff --git a/styles/src/themes/rose-pine/rose-pine-dawn.ts b/styles/src/themes/rose-pine/rose-pine-dawn.ts index 3ec5d30bb6..15d7b5de2d 100644 --- a/styles/src/themes/rose-pine/rose-pine-dawn.ts +++ b/styles/src/themes/rose-pine/rose-pine-dawn.ts @@ -6,12 +6,12 @@ import { ThemeConfig, } from "../../common" -import { color as c, syntax } from "./common"; +import { color as c, syntax } from "./common" const color = c.dawn -const green = chroma.mix(color.foam, "#10b981", 0.6, 'lab'); -const magenta = chroma.mix(color.love, color.pine, 0.5, 'lab'); +const green = chroma.mix(color.foam, "#10b981", 0.6, "lab") +const magenta = chroma.mix(color.love, color.pine, 0.5, "lab") export const theme: ThemeConfig = { name: "Rosé Pine Dawn", @@ -21,7 +21,19 @@ export const theme: ThemeConfig = { licenseUrl: "https://github.com/edunfelt/base16-rose-pine-scheme", licenseFile: `${__dirname}/LICENSE`, inputColor: { - neutral: chroma.scale([color.base, color.surface, color.highlightHigh, color.overlay, color.muted, color.subtle, color.text].reverse()).domain([0, 0.35, 0.45, 0.65, 0.7, 0.8, 0.9, 1]), + neutral: chroma + .scale( + [ + color.base, + color.surface, + color.highlightHigh, + color.overlay, + color.muted, + color.subtle, + color.text, + ].reverse() + ) + .domain([0, 0.35, 0.45, 0.65, 0.7, 0.8, 0.9, 1]), red: colorRamp(chroma(color.love)), orange: colorRamp(chroma(color.iris)), yellow: colorRamp(chroma(color.gold)), @@ -32,6 +44,6 @@ export const theme: ThemeConfig = { magenta: colorRamp(chroma(magenta)), }, override: { - syntax: syntax(color) - } + syntax: syntax(color), + }, } diff --git a/styles/src/themes/rose-pine/rose-pine-moon.ts b/styles/src/themes/rose-pine/rose-pine-moon.ts index 4e70d2f0ad..c5ef0c997f 100644 --- a/styles/src/themes/rose-pine/rose-pine-moon.ts +++ b/styles/src/themes/rose-pine/rose-pine-moon.ts @@ -6,12 +6,12 @@ import { ThemeConfig, } from "../../common" -import { color as c, syntax } from "./common"; +import { color as c, syntax } from "./common" const color = c.moon -const green = chroma.mix(color.foam, "#10b981", 0.6, 'lab'); -const magenta = chroma.mix(color.love, color.pine, 0.5, 'lab'); +const green = chroma.mix(color.foam, "#10b981", 0.6, "lab") +const magenta = chroma.mix(color.love, color.pine, 0.5, "lab") export const theme: ThemeConfig = { name: "Rosé Pine Moon", @@ -21,7 +21,17 @@ export const theme: ThemeConfig = { licenseUrl: "https://github.com/edunfelt/base16-rose-pine-scheme", licenseFile: `${__dirname}/LICENSE`, inputColor: { - neutral: chroma.scale([color.base, color.surface, color.highlightHigh, color.overlay, color.muted, color.subtle, color.text]).domain([0, 0.3, 0.55, 1]), + neutral: chroma + .scale([ + color.base, + color.surface, + color.highlightHigh, + color.overlay, + color.muted, + color.subtle, + color.text, + ]) + .domain([0, 0.3, 0.55, 1]), red: colorRamp(chroma(color.love)), orange: colorRamp(chroma(color.iris)), yellow: colorRamp(chroma(color.gold)), @@ -32,6 +42,6 @@ export const theme: ThemeConfig = { magenta: colorRamp(chroma(magenta)), }, override: { - syntax: syntax(color) - } + syntax: syntax(color), + }, } diff --git a/styles/src/themes/rose-pine/rose-pine.ts b/styles/src/themes/rose-pine/rose-pine.ts index 6c4a6ac49b..0f3b439338 100644 --- a/styles/src/themes/rose-pine/rose-pine.ts +++ b/styles/src/themes/rose-pine/rose-pine.ts @@ -5,12 +5,12 @@ import { ThemeLicenseType, ThemeConfig, } from "../../common" -import { color as c, syntax } from "./common"; +import { color as c, syntax } from "./common" const color = c.default -const green = chroma.mix(color.foam, "#10b981", 0.6, 'lab'); -const magenta = chroma.mix(color.love, color.pine, 0.5, 'lab'); +const green = chroma.mix(color.foam, "#10b981", 0.6, "lab") +const magenta = chroma.mix(color.love, color.pine, 0.5, "lab") export const theme: ThemeConfig = { name: "Rosé Pine", @@ -20,7 +20,15 @@ export const theme: ThemeConfig = { licenseUrl: "https://github.com/edunfelt/base16-rose-pine-scheme", licenseFile: `${__dirname}/LICENSE`, inputColor: { - neutral: chroma.scale([color.base, color.surface, color.highlightHigh, color.overlay, color.muted, color.subtle, color.text]), + neutral: chroma.scale([ + color.base, + color.surface, + color.highlightHigh, + color.overlay, + color.muted, + color.subtle, + color.text, + ]), red: colorRamp(chroma(color.love)), orange: colorRamp(chroma(color.iris)), yellow: colorRamp(chroma(color.gold)), @@ -31,6 +39,6 @@ export const theme: ThemeConfig = { magenta: colorRamp(chroma(magenta)), }, override: { - syntax: syntax(color) - } + syntax: syntax(color), + }, }