diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml new file mode 100644 index 0000000..90771fc --- /dev/null +++ b/src-tauri/Cargo.toml @@ -0,0 +1,52 @@ +[package] +name = "claude-usage-widget" +version = "0.1.0" +description = "Always-on-top Windows widget visualizing local Claude Code usage" +authors = ["megaproxy"] +edition = "2021" +rust-version = "1.77" + +[lib] +name = "claude_usage_widget_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +[build-dependencies] +tauri-build = { version = "2", features = [] } + +[dependencies] +tauri = { version = "2", features = [] } +tauri-plugin-autostart = "2" +tauri-plugin-store = "2" +tauri-plugin-dialog = "2" + +serde = { version = "1", features = ["derive"] } +serde_json = "1" +chrono = { version = "0.4", features = ["serde"] } + +notify = "6" +notify-debouncer-full = "0.3" +walkdir = "2" + +anyhow = "1" +thiserror = "1" +tokio = { version = "1", features = ["full"] } +dirs = "5" +once_cell = "1" +parking_lot = "0.12" +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } + +[target.'cfg(windows)'.dependencies] +windows = { version = "0.58", features = ["Win32_System_Console"] } + +[features] +# Default: production binary (no console window on Windows) +default = ["custom-protocol"] +custom-protocol = ["tauri/custom-protocol"] + +[profile.release] +panic = "abort" +codegen-units = 1 +lto = true +opt-level = "s" +strip = true diff --git a/src-tauri/build.rs b/src-tauri/build.rs new file mode 100644 index 0000000..d860e1e --- /dev/null +++ b/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json new file mode 100644 index 0000000..c3faae0 --- /dev/null +++ b/src-tauri/capabilities/default.json @@ -0,0 +1,22 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capabilities granted to the main window. FS reads happen Rust-side, so no fs:* permissions are needed.", + "windows": ["main"], + "permissions": [ + "core:default", + "core:event:allow-listen", + "core:event:allow-unlisten", + "core:event:allow-emit", + "core:event:allow-emit-to", + "core:window:allow-start-dragging", + "core:window:allow-set-position", + "core:window:allow-close", + "core:window:allow-hide", + "core:window:allow-show", + "core:app:allow-version", + "autostart:default", + "store:default", + "dialog:default" + ] +} diff --git a/src-tauri/icons/README.md b/src-tauri/icons/README.md new file mode 100644 index 0000000..96be9e1 --- /dev/null +++ b/src-tauri/icons/README.md @@ -0,0 +1,13 @@ +# Icons + +Placeholder. Before `pnpm tauri build` will succeed you need real icons here. + +Quickest path: `pnpm tauri icon path/to/source-1024x1024.png` — Tauri generates every required size + format (`.ico`, `.icns`, `.png`). + +Files Tauri's bundler expects (referenced from `tauri.conf.json`): + +- `32x32.png` +- `128x128.png` +- `128x128@2x.png` +- `icon.icns` +- `icon.ico` diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json new file mode 100644 index 0000000..5d255a6 --- /dev/null +++ b/src-tauri/tauri.conf.json @@ -0,0 +1,56 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "Claude Usage Widget", + "version": "0.1.0", + "identifier": "com.megaproxy.claude-usage-widget", + "build": { + "beforeDevCommand": "pnpm dev", + "beforeBuildCommand": "pnpm build", + "devUrl": "http://localhost:1420", + "frontendDist": "../dist" + }, + "app": { + "windows": [ + { + "label": "main", + "title": "Claude Usage", + "width": 280, + "height": 360, + "minWidth": 280, + "minHeight": 360, + "resizable": false, + "decorations": false, + "transparent": true, + "alwaysOnTop": true, + "skipTaskbar": true, + "shadow": false, + "center": false, + "x": 40, + "y": 40, + "visible": true + } + ], + "security": { + "csp": "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self'" + } + }, + "plugins": { + "autostart": { + "args": ["--minimized"] + } + }, + "bundle": { + "active": true, + "targets": ["nsis"], + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ], + "category": "Utility", + "shortDescription": "At-a-glance Claude Code usage on the Windows desktop", + "longDescription": "Floating, always-on-top widget that visualizes your current 5-hour Claude Code session block, the past 7 days of usage, and a per-model breakdown. Reads JSONL transcripts directly from the Claude Code config directory — no Anthropic API, no auth." + } +}