bos-settings/frontend/src/lib/streaming.ts
Breadway cbac50683e Harden settings: split breadcrumbs secrets, typed exec, new panels
Load and save Wi-Fi networks in networks.toml (0600) instead of writing
PSKs back into breadcrumbs.toml. The password field is write-only.

Replace the generic argv runner with typed bakery/pacman/fwupd commands
and set a real Tauri CSP. Add Lock, Screenshots, Monitors, and Help
panels. Pin bread-theme and bread-utils to bread-ecosystem v0.7.1.
bread-screenshots is not on that tag, so --screenshot calls grim
locally. bakery.toml lists webkitgtk-4.1 deps; README/CLAUDE.md match
Tauri 2 + Svelte 5 and single-trunk main.
2026-08-15 21:47:00 +08:00

25 lines
790 B
TypeScript

// Frontend half of the event-streaming command pattern (see
// src/src/commands/streaming.rs) — listens for `cmd-output` lines from a
// typed Tauri command that runs a hardcoded program, then resolves once
// the process exits.
import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
export async function runStreamed(
command: string,
args: Record<string, unknown>,
onLine: (line: string) => void,
): Promise<boolean> {
const sessionId = crypto.randomUUID();
const unlisten = await listen<{ session_id: string; line: string }>("cmd-output", (event) => {
if (event.payload.session_id === sessionId) onLine(event.payload.line);
});
try {
return await invoke<boolean>(command, { sessionId, ...args });
} finally {
unlisten();
}
}