Draft auto-update process for comet in devtools

This commit is contained in:
Héctor Ramón Jiménez 2025-04-28 09:48:55 +02:00
parent a105ad4f9f
commit 267583c2a9
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
6 changed files with 250 additions and 107 deletions

View file

@ -7,8 +7,6 @@ use crate::futures::Subscription;
pub use internal::Span;
use std::io;
#[derive(Debug, Clone, Copy)]
pub enum Primitive {
Quad,
@ -36,8 +34,8 @@ pub fn init(name: &str) {
internal::init(name);
}
pub fn toggle_comet() -> Result<(), io::Error> {
internal::toggle_comet()
pub fn quit() -> bool {
internal::quit()
}
pub fn theme_changed(f: impl FnOnce() -> Option<theme::Palette>) {
@ -118,8 +116,6 @@ mod internal {
use beacon::client::{self, Client};
use beacon::span;
use std::io;
use std::process;
use std::sync::atomic::{self, AtomicBool, AtomicUsize};
use std::sync::{LazyLock, RwLock};
@ -129,25 +125,13 @@ mod internal {
name.clone_into(&mut NAME.write().expect("Write application name"));
}
pub fn toggle_comet() -> Result<(), io::Error> {
pub fn quit() -> bool {
if BEACON.is_connected() {
BEACON.quit();
Ok(())
true
} else {
let _ = process::Command::new("iced_comet")
.stdin(process::Stdio::null())
.stdout(process::Stdio::null())
.stderr(process::Stdio::null())
.spawn()?;
if let Some(palette) =
LAST_PALETTE.read().expect("Read last palette").as_ref()
{
log(client::Event::ThemeChanged(*palette));
}
Ok(())
false
}
}
@ -323,8 +307,8 @@ mod internal {
pub fn init(_name: &str) {}
pub fn toggle_comet() -> Result<(), io::Error> {
Ok(())
pub fn quit() -> bool {
false
}
pub fn theme_changed(_f: impl FnOnce() -> Option<theme::Palette>) {}