diff --git a/src/keeper.ts b/src/keeper.ts index f97252c..540d6aa 100644 --- a/src/keeper.ts +++ b/src/keeper.ts @@ -5,8 +5,8 @@ * real-user-wins semantics, plus the idle-watch loop that drives it. * * Runtime: Bun (uses `@nut-tree-fork/nut-js` for cross-platform mouse + - * screen). Importing this module sets `mouse.config.autoDelayMs = 0` as a - * side effect — see below. + * screen). The nut.js auto-delay is disabled inside `runKeeper`, not at + * module load, so importing this module is side-effect-free. * * Logging policy: * - The startup banner in `runKeeper` is unconditional so the user always @@ -20,14 +20,6 @@ import { mouse, Point, screen } from "@nut-tree-fork/nut-js"; import type { Config } from "./config.ts"; -/** - * nut.js inserts a configurable delay after every action (default 100ms). - * That default would silently more-than-double the duration of every - * `setPosition` and `getPosition` call. We drive cadence ourselves via - * `Config.stepDelay`, so disable nut.js's implicit delay entirely. - */ -mouse.config.autoDelayMs = 0; - /** * Promise-based `setTimeout` wrapper. Allows `await sleep(ms)` ergonomics. * @@ -145,6 +137,17 @@ async function simulateActivity(config: Config, log: ReturnType { + // nut.js inserts a configurable delay after every action (default 100ms). + // That default would silently more-than-double the duration of every + // setPosition and getPosition call. We drive cadence ourselves via + // config.stepDelay, so disable nut.js's implicit delay entirely. + // + // Setting this here (rather than at module load) keeps `keeper.ts` free + // of import-time side effects on the shared nut.js singleton — useful + // for tests and any future code path that imports this module without + // actually running the loop. + mouse.config.autoDelayMs = 0; + const log = makeLogger(config.verbose); log.info("Teams Status Keeper started. Press Ctrl+C to stop.");