Skip to main content

gpui_rhai_registry/
lib.rs

1//! Bundled, application-owned source distribution for GPUI Rhai.
2//!
3//! Most users install these sources through `gpui-rhai-cli`. The constants are
4//! public so alternative tooling can consume the exact same release snapshot.
5
6macro_rules! bundled_components {
7    ($(($constant:ident, $id:literal, $path:literal)),+ $(,)?) => {
8        $(pub const $constant: &str = include_str!($path);)+
9
10        /// Every official component keyed by its canonical module ID.
11        pub const BUNDLED_COMPONENT_SOURCES_BY_ID: &[(&str, &str)] = &[
12            $(($id, $constant),)+
13        ];
14
15        /// Every official component module ID in deterministic registry order.
16        pub const BUNDLED_COMPONENT_MODULE_IDS: &[&str] = &[
17            $($id,)+
18        ];
19
20        /// Every official component source in deterministic installation order.
21        pub const BUNDLED_COMPONENT_SOURCES: &[&str] = &[
22            $($constant,)+
23        ];
24    };
25}
26
27bundled_components!(
28    (
29        BUTTON_SOURCE,
30        "components/button",
31        "../components/button.rhai"
32    ),
33    (
34        ICON_BUTTON_SOURCE,
35        "components/icon_button",
36        "../components/icon_button.rhai"
37    ),
38    (LABEL_SOURCE, "components/label", "../components/label.rhai"),
39    (ICON_SOURCE, "components/icon", "../components/icon.rhai"),
40    (INPUT_SOURCE, "components/input", "../components/input.rhai"),
41    (
42        TEXTAREA_SOURCE,
43        "components/textarea",
44        "../components/textarea.rhai"
45    ),
46    (
47        SELECTABLE_CARD_GROUP_SOURCE,
48        "components/selectable_card_group",
49        "../components/selectable_card_group.rhai"
50    ),
51    (
52        DIVIDER_SOURCE,
53        "components/divider",
54        "../components/divider.rhai"
55    ),
56    (
57        POPOVER_SOURCE,
58        "components/popover",
59        "../components/popover.rhai"
60    ),
61    (
62        DIALOG_SOURCE,
63        "components/dialog",
64        "../components/dialog.rhai"
65    ),
66    (
67        COMBOBOX_SOURCE,
68        "components/combobox",
69        "../components/combobox.rhai"
70    ),
71    (
72        SELECT_SOURCE,
73        "components/select",
74        "../components/select.rhai"
75    ),
76    (
77        DATE_PICKER_SOURCE,
78        "components/date_picker",
79        "../components/date_picker.rhai"
80    ),
81    (
82        CALENDAR_SOURCE,
83        "components/calendar",
84        "../components/calendar.rhai"
85    ),
86    (
87        TIME_INPUT_SOURCE,
88        "components/time_input",
89        "../components/time_input.rhai"
90    ),
91    (
92        TIMELINE_SOURCE,
93        "components/timeline",
94        "../components/timeline.rhai"
95    ),
96    (
97        TIME_RANGE_PICKER_SOURCE,
98        "components/time_range_picker",
99        "../components/time_range_picker.rhai"
100    ),
101    (TABLE_SOURCE, "components/table", "../components/table.rhai"),
102    (
103        MARKDOWN_VIEWER_SOURCE,
104        "components/markdown_viewer",
105        "../components/markdown_viewer.rhai"
106    ),
107    (
108        SPLIT_PANE_SOURCE,
109        "components/split_pane",
110        "../components/split_pane.rhai"
111    ),
112    (
113        RESIZABLE_SOURCE,
114        "components/resizable",
115        "../components/resizable.rhai"
116    ),
117    (
118        DRAGGABLE_SOURCE,
119        "components/draggable",
120        "../components/draggable.rhai"
121    ),
122    (
123        DRAG_SOURCE_SOURCE,
124        "components/drag_source",
125        "../components/drag_source.rhai"
126    ),
127    (
128        DROP_ZONE_SOURCE,
129        "components/drop_zone",
130        "../components/drop_zone.rhai"
131    ),
132    (
133        SORTABLE_SOURCE,
134        "components/sortable",
135        "../components/sortable.rhai"
136    ),
137    (
138        PAN_ZOOM_SOURCE,
139        "components/pan_zoom",
140        "../components/pan_zoom.rhai"
141    ),
142    (
143        RANGE_SLIDER_SOURCE,
144        "components/range_slider",
145        "../components/range_slider.rhai"
146    ),
147    (
148        ROTATABLE_SOURCE,
149        "components/rotatable",
150        "../components/rotatable.rhai"
151    ),
152    (
153        SELECTION_AREA_SOURCE,
154        "components/selection_area",
155        "../components/selection_area.rhai"
156    ),
157    (TREE_SOURCE, "components/tree", "../components/tree.rhai"),
158    (
159        SELECTABLE_LIST_SOURCE,
160        "components/selectable_list",
161        "../components/selectable_list.rhai"
162    ),
163    (LIST_SOURCE, "components/list", "../components/list.rhai"),
164    (
165        COLUMN_BROWSER_SOURCE,
166        "components/column_browser",
167        "../components/column_browser.rhai"
168    ),
169    (
170        TAB_OVERFLOW_MENU_SOURCE,
171        "components/tab_overflow_menu",
172        "../components/tab_overflow_menu.rhai"
173    ),
174    (
175        SLIDING_PANEL_SOURCE,
176        "components/sliding_panel",
177        "../components/sliding_panel.rhai"
178    ),
179    (
180        PAGINATION_SOURCE,
181        "components/pagination",
182        "../components/pagination.rhai"
183    ),
184    (
185        CAROUSEL_SOURCE,
186        "components/carousel",
187        "../components/carousel.rhai"
188    ),
189    (
190        CHECKBOX_SOURCE,
191        "components/checkbox",
192        "../components/checkbox.rhai"
193    ),
194    (RADIO_SOURCE, "components/radio", "../components/radio.rhai"),
195    (
196        RADIO_GROUP_SOURCE,
197        "components/radio_group",
198        "../components/radio_group.rhai"
199    ),
200    (
201        SWITCH_SOURCE,
202        "components/switch",
203        "../components/switch.rhai"
204    ),
205    (TAG_SOURCE, "components/tag", "../components/tag.rhai"),
206    (
207        AVATAR_SOURCE,
208        "components/avatar",
209        "../components/avatar.rhai"
210    ),
211    (
212        PROGRESS_SOURCE,
213        "components/progress",
214        "../components/progress.rhai"
215    ),
216    (
217        SKELETON_SOURCE,
218        "components/skeleton",
219        "../components/skeleton.rhai"
220    ),
221    (
222        FORM_FIELD_SOURCE,
223        "components/form_field",
224        "../components/form_field.rhai"
225    ),
226    (
227        COLLAPSIBLE_SOURCE,
228        "components/collapsible",
229        "../components/collapsible.rhai"
230    ),
231    (
232        ACCORDION_SOURCE,
233        "components/accordion",
234        "../components/accordion.rhai"
235    ),
236    (TABS_SOURCE, "components/tabs", "../components/tabs.rhai"),
237    (
238        TOOLTIP_SOURCE,
239        "components/tooltip",
240        "../components/tooltip.rhai"
241    ),
242    (MENU_SOURCE, "components/menu", "../components/menu.rhai"),
243    (TOAST_SOURCE, "components/toast", "../components/toast.rhai"),
244    (ALERT_SOURCE, "components/alert", "../components/alert.rhai"),
245    (
246        ALERT_DIALOG_SOURCE,
247        "components/alert_dialog",
248        "../components/alert_dialog.rhai"
249    ),
250    (BADGE_SOURCE, "components/badge", "../components/badge.rhai"),
251    (
252        BUTTON_GROUP_SOURCE,
253        "components/button_group",
254        "../components/button_group.rhai"
255    ),
256    (CARD_SOURCE, "components/card", "../components/card.rhai"),
257    (EMPTY_SOURCE, "components/empty", "../components/empty.rhai"),
258    (
259        GROUP_BOX_SOURCE,
260        "components/group_box",
261        "../components/group_box.rhai"
262    ),
263    (
264        INPUT_GROUP_SOURCE,
265        "components/input_group",
266        "../components/input_group.rhai"
267    ),
268    (KBD_SOURCE, "components/kbd", "../components/kbd.rhai"),
269    (
270        TOGGLE_SOURCE,
271        "components/toggle",
272        "../components/toggle.rhai"
273    ),
274    (
275        TOGGLE_GROUP_SOURCE,
276        "components/toggle_group",
277        "../components/toggle_group.rhai"
278    ),
279    (
280        SLIDER_SOURCE,
281        "components/slider",
282        "../components/slider.rhai"
283    ),
284    (
285        CONTEXT_MENU_SOURCE,
286        "components/context_menu",
287        "../components/context_menu.rhai"
288    ),
289    (SHEET_SOURCE, "components/sheet", "../components/sheet.rhai"),
290    (
291        COMMAND_SOURCE,
292        "components/command",
293        "../components/command.rhai"
294    ),
295    (
296        COMMAND_DIALOG_SOURCE,
297        "components/command_dialog",
298        "../components/command_dialog.rhai"
299    ),
300    (
301        SPINNER_SOURCE,
302        "components/spinner",
303        "../components/spinner.rhai"
304    ),
305    (
306        SCROLL_AREA_SOURCE,
307        "components/scroll_area",
308        "../components/scroll_area.rhai"
309    ),
310    (
311        TITLE_BAR_SOURCE,
312        "components/title_bar",
313        "../components/title_bar.rhai"
314    ),
315    (
316        STATUS_BAR_SOURCE,
317        "components/status_bar",
318        "../components/status_bar.rhai"
319    ),
320    (
321        CODE_VIEWER_SOURCE,
322        "components/code_viewer",
323        "../components/code_viewer.rhai"
324    ),
325    (
326        DIFF_VIEWER_SOURCE,
327        "components/diff_viewer",
328        "../components/diff_viewer.rhai"
329    ),
330);
331
332macro_rules! bundled_motion {
333    ($(($constant:ident, $id:literal, $path:literal)),+ $(,)?) => {
334        $(pub const $constant: &str = include_str!($path);)+
335
336        /// Optional first-party motion components, built only from the public
337        /// Runtime API 2 substrate.
338        pub const BUNDLED_MOTION_SOURCES_BY_ID: &[(&str, &str)] = &[
339            $(($id, $constant),)+
340        ];
341
342        pub const BUNDLED_MOTION_SOURCES: &[&str] = &[
343            $($constant,)+
344        ];
345    };
346}
347
348bundled_motion!(
349    (
350        TEXT_REVEAL_SOURCE,
351        "motion/text_reveal",
352        "../motion/text_reveal.rhai"
353    ),
354    (
355        NUMBER_TICKER_SOURCE,
356        "motion/number_ticker",
357        "../motion/number_ticker.rhai"
358    ),
359    (MARQUEE_SOURCE, "motion/marquee", "../motion/marquee.rhai"),
360    (SHIMMER_SOURCE, "motion/shimmer", "../motion/shimmer.rhai"),
361    (
362        BORDER_BEAM_SOURCE,
363        "motion/border_beam",
364        "../motion/border_beam.rhai"
365    ),
366    (ORBIT_SOURCE, "motion/orbit", "../motion/orbit.rhai"),
367    (
368        PARTICLES_SOURCE,
369        "motion/particles",
370        "../motion/particles.rhai"
371    ),
372    (
373        ANIMATED_TABS_SOURCE,
374        "motion/animated_tabs",
375        "../motion/animated_tabs.rhai"
376    ),
377    (
378        REORDER_LIST_SOURCE,
379        "motion/reorder_list",
380        "../motion/reorder_list.rhai"
381    ),
382    (
383        SHARED_LAYOUT_CARDS_SOURCE,
384        "motion/shared_layout_cards",
385        "../motion/shared_layout_cards.rhai"
386    ),
387);
388
389/// Optional visualization components backed by the native `charts` feature.
390pub const CHART_SOURCE: &str = include_str!("../charts/chart.rhai");
391pub const BAR_CHART_SOURCE: &str = include_str!("../charts/bar_chart.rhai");
392pub const LINE_CHART_SOURCE: &str = include_str!("../charts/line_chart.rhai");
393pub const PIE_CHART_SOURCE: &str = include_str!("../charts/pie_chart.rhai");
394pub const MAP_CHART_SOURCE: &str = include_str!("../charts/map_chart.rhai");
395pub const BUNDLED_CHART_SOURCES_BY_ID: &[(&str, &str)] = &[
396    ("charts/chart", CHART_SOURCE),
397    ("charts/bar_chart", BAR_CHART_SOURCE),
398    ("charts/line_chart", LINE_CHART_SOURCE),
399    ("charts/pie_chart", PIE_CHART_SOURCE),
400    ("charts/map_chart", MAP_CHART_SOURCE),
401];
402pub const BUNDLED_CHART_SOURCES: &[&str] = &[
403    CHART_SOURCE,
404    BAR_CHART_SOURCE,
405    LINE_CHART_SOURCE,
406    PIE_CHART_SOURCE,
407    MAP_CHART_SOURCE,
408];
409
410macro_rules! bundled_assets {
411    ($(($constant:ident, $id:literal, $path:literal)),+ $(,)?) => {
412        $(pub const $constant: &str = include_str!($path);)+
413
414        /// Every bundled component asset keyed exactly as component metadata declares it.
415        pub const BUNDLED_ASSET_SOURCES: &[(&str, &str)] = &[
416            $(($id, $constant),)+
417        ];
418    };
419}
420
421bundled_assets!(
422    (CHECK_SVG, "icons/check.svg", "../assets/icons/check.svg"),
423    (CLOSE_SVG, "icons/close.svg", "../assets/icons/close.svg"),
424    (
425        CHEVRON_LEFT_SVG,
426        "icons/chevron_left.svg",
427        "../assets/icons/chevron_left.svg"
428    ),
429    (
430        CHEVRON_RIGHT_SVG,
431        "icons/chevron_right.svg",
432        "../assets/icons/chevron_right.svg"
433    ),
434    (
435        CALENDAR_SVG,
436        "icons/calendar.svg",
437        "../assets/icons/calendar.svg"
438    ),
439    (
440        DATE_PREVIOUS_SVG,
441        "icons/date_previous.svg",
442        "../assets/icons/date_previous.svg"
443    ),
444    (
445        DATE_NEXT_SVG,
446        "icons/date_next.svg",
447        "../assets/icons/date_next.svg"
448    ),
449    (
450        DISCLOSURE_DOWN_SVG,
451        "icons/disclosure_down.svg",
452        "../assets/icons/disclosure_down.svg"
453    ),
454    (
455        SORT_ASCENDING_SVG,
456        "icons/sort_ascending.svg",
457        "../assets/icons/sort_ascending.svg"
458    ),
459    (
460        SORT_DESCENDING_SVG,
461        "icons/sort_descending.svg",
462        "../assets/icons/sort_descending.svg"
463    ),
464    (
465        CHEVRON_DOWN_SVG,
466        "icons/chevron_down.svg",
467        "../assets/icons/chevron_down.svg"
468    ),
469    (
470        CHEVRON_UP_SVG,
471        "icons/chevron_up.svg",
472        "../assets/icons/chevron_up.svg"
473    ),
474    (MINUS_SVG, "icons/minus.svg", "../assets/icons/minus.svg"),
475    (PLUS_SVG, "icons/plus.svg", "../assets/icons/plus.svg"),
476    (SEARCH_SVG, "icons/search.svg", "../assets/icons/search.svg"),
477    (INFO_SVG, "icons/info.svg", "../assets/icons/info.svg"),
478    (
479        WARNING_SVG,
480        "icons/warning.svg",
481        "../assets/icons/warning.svg"
482    ),
483    (HELP_SVG, "icons/help.svg", "../assets/icons/help.svg"),
484);
485
486/// Visually neutral layout components (`layouts/*`).
487pub const BUNDLED_LAYOUT_SOURCES_BY_ID: &[(&str, &str)] = &[
488    ("layouts/stack", include_str!("../layouts/stack.rhai")),
489    ("layouts/inline", include_str!("../layouts/inline.rhai")),
490    ("layouts/toolbar", include_str!("../layouts/toolbar.rhai")),
491    ("layouts/region", include_str!("../layouts/region.rhai")),
492];
493
494/// Opinionated composite components (`patterns/*`).
495pub const BUNDLED_PATTERN_SOURCES_BY_ID: &[(&str, &str)] = &[
496    (
497        "patterns/composer",
498        include_str!("../patterns/composer.rhai"),
499    ),
500    (
501        "patterns/navigation_stack",
502        include_str!("../patterns/navigation_stack.rhai"),
503    ),
504    ("patterns/section", include_str!("../patterns/section.rhai")),
505    (
506        "patterns/description_list",
507        include_str!("../patterns/description_list.rhai"),
508    ),
509    ("patterns/stat", include_str!("../patterns/stat.rhai")),
510    (
511        "patterns/form_layout",
512        include_str!("../patterns/form_layout.rhai"),
513    ),
514    (
515        "patterns/inline_state",
516        include_str!("../patterns/inline_state.rhai"),
517    ),
518    (
519        "patterns/data_view",
520        include_str!("../patterns/data_view.rhai"),
521    ),
522    (
523        "patterns/list_detail",
524        include_str!("../patterns/list_detail.rhai"),
525    ),
526    (
527        "patterns/app_shell",
528        include_str!("../patterns/app_shell.rhai"),
529    ),
530];
531
532/// The Gallery acceptance application (`gpui-rhai gallery`), keyed by module ID.
533/// `gallery/main` is the entry module.
534pub const GALLERY_SOURCES_BY_ID: &[(&str, &str)] = &[
535    ("gallery/main", include_str!("../gallery/main.rhai")),
536    ("gallery/kit", include_str!("../gallery/kit.rhai")),
537    (
538        "gallery/pages/markdown",
539        include_str!("../gallery/pages/markdown.rhai"),
540    ),
541    (
542        "gallery/pages/messaging",
543        include_str!("../gallery/pages/messaging.rhai"),
544    ),
545    (
546        "gallery/pages/navigation",
547        include_str!("../gallery/pages/navigation.rhai"),
548    ),
549    (
550        "gallery/pages/inputs_and_choices",
551        include_str!("../gallery/pages/inputs_and_choices.rhai"),
552    ),
553    (
554        "gallery/retained_page_panel",
555        include_str!("../gallery/retained_page_panel.rhai"),
556    ),
557    (
558        "gallery/tabs_demo",
559        include_str!("../gallery/tabs_demo.rhai"),
560    ),
561    (
562        "gallery/shell_demo",
563        include_str!("../gallery/shell_demo.rhai"),
564    ),
565    (
566        "gallery/pages/temporal",
567        include_str!("../gallery/pages/temporal.rhai"),
568    ),
569    (
570        "gallery/pages/scrolling",
571        include_str!("../gallery/pages/scrolling.rhai"),
572    ),
573    (
574        "gallery/pages/foundations",
575        include_str!("../gallery/pages/foundations.rhai"),
576    ),
577    (
578        "gallery/pages/markers",
579        include_str!("../gallery/pages/markers.rhai"),
580    ),
581    (
582        "gallery/pages/fields",
583        include_str!("../gallery/pages/fields.rhai"),
584    ),
585    (
586        "gallery/pages/lists",
587        include_str!("../gallery/pages/lists.rhai"),
588    ),
589    (
590        "gallery/pages/browsers",
591        include_str!("../gallery/pages/browsers.rhai"),
592    ),
593    (
594        "gallery/pages/overlays",
595        include_str!("../gallery/pages/overlays.rhai"),
596    ),
597    (
598        "gallery/pages/containers",
599        include_str!("../gallery/pages/containers.rhai"),
600    ),
601    (
602        "gallery/pages/display",
603        include_str!("../gallery/pages/display.rhai"),
604    ),
605    (
606        "gallery/pages/interaction",
607        include_str!("../gallery/pages/interaction.rhai"),
608    ),
609    (
610        "gallery/pages/composition",
611        include_str!("../gallery/pages/composition.rhai"),
612    ),
613    (
614        "gallery/pages/scenes",
615        include_str!("../gallery/pages/scenes.rhai"),
616    ),
617    (
618        "gallery/pages/effects",
619        include_str!("../gallery/pages/effects.rhai"),
620    ),
621];
622
623/// Bundled application profiles, installed by `gpui-rhai init --profile`.
624pub const BUNDLED_PROFILES: &[(&str, &str)] = &[(
625    "productivity",
626    include_str!("../profiles/productivity.rhai"),
627)];
628
629/// The design-language token base, installed as `ui/tokens.rhai`.
630pub const TOKEN_BASE_SOURCE: &str = include_str!("../tokens.rhai");
631pub const DEFAULT_THEME: &str = include_str!("../themes/default_dark.rhai");
632pub const DEFAULT_LIGHT_THEME: &str = include_str!("../themes/default_light.rhai");
633pub const TOKYO_NIGHT_THEME: &str = include_str!("../themes/tokyo_night.rhai");
634pub const TOKYO_STORM_THEME: &str = include_str!("../themes/tokyo_storm.rhai");
635pub const CATPPUCCIN_LATTE_THEME: &str = include_str!("../themes/catppuccin_latte.rhai");
636pub const CATPPUCCIN_MOCHA_THEME: &str = include_str!("../themes/catppuccin_mocha.rhai");
637pub const ETHEREAL_THEME: &str = include_str!("../themes/ethereal.rhai");
638pub const EVERFOREST_THEME: &str = include_str!("../themes/everforest.rhai");
639pub const GRUVBOX_THEME: &str = include_str!("../themes/gruvbox.rhai");
640pub const HACKERMAN_THEME: &str = include_str!("../themes/hackerman.rhai");
641pub const NORD_THEME: &str = include_str!("../themes/nord.rhai");
642pub const RETRO_82_THEME: &str = include_str!("../themes/retro_82.rhai");
643pub const HERMARCHY_THEME: &str = include_str!("../themes/hermarchy.rhai");
644pub const FUTURISM_THEME: &str = include_str!("../themes/futurism.rhai");
645pub const AETHERIA_THEME: &str = include_str!("../themes/aetheria.rhai");
646pub const DRACULA_THEME: &str = include_str!("../themes/dracula.rhai");
647pub const MOLOKAI_THEME: &str = include_str!("../themes/molokai.rhai");
648pub const ABSOLUTELY_LIGHT_THEME: &str = include_str!("../themes/absolutely_light.rhai");
649pub const ABSOLUTELY_DARK_THEME: &str = include_str!("../themes/absolutely_dark.rhai");
650
651pub const EN_LOCALE: &str = include_str!("../locales/en.rhai");
652pub const ZH_CN_LOCALE: &str = include_str!("../locales/zh_cn.rhai");
653pub const AR_LOCALE: &str = include_str!("../locales/ar.rhai");
654pub const STUDIO_SOURCE: &str = include_str!("../studio/theme_studio.rhai");
655
656/// One deterministic, source-backed case exposed by the first-party Gallery.
657#[derive(Clone, Copy, Debug, Eq, PartialEq)]
658pub struct StoryCase {
659    pub id: &'static str,
660    pub title: &'static str,
661    pub purpose: &'static str,
662}
663
664/// Static first-party story metadata shared by Gallery, Theme Studio, and tests.
665#[derive(Clone, Copy, Debug, Eq, PartialEq)]
666pub struct StoryDefinition {
667    pub id: &'static str,
668    pub title: &'static str,
669    pub purpose: &'static str,
670    pub category: &'static str,
671    pub keywords: &'static [&'static str],
672    pub module_ids: &'static [&'static str],
673    pub source_module: &'static str,
674    pub source: &'static str,
675    pub cases: &'static [StoryCase],
676    pub fixture: Option<&'static str>,
677    pub required_features: &'static [&'static str],
678    pub platforms: &'static [&'static str],
679    pub test_requirements: &'static [&'static str],
680    pub documentation: &'static str,
681    pub theme_studio: bool,
682}
683
684pub const BUTTON_STORY_SOURCE: &str = include_str!("../stories/components/button.rhai");
685pub const TABS_STORY_SOURCE: &str = include_str!("../stories/components/tabs.rhai");
686pub const INPUT_STORY_SOURCE: &str = include_str!("../stories/components/input.rhai");
687pub const TABLE_STORY_SOURCE: &str = include_str!("../stories/components/table.rhai");
688pub const SPLIT_PANE_STORY_SOURCE: &str = include_str!("../stories/components/split_pane.rhai");
689pub const RESIZABLE_STORY_SOURCE: &str = include_str!("../stories/components/resizable.rhai");
690pub const DRAGGABLE_STORY_SOURCE: &str = include_str!("../stories/components/draggable.rhai");
691pub const DRAG_DROP_STORY_SOURCE: &str = include_str!("../stories/components/drag_drop.rhai");
692pub const SORTABLE_STORY_SOURCE: &str = include_str!("../stories/components/sortable.rhai");
693pub const PAN_ZOOM_STORY_SOURCE: &str = include_str!("../stories/components/pan_zoom.rhai");
694pub const RANGE_SLIDER_STORY_SOURCE: &str = include_str!("../stories/components/range_slider.rhai");
695pub const ROTATABLE_STORY_SOURCE: &str = include_str!("../stories/components/rotatable.rhai");
696pub const SELECTION_AREA_STORY_SOURCE: &str =
697    include_str!("../stories/components/selection_area.rhai");
698pub const TREE_STORY_SOURCE: &str = include_str!("../stories/components/tree.rhai");
699pub const LIST_STORY_SOURCE: &str = include_str!("../stories/components/list.rhai");
700pub const SELECTABLE_LIST_STORY_SOURCE: &str =
701    include_str!("../stories/components/selectable_list.rhai");
702pub const TABS_COLLECTION_STORY_SOURCE: &str =
703    include_str!("../stories/components/tabs_collection.rhai");
704pub const INTERACTION_LAB_STORY_SOURCE: &str =
705    include_str!("../stories/workbench/interaction_lab.rhai");
706pub const CHART_INTERACTION_STORY_SOURCE: &str = include_str!("../stories/charts/interaction.rhai");
707pub const CHART_CATALOG_STORY_SOURCE: &str = include_str!("../stories/charts/catalog.rhai");
708pub const CHART_STREAMING_STORY_SOURCE: &str = include_str!("../stories/charts/streaming.rhai");
709pub const MOTION_CATALOG_STORY_SOURCE: &str = include_str!("../stories/motion/catalog.rhai");
710pub const OPERATIONS_STORY_SOURCE: &str = include_str!("../stories/apps/operations.rhai");
711pub const HOST_EMBEDDING_STORY_SOURCE: &str = include_str!("../stories/apps/host_embedding.rhai");
712pub const HOST_RESIDENT_STORY_SOURCE: &str = include_str!("../stories/apps/host_resident.rhai");
713
714const BASIC_CASE: &[StoryCase] = &[StoryCase {
715    id: "basic",
716    title: "Basic",
717    purpose: "Exercise the normal controlled interaction path.",
718}];
719
720const TABLE_CASES: &[StoryCase] = &[
721    StoryCase {
722        id: "basic",
723        title: "Interactive",
724        purpose: "Sort, select and resize controlled columns.",
725    },
726    StoryCase {
727        id: "wide",
728        title: "Wide",
729        purpose: "Reach the logical tail column with native horizontal scrolling in either locale direction.",
730    },
731    StoryCase {
732        id: "loading",
733        title: "Loading",
734        purpose: "Retain the bordered viewport while loading.",
735    },
736    StoryCase {
737        id: "empty",
738        title: "Empty",
739        purpose: "Keep header and body geometry for empty data.",
740    },
741    StoryCase {
742        id: "projected-empty",
743        title: "Filtered empty",
744        purpose: "Show a valid projection with no matching rows.",
745    },
746];
747
748const NO_FEATURES: &[&str] = &[];
749const CHARTS_FEATURE: &[&str] = &["charts"];
750const DESKTOP_PLATFORMS: &[&str] = &["macos", "linux"];
751const STANDARD_STORY_TESTS: &[&str] = &["prepare", "mount", "draw", "semantics", "interaction"];
752const WORKBENCH_TESTS: &[&str] = &[
753    "prepare",
754    "mount",
755    "draw",
756    "semantics",
757    "normal",
758    "cancel",
759    "failure",
760    "streaming",
761    "large",
762];
763
764const COMPONENT_CATALOG_CASES: &[StoryCase] = &[
765    StoryCase {
766        id: "basic",
767        title: "Foundations",
768        purpose: "Inspect actions, status, application chrome, and public-launch foundations.",
769    },
770    StoryCase {
771        id: "forms",
772        title: "Forms",
773        purpose: "Exercise editing, choice, selection, validation, and IME-ready controls.",
774    },
775    StoryCase {
776        id: "navigation",
777        title: "Navigation & data",
778        purpose: "Exercise Tabs, disclosure, virtual Table, sorting, and pagination.",
779    },
780    StoryCase {
781        id: "documents",
782        title: "Code & diff",
783        purpose: "Render the native CodeViewer and direction-neutral DiffViewer surfaces.",
784    },
785    StoryCase {
786        id: "overlays",
787        title: "Commands & overlays",
788        purpose: "Open menus, dialogs, sheets, command surfaces, tooltips, and toasts.",
789    },
790];
791
792const CHART_INTERACTION_CASES: &[StoryCase] = &[
793    StoryCase {
794        id: "basic",
795        title: "Titles & wheel",
796        purpose: "Compare absent/explicit titles and plain-wheel propagation.",
797    },
798    StoryCase {
799        id: "diagnostics",
800        title: "Invalid diagnostics",
801        purpose: "Break a valid chart and inspect last-good rendering plus invalid semantics.",
802    },
803];
804
805const OPERATIONS_CASES: &[StoryCase] = &[
806    StoryCase {
807        id: "basic",
808        title: "Dashboard",
809        purpose: "Enter the complete Operations Workbench on its dashboard.",
810    },
811    StoryCase {
812        id: "config-diff",
813        title: "Configuration diff",
814        purpose: "Start at the cross-host configuration comparison and deployment flow.",
815    },
816    StoryCase {
817        id: "command-dialog",
818        title: "Command dialog",
819        purpose: "Open the keyboard navigation surface in a deterministic initial frame.",
820    },
821    StoryCase {
822        id: "theme-overrides",
823        title: "Host theme overrides",
824        purpose: "Apply nonzero Host radii uniformly and preserve Workbench state across themes.",
825    },
826    StoryCase {
827        id: "loading",
828        title: "Loading",
829        purpose: "Present deterministic loading surfaces without starting background work.",
830    },
831    StoryCase {
832        id: "empty",
833        title: "Empty",
834        purpose: "Present actionable empty Dashboard and Hosts states.",
835    },
836    StoryCase {
837        id: "failure",
838        title: "Partial failure",
839        purpose: "Keep healthy data usable while one host and a simulated deployment fail.",
840    },
841    StoryCase {
842        id: "failure-terminal",
843        title: "Failure terminal",
844        purpose: "Present the committed failure result without replaying an interaction script.",
845    },
846    StoryCase {
847        id: "streaming",
848        title: "Streaming update",
849        purpose: "Consume a bounded Rust subscription and expose its latest revision.",
850    },
851    StoryCase {
852        id: "large",
853        title: "Large dataset",
854        purpose: "Exercise a 1,000-row Rust NativeCollection through the virtualized Table.",
855    },
856];
857
858pub const BUNDLED_STORIES: &[StoryDefinition] = &[
859    StoryDefinition {
860        id: "components/catalog",
861        title: "Component Catalog",
862        purpose: "Browse every official component through the shared responsive design specimen.",
863        category: "components",
864        keywords: &[
865            "component",
866            "control",
867            "form",
868            "navigation",
869            "data",
870            "overlay",
871            "document",
872        ],
873        module_ids: BUNDLED_COMPONENT_MODULE_IDS,
874        source_module: "stories/components/catalog",
875        source: STUDIO_SOURCE,
876        cases: COMPONENT_CATALOG_CASES,
877        fixture: Some("component-catalog"),
878        required_features: NO_FEATURES,
879        platforms: DESKTOP_PLATFORMS,
880        test_requirements: STANDARD_STORY_TESTS,
881        documentation: "docs/components/catalog.md",
882        theme_studio: true,
883    },
884    StoryDefinition {
885        id: "components/button",
886        title: "Button, Badge, and Tag",
887        purpose: "Compare action, status, and metadata density with real activation.",
888        category: "actions",
889        keywords: &["action", "badge", "tag", "density", "button"],
890        module_ids: &["components/button", "components/badge", "components/tag"],
891        source_module: "stories/components/button",
892        source: BUTTON_STORY_SOURCE,
893        cases: BASIC_CASE,
894        fixture: None,
895        required_features: NO_FEATURES,
896        platforms: DESKTOP_PLATFORMS,
897        test_requirements: STANDARD_STORY_TESTS,
898        documentation: "docs/components/catalog.md#actions-choices-and-forms",
899        theme_studio: true,
900    },
901    StoryDefinition {
902        id: "components/input",
903        title: "Input and Textarea",
904        purpose: "Exercise controlled single-line and multiline native editing.",
905        category: "forms",
906        keywords: &["form", "ime", "text", "input", "textarea"],
907        module_ids: &["components/input", "components/textarea"],
908        source_module: "stories/components/input",
909        source: INPUT_STORY_SOURCE,
910        cases: BASIC_CASE,
911        fixture: None,
912        required_features: NO_FEATURES,
913        platforms: DESKTOP_PLATFORMS,
914        test_requirements: STANDARD_STORY_TESTS,
915        documentation: "docs/components/catalog.md#actions-choices-and-forms",
916        theme_studio: true,
917    },
918    StoryDefinition {
919        id: "components/tabs",
920        title: "Tabs",
921        purpose: "Exercise controlled selection, content layout, and disabled navigation.",
922        category: "navigation",
923        keywords: &["navigation", "selection", "panel", "tabs"],
924        module_ids: &[
925            "components/tabs",
926            "components/menu",
927            "components/icon_button",
928            "components/table",
929            "charts/chart",
930        ],
931        source_module: "stories/components/tabs",
932        source: TABS_STORY_SOURCE,
933        cases: BASIC_CASE,
934        fixture: None,
935        required_features: CHARTS_FEATURE,
936        platforms: DESKTOP_PLATFORMS,
937        test_requirements: STANDARD_STORY_TESTS,
938        documentation: "docs/components/catalog.md#tabs",
939        theme_studio: true,
940    },
941    StoryDefinition {
942        id: "components/table",
943        title: "Table",
944        purpose: "Exercise controlled sorting, selection, and semantic cell adornments.",
945        category: "data",
946        keywords: &["data", "virtual", "selection", "badge", "table"],
947        module_ids: &["components/table", "components/badge"],
948        source_module: "stories/components/table",
949        source: TABLE_STORY_SOURCE,
950        cases: TABLE_CASES,
951        fixture: None,
952        required_features: NO_FEATURES,
953        platforms: DESKTOP_PLATFORMS,
954        test_requirements: STANDARD_STORY_TESTS,
955        documentation: "docs/components/catalog.md#navigation-and-data",
956        theme_studio: true,
957    },
958    StoryDefinition {
959        id: "components/split-pane",
960        title: "Split Pane",
961        purpose: "Resize, collapse, and keyboard-adjust a controlled two-panel layout.",
962        category: "layout",
963        keywords: &["layout", "resize", "separator", "panel", "split"],
964        module_ids: &["components/split_pane", "components/button"],
965        source_module: "stories/components/split_pane",
966        source: SPLIT_PANE_STORY_SOURCE,
967        cases: BASIC_CASE,
968        fixture: None,
969        required_features: NO_FEATURES,
970        platforms: DESKTOP_PLATFORMS,
971        test_requirements: STANDARD_STORY_TESTS,
972        documentation: "docs/components/catalog.md#split-pane",
973        theme_studio: true,
974    },
975    StoryDefinition {
976        id: "components/resizable",
977        title: "Resizable",
978        purpose: "Resize and reposition one controlled rectangle from physical edges and corners.",
979        category: "layout",
980        keywords: &["layout", "resize", "edge", "corner", "rectangle"],
981        module_ids: &["components/resizable", "components/button"],
982        source_module: "stories/components/resizable",
983        source: RESIZABLE_STORY_SOURCE,
984        cases: BASIC_CASE,
985        fixture: None,
986        required_features: NO_FEATURES,
987        platforms: DESKTOP_PLATFORMS,
988        test_requirements: STANDARD_STORY_TESTS,
989        documentation: "docs/components/catalog.md#resizable",
990        theme_studio: true,
991    },
992    StoryDefinition {
993        id: "components/draggable",
994        title: "Draggable",
995        purpose: "Move a controlled card through native preview, pointer commit, and keyboard steps.",
996        category: "layout",
997        keywords: &["layout", "drag", "position", "direct manipulation"],
998        module_ids: &["components/draggable", "components/button"],
999        source_module: "stories/components/draggable",
1000        source: DRAGGABLE_STORY_SOURCE,
1001        cases: BASIC_CASE,
1002        fixture: None,
1003        required_features: NO_FEATURES,
1004        platforms: DESKTOP_PLATFORMS,
1005        test_requirements: STANDARD_STORY_TESTS,
1006        documentation: "docs/components/interaction-behaviors.md#draggable--planned",
1007        theme_studio: true,
1008    },
1009    StoryDefinition {
1010        id: "components/drag-drop",
1011        title: "Drag source and drop zone",
1012        purpose: "Transfer one bounded typed payload between controlled application containers.",
1013        category: "layout",
1014        keywords: &["drag", "drop", "payload", "copy", "move", "keyboard"],
1015        module_ids: &["components/drag_source", "components/drop_zone"],
1016        source_module: "stories/components/drag_drop",
1017        source: DRAG_DROP_STORY_SOURCE,
1018        cases: BASIC_CASE,
1019        fixture: None,
1020        required_features: NO_FEATURES,
1021        platforms: DESKTOP_PLATFORMS,
1022        test_requirements: STANDARD_STORY_TESTS,
1023        documentation: "docs/components/interaction-behaviors.md#dragsource-and-dropzone--implemented",
1024        theme_studio: true,
1025    },
1026    StoryDefinition {
1027        id: "components/sortable",
1028        title: "Sortable",
1029        purpose: "Propose identity-safe order changes without mutating the controlled collection during preview.",
1030        category: "layout",
1031        keywords: &["sort", "reorder", "drag", "keyboard", "scroll"],
1032        module_ids: &["components/sortable", "components/scroll_area"],
1033        source_module: "stories/components/sortable",
1034        source: SORTABLE_STORY_SOURCE,
1035        cases: BASIC_CASE,
1036        fixture: None,
1037        required_features: NO_FEATURES,
1038        platforms: DESKTOP_PLATFORMS,
1039        test_requirements: STANDARD_STORY_TESTS,
1040        documentation: "docs/components/interaction-behaviors.md#sortable--bounded-implementation-complete",
1041        theme_studio: true,
1042    },
1043    StoryDefinition {
1044        id: "components/pan-zoom",
1045        title: "PanZoom",
1046        purpose: "Pan and pointer-anchor zoom one controlled Canvas viewport through native signals.",
1047        category: "layout",
1048        keywords: &["pan", "zoom", "canvas", "wheel", "transform"],
1049        module_ids: &["components/pan_zoom"],
1050        source_module: "stories/components/pan_zoom",
1051        source: PAN_ZOOM_STORY_SOURCE,
1052        cases: BASIC_CASE,
1053        fixture: None,
1054        required_features: NO_FEATURES,
1055        platforms: DESKTOP_PLATFORMS,
1056        test_requirements: STANDARD_STORY_TESTS,
1057        documentation: "docs/components/interaction-behaviors.md#panzoom--canvas-implementation",
1058        theme_studio: true,
1059    },
1060    StoryDefinition {
1061        id: "components/range-slider",
1062        title: "RangeSlider",
1063        purpose: "Select one controlled ordered interval with two independent native thumbs.",
1064        category: "forms",
1065        keywords: &["range", "slider", "interval", "thumb", "keyboard"],
1066        module_ids: &["components/range_slider"],
1067        source_module: "stories/components/range_slider",
1068        source: RANGE_SLIDER_STORY_SOURCE,
1069        cases: BASIC_CASE,
1070        fixture: None,
1071        required_features: NO_FEATURES,
1072        platforms: DESKTOP_PLATFORMS,
1073        test_requirements: STANDARD_STORY_TESTS,
1074        documentation: "docs/components/catalog.md#range-slider",
1075        theme_studio: true,
1076    },
1077    StoryDefinition {
1078        id: "components/rotatable",
1079        title: "Rotatable",
1080        purpose: "Rotate one controlled Canvas around an explicit local pivot.",
1081        category: "layout",
1082        keywords: &["rotate", "canvas", "pivot", "snap", "keyboard"],
1083        module_ids: &["components/rotatable"],
1084        source_module: "stories/components/rotatable",
1085        source: ROTATABLE_STORY_SOURCE,
1086        cases: BASIC_CASE,
1087        fixture: None,
1088        required_features: NO_FEATURES,
1089        platforms: DESKTOP_PLATFORMS,
1090        test_requirements: STANDARD_STORY_TESTS,
1091        documentation: "docs/components/interaction-behaviors.md#rotatable--canvas-implementation",
1092        theme_studio: true,
1093    },
1094    StoryDefinition {
1095        id: "components/selection-area",
1096        title: "SelectionArea",
1097        purpose: "Select keyed Canvas objects by click, modifiers, keyboard range, or native marquee.",
1098        category: "layout",
1099        keywords: &["selection", "marquee", "canvas", "range", "keyboard"],
1100        module_ids: &["components/selection_area"],
1101        source_module: "stories/components/selection_area",
1102        source: SELECTION_AREA_STORY_SOURCE,
1103        cases: BASIC_CASE,
1104        fixture: None,
1105        required_features: NO_FEATURES,
1106        platforms: DESKTOP_PLATFORMS,
1107        test_requirements: STANDARD_STORY_TESTS,
1108        documentation: "docs/components/interaction-behaviors.md#selectionarea--canvas-implementation",
1109        theme_studio: true,
1110    },
1111    StoryDefinition {
1112        id: "components/tree",
1113        title: "Tree",
1114        purpose: "Navigate and select a virtualized stable-key hierarchical outline.",
1115        category: "navigation",
1116        keywords: &["tree", "outline", "hierarchy", "virtual", "keyboard"],
1117        module_ids: &["components/tree"],
1118        source_module: "stories/components/tree",
1119        source: TREE_STORY_SOURCE,
1120        cases: BASIC_CASE,
1121        fixture: None,
1122        required_features: NO_FEATURES,
1123        platforms: DESKTOP_PLATFORMS,
1124        test_requirements: STANDARD_STORY_TESTS,
1125        documentation: "docs/components/catalog.md#tree",
1126        theme_studio: true,
1127    },
1128    StoryDefinition {
1129        id: "components/list",
1130        title: "List",
1131        purpose: "Select and open keyed rows with a status badge, a title, a secondary line and meta.",
1132        category: "navigation",
1133        keywords: &["list", "rows", "selection", "virtual", "keyboard"],
1134        module_ids: &["components/list", "components/badge"],
1135        source_module: "stories/components/list",
1136        source: LIST_STORY_SOURCE,
1137        cases: BASIC_CASE,
1138        fixture: None,
1139        required_features: NO_FEATURES,
1140        platforms: DESKTOP_PLATFORMS,
1141        test_requirements: STANDARD_STORY_TESTS,
1142        documentation: "docs/components/catalog.md#list",
1143        theme_studio: true,
1144    },
1145    StoryDefinition {
1146        id: "components/selectable_list",
1147        title: "SelectableList",
1148        purpose: "Select and open rows the application draws, each with a control of its own.",
1149        category: "navigation",
1150        keywords: &[
1151            "list",
1152            "rows",
1153            "selection",
1154            "custom rows",
1155            "node factory",
1156            "media",
1157        ],
1158        module_ids: &["components/selectable_list", "components/button"],
1159        source_module: "stories/components/selectable_list",
1160        source: SELECTABLE_LIST_STORY_SOURCE,
1161        cases: BASIC_CASE,
1162        fixture: None,
1163        required_features: NO_FEATURES,
1164        platforms: DESKTOP_PLATFORMS,
1165        test_requirements: STANDARD_STORY_TESTS,
1166        documentation: "docs/components/catalog.md#selectablelist",
1167        theme_studio: true,
1168    },
1169    StoryDefinition {
1170        id: "components/tabs-collection",
1171        title: "Tabs collection",
1172        purpose: "Switch, add and close document tabs in the bar variant, with counts and an overflow menu.",
1173        category: "navigation",
1174        keywords: &[
1175            "tabs",
1176            "documents",
1177            "panel",
1178            "close",
1179            "add",
1180            "count",
1181            "scroll",
1182        ],
1183        module_ids: &[
1184            "components/tabs",
1185            "components/menu",
1186            "components/icon_button",
1187        ],
1188        source_module: "stories/components/tabs_collection",
1189        source: TABS_COLLECTION_STORY_SOURCE,
1190        cases: BASIC_CASE,
1191        fixture: None,
1192        required_features: NO_FEATURES,
1193        platforms: DESKTOP_PLATFORMS,
1194        test_requirements: STANDARD_STORY_TESTS,
1195        documentation: "docs/components/catalog.md#tabs",
1196        theme_studio: true,
1197    },
1198    StoryDefinition {
1199        id: "workbench/interaction-lab",
1200        title: "Interaction Workbench",
1201        purpose: "Exercise the complete 0.1.8 direct-manipulation stack in one stateful application scene.",
1202        category: "acceptance",
1203        keywords: &[
1204            "interaction",
1205            "acceptance",
1206            "canvas",
1207            "drag",
1208            "tree",
1209            "sortable",
1210        ],
1211        module_ids: &[
1212            "components/split_pane",
1213            "components/resizable",
1214            "components/draggable",
1215            "components/drag_source",
1216            "components/drop_zone",
1217            "components/sortable",
1218            "components/pan_zoom",
1219            "components/rotatable",
1220            "components/selection_area",
1221            "components/range_slider",
1222            "components/tree",
1223            "components/scroll_area",
1224        ],
1225        source_module: "stories/workbench/interaction_lab",
1226        source: INTERACTION_LAB_STORY_SOURCE,
1227        cases: BASIC_CASE,
1228        fixture: None,
1229        required_features: NO_FEATURES,
1230        platforms: DESKTOP_PLATFORMS,
1231        test_requirements: STANDARD_STORY_TESTS,
1232        documentation: "docs/components/interaction-behaviors.md#integrated-acceptance-scene",
1233        theme_studio: false,
1234    },
1235    StoryDefinition {
1236        id: "charts/interaction",
1237        title: "Chart titles and wheel interaction",
1238        purpose: "Compare absent and explicit titles while preserving parent scrolling.",
1239        category: "charts",
1240        keywords: &["chart", "scroll", "wheel", "zoom", "title"],
1241        module_ids: &[
1242            "charts/chart",
1243            "components/scroll_area",
1244            "components/button",
1245        ],
1246        source_module: "stories/charts/interaction",
1247        source: CHART_INTERACTION_STORY_SOURCE,
1248        cases: CHART_INTERACTION_CASES,
1249        fixture: None,
1250        required_features: CHARTS_FEATURE,
1251        platforms: DESKTOP_PLATFORMS,
1252        test_requirements: STANDARD_STORY_TESTS,
1253        documentation: "docs/charts.md",
1254        theme_studio: false,
1255    },
1256    StoryDefinition {
1257        id: "charts/catalog",
1258        title: "Chart Catalog",
1259        purpose: "Compare every built-in series family and each source-owned specialized adapter.",
1260        category: "charts",
1261        keywords: &[
1262            "chart",
1263            "bar",
1264            "line",
1265            "pie",
1266            "map",
1267            "cartesian",
1268            "polar",
1269            "geo",
1270        ],
1271        module_ids: &[
1272            "charts/chart",
1273            "charts/bar_chart",
1274            "charts/line_chart",
1275            "charts/pie_chart",
1276            "charts/map_chart",
1277        ],
1278        source_module: "stories/charts/catalog",
1279        source: CHART_CATALOG_STORY_SOURCE,
1280        cases: BASIC_CASE,
1281        fixture: Some("chart-catalog"),
1282        required_features: CHARTS_FEATURE,
1283        platforms: DESKTOP_PLATFORMS,
1284        test_requirements: STANDARD_STORY_TESTS,
1285        documentation: "docs/charts.md",
1286        theme_studio: false,
1287    },
1288    StoryDefinition {
1289        id: "charts/streaming",
1290        title: "Native streaming line",
1291        purpose: "Exercise revisioned Host-owned chart data without rebuilding rows in Rhai.",
1292        category: "charts",
1293        keywords: &["chart", "line", "stream", "native", "performance"],
1294        module_ids: &["charts/chart"],
1295        source_module: "stories/charts/streaming",
1296        source: CHART_STREAMING_STORY_SOURCE,
1297        cases: BASIC_CASE,
1298        fixture: Some("chart-catalog"),
1299        required_features: CHARTS_FEATURE,
1300        platforms: DESKTOP_PLATFORMS,
1301        test_requirements: &["prepare", "mount", "draw", "streaming", "100k benchmark"],
1302        documentation: "docs/charts.md#performance-contract",
1303        theme_studio: false,
1304    },
1305    StoryDefinition {
1306        id: "motion/catalog",
1307        title: "Motion Catalog",
1308        purpose: "Exercise every first-party Motion component and the native timeline controls.",
1309        category: "motion",
1310        keywords: &[
1311            "motion",
1312            "timeline",
1313            "transition",
1314            "spring",
1315            "reduced",
1316            "animation",
1317        ],
1318        module_ids: &[
1319            "motion/text_reveal",
1320            "motion/number_ticker",
1321            "motion/marquee",
1322            "motion/shimmer",
1323            "motion/border_beam",
1324            "motion/orbit",
1325            "motion/particles",
1326            "motion/animated_tabs",
1327            "motion/reorder_list",
1328            "motion/shared_layout_cards",
1329        ],
1330        source_module: "stories/motion/catalog",
1331        source: MOTION_CATALOG_STORY_SOURCE,
1332        cases: BASIC_CASE,
1333        fixture: None,
1334        required_features: NO_FEATURES,
1335        platforms: DESKTOP_PLATFORMS,
1336        test_requirements: STANDARD_STORY_TESTS,
1337        documentation: "docs/motion.md",
1338        theme_studio: false,
1339    },
1340    StoryDefinition {
1341        id: "apps/host-embedding",
1342        title: "HostSlot resident form",
1343        purpose: "Embed an independently mounted Rhai form through an opaque Rust Host boundary.",
1344        category: "applications",
1345        keywords: &["host", "embedding", "slot", "ime", "input", "resident"],
1346        module_ids: &["components/input", "components/textarea"],
1347        source_module: "stories/apps/host_embedding",
1348        source: HOST_EMBEDDING_STORY_SOURCE,
1349        cases: BASIC_CASE,
1350        fixture: Some("host-embedding"),
1351        required_features: NO_FEATURES,
1352        platforms: DESKTOP_PLATFORMS,
1353        test_requirements: &["prepare", "mount", "draw", "host-slot", "ime"],
1354        documentation: "docs/embedding.md#rhai-shells-around-host-owned-content",
1355        theme_studio: false,
1356    },
1357    StoryDefinition {
1358        id: "apps/operations",
1359        title: "Operations Workbench",
1360        purpose: "Complete a cross-page host inspection, configuration, and deployment task.",
1361        category: "applications",
1362        keywords: &["application", "operations", "hosts", "config", "deployment"],
1363        module_ids: &[
1364            "components/button",
1365            "components/badge",
1366            "components/command",
1367            "components/command_dialog",
1368            "components/dialog",
1369            "components/sheet",
1370            "components/input",
1371            "components/table",
1372            "components/pagination",
1373            "components/code_viewer",
1374            "components/diff_viewer",
1375            "components/progress",
1376            "components/toast",
1377            "components/alert",
1378            "components/empty",
1379            "components/skeleton",
1380            "components/spinner",
1381            "components/title_bar",
1382            "components/status_bar",
1383            "charts/chart",
1384        ],
1385        source_module: "stories/apps/operations",
1386        source: OPERATIONS_STORY_SOURCE,
1387        cases: OPERATIONS_CASES,
1388        fixture: Some("operations"),
1389        required_features: CHARTS_FEATURE,
1390        platforms: DESKTOP_PLATFORMS,
1391        test_requirements: WORKBENCH_TESTS,
1392        documentation: "docs/gallery.md#operations-workbench",
1393        theme_studio: false,
1394    },
1395];
1396
1397pub const BUNDLED_THEME_SOURCES: &[(&str, &str)] = &[
1398    ("default_dark.rhai", DEFAULT_THEME),
1399    ("default_light.rhai", DEFAULT_LIGHT_THEME),
1400    ("tokyo_night.rhai", TOKYO_NIGHT_THEME),
1401    ("tokyo_storm.rhai", TOKYO_STORM_THEME),
1402    ("catppuccin_latte.rhai", CATPPUCCIN_LATTE_THEME),
1403    ("catppuccin_mocha.rhai", CATPPUCCIN_MOCHA_THEME),
1404    ("ethereal.rhai", ETHEREAL_THEME),
1405    ("everforest.rhai", EVERFOREST_THEME),
1406    ("gruvbox.rhai", GRUVBOX_THEME),
1407    ("hackerman.rhai", HACKERMAN_THEME),
1408    ("nord.rhai", NORD_THEME),
1409    ("retro_82.rhai", RETRO_82_THEME),
1410    ("hermarchy.rhai", HERMARCHY_THEME),
1411    ("futurism.rhai", FUTURISM_THEME),
1412    ("aetheria.rhai", AETHERIA_THEME),
1413    ("dracula.rhai", DRACULA_THEME),
1414    ("molokai.rhai", MOLOKAI_THEME),
1415    ("absolutely_light.rhai", ABSOLUTELY_LIGHT_THEME),
1416    ("absolutely_dark.rhai", ABSOLUTELY_DARK_THEME),
1417];
1418
1419mod lucide;
1420mod skills;
1421
1422pub use lucide::{LUCIDE_ICONS, LUCIDE_LICENSE, LUCIDE_VERSION};
1423pub use skills::BUNDLED_SKILL_FILES;
1424
1425/// The SVG of the Lucide icon `name`, as `gpui-rhai add lucide/<name>` installs it.
1426#[must_use]
1427pub fn lucide_icon(name: &str) -> Option<&'static str> {
1428    LUCIDE_ICONS
1429        .binary_search_by_key(&name, |(icon, _)| icon)
1430        .ok()
1431        .map(|index| LUCIDE_ICONS[index].1)
1432}
1433
1434#[cfg(test)]
1435mod tests {
1436    use super::*;
1437    use std::collections::BTreeSet;
1438
1439    /// Quoted strings of a `"tokens": [...]`-style list starting after `key`.
1440    fn declared_list(header: &str, key: &str) -> BTreeSet<String> {
1441        let Some(start) = header.find(key) else {
1442            return BTreeSet::new();
1443        };
1444        let rest = &header[start + key.len()..];
1445        let open = rest.find('[').unwrap();
1446        let close = rest.find(']').unwrap();
1447        rest[open + 1..close]
1448            .split(',')
1449            .map(|item| item.trim().trim_matches('"').to_owned())
1450            .filter(|item| !item.is_empty())
1451            .collect()
1452    }
1453
1454    /// Literal string arguments of `call("...")` occurrences, mapped through `prefix`.
1455    fn literal_arguments(source: &str, call: &str, prefix: &str) -> BTreeSet<String> {
1456        source
1457            .match_indices(call)
1458            .filter_map(|(index, _)| {
1459                let rest = source[index + call.len()..].strip_prefix('"')?;
1460                let end = rest.find('"')?;
1461                Some(format!("{prefix}{}", &rest[..end]))
1462            })
1463            .collect()
1464    }
1465
1466    /// Every bundled module an app imports by ID: components, layouts, patterns and
1467    /// charts. The source lints below run over all of them, so a new module is covered
1468    /// without editing a list.
1469    fn ui_sources() -> impl Iterator<Item = &'static (&'static str, &'static str)> {
1470        BUNDLED_COMPONENT_SOURCES_BY_ID
1471            .iter()
1472            .chain(BUNDLED_LAYOUT_SOURCES_BY_ID)
1473            .chain(BUNDLED_PATTERN_SOURCES_BY_ID)
1474            .chain(BUNDLED_CHART_SOURCES_BY_ID)
1475    }
1476
1477    /// The lines after the header comment with their 1-based line numbers in the file,
1478    /// without `//` comments.
1479    fn code_lines(source: &str) -> impl Iterator<Item = (usize, &str)> {
1480        let (header, body) = source.split_once("*/").unwrap_or(("", source));
1481        let first = header.matches('\n').count() + 1;
1482        body.lines()
1483            .enumerate()
1484            .map(move |(index, line)| (first + index, line.split("//").next().unwrap_or(line)))
1485    }
1486
1487    /// The argument text of every `call` in `line`, up to the next `)`. A `*` in `call`
1488    /// stands for any `_suffix`: `.padding*(px(` also matches `.padding_start(px(`.
1489    fn call_arguments<'line>(line: &'line str, call: &str) -> Vec<&'line str> {
1490        let (head, tail) = call.split_once('*').unwrap_or((call, ""));
1491        line.match_indices(head)
1492            .filter_map(|(index, _)| {
1493                let rest = line[index + head.len()..]
1494                    .trim_start_matches(|character: char| {
1495                        !tail.is_empty() && (character == '_' || character.is_ascii_lowercase())
1496                    })
1497                    .strip_prefix(tail)?;
1498                Some(rest.split(')').next().unwrap_or(rest).trim())
1499            })
1500            .collect()
1501    }
1502
1503    /// A numeric `px(...)` argument; `None` for a prop or computed value, which is the
1504    /// caller's to choose.
1505    fn pixels(argument: &str) -> Option<f64> {
1506        argument.parse().ok()
1507    }
1508
1509    fn never(_: &str) -> bool {
1510        false
1511    }
1512
1513    fn zero(argument: &str) -> bool {
1514        pixels(argument) == Some(0.0)
1515    }
1516
1517    /// Hairlines, focus borders, indicator bars, lamps, slider tracks, grab zones and
1518    /// close glyphs: the structural constants of docs/design/atoms.md section 2.
1519    fn structural_size(argument: &str) -> bool {
1520        pixels(argument).is_none_or(|value| value <= 14.0)
1521    }
1522
1523    /// A call matched in code (see [`call_arguments`]), whether one of its arguments is
1524    /// structure rather than design, and the fix for one that is not.
1525    type VisualRule = (&'static str, fn(&str) -> bool, &'static str);
1526
1527    /// One rule table for the visual contract of docs/design/atoms.md (sections 1, 2 and
1528    /// 11): no decoration, literal color, font size, line height, control height or
1529    /// spacing in official source.
1530    const VISUAL_RULES: &[VisualRule] = &[
1531        ("shadow(", never, "decoration belongs to themes"),
1532        ("linear_gradient(", never, "decoration belongs to themes"),
1533        // Fully transparent is structure: it reserves a border in idle geometry.
1534        (
1535            "rgba(",
1536            |argument| argument == "0x00000000",
1537            "use theme_color",
1538        ),
1539        ("rgb(", never, "use theme_color"),
1540        ("font_size(px(", never, "use a typography role"),
1541        ("line_height(px(", never, "use a typography role"),
1542        (".height(px(", structural_size, "use a metrics token"),
1543        ("min_height(px(", structural_size, "use a metrics token"),
1544        // 240px and wider is a layout width (dialogs, popovers, toasts), not rhythm.
1545        (
1546            ".width(px(",
1547            |argument| {
1548                structural_size(argument) || pixels(argument).is_some_and(|value| value >= 240.0)
1549            },
1550            "use a metrics token",
1551        ),
1552        // A literal radius only turns a structural shape into a semantic circle.
1553        (
1554            "radius*(px(",
1555            |argument| pixels(argument).is_none_or(|value| value <= 7.0),
1556            "use theme_radius",
1557        ),
1558        (".padding*(px(", zero, "use a spacing or metrics token"),
1559        (".margin*(px(", zero, "use a spacing or metrics token"),
1560        (".gap(px(", zero, "use a spacing or metrics token"),
1561    ];
1562
1563    /// Code lines the rules cannot tell from structure, each with its reason. An entry
1564    /// that no longer matches fails the lint, so this list cannot go stale.
1565    const VISUAL_EXCEPTIONS: &[(&str, &str)] = &[
1566        // The caller's inset clears the platform window buttons; it is not spacing.
1567        ("components/title_bar", ".padding_start(px(inset))"),
1568    ];
1569
1570    /// Component contract C7 and the visual rules of docs/design/atoms.md, checked on the
1571    /// source text of every component, layout, pattern and chart: every literal token a
1572    /// module reads is declared, the header and the runtime metadata agree, and visual
1573    /// values come from tokens except where [`VISUAL_RULES`] allows a structural literal.
1574    #[test]
1575    fn components_declare_what_they_read_and_keep_geometry_in_tokens() {
1576        let mut problems = Vec::new();
1577        let mut matched_exceptions = BTreeSet::new();
1578        for (id, source) in ui_sources() {
1579            let (header, body) = source.split_once("*/").unwrap();
1580            let tokens = declared_list(header, "\"tokens\":");
1581            let metadata = body.split("schema:").next().unwrap();
1582            if tokens != declared_list(metadata, "tokens:") {
1583                problems.push(format!("{id}: header and metadata token lists differ"));
1584            }
1585            if declared_list(header, "\"environment\":") != declared_list(metadata, "environment:")
1586            {
1587                problems.push(format!(
1588                    "{id}: header and metadata environment lists differ"
1589                ));
1590            }
1591            let code = code_lines(source)
1592                .map(|(_, line)| line)
1593                .collect::<Vec<_>>()
1594                .join("\n");
1595            let mut read = literal_arguments(&code, "theme_color(", "");
1596            read.extend(literal_arguments(&code, "theme_length(", ""));
1597            read.extend(literal_arguments(&code, "theme_spacing(", "spacing."));
1598            read.extend(literal_arguments(&code, "theme_radius(", "radius."));
1599            read.extend(literal_arguments(&code, ".typography(", "typography."));
1600            let undeclared = read.difference(&tokens).collect::<Vec<_>>();
1601            if !undeclared.is_empty() {
1602                problems.push(format!("{id} reads undeclared tokens: {undeclared:?}"));
1603            }
1604            for (number, line) in code_lines(source) {
1605                for (call, allowed, fix) in VISUAL_RULES {
1606                    for argument in call_arguments(line, call) {
1607                        if allowed(argument) {
1608                            continue;
1609                        }
1610                        match VISUAL_EXCEPTIONS
1611                            .iter()
1612                            .position(|(module, fragment)| module == id && line.contains(fragment))
1613                        {
1614                            Some(exception) => {
1615                                matched_exceptions.insert(exception);
1616                            }
1617                            None => problems.push(format!(
1618                                "registry/{id}.rhai:{number}: {fix}: {}",
1619                                line.trim()
1620                            )),
1621                        }
1622                    }
1623                }
1624            }
1625        }
1626        for (index, (module, fragment)) in VISUAL_EXCEPTIONS.iter().enumerate() {
1627            if !matched_exceptions.contains(&index) {
1628                problems.push(format!(
1629                    "stale visual exception: {module} no longer needs `{fragment}`"
1630                ));
1631            }
1632        }
1633        assert!(problems.is_empty(), "{}", problems.join("\n"));
1634    }
1635
1636    /// Declarative assets are preloaded only when a module declares them, so an
1637    /// undeclared bundled asset cannot be drawn with `asset(...)` at all.
1638    #[test]
1639    fn every_bundled_asset_is_declared_by_a_module() {
1640        let mut declared = BTreeSet::new();
1641        for (_, source) in ui_sources() {
1642            let (header, _) = source.split_once("*/").unwrap();
1643            declared.extend(declared_list(header, "\"assets\":"));
1644        }
1645        let orphans = BUNDLED_ASSET_SOURCES
1646            .iter()
1647            .map(|(path, _)| (*path).to_owned())
1648            .filter(|path| !declared.contains(path))
1649            .collect::<Vec<_>>();
1650        assert!(orphans.is_empty(), "undeclared bundled assets: {orphans:?}");
1651    }
1652
1653    #[test]
1654    fn release_snapshot_has_the_expected_catalog_size() {
1655        assert_eq!(BUNDLED_COMPONENT_SOURCES.len(), 74);
1656        assert_eq!(BUNDLED_COMPONENT_SOURCES_BY_ID.len(), 74);
1657        assert_eq!(BUNDLED_MOTION_SOURCES.len(), 10);
1658        assert_eq!(BUNDLED_MOTION_SOURCES_BY_ID.len(), 10);
1659        assert_eq!(BUNDLED_CHART_SOURCES.len(), 5);
1660        assert_eq!(BUNDLED_CHART_SOURCES_BY_ID.len(), 5);
1661        assert_eq!(BUNDLED_ASSET_SOURCES.len(), 18);
1662        assert_eq!(BUNDLED_THEME_SOURCES.len(), 19);
1663        assert_eq!(BUNDLED_STORIES.len(), 25);
1664        assert!(
1665            BUNDLED_COMPONENT_SOURCES
1666                .iter()
1667                .all(|source| !source.is_empty())
1668        );
1669        assert!(
1670            BUNDLED_MOTION_SOURCES
1671                .iter()
1672                .all(|source| !source.is_empty())
1673        );
1674        assert!(
1675            BUNDLED_CHART_SOURCES
1676                .iter()
1677                .all(|source| !source.is_empty())
1678        );
1679        assert!(
1680            BUNDLED_THEME_SOURCES
1681                .iter()
1682                .all(|(_, source)| !source.is_empty())
1683        );
1684        assert_eq!(
1685            BUNDLED_COMPONENT_SOURCES_BY_ID
1686                .iter()
1687                .map(|(id, _)| *id)
1688                .collect::<std::collections::BTreeSet<_>>()
1689                .len(),
1690            BUNDLED_COMPONENT_SOURCES_BY_ID.len()
1691        );
1692        assert_eq!(
1693            BUNDLED_ASSET_SOURCES
1694                .iter()
1695                .map(|(id, _)| *id)
1696                .collect::<std::collections::BTreeSet<_>>()
1697                .len(),
1698            BUNDLED_ASSET_SOURCES.len()
1699        );
1700        let story_ids = BUNDLED_STORIES
1701            .iter()
1702            .map(|story| story.id)
1703            .collect::<std::collections::BTreeSet<_>>();
1704        assert_eq!(story_ids.len(), BUNDLED_STORIES.len());
1705        for story in BUNDLED_STORIES {
1706            assert!(!story.source.is_empty(), "{} source is empty", story.id);
1707            assert!(!story.cases.is_empty(), "{} has no cases", story.id);
1708            assert!(!story.platforms.is_empty(), "{} has no platforms", story.id);
1709            assert!(
1710                !story.test_requirements.is_empty(),
1711                "{} has no test requirements",
1712                story.id
1713            );
1714            assert!(
1715                story
1716                    .required_features
1717                    .iter()
1718                    .all(|feature| *feature == "charts"),
1719                "{} declares an unknown feature",
1720                story.id
1721            );
1722            assert!(story.source_module.starts_with("stories/"));
1723            let case_ids = story
1724                .cases
1725                .iter()
1726                .map(|case| case.id)
1727                .collect::<std::collections::BTreeSet<_>>();
1728            assert_eq!(case_ids.len(), story.cases.len(), "{} case IDs", story.id);
1729            for module in story.module_ids {
1730                assert!(
1731                    BUNDLED_COMPONENT_SOURCES_BY_ID
1732                        .iter()
1733                        .chain(BUNDLED_MOTION_SOURCES_BY_ID)
1734                        .chain(BUNDLED_CHART_SOURCES_BY_ID)
1735                        .any(|(id, _)| id == module),
1736                    "{} references unknown module {module}",
1737                    story.id
1738                );
1739            }
1740        }
1741        assert!(!CHART_SOURCE.contains("title: prop_or(props, \"title\", \"\")"));
1742        for source in [
1743            BAR_CHART_SOURCE,
1744            LINE_CHART_SOURCE,
1745            PIE_CHART_SOURCE,
1746            MAP_CHART_SOURCE,
1747        ] {
1748            assert!(!source.contains("title: #{ schema: #{ type: \"string\" }, required: false, sensitive: false, \"default\""));
1749        }
1750    }
1751
1752    #[test]
1753    fn lucide_icons_are_sorted_svgs_found_by_name() {
1754        assert!(LUCIDE_ICONS.len() > 2000);
1755        assert!(LUCIDE_ICONS.windows(2).all(|pair| pair[0].0 < pair[1].0));
1756        assert!(LUCIDE_ICONS.iter().all(|(_, svg)| svg.contains("<svg")));
1757        assert!(lucide_icon("arrow-left").is_some_and(|svg| svg.contains("currentColor")));
1758        assert_eq!(lucide_icon("no-such-icon"), None);
1759        assert!(LUCIDE_LICENSE.starts_with("ISC License"));
1760    }
1761
1762    #[test]
1763    fn every_public_module_has_story_coverage() {
1764        let covered_modules = BUNDLED_STORIES
1765            .iter()
1766            .flat_map(|story| story.module_ids.iter().copied())
1767            .collect::<std::collections::BTreeSet<_>>();
1768        for (domain, modules) in [
1769            ("component", BUNDLED_COMPONENT_SOURCES_BY_ID),
1770            ("Motion", BUNDLED_MOTION_SOURCES_BY_ID),
1771            ("Chart", BUNDLED_CHART_SOURCES_BY_ID),
1772        ] {
1773            for (module, _) in modules {
1774                assert!(
1775                    covered_modules.contains(module),
1776                    "public {domain} module {module} has no Gallery story"
1777                );
1778            }
1779        }
1780    }
1781}