/** * registry.ts — internal built-in section registry. * * V1 keeps registration internal: there is no public `registerSection()` until * a real optional-package use case proves its lifecycle. Duplicate keys fail at * construction. Unknown raw sections are preserved elsewhere (persistence), so * this closed set does not block forward compatibility. */ import type { ConfigSection, SectionHandle } from "./schema.ts"; import { builtinSections } from "./sections/index.ts"; export class SectionRegistry { private readonly byKey = new Map>(); constructor(handles: readonly SectionHandle[] = builtinSections) { for (const handle of handles) this.add(handle); } private add(handle: SectionHandle): void { if (this.byKey.has(handle.key)) { throw new Error(`pix-runtime: duplicate section key "${handle.key}"`); } this.byKey.set(handle.key, handle.__section); } get(key: string): ConfigSection | undefined { return this.byKey.get(key); } all(): ConfigSection[] { return [...this.byKey.values()]; } keys(): string[] { return [...this.byKey.keys()]; } }