// src/core/dashboard-events.ts
import { logger } from '../utils/logger.js';
export class DashboardEventBus {
    subs = new Set();
    subscribe(fn) {
        this.subs.add(fn);
        return () => this.subs.delete(fn);
    }
    publish(event) {
        for (const fn of this.subs) {
            try {
                fn(event);
            }
            catch (err) {
                // Subscriber errors must not break publishing.
                logger.error(`[dashboard-events] subscriber threw: ${err}`);
            }
        }
    }
}
/** Process-wide singleton — daemon publishers and IPC SSE handler share. */
export const dashboardEventBus = new DashboardEventBus();
//# sourceMappingURL=dashboard-events.js.map