/** * rTime applet definitions — Commitment Meter. */ import type { AppletDefinition, AppletLiveData } from "../../shared/applet-types"; const commitmentMeter: AppletDefinition = { id: "commitment-meter", label: "Commitment Meter", icon: "⏳", accentColor: "#7c3aed", ports: [ { name: "pool-in", type: "json", direction: "input" }, { name: "committed-out", type: "number", direction: "output" }, ], renderCompact(data: AppletLiveData): string { const { snapshot } = data; const committed = (snapshot.committed as number) || 0; const capacity = (snapshot.capacity as number) || 1; const pct = Math.min(100, Math.round((committed / capacity) * 100)); const label = (snapshot.poolName as string) || "Pool"; return `
${label}
${pct}%
${committed}/${capacity} hrs
`; }, onInputReceived(portName, value, ctx) { if (portName === "pool-in" && value && typeof value === "object") { const pool = value as Record; ctx.emitOutput("committed-out", Number(pool.committed) || 0); } }, }; export const timeApplets: AppletDefinition[] = [commitmentMeter];