/**
 * Typed event bus for index lifecycle events. Forwarded into the WS
 * broadcast pipeline by `server.ts` (T11) and consumed by the in-process
 * `SearchService` state machine.
 *
 * Payloads match `src/server/ws/protocol.ts` additions (design §9) exactly
 * so forwarding is a no-op cast — the WS layer just stamps a `type` prefix
 * and ships it.
 */
import { EventEmitter } from "node:events";
// ── Typed emitter ────────────────────────────────────────────────────
/**
 * Thin typed wrapper over `EventEmitter`. We use a hand-rolled generic
 * rather than TS 5's built-in typed emitter so downstream code doesn't
 * need `@types/node` >= 22 semantics leaking.
 */
export class ProgressBus {
    emitter = new EventEmitter();
    on(event, listener) {
        this.emitter.on(event, listener);
        return this;
    }
    off(event, listener) {
        this.emitter.off(event, listener);
        return this;
    }
    once(event, listener) {
        this.emitter.once(event, listener);
        return this;
    }
    emit(event, ...args) {
        return this.emitter.emit(event, ...args);
    }
    removeAllListeners(event) {
        if (event)
            this.emitter.removeAllListeners(event);
        else
            this.emitter.removeAllListeners();
        return this;
    }
}
/**
 * Shared singleton — there is one bus per server process. Per-project
 * scoping is carried in each event's `projectId` field; the WS layer
 * filters subscribers.
 */
export const progressBus = new ProgressBus();
//# sourceMappingURL=progress-bus.js.map