import { parseBundle, type InstrumentBundle } from './bundle.ts'; /** * Discovery of committed bundles: every * ../simulated_instruments//exports/*.json, inlined at build time. * A bundle that fails validation is reported and skipped rather than * taking the app down. Bundles imported at runtime live in imports.ts, * not here. */ const bundleModules = import.meta.glob('../../../../../simulated_instruments/*/exports/*.json', { eager: true, query: '?raw', import: 'default', }) as Record; export function loadCatalog(): InstrumentBundle[] { const out: InstrumentBundle[] = []; for (const [path, text] of Object.entries(bundleModules)) { try { out.push(parseBundle(text)); } catch (err) { console.warn(`skipping ${path}: ${err instanceof Error ? err.message : String(err)}`); } } out.sort((a, b) => a.name.localeCompare(b.name)); return out; }