export class ExtensionRegistry { #values = new Map(); add(name: string, value: T): void { const values = this.#values.get(name); if (values) { values.push(value); } else { this.#values.set(name, [value]); } } get(name: string): T { const values = this.all(name); if (values.length !== 1) { throw new Error(`"${name}" needs exactly one value, found ${values.length}.`); } return values[0] as T; } all(name: string): T[] { return [...(this.#values.get(name) ?? [])] as T[]; } clear(): void { this.#values.clear(); } }