mirror of
https://github.com/hanzo-apps/desktop-tauri.git
synced 2026-11-09 15:49:35 +00:00
DEFECT: hanzo-templates shipped 71 templates and not one of them built a native application. Every "make me a desktop app" request dead-ended in the browser, and the one repo that looked like it might help (`mobile`) was completely empty — no commits, no files. There was no answer to "how do I ship a .dmg / .msi / .deb from this platform". REASON for the shape: - Tauri v2 by default. A Rust core against the OS webview produces single-digit MB installers; Electron is reserved for the cases where Chromium itself is the requirement (see desktop-recorder's desktopCapturer). - ONE seam, `src/native.ts`. A native window cannot be iframed, so the gallery preview has to be a real build of the same UI, not a screenshot and not a dead link. `bridge()` resolves a command through the Rust core (or the Electron main process) when it is running natively and through the fallbacks in `src/web.ts` when it is a browser tab. No call site branches; the two shells implement the same contract, which is why app.tsx and shell.tsx are identical across both. - Frameless everywhere. `decorations: false` / `frame: false` means the titlebar in shell.tsx IS the chrome, so the traffic lights do real work through the same bridge rather than importing a shell-specific API. - @hanzo/base for the backend and the a.hanzo.ai analytics/chat runtime in index.html, so a fork starts with persistence and telemetry already wired. - Release fans out to per-OS runners. Desktop bundles must be produced on the target OS (codesign, .dmg/.msi/.deb tooling); this one workflow is the documented exception to the shared build fleet. Upstream and license are recorded in every README. MIT/Apache-2.0/BSD only: these are meant to be forked and commercialised. Co-authored-by: Hanzo Dev <[email protected]>
47 lines
1.3 KiB
Rust
47 lines
1.3 KiB
Rust
//! Hanzo desktop starter — the smallest complete Tauri v2 core: two commands,
|
|
//! one window, no plugins. Everything a fork adds hangs off `run()`.
|
|
|
|
use serde::Serialize;
|
|
|
|
#[derive(Serialize)]
|
|
pub struct Env {
|
|
os: String,
|
|
arch: String,
|
|
family: String,
|
|
cores: usize,
|
|
tauri: String,
|
|
}
|
|
|
|
/// Host facts the webview cannot know. The web build answers the same shape
|
|
/// from `navigator`, which is why the UI never branches.
|
|
#[tauri::command]
|
|
fn app_env() -> Env {
|
|
Env {
|
|
os: std::env::consts::OS.into(),
|
|
arch: std::env::consts::ARCH.into(),
|
|
family: std::env::consts::FAMILY.into(),
|
|
cores: std::thread::available_parallelism().map(|n| n.get()).unwrap_or(1),
|
|
tauri: tauri::VERSION.into(),
|
|
}
|
|
}
|
|
|
|
/// FNV-1a, byte for byte the same as the fallback in `src/web.ts` — a command
|
|
/// round-trip you can verify rather than trust.
|
|
#[tauri::command]
|
|
fn digest(text: String) -> String {
|
|
let mut h: u32 = 0x811c_9dc5;
|
|
for b in text.as_bytes() {
|
|
h ^= *b as u32;
|
|
h = h.wrapping_mul(0x0100_0193);
|
|
}
|
|
format!("fnv1a:{h:08x}")
|
|
}
|
|
|
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|
pub fn run() {
|
|
tauri::Builder::default()
|
|
.invoke_handler(tauri::generate_handler![app_env, digest])
|
|
.run(tauri::generate_context!())
|
|
.expect("error while running tauri application");
|
|
}
|