Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,043 changes: 1,031 additions & 12 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace]
members = ["kovar", "kovar-cli", "kovar-macros"]
members = ["kovar", "kovar-cli", "kovar-macros", "examples/demo"]

resolver = "3"
60 changes: 60 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Kovar development commands

# Use PowerShell on Windows
set windows-powershell := true

# Default: show available commands
default:
@just --list

# === CLI Commands ===

# Create a new Kovar project
cli-new name:
cargo run -p kovar-cli -- new {{name}}

# Launch the visual editor
cli-edit *args:
cargo run -p kovar-cli -- edit {{args}}

# === Build Commands ===

# Build all packages
build:
cargo build --release

# Build CLI only
build-cli:
cargo build -p kovar-cli --release

# === Demo Commands ===

# Run the demo project
demo:
cargo run -p demo

# Build the demo project
build-demo:
cargo build -p demo --release

# Edit demo UI
edit-demo:
cargo run -p kovar-cli -- edit examples/demo/ui/index.html

# === Development ===

# Check all packages
check:
cargo check --workspace

# Run clippy lints
lint:
cargo clippy --workspace

# Format code
fmt:
cargo fmt --all

# Clean build artifacts
clean:
cargo clean
12 changes: 12 additions & 0 deletions examples/demo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "demo"
version = "0.1.0"
edition = "2024"

[dependencies]
kovar = { path = "../../kovar" }
serde_json = "1.0"
tokio = { version = "1", features = ["full"] }
sysinfo = "0.37.2"
chrono = "0.4"
rand = "0.9.2"
84 changes: 84 additions & 0 deletions examples/demo/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
use chrono::Local;
use kovar::import_html;
use rand::rngs::SmallRng;
use rand::seq::IndexedRandom;
use rand::{Rng, SeedableRng};
use sysinfo::System;

import_html!("ui/index.html");

#[tokio::main]
async fn main() {
let ui = UI::new();

// Left cat: Time and weekday
ui.spawn(|ui| async move {
loop {
let now = Local::now();
ui.text_1.set(&now.format("%H:%M").to_string());
ui.text_2.set(&now.format("%a").to_string()); // Mon, Tue, etc.
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
}
});

// Left cat: System stats
ui.spawn(|ui| async move {
let mut sys = System::new_all();
loop {
sys.refresh_cpu_usage();
sys.refresh_memory();

let cpu = sys.global_cpu_usage();
let mem = sys.used_memory() as f64 / sys.total_memory() as f64 * 100.0;

ui.text_3.set(&format!("{:.1}%", cpu));
ui.text_4.set(&format!("{:.1}%", mem));

tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
}
});

// Right cat: Random moods
ui.spawn(|ui| async move {
let moods = ["^_^", ">_<", "o_o", "=^.^=", "zzZ", ":3", "uwu", "owo"];
let mut rng = SmallRng::from_os_rng();
loop {
let mood = moods.choose(&mut rng).unwrap();
ui.text_5.set(mood);
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
}
});

// Right cat: Random cat sounds
ui.spawn(|ui| async move {
let sounds = ["meow", "purr", "hiss", "mrrp", "nya~"];
let mut rng = SmallRng::from_os_rng();
loop {
let sound = sounds.choose(&mut rng).unwrap();
ui.text_6.set(sound);
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
}
});

// Right cat: Counter
ui.spawn(|ui| async move {
let mut count: u32 = 0;
loop {
ui.text_7.set(&format!("{:05}", count % 100000));
count = count.wrapping_add(1);
tokio::time::sleep(tokio::time::Duration::from_millis(50)).await;
}
});

// Right cat: Random number
ui.spawn(|ui| async move {
let mut rng = SmallRng::from_os_rng();
loop {
let n: u32 = rng.random_range(0..10000);
ui.text_8.set(&format!("#{:04}", n));
tokio::time::sleep(tokio::time::Duration::from_millis(200)).await;
}
});

ui.run().await;
}
25 changes: 25 additions & 0 deletions examples/demo/ui/index.html

Large diffs are not rendered by default.

736 changes: 736 additions & 0 deletions examples/demo/ui/index.tldr

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions kovar-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ path = "src/main.rs"
[dependencies]
axum = "0.8.8"
clap = { version = "4.5.54", features = ["derive"] }
mime_guess = "2.0.5"
opener = "0.8.3"
rust-embed = "8.9.0"
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.148"
tokio = { version = "1.49.0", features = ["full"] }
Expand Down
14 changes: 14 additions & 0 deletions kovar-cli/assets/editor/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="https://cdn.jsdelivr.net/gh/kovar-rs/kovar-editor@gh-pages/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Kovar Editor</title>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/kovar-rs/kovar-editor@gh-pages/editor.min.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/kovar-rs/kovar-editor@gh-pages/editor.min.css">
</head>
<body>
<div id="root"></div>
</body>
</html>
1 change: 1 addition & 0 deletions kovar-cli/assets/editor/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading