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/.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 diff --git a/.gitignore b/.gitignore index 30d0fcbf1c..dbffa0f829 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 diff --git a/Cargo.lock b/Cargo.lock index 3ba305b2cc..3732653a15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -192,6 +192,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" @@ -1104,8 +1153,8 @@ checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", "bitflags", - "clap_derive", - "clap_lex", + "clap_derive 3.2.25", + "clap_lex 0.2.4", "indexmap", "once_cell", "strsim", @@ -1113,6 +1162,30 @@ dependencies = [ "textwrap", ] +[[package]] +name = "clap" +version = "4.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2686c4115cb0810d9a984776e197823d08ec94f176549a89a9efded477c456dc" +dependencies = [ + "clap_builder", + "clap_derive 4.3.2", + "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e53afce1efce6ed1f633cf0e57612fe51db54a1ee4fd8f8503d078fe02d69ae" +dependencies = [ + "anstream", + "anstyle", + "bitflags", + "clap_lex 0.5.0", + "strsim", +] + [[package]] name = "clap_derive" version = "3.2.25" @@ -1126,6 +1199,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" @@ -1135,12 +1220,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", @@ -1250,7 +1341,7 @@ dependencies = [ "axum-extra", "base64 0.13.1", "call", - "clap", + "clap 3.2.25", "client", "collections", "ctor", @@ -1345,6 +1436,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" @@ -6918,18 +7015,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" @@ -8782,6 +8867,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" +[[package]] +name = "xtask" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap 4.3.5", + "schemars", + "serde_json", + "theme", +] + [[package]] name = "yaml-rust" version = "0.4.5" @@ -8811,7 +8907,7 @@ dependencies = [ [[package]] name = "zed" -version = "0.92.0" +version = "0.93.0" dependencies = [ "activity_indicator", "ai", @@ -8890,7 +8986,6 @@ dependencies = [ "text", "theme", "theme_selector", - "theme_testbench", "thiserror", "tiny_http", "toml", diff --git a/Cargo.toml b/Cargo.toml index fca7355964..640384a792 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,11 +61,11 @@ members = [ "crates/text", "crates/theme", "crates/theme_selector", - "crates/theme_testbench", "crates/util", "crates/vim", "crates/workspace", "crates/welcome", + "crates/xtask", "crates/zed", ] default-members = ["crates/zed"] @@ -118,3 +118,4 @@ split-debuginfo = "unpacked" [profile.release] debug = true lto = "thin" +codegen-units = 1 diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index 444d1f9ed7..635578fdda 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -412,6 +412,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/assets/keymaps/vim.json b/assets/keymaps/vim.json index 47c5f8c458..05159e9446 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", @@ -90,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": [ @@ -143,6 +149,7 @@ "Delete" ], "shift-d": "vim::DeleteToEndOfLine", + "shift-j": "editor::JoinLines", "y": [ "vim::PushOperator", "Yank" @@ -184,7 +191,6 @@ "p": "vim::Paste", "u": "editor::Undo", "ctrl-r": "editor::Redo", - "ctrl-o": "pane::GoBack", "/": [ "buffer_search::Deploy", { 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/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 4ca7e7de26..6e10916a3d 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -309,7 +309,7 @@ impl AssistantPanel { Some( MouseEventHandler::::new(0, cx, |state, _| { - let style = style.model.style_for(state, false); + let style = style.model.style_for(state); Label::new(model, style.text.clone()) .contained() .with_style(style.container) @@ -414,7 +414,7 @@ impl AssistantPanel { .with_style(style.title.container), ) .contained() - .with_style(*style.container.style_for(state, false)) + .with_style(*style.container.style_for(state)) }) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, move |_, this, cx| { @@ -1668,19 +1668,19 @@ impl ConversationEditor { 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) 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..04fc9650eb 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.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![ @@ -361,8 +366,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 + .inactive_state() + .default + .icon_width, + ) + .with_margin_top( + titlebar + .toggle_contacts_button + .inactive_state() + .default + .icon_width, + ) .aligned(), ) }; @@ -372,7 +389,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 +437,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 +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, false); + let style = titlebar.share_button.inactive_state().style_for(state); Label::new(label, style.text.clone()) .contained() .with_style(style.container) @@ -511,7 +529,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 +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, false); + 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/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..0c8b27a151 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.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); @@ -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.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); @@ -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..aec876bd78 100644 --- a/crates/command_palette/src/command_palette.rs +++ b/crates/command_palette/src/command_palette.rs @@ -185,8 +185,8 @@ 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); 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..de78b51e9c 100644 --- a/crates/context_menu/src/context_menu.rs +++ b/crates/context_menu/src/context_menu.rs @@ -328,10 +328,8 @@ 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 style = style.item.in_state(self.selected_index == Some(ix)); + let style = style.style_for(&mut Default::default()); match label { ContextMenuItemLabel::String(label) => { @@ -363,10 +361,8 @@ 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 style = style.item.in_state(self.selected_index == Some(ix)); + let style = style.style_for(&mut Default::default()); match action { ContextMenuItemAction::Action(action) => KeystrokeLabel::new( @@ -412,8 +408,8 @@ 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 style = style.item.in_state(self.selected_index == Some(ix)); + 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/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/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/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..c1e38614ef 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); @@ -3320,15 +3322,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 +3386,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() @@ -3952,6 +3958,60 @@ impl Editor { }); } + pub fn join_lines(&mut self, _: &JoinLines, cx: &mut ViewContext) { + let mut row_ranges = Vec::>::new(); + 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 + } else { + selection.end.row + }; + + 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 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) > indent.len { + " " + } 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) + }); + }); + } + 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; @@ -7949,6 +8009,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 +8021,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/editor_tests.rs b/crates/editor/src/editor_tests.rs index e2b876f4b7..6fcb6f778f 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,137 @@ fn test_delete_line(cx: &mut TestAppContext) { }); } +#[gpui::test] +fn test_join_lines_with_single_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(); + + assert_eq!( + editor.selections.ranges::(cx), + &[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!( + editor.selections.ranges::(cx), + &[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)]) + }); + 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)] + ); + + // Undo should be transactional + 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)] + ); + + // 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)]) + }); + 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)] + ); + + // We can remove trailing newlines + 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)] + ); + + // 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!( + editor.selections.ranges::(cx), + [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 + }); +} + +#[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, |_| {}); diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index d6f9a2e906..6525e7fc22 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 { @@ -1527,7 +1529,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() @@ -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, @@ -2090,7 +2094,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/gpui/src/color.rs b/crates/gpui/src/color.rs index b6c1e3aff9..2a0c2c1dc1 100644 --- a/crates/gpui/src/color.rs +++ b/crates/gpui/src/color.rs @@ -6,15 +6,16 @@ use std::{ use crate::json::ToJson; use pathfinder_color::{ColorF, ColorU}; +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 { diff --git a/crates/gpui/src/elements/container.rs b/crates/gpui/src/elements/container.rs index 3ce323db09..3b95feb9ef 100644 --- a/crates/gpui/src/elements/container.rs +++ b/crates/gpui/src/elements/container.rs @@ -12,10 +12,11 @@ use crate::{ scene::{self, Border, CursorRegion, Quad}, AnyElement, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext, }; +use schemars::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, @@ -332,7 +333,7 @@ impl ToJson for ContainerStyle { } } -#[derive(Clone, Copy, Debug, Default)] +#[derive(Clone, Copy, Debug, Default, JsonSchema)] pub struct Margin { pub top: f32, pub left: f32, @@ -359,7 +360,7 @@ impl ToJson for Margin { } } -#[derive(Clone, Copy, Debug, Default)] +#[derive(Clone, Copy, Debug, Default, JsonSchema)] pub struct Padding { pub top: f32, pub left: f32, @@ -486,9 +487,10 @@ impl ToJson for Padding { } } -#[derive(Clone, Copy, Debug, Default, Deserialize)] +#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)] pub struct Shadow { #[serde(default, deserialize_with = "deserialize_vec2f")] + #[schemars(with = "Vec::")] offset: Vector2F, #[serde(default)] blur: 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/svg.rs b/crates/gpui/src/elements/svg.rs index a6b4fab980..4ef880b3e1 100644 --- a/crates/gpui/src/elements/svg.rs +++ b/crates/gpui/src/elements/svg.rs @@ -8,6 +8,7 @@ use crate::{ }, scene, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext, }; +use schemars::JsonSchema; use serde_derive::Deserialize; use serde_json::json; use std::{borrow::Cow, ops::Range}; @@ -115,14 +116,14 @@ impl Element for Svg { } } -#[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, 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 57dad48e34..4f0d4fd461 100644 --- a/crates/gpui/src/font_cache.rs +++ b/crates/gpui/src/font_cache.rs @@ -7,13 +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, }; -#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +#[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 5e77593d05..3b4a94dd0e 100644 --- a/crates/gpui/src/fonts.rs +++ b/crates/gpui/src/fonts.rs @@ -16,7 +16,7 @@ use serde::{de, Deserialize, Serialize}; use serde_json::Value; use std::{cell::RefCell, sync::Arc}; -#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, JsonSchema)] pub struct FontId(pub usize); pub type GlyphId = u32; @@ -59,20 +59,44 @@ pub struct Features { pub zero: Option, } -#[derive(Clone, Debug)] +#[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, + #[schemars(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: f32, + /// The font stretchiness, as defined in CSS. + pub stretch: f32, +} + +#[derive(JsonSchema)] +#[schemars(remote = "Style")] +pub enum StyleDef { + /// A face that is neither italic not obliqued. + Normal, + /// A form that is generally cursive in nature. + Italic, + /// A typically-sloped version of the regular face. + Oblique, +} + +#[derive(Copy, Clone, Debug, Default, PartialEq, JsonSchema)] pub struct HighlightStyle { pub color: Option, + #[schemars(with = "Option::")] pub weight: Option, pub italic: Option, pub underline: Option, @@ -81,9 +105,10 @@ pub struct HighlightStyle { impl Eq for HighlightStyle {} -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, JsonSchema)] pub struct Underline { pub color: Option, + #[schemars(with = "f32")] pub thickness: OrderedFloat, pub squiggly: bool, } 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/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/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/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(); }), ); }); 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 c8781c195c..110bdc846b 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1254,7 +1254,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::>() @@ -1265,7 +1268,7 @@ impl ProjectPanel { .filter(|destination| details.path.starts_with(destination)) .is_some() { - style = entry_style.active.clone().unwrap(); + style = entry_style.active_state().default.clone(); } let row_container_style = if show_editor { @@ -1406,9 +1409,11 @@ 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 context_menu_item = - context_menu_item_style.style_for(state, true).clone(); + let button_style = button_style.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 0dc5dad3bf..fc17b57c6d 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,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.default.label.clone()), + Label::new( + path.to_string(), + style.inactive_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..c6a86b2f6a 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.inactive_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..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.style_for(state, false); + let style = theme.search.option_button.inactive_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 7147336479..c012e04807 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, @@ -128,16 +129,16 @@ 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: Interactive, - pub user_menu_button: Interactive, + pub toggle_contacts_button: Toggleable>, + pub user_menu_button: Toggleable>, 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,17 +200,17 @@ 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, 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, @@ -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,17 +246,17 @@ pub struct ContactFinder { pub disabled_contact_button: IconButton, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct DropdownMenu { #[serde(flatten)] pub container: ContainerStyle, pub header: Interactive, pub section_header: ContainedText, - pub item: Interactive, + pub item: Toggleable>, pub row_height: f32, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct DropdownMenuItem { #[serde(flatten)] pub container: ContainerStyle, @@ -266,11 +267,11 @@ pub struct DropdownMenuItem { pub secondary_text_spacing: f32, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] 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, @@ -294,13 +295,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, @@ -308,7 +309,7 @@ pub struct AvatarRibbon { pub height: f32, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct OfflineIcon { #[serde(flatten)] pub container: ContainerStyle, @@ -316,7 +317,7 @@ pub struct OfflineIcon { pub color: Color, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Tab { pub height: f32, #[serde(flatten)] @@ -333,7 +334,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, @@ -342,14 +343,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, @@ -359,14 +360,14 @@ 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, pub dismiss_button: Interactive, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct FindEditor { #[serde(flatten)] pub input: FieldEditor, @@ -374,7 +375,7 @@ pub struct FindEditor { pub max_width: f32, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct StatusBar { #[serde(flatten)] pub container: ContainerStyle, @@ -390,15 +391,15 @@ 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, pub group_right: ContainerStyle, - pub button: Interactive, + pub button: Toggleable>, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct StatusBarDiagnosticSummary { pub container_ok: ContainerStyle, pub container_warning: ContainerStyle, @@ -413,7 +414,7 @@ pub struct StatusBarDiagnosticSummary { pub summary_spacing: f32, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct StatusBarLspStatus { #[serde(flatten)] pub container: ContainerStyle, @@ -424,14 +425,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, @@ -440,20 +441,20 @@ pub struct PanelButton { pub label: ContainedText, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] 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, } -#[derive(Clone, Debug, Deserialize, Default)] +#[derive(Clone, Debug, Deserialize, Default, JsonSchema)] pub struct ProjectPanelEntry { pub height: f32, #[serde(flatten)] @@ -465,28 +466,28 @@ 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, - pub item: Interactive, + pub item: Toggleable>, pub keystroke_margin: f32, pub separator: ContainerStyle, } -#[derive(Clone, Debug, Deserialize, Default)] +#[derive(Clone, Debug, Deserialize, Default, JsonSchema)] pub struct ContextMenuItem { #[serde(flatten)] pub container: ContainerStyle, @@ -496,13 +497,13 @@ pub struct ContextMenuItem { pub icon_spacing: f32, } -#[derive(Debug, Deserialize, Default)] +#[derive(Debug, Deserialize, Default, JsonSchema)] pub struct CommandPalette { - pub key: Interactive, + pub key: Toggleable, pub keystroke_spacing: f32, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct InviteLink { #[serde(flatten)] pub container: ContainerStyle, @@ -511,7 +512,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, @@ -519,7 +520,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, @@ -528,7 +529,7 @@ pub struct IconButton { pub button_width: f32, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ChatMessage { #[serde(flatten)] pub container: ContainerStyle, @@ -537,7 +538,7 @@ pub struct ChatMessage { pub timestamp: ContainedText, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ChannelSelect { #[serde(flatten)] pub container: ContainerStyle, @@ -549,7 +550,7 @@ pub struct ChannelSelect { pub menu: ContainerStyle, } -#[derive(Deserialize, Default)] +#[derive(Deserialize, Default, JsonSchema)] pub struct ChannelName { #[serde(flatten)] pub container: ContainerStyle, @@ -557,7 +558,7 @@ pub struct ChannelName { pub name: TextStyle, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Picker { #[serde(flatten)] pub container: ContainerStyle, @@ -565,10 +566,10 @@ 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)] +#[derive(Clone, Debug, Deserialize, Default, JsonSchema)] pub struct ContainedText { #[serde(flatten)] pub container: ContainerStyle, @@ -576,7 +577,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, @@ -584,7 +585,7 @@ pub struct ContainedLabel { pub label: LabelStyle, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct ProjectDiagnostics { #[serde(flatten)] pub container: ContainerStyle, @@ -594,7 +595,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, @@ -604,21 +605,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, @@ -635,7 +636,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, @@ -652,7 +653,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)] @@ -693,7 +694,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, @@ -702,14 +703,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, @@ -718,7 +719,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, @@ -729,7 +730,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)] @@ -737,7 +738,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, @@ -747,13 +748,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, @@ -763,21 +764,21 @@ 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 indicator: Toggleable>, pub vertical_scale: f32, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct Folds { - pub indicator: Interactive, + pub indicator: Toggleable>, pub ellipses: FoldEllipses, pub fold_background: Color, pub icon_margin_scale: f32, @@ -785,14 +786,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, @@ -802,41 +803,49 @@ 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, - pub hover_and_active: Option, + pub hovered: Option, pub clicked: Option, - pub click_and_active: Option, - pub active: Option, pub disabled: Option, } -impl Interactive { - pub fn style_for(&self, state: &mut MouseState, active: bool) -> &T { +#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)] +pub struct Toggleable { + active: T, + inactive: T, +} + +impl Toggleable { + pub fn new(active: T, inactive: T) -> Self { + Self { active, inactive } + } + pub fn in_state(&self, 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() { + &self.active + } else { + &self.inactive + } + } + pub fn active_state(&self) -> &T { + self.in_state(true) + } + pub fn inactive_state(&self) -> &T { + self.in_state(false) + } +} + +impl Interactive { + 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) + self.hovered.as_ref().unwrap_or(&self.default) } else { &self.default } } - pub fn disabled_style(&self) -> &T { self.disabled.as_ref().unwrap_or(&self.default) } @@ -849,13 +858,9 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive { { #[derive(Deserialize)] struct Helper { - #[serde(flatten)] default: Value, - hover: Option, - hover_and_active: Option, + hovered: Option, clicked: Option, - click_and_active: Option, - active: Option, disabled: Option, } @@ -880,21 +885,15 @@ 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 hovered = deserialize_state(json.hovered)?; 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, + hovered, clicked, - click_and_active, - active, disabled, }) } @@ -911,7 +910,7 @@ impl Editor { } } -#[derive(Default)] +#[derive(Default, JsonSchema)] pub struct SyntaxTheme { pub highlights: Vec<(String, HighlightStyle)>, } @@ -945,7 +944,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, @@ -957,7 +956,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, @@ -991,7 +990,7 @@ pub struct TerminalStyle { pub dim_foreground: Color, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct AssistantStyle { pub container: ContainerStyle, pub hamburger_button: IconStyle, @@ -1014,15 +1013,14 @@ pub struct AssistantStyle { pub saved_conversation: SavedConversation, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct SavedConversation { - #[serde(flatten)] pub container: Interactive, pub saved_at: ContainedText, pub title: ContainedText, } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct FeedbackStyle { pub submit_button: Interactive, pub button_margin: f32, @@ -1031,7 +1029,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, @@ -1045,7 +1043,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, @@ -1060,13 +1058,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, @@ -1079,7 +1077,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, @@ -1090,7 +1088,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, @@ -1100,7 +1098,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 058123e53d..308ea6f2d7 100644 --- a/crates/theme/src/ui.rs +++ b/crates/theme/src/ui.rs @@ -12,11 +12,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, @@ -100,7 +101,7 @@ pub fn svg(style: &SvgStyle) -> ConstrainedBox { .with_height(style.dimensions.height) } -#[derive(Clone, Deserialize, Default)] +#[derive(Clone, Deserialize, Default, JsonSchema)] pub struct IconStyle { pub icon: SvgStyle, pub container: ContainerStyle, @@ -150,7 +151,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() @@ -162,7 +163,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, @@ -200,13 +201,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/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/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"); +} 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 8ced21a809..ebaf399e22 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -498,7 +498,9 @@ 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 style = button_style.in_state(is_active); + + 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..49f9db12e6 100644 --- a/crates/workspace/src/toolbar.rs +++ b/crates/workspace/src/toolbar.rs @@ -231,7 +231,7 @@ fn nav_button ) -> AnyElement { MouseEventHandler::::new(0, cx, |state, _| { let style = if enabled { - style.style_for(state, false) + style.style_for(state) } else { style.disabled_style() }; diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 6fcb12e77c..8b1092fad0 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); diff --git a/crates/xtask/Cargo.toml b/crates/xtask/Cargo.toml new file mode 100644 index 0000000000..3d3f7d4357 --- /dev/null +++ b/crates/xtask/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "xtask" +version = "0.1.0" +edition = "2021" +publish = false +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = "1.0" +clap = {version = "4.0", features = ["derive"]} +theme = {path = "../theme"} +serde_json.workspace = true +schemars.workspace = true diff --git a/crates/xtask/src/cli.rs b/crates/xtask/src/cli.rs new file mode 100644 index 0000000000..bffda1bc16 --- /dev/null +++ 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 new file mode 100644 index 0000000000..38e5658ce7 --- /dev/null +++ b/crates/xtask/src/main.rs @@ -0,0 +1,29 @@ +mod cli; + +use std::path::PathBuf; + +use anyhow::Result; +use clap::Parser; +use schemars::schema_for; +use theme::Theme; + +fn build_themes(out_dir: PathBuf, file_name: PathBuf) -> Result<()> { + let theme = schema_for!(Theme); + let output = serde_json::to_string_pretty(&theme)?; + + std::fs::create_dir(&out_dir)?; + + let mut file_path = out_dir; + file_path.push(file_name); + + std::fs::write(file_path, output)?; + + Ok(()) +} + +fn main() -> Result<()> { + let args = cli::Cli::parse(); + match args.command { + cli::Commands::BuildThemeTypes { out_dir, file_name } => build_themes(out_dir, file_name), + } +} diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index d8e47d1c3e..3bf500057f 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] @@ -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); 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) + +; ... +``` 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/.zed/settings.json b/styles/.zed/settings.json new file mode 100644 index 0000000000..5c31fc5ac1 --- /dev/null +++ b/styles/.zed/settings.json @@ -0,0 +1,20 @@ +// 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 + }, + "TSX": { + "tab_size": 4 + }, + "JavaScript": { + "tab_size": 4 + }, + "JSON": { + "tab_size": 4 + } + } +} diff --git a/styles/package-lock.json b/styles/package-lock.json index d1d0ed0eb8..236e571148 100644 --- a/styles/package-lock.json +++ b/styles/package-lock.json @@ -1,7 +1,7 @@ { "name": "styles", "version": "1.0.0", - "lockfileVersion": 2, + "lockfileVersion": 3, "requires": true, "packages": { "": { @@ -17,10 +17,53 @@ "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" + "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", @@ -32,6 +75,44 @@ "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", @@ -40,6 +121,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", @@ -54,6 +144,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", @@ -79,16 +174,153 @@ "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", @@ -108,11 +340,48 @@ "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", @@ -123,11 +392,43 @@ "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", @@ -139,16 +440,132 @@ "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", @@ -165,21 +582,834 @@ "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", @@ -222,6 +1452,19 @@ } } }, + "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", @@ -235,11 +1478,227 @@ "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", @@ -247,176 +1706,17 @@ "engines": { "node": ">=6" } - } - }, - "dependencies": { - "@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==", - "requires": { - "@jridgewell/trace-mapping": "0.3.9" + }, + "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" } - }, - "@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/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==" - }, - "@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "requires": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, - "@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==" - }, - "@tsconfig/node10": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", - "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==" - }, - "@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==" - }, - "@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" - }, - "@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==" - }, - "@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/node": { - "version": "18.14.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.1.tgz", - "integrity": "sha512-QH+37Qds3E0eDlReeboBxfHbX9omAcBCXEzswCu6jySP642jiM3cYSIkU/REqwhCUqXdonHFuBfJDiAJxMNhaQ==" - }, - "acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==" - }, - "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==" - }, - "arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" - }, - "ayu": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/ayu/-/ayu-8.0.1.tgz", - "integrity": "sha512-yuPZ2kZYQoYaPRQ/78F9rXDVx1rVGCJ1neBYithBoSprD6zPdIJdAKizUXG0jtTBu7nTFyAnVFFYuLnCS3cpDw==", - "requires": { - "@types/chroma-js": "^2.0.0", - "chroma-js": "^2.1.0", - "nonenumerable": "^1.1.1" - } - }, - "bezier-easing": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/bezier-easing/-/bezier-easing-2.1.0.tgz", - "integrity": "sha512-gbIqZ/eslnUFC1tjEvtz0sgx+xTK20wDnYMIA27VA04R7w6xxXQPZDbibjA9DTWZRA2CXtwHykkVzlCaAJAZig==" - }, - "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==" - }, - "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==" - }, - "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==" - }, - "deepmerge": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.0.tgz", - "integrity": "sha512-z2wJZXrmeHdvYJp/Ux55wIjqo81G5Bp4c+oELTW+7ar6SogWHajt5a9gO3s3IDaGSAXjDk0vlQKN3rms8ab3og==" - }, - "diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" - }, - "make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" - }, - "nonenumerable": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/nonenumerable/-/nonenumerable-1.1.1.tgz", - "integrity": "sha512-ptUD9w9D8WqW6fuJJkZNCImkf+0vdbgUTbRK3i7jsy3olqtH96hYE6Q/S3Tx9NWbcB/ocAjYshXCAUP0lZ9B4Q==" - }, - "toml": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", - "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" - }, - "ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", - "requires": { - "@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" - } - }, - "typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "peer": true - }, - "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==" - }, - "yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==" } } } diff --git a/styles/package.json b/styles/package.json index 2a0881863b..8820259e86 100644 --- a/styles/package.json +++ b/styles/package.json @@ -6,7 +6,9 @@ "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", + "test": "vitest" }, "author": "", "license": "ISC", @@ -19,13 +21,20 @@ "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" + "ts-deepmerge": "^6.0.3", + "ts-node": "^10.9.1", + "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/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/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) +}) diff --git a/styles/src/element/index.ts b/styles/src/element/index.ts new file mode 100644 index 0000000000..b1e3cfe415 --- /dev/null +++ b/styles/src/element/index.ts @@ -0,0 +1,4 @@ +import { interactive } from "./interactive" +import { toggleable } from "./toggle" + +export { interactive, toggleable } diff --git a/styles/src/element/interactive.test.ts b/styles/src/element/interactive.test.ts new file mode 100644 index 0000000000..b0cc57875f --- /dev/null +++ b/styles/src/element/interactive.test.ts @@ -0,0 +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", () => { + 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/element/interactive.ts b/styles/src/element/interactive.ts new file mode 100644 index 0000000000..1c0f393cff --- /dev/null +++ b/styles/src/element/interactive.ts @@ -0,0 +1,97 @@ +import merge from "ts-deepmerge" +import { DeepPartial } from "utility-types" + +type InteractiveState = + | "default" + | "hovered" + | "clicked" + | "selected" + | "disabled" + +type Interactive = { + 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." + +interface InteractiveProps { + base?: T + state: Partial>> +} + +/** + * 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 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(NO_DEFAULT_OR_BASE_ERROR) + + 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: defaultState, + } + + let stateCount = 0 + + 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.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(NOT_ENOUGH_STATES_ERROR) + } + + return interactiveObj +} 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 new file mode 100644 index 0000000000..ead8f1e824 --- /dev/null +++ b/styles/src/element/toggle.ts @@ -0,0 +1,47 @@ +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." +export 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 +} 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 e4e342eb01..942b97a232 100644 --- a/styles/src/styleTree/assistant.ts +++ b/styles/src/styleTree/assistant.ts @@ -1,6 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { text, border, background, foreground } from "./components" import editor from "./editor" +import { interactive } from "../element" export default function assistant(colorScheme: ColorScheme) { const layer = colorScheme.highest @@ -15,83 +16,104 @@ export default function assistant(colorScheme: ColorScheme) { background: editor(colorScheme).background, }, hamburgerButton: { - icon: { - color: text(layer, "sans", "default", { size: "sm" }).color, - asset: "icons/hamburger_15.svg", - dimensions: { - width: 15, - height: 15, + icon: { + color: text(layer, "sans", "default", { size: "sm" }).color, + asset: "icons/hamburger_15.svg", + dimensions: { + width: 15, + height: 15, + }, }, - }, - container: { - margin: { left: 12 }, - } + container: { + margin: { left: 12 }, + } }, zoomInButton: { - icon: { - color: text(layer, "sans", "default", { size: "sm" }).color, - asset: "icons/maximize_8.svg", - dimensions: { - width: 12, - height: 12, + icon: { + color: text(layer, "sans", "default", { size: "sm" }).color, + asset: "icons/maximize_8.svg", + dimensions: { + width: 12, + height: 12, + }, }, - }, - container: { - margin: { right: 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, + icon: { + color: text(layer, "sans", "default", { size: "sm" }).color, + asset: "icons/minimize_8.svg", + dimensions: { + width: 12, + height: 12, + }, }, - }, - container: { - margin: { right: 12 }, - } + container: { + margin: { right: 12 }, + } }, plusButton: { - icon: { - color: text(layer, "sans", "default", { size: "sm" }).color, - asset: "icons/plus_12.svg", - dimensions: { - width: 12, - height: 12, + icon: { + color: text(layer, "sans", "default", { size: "sm" }).color, + asset: "icons/plus_12.svg", + dimensions: { + width: 12, + height: 12, + }, }, - }, - container: { - margin: { right: 12 }, - } + container: { + margin: { right: 12 }, + } }, title: { - margin: { left: 12 }, - ...text(layer, "sans", "default", { size: "sm" }) + margin: { left: 12 }, + ...text(layer, "sans", "default", { size: "sm" }) }, 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" }), - } + container: interactive({ + base: { + background: background(layer, "on"), + }, + state: { + hovered: { + 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" }), + default: { + ...text(layer, "sans", "default", { + size: "sm", + weight: "bold", + }), + }, }, assistantSender: { - ...text(layer, "sans", "accent", { size: "sm", weight: "bold" }), + default: { + ...text(layer, "sans", "accent", { + size: "sm", + weight: "bold", + }), + }, }, systemSender: { - ...text(layer, "sans", "variant", { size: "sm", weight: "bold" }), + default: { + ...text(layer, "sans", "variant", { + size: "sm", + weight: "bold", + }), + }, }, sentAt: { margin: { top: 2, left: 8 }, @@ -100,17 +122,21 @@ export default function assistant(colorScheme: ColorScheme) { modelInfoContainer: { margin: { right: 16, top: 4 }, }, - model: { - background: background(layer, "on"), - 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 }), + model: interactive({ + base: { + background: background(layer, "on"), + margin: { right: 8 }, + padding: 4, + cornerRadius: 4, + ...text(layer, "sans", "default", { size: "xs" }), }, - }, + state: { + hovered: { + background: background(layer, "on", "hovered"), + border: border(layer, "on", { overlay: true }), + }, + }, + }), remainingTokens: { margin: { right: 12 }, ...text(layer, "sans", "positive", { size: "xs" }), diff --git a/styles/src/styleTree/commandPalette.ts b/styles/src/styleTree/commandPalette.ts index c49e1f194c..5d4b7373c3 100644 --- a/styles/src/styleTree/commandPalette.ts +++ b/styles/src/styleTree/commandPalette.ts @@ -1,12 +1,13 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, background } from "./components" +import { toggleable } from "../element" export default function commandPalette(colorScheme: ColorScheme) { let layer = colorScheme.highest - return { - keystrokeSpacing: 8, - key: { + + const key = toggleable({ + base: { text: text(layer, "mono", "variant", "default", { size: "xs" }), cornerRadius: 2, background: background(layer, "on"), @@ -21,10 +22,21 @@ export default function commandPalette(colorScheme: ColorScheme) { 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/components.ts b/styles/src/styleTree/components.ts index a575dad527..bfd1f75cb0 100644 --- a/styles/src/styleTree/components.ts +++ b/styles/src/styleTree/components.ts @@ -85,7 +85,7 @@ export function foreground( return getStyle(layer, styleSetOrStyles, style).foreground } -interface Text { +interface Text extends Object { family: keyof typeof fontFamilies color: string size: number diff --git a/styles/src/styleTree/contactList.ts b/styles/src/styleTree/contactList.ts index a597e44d9f..88ae04277e 100644 --- a/styles/src/styleTree/contactList.ts +++ b/styles/src/styleTree/contactList.ts @@ -1,6 +1,6 @@ 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 @@ -71,47 +71,85 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, rowHeight: 28, sectionIconSize: 8, - headerRow: { - ...text(layer, "mono", { size: "sm" }), - margin: { top: 14 }, - padding: { - left: sidePadding, - right: sidePadding, + 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, "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: { + active: { + default: { + ...text(layer, "mono", "active", { size: "sm" }), + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "hovered"), + }, + clicked: { + background: background(layer, "pressed"), + }, + }, }, - active: { - ...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" }), }, - }, - leaveCall: { - background: background(layer), - border: border(layer), - cornerRadius: 6, - margin: { - top: 1, + state: { + hovered: { + ...text(layer, "sans", "hovered", { size: "xs" }), + background: background(layer, "hovered"), + border: border(layer, "hovered"), + }, }, - 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, + inactive: { + default: { + padding: { + left: sidePadding, + right: sidePadding, + }, + }, }, active: { - background: background(layer, "active"), + default: { + background: background(layer, "active"), + padding: { + left: sidePadding, + right: sidePadding, + }, + }, }, }, + contactAvatar: { cornerRadius: 10, width: 18, @@ -135,12 +173,14 @@ export default function contactsPanel(colorScheme: ColorScheme) { }, }, contactButtonSpacing: nameMargin, - contactButton: { - ...contactButton, - hover: { - background: background(layer, "hovered"), + contactButton: interactive({ + base: { ...contactButton }, + state: { + hovered: { + background: background(layer, "hovered"), + }, }, - }, + }), disabledButton: { ...contactButton, background: background(layer, "on"), @@ -149,34 +189,52 @@ export default function contactsPanel(colorScheme: ColorScheme) { callingIndicator: { ...text(layer, "mono", "variant", { size: "xs" }), }, - treeBranch: { - color: borderColor(layer), - width: 1, - hover: { - color: borderColor(layer), + treeBranch: toggleable({ + base: interactive({ + base: { + color: borderColor(layer), + width: 1, + }, + state: { + hovered: { + color: borderColor(layer), + }, + }, + }), + state: { + active: { + default: { + color: borderColor(layer), + }, + }, }, - active: { - 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") }, + }, }, - }, - 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..825c5a389a 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" const avatarSize = 12 const headerPadding = 8 @@ -21,24 +21,32 @@ export default function contactNotification(colorScheme: ColorScheme): Object { ...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"), + 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: { - color: foreground(layer, "variant"), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - hover: { - color: foreground(layer, "hovered"), + 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 f14cd90219..a59284c43a 100644 --- a/styles/src/styleTree/contextMenu.ts +++ b/styles/src/styleTree/contextMenu.ts @@ -1,5 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, borderColor, text } from "./components" +import { interactive, toggleable } from "../element" export default function contextMenu(colorScheme: ColorScheme) { let layer = colorScheme.middle @@ -10,37 +11,54 @@ export default function contextMenu(colorScheme: ColorScheme) { 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 }, + 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 }, + }, + }, + clicked: { + background: background(layer, "pressed"), + }, + }, + }), + state: { + active: { + default: { + background: background(layer, "active"), + }, + hovered: { + background: background(layer, "hovered"), + }, + clicked: { + background: background(layer, "pressed"), + }, }, }, - active: { - background: background(layer, "active"), - }, - activeHover: { - 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..1e09f4ff6b 100644 --- a/styles/src/styleTree/copilot.ts +++ b/styles/src/styleTree/copilot.ts @@ -1,60 +1,69 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, svg, text } from "./components" - +import { interactive } from "../element" export default function copilot(colorScheme: ColorScheme) { let layer = colorScheme.middle let content_width = 264 - let ctaButton = { + let ctaButton = // Copied from welcome screen. FIXME: Move this into a ZDS component - 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"), - }, - } + 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: { - icon: svg( - foreground(layer, "variant"), - "icons/link_out_12.svg", - 12, - 12 - ), - container: { - cornerRadius: 6, - padding: { left: 6 }, - }, - hover: { + outLinkIcon: interactive({ + base: { icon: svg( - foreground(layer, "hovered"), + 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: { - ...text(layer, "sans", { size: "xs", weight: "bold" }), + default: { + ...text(layer, "sans", { size: "xs", weight: "bold" }), + }, }, titlebar: { background: background(colorScheme.lowest), @@ -75,42 +84,46 @@ export default function copilot(colorScheme: ColorScheme) { 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: { + closeIcon: interactive({ + base: { icon: svg( - foreground(layer, "on"), + 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, + }, + }, }, - clicked: { - icon: svg( - foreground(layer, "base"), - "icons/x_mark_8.svg", - 8, - 8 - ), + 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, @@ -185,28 +198,32 @@ export default function copilot(colorScheme: ColorScheme) { }, }, 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", { + 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, + }), + }, + }, + }), }, }, diff --git a/styles/src/styleTree/editor.ts b/styles/src/styleTree/editor.ts index 55f3da6e90..c53f3ba2ff 100644 --- a/styles/src/styleTree/editor.ts +++ b/styles/src/styleTree/editor.ts @@ -4,6 +4,7 @@ import { background, border, borderColor, foreground, text } from "./components" import hoverPopover from "./hoverPopover" import { buildSyntax } from "../theme/syntax" +import { interactive, toggleable } from "../element" export default function editor(colorScheme: ColorScheme) { const { isLight } = colorScheme @@ -48,46 +49,76 @@ export default function editor(colorScheme: ColorScheme) { // Inline autocomplete suggestions, Co-pilot suggestions, etc. suggestion: syntax.predictive, codeActions: { - indicator: { - color: foreground(layer, "variant"), + indicator: toggleable({ + base: interactive({ + base: { + color: foreground(layer, "variant"), + }, + state: { + hovered: { + color: foreground(layer, "variant", "hovered"), + }, + clicked: { + color: foreground(layer, "variant", "pressed"), + }, + }, + }), + state: { + active: { + default: { + color: foreground(layer, "accent"), + }, + hovered: { + color: foreground(layer, "accent", "hovered"), + }, + clicked: { + color: foreground(layer, "accent", "pressed"), + }, + }, + }, + }), - 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"), + indicator: toggleable({ + base: interactive({ + base: { + color: foreground(layer, "variant"), + }, + state: { + hovered: { + color: foreground(layer, "on"), + }, + clicked: { + color: foreground(layer, "base"), + }, + }, + }), + state: { + active: { + default: { + color: foreground(layer, "default"), + }, + hovered: { + color: foreground(layer, "variant"), + }, + }, }, - 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(), + default: { + color: colorScheme.ramps.neutral(0.5).alpha(0.0).hex(), + }, - hover: { + hovered: { color: colorScheme.ramps.neutral(0.5).alpha(0.5).hex(), }, @@ -223,21 +254,26 @@ export default function editor(colorScheme: ColorScheme) { 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, + jumpIcon: interactive({ + base: { + 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"), + state: { + hovered: { + background: background(layer, "on", "hovered"), + }, }, - }, + }), + scrollbar: { width: 12, minHeightFactor: 1.0, diff --git a/styles/src/styleTree/feedback.ts b/styles/src/styleTree/feedback.ts index 5eef4b4279..c98cbe768f 100644 --- a/styles/src/styleTree/feedback.ts +++ b/styles/src/styleTree/feedback.ts @@ -1,35 +1,40 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, text } from "./components" +import { interactive } from "../element" export default function feedback(colorScheme: ColorScheme) { let layer = colorScheme.highest return { - submit_button: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 4, + 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, + }, }, - 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"), + }, }, - 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"), - }, - }, + }), button_margin: 8, info_text_default: text(layer, "sans", "default", { size: "xs" }), link_text_default: text(layer, "sans", "default", { diff --git a/styles/src/styleTree/picker.ts b/styles/src/styleTree/picker.ts index d84bd6fc7a..5501bd4df2 100644 --- a/styles/src/styleTree/picker.ts +++ b/styles/src/styleTree/picker.ts @@ -1,6 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, text } from "./components" +import { interactive, toggleable } from "../element" export default function picker(colorScheme: ColorScheme): any { let layer = colorScheme.lowest @@ -38,35 +39,65 @@ export default function picker(colorScheme: ColorScheme): any { ...container, padding: {}, }, - item: { - padding: { - bottom: 4, - left: 12, - right: 12, - top: 4, + 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 + ), + }, + clicked: { + background: withOpacity( + background(layer, "pressed"), + 0.5 + ), + }, + }, + }), + state: { + active: { + default: { + background: withOpacity( + background(layer, "base", "active"), + 0.5 + ), + }, + 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" }), - 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: { diff --git a/styles/src/styleTree/projectPanel.ts b/styles/src/styleTree/projectPanel.ts index a86ae010b6..6bec951288 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, toggleable } from "../element" export default function projectPanel(colorScheme: ColorScheme) { const { isLight } = colorScheme @@ -28,48 +28,79 @@ export default function projectPanel(colorScheme: ColorScheme) { }, } - let entry = { - ...baseEntry, - text: text(layer, "mono", "variant", { size: "sm" }), - hover: { - background: background(layer, "variant", "hovered"), + const default_entry = interactive({ + base: { + ...baseEntry, + text: text(layer, "mono", "variant", { size: "sm" }), + status, }, - active: { - background: colorScheme.isLight - ? withOpacity(background(layer, "active"), 0.5) - : background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), + state: { + default: { + background: background(layer), + }, + hovered: { + background: background(layer, "variant", "hovered"), + }, + clicked: { + background: background(layer, "variant", "pressed"), + }, }, - activeHover: { - background: background(layer, "active"), - text: text(layer, "mono", "active", { size: "sm" }), + }) + + let 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"), + }, + }, + }), }, - 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"), + 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"), + }, + clicked: { + ...text(layer, "sans", "default", { size: "sm" }), + background: background(layer, "pressed"), + border: border(layer, "active"), + }, + }, + }), background: background(layer), padding: { left: 6, right: 6, top: 0, bottom: 6 }, indentWidth: 12, @@ -94,8 +125,12 @@ export default function projectPanel(colorScheme: ColorScheme) { ...entry, text: text(layer, "mono", "disabled"), active: { - background: background(layer, "active"), - text: text(layer, "mono", "disabled", { size: "sm" }), + ...entry.active, + default: { + ...entry.active.default, + 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 d69c4bb2d9..b471e6cbda 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -1,6 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" +import { interactive, toggleable } from "../element" export default function search(colorScheme: ColorScheme) { let layer = colorScheme.highest @@ -35,36 +36,50 @@ 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: { - ...text(layer, "mono", "on"), - background: background(layer, "on"), - cornerRadius: 6, - border: border(layer, "on"), - margin: { - right: 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: { + 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", "accent"), + }, + hovered: { + ...text(layer, "mono", "accent", "hovered"), + }, + clicked: { + ...text(layer, "mono", "accent", "pressed"), + }, + }, }, - 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, @@ -97,17 +112,24 @@ export default function search(colorScheme: ColorScheme) { ...text(layer, "mono", "on"), size: 18, }, - dismissButton: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 14, - padding: { - left: 10, - right: 10, + dismissButton: interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: 14, + padding: { + left: 10, + right: 10, + }, }, - hover: { - color: foreground(layer, "hovered"), + state: { + hovered: { + color: foreground(layer, "hovered"), + }, + clicked: { + color: foreground(layer, "pressed"), + }, }, - }, + }), } } diff --git a/styles/src/styleTree/simpleMessageNotification.ts b/styles/src/styleTree/simpleMessageNotification.ts index 8d88f05c53..e894db3514 100644 --- a/styles/src/styleTree/simpleMessageNotification.ts +++ b/styles/src/styleTree/simpleMessageNotification.ts @@ -1,5 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { background, border, foreground, text } from "./components" +import { interactive } from "../element" const headerPadding = 8 @@ -12,33 +13,41 @@ export default function simpleMessageNotification( ...text(layer, "sans", { size: "xs" }), margin: { left: headerPadding, right: headerPadding }, }, - 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"), + 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 }, }, - }, - dismissButton: { - color: foreground(layer), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - hover: { - color: foreground(layer, "hovered"), + 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 a8d926f40e..339e2e40cf 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, toggleable } from "../element" export default function statusBar(colorScheme: ColorScheme) { let layer = colorScheme.lowest @@ -25,95 +25,123 @@ export default function statusBar(colorScheme: ColorScheme) { }, 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"), + 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: { - ...diagnosticStatusContainer, - iconSpacing: 4, - iconWidth: 14, - height: 18, - message: text(layer, "sans"), - iconColor: foreground(layer), - hover: { + lspStatus: interactive({ + base: { + ...diagnosticStatusContainer, + iconSpacing: 4, + iconWidth: 14, + height: 18, message: text(layer, "sans"), iconColor: foreground(layer), - background: background(layer, "hovered"), }, - }, - 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 }, + state: { + hovered: { + message: text(layer, "sans"), + iconColor: foreground(layer), + background: background(layer, "hovered"), + }, }, - containerWarning: { - ...diagnosticStatusContainer, - background: background(layer, "warning"), - border: border(layer, "warning"), + }), + diagnosticMessage: interactive({ + base: { + ...text(layer, "sans"), }, - containerError: { - ...diagnosticStatusContainer, - background: background(layer, "negative"), - border: border(layer, "negative"), - }, - hover: { - iconColorOk: foreground(layer, "on"), + 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 }, - background: background(layer, "on", "hovered"), }, containerWarning: { ...diagnosticStatusContainer, - background: background(layer, "warning", "hovered"), - border: border(layer, "warning", "hovered"), + background: background(layer, "warning"), + border: border(layer, "warning"), }, containerError: { ...diagnosticStatusContainer, - background: background(layer, "negative", "hovered"), - border: border(layer, "negative", "hovered"), + 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: { - ...statusContainer, - iconSize: 16, - iconColor: foreground(layer, "variant"), - label: { - margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), + 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"), + }, + hovered: { + iconColor: foreground(layer, "hovered"), + background: background(layer, "hovered"), + }, + clicked: { + iconColor: foreground(layer, "pressed"), + background: background(layer, "pressed"), + }, + }, }, - hover: { - iconColor: foreground(layer, "hovered"), - background: background(layer, "variant"), - }, - active: { - 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 c5b397b34a..af35a8fef4 100644 --- a/styles/src/styleTree/tabBar.ts +++ b/styles/src/styleTree/tabBar.ts @@ -1,6 +1,7 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" import { text, border, background, foreground } from "./components" +import { interactive, toggleable } from "../element" export default function tabBar(colorScheme: ColorScheme) { const height = 32 @@ -87,17 +88,36 @@ export default function tabBar(colorScheme: ColorScheme) { inactiveTab: inactivePaneInactiveTab, }, draggedTab, - paneButton: { - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: activePaneActiveTab.height, - hover: { - color: foreground(layer, "hovered"), + paneButton: toggleable({ + base: interactive({ + base: { + color: foreground(layer, "variant"), + iconWidth: 12, + buttonWidth: activePaneActiveTab.height, + }, + state: { + hovered: { + color: foreground(layer, "hovered"), + }, + clicked: { + color: foreground(layer, "pressed"), + }, + }, + }), + state: { + active: { + default: { + color: foreground(layer, "accent"), + }, + hovered: { + color: foreground(layer, "hovered"), + }, + clicked: { + color: foreground(layer, "pressed"), + }, + }, }, - active: { - color: foreground(layer, "accent"), - }, - }, + }), paneButtonContainer: { background: tab.background, border: { diff --git a/styles/src/styleTree/toggle.ts b/styles/src/styleTree/toggle.ts new file mode 100644 index 0000000000..2b6858e15b --- /dev/null +++ b/styles/src/styleTree/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 +} diff --git a/styles/src/styleTree/toolbarDropdownMenu.ts b/styles/src/styleTree/toolbarDropdownMenu.ts index 92616eb022..d82e5f1cde 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, toggleable } from "../element" export default function dropdownMenu(colorScheme: ColorScheme) { let layer = colorScheme.middle @@ -9,38 +9,56 @@ export default function dropdownMenu(colorScheme: ColorScheme) { 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" }), - } - }, + 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"), + }, + state: { + hovered: { + background: background(layer, "hovered"), + }, + clicked: { + background: background(layer, "pressed"), + }, + }, + }), 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" }), + 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, "hovered"), + }, + }, }, - active: { - background: background(layer, "active"), - }, - activeHover: { - background: background(layer, "active"), - }, - }, + }), } } diff --git a/styles/src/styleTree/updateNotification.ts b/styles/src/styleTree/updateNotification.ts index 281012e62f..c6ef81c667 100644 --- a/styles/src/styleTree/updateNotification.ts +++ b/styles/src/styleTree/updateNotification.ts @@ -1,5 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { foreground, text } from "./components" +import { interactive } from "../element" const headerPadding = 8 @@ -10,22 +11,30 @@ export default function updateNotification(colorScheme: ColorScheme): Object { ...text(layer, "sans", { size: "xs" }), margin: { left: headerPadding, right: headerPadding }, }, - actionMessage: { - ...text(layer, "sans", { size: "xs" }), - margin: { left: headerPadding, top: 6, bottom: 6 }, - hover: { - color: foreground(layer, "hovered"), + actionMessage: interactive({ + base: { + ...text(layer, "sans", { size: "xs" }), + margin: { left: headerPadding, top: 6, bottom: 6 }, }, - }, - dismissButton: { - color: foreground(layer), - iconWidth: 8, - iconHeight: 8, - buttonWidth: 8, - buttonHeight: 8, - hover: { - color: foreground(layer, "hovered"), + 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 10e6e02b95..311ff6daff 100644 --- a/styles/src/styleTree/welcome.ts +++ b/styles/src/styleTree/welcome.ts @@ -8,6 +8,7 @@ import { TextProperties, svg, } from "./components" +import { interactive } from "../element" export default function welcome(colorScheme: ColorScheme) { let layer = colorScheme.highest @@ -63,27 +64,31 @@ export default function welcome(colorScheme: ColorScheme) { 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"), + 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: { diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index ae8de178f8..bd14a3af72 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -1,5 +1,6 @@ import { ColorScheme } from "../theme/colorScheme" import { withOpacity } from "../theme/color" +import { toggleable } from "../element" import { background, border, @@ -10,38 +11,53 @@ import { } 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 = { - cornerRadius: 6, - padding: { - top: 1, - bottom: 1, - left: 8, - right: 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"), + }, + }, }, - ...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 @@ -78,19 +94,24 @@ export default function workspace(colorScheme: ColorScheme) { }, cornerRadius: 4, }, - keyboardHint: { - ...text(layer, "sans", "variant", { size: "sm" }), - padding: { - top: 3, - left: 8, - right: 8, - bottom: 3, + keyboardHint: interactive({ + base: { + ...text(layer, "sans", "variant", { size: "sm" }), + padding: { + top: 3, + left: 8, + right: 8, + bottom: 3, + }, + cornerRadius: 8, }, - cornerRadius: 8, - hover: { - ...text(layer, "sans", "active", { size: "sm" }), + state: { + hovered: { + ...text(layer, "sans", "active", { size: "sm" }), + }, }, - }, + }), + keyboardHintWidth: 320, }, joiningProjectAvatar: { @@ -201,12 +222,15 @@ export default function workspace(colorScheme: ColorScheme) { // Sign in buttom // FlatButton, Variant - signInPrompt: { - margin: { - left: itemSpacing, + signInPrompt: merge(titlebarButton, { + inactive: { + default: { + margin: { + left: itemSpacing, + }, + }, }, - ...titlebarButton, - }, + }), // Offline Indicator offlineIcon: { @@ -234,40 +258,68 @@ export default function workspace(colorScheme: ColorScheme) { }, cornerRadius: 6, }, - callControl: { - cornerRadius: 6, - color: foreground(layer, "variant"), - iconWidth: 12, - buttonWidth: 20, - hover: { - background: background(layer, "variant", "hovered"), - color: foreground(layer, "variant", "hovered"), + 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"), + }, + }, + }, + }), + userMenuButton: merge(titlebarButton, { + inactive: { + default: { + buttonWidth: 20, + iconWidth: 12, + }, }, - }, - 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"), + // posiewic: these properties are not currently set on main + default: { + iconWidth: 12, + button_width: 20, + }, }, - 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, @@ -285,12 +337,45 @@ export default function workspace(colorScheme: ColorScheme) { background: background(colorScheme.highest), border: border(colorScheme.highest, { bottom: true }), itemSpacing: 8, - navButton: { - color: foreground(colorScheme.highest, "on"), - iconWidth: 12, - buttonWidth: 24, + 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, - hover: { + padding: { + left: 6, + right: 6, + }, + }, + state: { + hovered: { color: foreground(colorScheme.highest, "on", "hovered"), background: background( colorScheme.highest, @@ -298,25 +383,8 @@ export default function workspace(colorScheme: ColorScheme) { "hovered" ), }, - disabled: { - color: foreground(colorScheme.highest, "on", "disabled"), - }, }, - padding: { left: 8, right: 8, top: 4, bottom: 4 }, - }, - 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), 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] = { 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/themes/rose-pine/common.ts b/styles/src/themes/rose-pine/common.ts new file mode 100644 index 0000000000..8b3b3b7000 --- /dev/null +++ b/styles/src/themes/rose-pine/common.ts @@ -0,0 +1,75 @@ +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', + }, + 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): Partial => { + return { + comment: { color: c.muted }, + operator: { color: c.pine }, + punctuation: { color: c.subtle }, + variable: { color: c.text }, + string: { color: c.gold }, + 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 }, + "function.method": { color: c.rose }, + 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) + } } 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 6d24728a0a..7a8ec69927 100644 --- a/styles/tsconfig.json +++ b/styles/tsconfig.json @@ -20,7 +20,17 @@ "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"] } diff --git a/styles/vitest.config.ts b/styles/vitest.config.ts new file mode 100644 index 0000000000..00f3a9852d --- /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"], + }, +})