Skip to main content

arc_gpui/
lib.rs

1//! # `arc-gpui` — Unified Facade Crate for Arc-rs
2//!
3//! Install a single dependency in `Cargo.toml` to access the entire Arc-rs ecosystem on GPUI:
4//!
5//! ```toml
6//! [dependencies]
7//! arc-gpui = "0.2.0"
8//! ```
9//!
10//! Disable the node-graph canvas if you only need UI components, tokens, and motion:
11//!
12//! ```toml
13//! [dependencies]
14//! arc-gpui = { version = "0.2.0", default-features = false }
15//! ```
16//!
17//! ## Included Modules
18//! - [`tokens`] (`arc-tokens`): OKLCH/OKLab palettes, 8 semantic accents, radii, shadows, typography, i18n, spring specs.
19//! - [`motion`] (`arc-motion`): analytical ODE spring solver, cubic bezier, FLIP shared layout, presence, drag/inertia.
20//! - [`ui`] (`arc-ui`): 120+ interactive desktop components and charts, also re-exported at the crate root.
21//! - [`flow`] (`arc-flow`, enabled by default via feature `flow`): GPU-accelerated node & workflow canvas.
22//! - [`flow_core`] (`arc-flow-core`, enabled by default via feature `flow`): UI-agnostic graph kernel.
23//! - [`gpui_kit`]: Underlying GPUI Kit runtime re-export.
24//! - [`prelude`]: Common setup helpers, theme/locale traits, and core components.
25
26pub use arc_motion as motion;
27pub use arc_tokens as tokens;
28pub use arc_ui as ui;
29pub use gpui_kit;
30
31#[cfg(feature = "flow")]
32pub use arc_flow as flow;
33#[cfg(feature = "flow")]
34pub use arc_flow_core as flow_core;
35#[cfg(feature = "graph")]
36pub use arc_graph as graph;
37#[cfg(feature = "graph")]
38pub use arc_graph_core as graph_core;
39
40pub use arc_ui::{
41    ActionButton, ActionSwap, ActivityHeatmap, Alert, AnimatedCounter, AnnouncementBar, ArcDialog,
42    ArcHoverCard, ArcOverlay, ArcPopover, ArcTooltip, Avatar, AvatarGroup, Badge, BarChart,
43    BillingToggle, BottomSheet, Breadcrumb, BrushChart, Button, ButtonGroup, Calendar, Card,
44    CardStack, Carousel, ChatThread, Checkbox, ChipGroup, CodeBlock, ColorPicker, Combobox,
45    CommentThread, ConfirmMorph, ContextMenu, CookieConsent, CopyButton, Countdown, DatePicker,
46    DateRangePicker, DonutChart, Drawer, DropdownMenu, ElasticSlider, EmptyState, ExpandableCard,
47    ExpandableText, ExpandingButtonGroup, ExpandingSearch, FileDropzone, FilterToolbar,
48    FloatingButtonGroup, Gauge, HoldToConfirm, IconMorph, ImageCompare, InViewTitle, InlineEdit,
49    Input, JsonViewer, LineChart, MentionInput, MetricCard, MoneyInput, MorphSelect, MultiSelect,
50    NumberField, OnboardingChecklist, Pagination, PasswordField, PasswordStrength, PhoneInput,
51    Progress, RadioCards, RadioGroup, RangeHistogramSlider, Rating, Reactions, ReorderableList,
52    ResizablePanels, RichTextEditor, Ridgeline, RulerSlider, ScrollArea, ScrubInput, SearchField,
53    SegmentedControl, Select, ShortcutRecorder, SignaturePad, Skeleton, Slider, SlopeChart,
54    SlotText, SortableDataTable, Sparkline, SplitButton, Stepper, Streamgraph, SwipeActions,
55    Switch, Tabs, TagInput, TextMorph, TextReveal, TextShimmer, Textarea, ThemeSwitch, TimePicker,
56    Timeline, Toast, ToastStack, ToggleGroup, TreeTable, TreeView, Treemap, UsageMeter, UserMenu,
57    WaffleChart,
58};
59pub use arc_ui::{
60    ChangelogEntry, ChangelogFeed, ChangelogKind, ChangelogMedia, CommandItem, CommandPalette,
61    ComparisonColumn, ComparisonRow, ComparisonSection, ComparisonTable, ComparisonValue,
62    EmptyScene, EmptyStates, FileUpload, FileUploadItem, NotificationActor, NotificationCenter,
63    NotificationItem, NotificationTone, OtpInput, OtpInputMode, PageActivity, PageFile, PageHeader,
64    PageIssue, PageMilestone, PagePerson, PageSection, PageUpdate, UploadRequest,
65};
66/// Re-export all UI components & charts at the crate root for ergonomic imports
67/// (`use arc_gpui::{Button, Toast, LineChart, ...};`).
68pub use arc_ui::{
69    actions, blocks, chart, data, disclosure, feedback, inputs, install_overlay_layer, overlay,
70    text,
71};
72
73#[cfg(feature = "flow")]
74pub use arc_flow::{DefaultNodeRenderer, FlowCanvas, NodeRenderCtx, NodeRenderer};
75#[cfg(feature = "graph")]
76pub use arc_graph::{Graph2D, Lod, RenderCounts};
77
78/// Convenient prelude for bootstrapping an Arc-rs GPUI application.
79pub mod prelude {
80    #[cfg(feature = "flow")]
81    pub use crate::flow::{DefaultNodeRenderer, FlowCanvas, NodeRenderCtx, NodeRenderer};
82    #[cfg(feature = "graph")]
83    pub use crate::graph::{Graph2D, Lod, RenderCounts};
84    pub use crate::motion::{
85        ArcPresence, CubicBezier, ReducedMotionChoice, SpringSolver, arc_spring, arc_transition,
86        is_reduced_motion, set_reduced_motion, set_time_scale,
87    };
88    pub use crate::tokens::{
89        Accent, ActiveArcLocale as _, ActiveArcTheme as _, ArcColors, ControlHeights, Locale,
90        Radii, Shadows, Spacing, ThemeMode, Typography, install_arc_theme, set_locale,
91    };
92    pub use crate::ui::install_overlay_layer;
93}
94
95/// One-shot Arc-rs initialization helper to run inside `gpui_kit::application().run(|cx| ...)`.
96///
97/// Installs `gpui_kit`, the window-level `ArcOverlay` portal layer, locale, and Arc theme.
98pub fn init_arc(
99    mode: tokens::ThemeMode,
100    accent: tokens::Accent,
101    locale: tokens::Locale,
102    cx: &mut gpui_kit::App,
103) {
104    gpui_kit::init(cx);
105    ui::install_overlay_layer(cx);
106    tokens::set_locale(locale, cx);
107    tokens::install_arc_theme(mode, accent, cx);
108}
109
110#[cfg(test)]
111mod tests {
112    use super::*;
113
114    #[test]
115    fn facade_reexports_all_layers() {
116        // Tokens + Motion
117        let _ = tokens::ControlHeights::MD;
118        let _ = motion::CubicBezier::new(0.2, 0.0, 0.0, 1.0);
119        // UI
120        let _ = std::any::type_name::<Button>();
121        // Flow (default feature)
122        #[cfg(feature = "flow")]
123        {
124            let _ = flow_core::FORMAT_VERSION;
125            let _ = std::any::type_name::<FlowCanvas>();
126        }
127    }
128}