import { channel, type Channel } from './channel'; /** Registry of named broadcast channels, lazily created and shared by name. */ export class Rooms { private readonly hubs = new Map>(); /** Returns the channel for `name`, creating it on first access. */ room(name: string): Channel { let hub = this.hubs.get(name); if (!hub) { hub = channel(); this.hubs.set(name, hub); } return hub as unknown as Channel; } /** Lists the names of all rooms created so far. */ names(): string[] { return [...this.hubs.keys()]; } }