Rewrite the Timer app

This commit is contained in:
James Babcock committed 2026-09-04 02:23:58 -07:00
1 parent 99a8b97169
commit f601a62c75
14 files changed
+2990 -826

No files matched your search

+30 -10
View File
@@ -1,17 +1,37 @@
import { launchWorkerAppWindow, type AppDefinition } from "../app-definition";
import { type AppDefinition } from "../app-definition";
import { shell } from "../../ui/shell/shell";
import { registerTimerTools } from "../../assistant/timer-tools";
import { timerEngine, timersWakeSetting } from "./timer-engine";
import { createTimerAppWindow, startTimersTrayIcon, TIMER_SURFACE_ID, TIMER_WINDOW_ID } from "./timer-app";
/**
* Timers, stopwatch and alarms. The clock engine boots with the shell so
* timers and alarms fire (and the assistant's timer.* / alarm.* tools work)
* with no window open; launching only opens the view on it.
*/
const timerApp: AppDefinition = {
appId: "timer",
title: "Timer",
title: "Timers",
icon: "timer",
launch: (ctx) =>
launchWorkerAppWindow(ctx, {
createWorker: () => new Worker("./timer-app.worker"),
windowId: "timer:main",
title: "Timer",
iconLetter: "T",
icon: "timer",
}),
boot: (ctx) => {
timerEngine.boot({
playBuzzer: (payload) => ctx.actions.playBuzzerSequence(payload),
onRing: () => {
// Bring the ringing item on screen: focus the Timers window, then
// wake the display if it is off (a setting, since a wearer may
// prefer the phone notification alone while the glasses sleep).
void ctx
.launchApp("timer")
.then(() => {
if (timersWakeSetting.get() && !shell.isScreenOn()) shell.wake("window");
})
.catch((error) => console.error(`timers ring launch failed: ${error}`));
},
});
startTimersTrayIcon();
registerTimerTools((appId) => ctx.launchApp(appId));
},
launch: (ctx) => ctx.launchInProcessApp(TIMER_WINDOW_ID, TIMER_SURFACE_ID, createTimerAppWindow),
};
export default timerApp;