web: the library checks for wasm32 (carried)

This commit is contained in:
ZacharyZhang-NY committed 2026-09-29 19:16:41 -04:00
1 parent fe467d2bfe
commit a03df0987c
44 files changed
+141 -104

No files matched your search

+3 -1
View File
@@ -1,4 +1,6 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use web_time::Instant;
use crate::motion;
+2 -1
View File
@@ -1,6 +1,6 @@
use std::{
f32::consts::{FRAC_PI_2, PI, TAU},
time::{Duration, Instant},
time::Duration,
};
use gpui::{
@@ -8,6 +8,7 @@ use gpui::{
MouseMoveEvent, ParentElement, PathBuilder, Pixels, Point, Refineable, RenderOnce,
SharedString, StatefulInteractiveElement, StyleRefinement, Styled, Window, canvas, div, point,
};
use web_time::Instant;
use super::{
axes::anchored,
+1 -2
View File
@@ -1,10 +1,9 @@
use std::time::Instant;
use gpui::{
App, Bounds, ContentMask, Div, ElementId, Entity, InteractiveElement, IntoElement,
ParentElement, PathBuilder, Pixels, Refineable, RenderOnce, StyleRefinement, Styled, Window,
canvas, div, fill, size,
};
use web_time::Instant;
use super::{
axes::beside,
+2 -4
View File
@@ -1,13 +1,11 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
App, ElementId, Entity, FontWeight, InteractiveElement, IntoElement, MouseButton,
ParentElement, RenderOnce, SharedString, StatefulInteractiveElement, Styled, Window, div,
prelude::*, relative, transparent_black,
};
use web_time::Instant;
use super::stream::StreamingText;
use crate::{
+2 -1
View File
@@ -1,10 +1,11 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{
App, ElementId, HighlightStyle, IntoElement, ParentElement, RenderOnce, SharedString, Styled,
StyledText, Window, div,
};
use unicode_segmentation::UnicodeSegmentation;
use web_time::Instant;
use super::code::CodeBlock;
use crate::{
+2 -1
View File
@@ -1,6 +1,7 @@
use std::{rc::Rc, time::Instant};
use std::rc::Rc;
use gpui::{App, ElementId, IntoElement, ParentElement, RenderOnce, Styled, Window, div};
use web_time::Instant;
use crate::{
buttons::{ButtonVariant, IconButton},
+2 -4
View File
@@ -1,13 +1,11 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
AnyElement, App, Div, ElementId, HoverListenerMode, InteractiveElement, IntoElement,
MouseButton, ParentElement, RenderOnce, StatefulInteractiveElement, StyleRefinement, Styled,
Task, Window, div, prelude::*, relative,
};
use web_time::Instant;
use crate::{
motion,
+2 -4
View File
@@ -1,11 +1,9 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
App, ElementId, IntoElement, ParentElement, RenderOnce, Styled, Task, Window, div, prelude::*,
};
use web_time::Instant;
use crate::{
forms::Run,
+2 -1
View File
@@ -1,10 +1,11 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use anyhow::anyhow;
use gpui::{
Context, Entity, FocusHandle, IntoElement, ParentElement, Pixels, Render, Styled,
TestAppContext, VisualTestContext, Window, div, px,
};
use web_time::Instant;
use super::{press, settle, setup, wait};
use crate::{
+2 -4
View File
@@ -1,7 +1,4 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
Anchor, Animation, AnimationExt, AnyElement, App, ClickEvent, Context, ElementId, Entity,
@@ -9,6 +6,7 @@ use gpui::{
RenderOnce, SharedString, StatefulInteractiveElement, Styled, Task, Window, anchored, canvas,
div, point, prelude::*, relative,
};
use web_time::Instant;
use crate::{
buttons::{Button, ButtonVariant, IconButton},
+2 -4
View File
@@ -1,9 +1,7 @@
use std::{
ops::Range,
time::{Duration, Instant},
};
use std::{ops::Range, time::Duration};
use unicode_segmentation::UnicodeSegmentation;
use web_time::Instant;
pub(crate) fn prev_grapheme(text: &str, offset: usize) -> usize {
text.grapheme_indices(true)
+1 -2
View File
@@ -1,11 +1,10 @@
use std::time::Instant;
use gpui::{
Animation, AnimationExt, AnyElement, App, ElementId, Entity, FontWeight, InteractiveElement,
IntoElement, ParentElement, Pixels, RenderOnce, SharedString, StatefulInteractiveElement,
Styled, Window, canvas, div,
};
use smallvec::SmallVec;
use web_time::Instant;
use crate::{
motion,
+2 -5
View File
@@ -1,8 +1,4 @@
use std::{
cell::Cell,
rc::Rc,
time::{Duration, Instant},
};
use std::{cell::Cell, rc::Rc, time::Duration};
use gpui::{
AnyElement, App, Axis, Bounds, Canvas, Div, ElementId, EmptyView, Entity, EntityId,
@@ -11,6 +7,7 @@ use gpui::{
div, point, prelude::*,
};
use smallvec::SmallVec;
use web_time::Instant;
use super::ScrollShadow;
use crate::{motion, theme::ActiveTheme};
+2 -4
View File
@@ -1,12 +1,10 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
AnyElement, App, ElementId, IntoElement, ParentElement, Pixels, RenderOnce, ScrollHandle,
Styled, Window, canvas, div, point, prelude::*,
};
use web_time::Instant;
use crate::{
buttons::{ButtonVariant, IconButton},
+1 -2
View File
@@ -1,10 +1,9 @@
use std::time::Instant;
use gpui::{
Animation, AnimationExt, AnyElement, App, ElementId, InteractiveElement, IntoElement,
ParentElement, RenderOnce, Styled, Window, div,
};
use smallvec::SmallVec;
use web_time::Instant;
use crate::{motion, theme::ActiveTheme};
+1
View File
@@ -65,6 +65,7 @@ pub fn init(cx: &mut App) {
]);
forms::bind_keys(cx);
editor::bind_keys(cx);
#[cfg(not(target_family = "wasm"))]
terminal::bind_keys(cx);
documents::bind_keys(cx);
}
+2 -4
View File
@@ -1,12 +1,10 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
App, Div, ElementId, InteractiveElement, IntoElement, MouseButton, ParentElement, RenderOnce,
ScrollHandle, SharedString, StatefulInteractiveElement, StyleRefinement, Styled, Window, div,
};
use web_time::Instant;
use super::ListItem;
use crate::primitives::tab_stop;
+2 -1
View File
@@ -1,10 +1,11 @@
use std::{rc::Rc, time::Instant};
use std::rc::Rc;
use gpui::{
AnyElement, App, ElementId, InteractiveElement, IntoElement, MouseButton, ParentElement,
Pixels, RenderOnce, ScrollDelta, SharedString, StatefulInteractiveElement, Styled, TouchPhase,
Window, div, prelude::*,
};
use web_time::Instant;
use crate::{
data_display::Tone,
+1 -1
View File
@@ -26,7 +26,7 @@ const JUMP: f64 = 10.0;
/// When the pointer last moved over the player, and whether a wake is set to hide the controls.
struct Watch {
moved: std::time::Instant,
moved: web_time::Instant,
waking: bool,
}
+2 -1
View File
@@ -1,9 +1,10 @@
use std::{rc::Rc, time::Instant};
use std::rc::Rc;
use gpui::{
AnyElement, App, ElementId, IntoElement, ParentElement, RenderOnce, Styled, Window, div,
prelude::*,
};
use web_time::Instant;
use crate::{
buttons::{Button, ButtonVariant, IconButton, ToggleButton, ToggleItem},
+2 -1
View File
@@ -1,10 +1,11 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{
Context, Entity, IntoElement, Modifiers, MouseButton, ParentElement, Render, ScrollDelta,
ScrollWheelEvent, SharedString, Styled, TestAppContext, TouchPhase, VisualTestContext, Window,
div, point, px,
};
use web_time::Instant;
use super::{picture, press, settle, setup, tab_to};
use crate::media::{
+2 -1
View File
@@ -1,9 +1,10 @@
use std::{rc::Rc, time::Instant};
use std::rc::Rc;
use gpui::{
App, ElementId, IntoElement, MouseButton, ParentElement, RenderOnce, SharedString, Styled,
Window, div, prelude::*,
};
use web_time::Instant;
use crate::{
buttons::{Button, ButtonVariant},
+1 -2
View File
@@ -1,9 +1,8 @@
use std::time::Instant;
use gpui::{
App, Context, Entity, InteractiveElement, IntoElement, Modifiers, ParentElement, Render,
Styled, TestAppContext, Window, div, px,
};
use web_time::Instant;
use super::{press, settle, setup, tab_to};
use crate::{
+5 -2
View File
@@ -1,9 +1,10 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{
App, ElementId, FocusHandle, InteractiveElement, IntoElement, ParentElement, RenderOnce,
Styled, Task, Window, div,
};
use web_time::Instant;
use crate::{
buttons::{Button, ButtonVariant},
@@ -202,7 +203,9 @@ impl RenderOnce for Stopwatch {
#[cfg(test)]
mod tests {
use std::time::{Duration, Instant};
use std::time::Duration;
use web_time::Instant;
use super::{Run, tenths};
+2 -1
View File
@@ -1,6 +1,6 @@
use std::{
f32::consts::{PI, TAU},
time::{Duration, Instant},
time::Duration,
};
use gpui::{
@@ -9,6 +9,7 @@ use gpui::{
prelude::*,
};
use smallvec::SmallVec;
use web_time::Instant;
use super::{NUDGE, SLOW, duration, ease_out_cubic};
use crate::theme::ActiveTheme;
+2 -1
View File
@@ -1,9 +1,10 @@
use std::{collections::HashMap, rc::Rc, time::Instant};
use std::{collections::HashMap, rc::Rc};
use gpui::{
AnyElement, App, ElementId, Entity, IntoElement, ParentElement, Pixels, RenderOnce,
SharedString, Styled, Window, canvas, div,
};
use web_time::Instant;
use super::{BASE, duration, ease_in_out_cubic, ease_out_cubic};
use crate::theme::{ActiveTheme, Elevation};
+2 -1
View File
@@ -1,4 +1,4 @@
use std::{f32::consts::PI, time::Instant};
use std::f32::consts::PI;
use gpui::{
Animation, AnimationExt, AnyElement, App, Div, ElementId, InteractiveElement, IntoElement,
@@ -6,6 +6,7 @@ use gpui::{
prelude::*, radians,
};
use smallvec::SmallVec;
use web_time::Instant;
use super::{BASE, FAST, NUDGE, Skeleton, Spinner, changes, duration, ease_out_cubic};
use crate::{
+2 -4
View File
@@ -1,7 +1,4 @@
use std::{
f32::consts::TAU,
time::{Duration, Instant},
};
use std::{f32::consts::TAU, time::Duration};
use gpui::{
Animation, AnimationExt, AnyElement, App, Bounds, Div, ElementId, Hsla, InteractiveElement,
@@ -10,6 +7,7 @@ use gpui::{
px, size,
};
use smallvec::SmallVec;
use web_time::Instant;
use super::{
duration,
+2 -1
View File
@@ -1,10 +1,11 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{
Animation, AnimationExt, AnyElement, App, ElementId, IntoElement, ParentElement, RenderOnce,
Styled, Window, div,
};
use smallvec::SmallVec;
use web_time::Instant;
use super::{BASE, NUDGE, duration, ease_out_cubic};
use crate::theme::ActiveTheme;
+5 -5
View File
@@ -1,11 +1,9 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
App, ElementId, Entity, IntoElement, ParentElement, RenderOnce, Styled, Task, Window, div,
};
use web_time::Instant;
use crate::{
buttons::{Button, ButtonVariant, IconButton},
@@ -298,7 +296,9 @@ impl RenderOnce for PomodoroTimer {
#[cfg(test)]
mod tests {
use std::time::{Duration, Instant};
use std::time::Duration;
use web_time::Instant;
use super::{Cycle, Lengths, Phase};
+1 -1
View File
@@ -2,10 +2,10 @@ use gpui::{
AnyElement, Context, Entity, IntoElement, KeyBinding, KeyUpEvent, Keystroke, Modifiers,
ParentElement, Render, Styled, TestAppContext, VisualTestContext, Window, div, px,
};
use std::time::Instant;
use gpui::SharedString;
use jiff::civil::date;
use web_time::Instant;
use super::{AssigneePicker, IssueId, Person, Priority, Status, StatusSelect, Task, TaskList};
use crate::{documents::Checklist, forms::bind_keys, primitives::FocusNext, theme::Theme};
+2 -4
View File
@@ -1,12 +1,10 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
App, ElementId, InteractiveElement, IntoElement, ParentElement, RenderOnce, SharedString,
Styled, Task, Window, div,
};
use web_time::Instant;
use crate::{
buttons::{Button, ButtonVariant},
+2 -1
View File
@@ -1,9 +1,10 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{
Animation, AnimationExt, AnyElement, App, ElementId, IntoElement, ParentElement, RenderOnce,
Styled, Task, Window, div, prelude::*,
};
use web_time::Instant;
use crate::{
buttons::{ButtonVariant, IconButton},
+15 -7
View File
@@ -1,13 +1,10 @@
use std::ops::Range;
use std::ops::{Index, Range};
use alacritty_terminal::{
term::color::Colors,
vte::ansi::{Attr, Color, Handler, Processor},
};
use gpui::{
App, FontStyle, FontWeight, HighlightStyle, IntoElement, ParentElement, RenderOnce,
SharedString, StrikethroughStyle, Styled, StyledText, UnderlineStyle, Window, div,
};
use vte::ansi::{Attr, Color, Handler, Processor, Rgb};
use super::colors::Ink;
use crate::theme::{ActiveTheme, TextSize};
@@ -93,9 +90,20 @@ pub(crate) fn printed(source: &str) -> (String, Vec<(Range<usize>, Pen)>) {
(printed.text, printed.spans)
}
/// Plain text sets no colors with OSC 4, 10 or 11.
struct Unset;
impl Index<usize> for Unset {
type Output = Option<Rgb>;
fn index(&self, _: usize) -> &Option<Rgb> {
&None
}
}
impl Pen {
fn style(&self, ink: &Ink, rule: gpui::Pixels) -> HighlightStyle {
let set = Colors::default();
let set = Unset;
let paint =
|color: Option<Color>, plain| color.map_or(plain, |color| ink.resolve(color, &set));
let (mut fg, mut bg) = (paint(self.fg, ink.fg), paint(self.bg, ink.bg));
@@ -158,7 +166,7 @@ impl RenderOnce for AnsiText {
#[cfg(test)]
mod tests {
use alacritty_terminal::vte::ansi::NamedColor;
use vte::ansi::NamedColor;
use super::*;
+15 -9
View File
@@ -1,8 +1,7 @@
use alacritty_terminal::{
term::color::Colors,
vte::ansi::{Color, NamedColor, Rgb},
};
use std::ops::Index;
use gpui::{Hsla, Rgba};
use vte::ansi::{Color, NamedColor, Rgb};
use crate::theme::Palette;
@@ -24,7 +23,7 @@ impl Ink {
}
/// A color as painted, after any the program set with OSC 4, 10 or 11.
pub(crate) fn resolve(&self, color: Color, set: &Colors) -> Hsla {
pub(crate) fn resolve(&self, color: Color, set: &impl Set) -> Hsla {
match color {
Color::Spec(spec) => hsla(spec),
Color::Indexed(index) => self.indexed(index as usize, set),
@@ -32,8 +31,8 @@ impl Ink {
}
}
fn named(&self, name: NamedColor, set: &Colors) -> Hsla {
if let Some(spec) = set[name] {
fn named(&self, name: NamedColor, set: &impl Set) -> Hsla {
if let Some(spec) = set[name as usize] {
return hsla(spec);
}
match name {
@@ -49,7 +48,7 @@ impl Ink {
}
}
fn indexed(&self, index: usize, set: &Colors) -> Hsla {
fn indexed(&self, index: usize, set: &impl Set) -> Hsla {
if let Some(spec) = set[index] {
return hsla(spec);
}
@@ -76,7 +75,8 @@ impl Ink {
}
/// Color `index` as an answer to a program's query.
pub(crate) fn query(&self, index: usize, set: &Colors) -> Rgb {
#[cfg(not(target_family = "wasm"))]
pub(crate) fn query(&self, index: usize, set: &impl Set) -> Rgb {
let color = match index {
256 => self.named(NamedColor::Foreground, set),
257 => self.named(NamedColor::Background, set),
@@ -93,6 +93,11 @@ impl Ink {
}
}
/// Colors a program set with OSC 4, 10 or 11, by index.
pub(crate) trait Set: Index<usize, Output = Option<Rgb>> {}
impl<T: Index<usize, Output = Option<Rgb>>> Set for T {}
fn hsla(spec: Rgb) -> Hsla {
let channel = |value: u8| f32::from(value) / 255.0;
Rgba {
@@ -106,6 +111,7 @@ fn hsla(spec: Rgb) -> Hsla {
#[cfg(test)]
mod tests {
use alacritty_terminal::term::color::Colors;
use gpui::{black, white};
use super::*;
+10
View File
@@ -1,28 +1,38 @@
mod ansi;
mod block;
mod colors;
#[cfg(not(target_family = "wasm"))]
mod frame;
mod history;
#[cfg(not(target_family = "wasm"))]
mod input;
#[cfg(not(target_family = "wasm"))]
mod keys;
mod links;
mod logs;
#[cfg(not(target_family = "wasm"))]
mod paint;
mod processes;
#[cfg(not(target_family = "wasm"))]
mod pty;
#[cfg(not(target_family = "wasm"))]
mod search;
mod shells;
#[cfg(all(test, feature = "test-support"))]
mod tests;
#[cfg(not(target_family = "wasm"))]
mod view;
pub use ansi::AnsiText;
pub use block::{CommandBlock, CommandState};
pub use history::{CommandHistory, PastCommand};
#[cfg(not(target_family = "wasm"))]
pub(crate) use input::bind_keys;
pub use links::{Target, links};
pub use logs::{LogLevel, LogLine, LogViewer};
pub use processes::{Process, ProcessList};
#[cfg(not(target_family = "wasm"))]
pub use pty::Launch;
pub use shells::{ShellChoice, ShellSelector, TerminalToolbar};
#[cfg(not(target_family = "wasm"))]
pub use view::{Terminal, TerminalEvent};
+2 -1
View File
@@ -1,4 +1,4 @@
use std::{borrow::Cow, process::ExitStatus, rc::Rc, sync::Arc, time::Instant};
use std::{borrow::Cow, process::ExitStatus, rc::Rc, sync::Arc};
use alacritty_terminal::{
event::{Event, Notify, OnResize},
@@ -13,6 +13,7 @@ use gpui::{
App, ClipboardItem, Context, EventEmitter, FocusHandle, Focusable, IntoElement, ParentElement,
Pixels, Point, Render, SharedString, Size, Styled, Task, Window, div, font, prelude::*, size,
};
use web_time::Instant;
use super::{
colors::Ink,
+2 -1
View File
@@ -20,9 +20,10 @@ mod tooling;
#[cfg(all(test, feature = "test-support"))]
mod tests;
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{App, Global, SharedString, WindowAppearance};
use web_time::Instant;
use crate::motion;
pub use calendar::CalendarSizes;
+4 -7
View File
@@ -1,9 +1,4 @@
use std::{
collections::VecDeque,
fmt,
rc::Rc,
time::{Duration, Instant},
};
use std::{collections::VecDeque, fmt, rc::Rc, time::Duration};
use gpui::{
AnyElement, App, DispatchPhase, ElementId, InteractiveElement, IntoElement, KeyContext,
@@ -12,6 +7,7 @@ use gpui::{
Window, canvas, div, prelude::FluentBuilder,
};
use smallvec::SmallVec;
use web_time::Instant;
use crate::{
layout::on_axis,
@@ -264,9 +260,10 @@ impl RenderOnce for EventLogger {
#[cfg(test)]
mod tests {
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{Modifiers, MouseButton, point, px};
use web_time::Instant;
use super::{KEPT, Log, Seen};
+5 -5
View File
@@ -1,12 +1,10 @@
use std::{
collections::VecDeque,
time::{Duration, Instant},
};
use std::{collections::VecDeque, time::Duration};
use gpui::{
App, Bounds, ElementId, FontWeight, InteractiveElement, IntoElement, ParentElement, RenderOnce,
Styled, Window, canvas, div, fill, point, size,
};
use web_time::Instant;
use crate::{
theme::{ActiveTheme, Radius, TextSize},
@@ -183,7 +181,9 @@ impl RenderOnce for FpsMeter {
#[cfg(test)]
mod tests {
use std::time::{Duration, Instant};
use std::time::Duration;
use web_time::Instant;
use super::{Frames, missed};