import { logger } from "../../utils/logger.js";
export class FrameBus {
    handlers = {};
    subscribe(type, fn) {
        if (!this.handlers[type]) {
            this.handlers[type] = [];
        }
        this.handlers[type].push(fn);
    }
    publish(frame) {
        const subs = this.handlers[frame.type];
        if (!subs) {
            return;
        }
        for (const fn of subs) {
            try {
                fn(frame);
            }
            catch (err) {
                logger.error(`[FrameBus] Subscriber threw on ${frame.type}:`, err);
            }
        }
    }
}
//# sourceMappingURL=frameBus.js.map