tawasuyu

tawasuyu/brahman

Rust 492TOML 194Markdown 53JSON 176939 Sutichaykuna

⎇ 53dbdf0f1deea10d6fc567ea2b43e1e75d6d60cd crates/apps/yahweh-shell/src/main.rs Rust · 63 siq'ikuna · 2.1 KB Ñawpa willay Pi imata llamkarqan ch'uya

chore: monorepo inicial con arje + minga + yahweh absorbidos 53dbdf0f1 · Sergio ·

1//! Yahweh — bootstrap GPUI.
2//!
3//! Fase 6: además del LayoutModel, la Shell crea un `AppBus` (Entity) y se
4//! lo pasa al LayoutHost. El bus circula a viewers (TextViewer,
5//! ImageViewer) que se subscriben directo, y el LayoutHost forwardea los
6//! eventos tipados de los explorers (FileExplorer, DatabaseExplorer)
7//! traducidos a AppEvent.
8
9mod hot_reload;
10mod layout_host;
11mod layout_model;
12mod managed_tree;
13mod persister;
14mod status_panel;
15
16use gpui::{App, Application, Bounds, WindowBounds, WindowOptions, prelude::*, px, size};
17
18use yahweh_bus::AppBus;
19use yahweh_core::LayerConfig;
20use yahweh_theme::Theme;
21
22use crate::layout_host::LayoutHost;
23use crate::layout_model::LayoutModel;
24use crate::persister::Persister;
25
26const LAYOUT_PATH: &str = "layout.json";
27
28fn main() {
29    Application::new().run(|cx: &mut App| {
30        Theme::install_default(cx);
31
32        let config = LayerConfig::load_or_default(LAYOUT_PATH);
33        let bounds = Bounds::centered(None, size(px(1300.), px(800.)), cx);
34
35        cx.open_window(
36            WindowOptions {
37                window_bounds: Some(WindowBounds::Windowed(bounds)),
38                ..Default::default()
39            },
40            |_w, cx| {
41                let model = cx.new(|_| LayoutModel::new(config.clone()));
42                let bus = cx.new(|_| AppBus);
43                let persister = cx.new(|cx| {
44                    Persister::new(LAYOUT_PATH.into(), model.clone(), cx)
45                });
46                // Hot-reload: notify watcher en el dir del JSON. El
47                // watcher debe mantenerse vivo (drop ⇒ stop), así que lo
48                // movemos a una static atómica vía Box::leak.
49                match hot_reload::spawn_watch(LAYOUT_PATH.into(), model.clone(), cx) {
50                    Ok(watcher) => {
51                        Box::leak(Box::new(watcher));
52                    }
53                    Err(e) => {
54                        eprintln!("[hot_reload] no se pudo iniciar watcher: {}", e);
55                    }
56                }
57                cx.new(|cx| LayoutHost::new(model, bus, persister, cx))
58            },
59        )
60        .unwrap();
61        cx.activate(true);
62    });
63}