1import { parseBundle, type InstrumentBundle } from './bundle.ts';
3/**
4 * Discovery of committed bundles: every
5 * ../simulated_instruments/<repo>/exports/*.json, inlined at build time.
6 * A bundle that fails validation is reported and skipped rather than
7 * taking the app down. Bundles imported at runtime live in imports.ts,
8 * not here.
9 */
11const bundleModules = import.meta.glob('../../../../../simulated_instruments/*/exports/*.json', {
12 eager: true,
13 query: '?raw',
14 import: 'default',
15}) as Record<string, string>;
17export function loadCatalog(): InstrumentBundle[] {
18 const out: InstrumentBundle[] = [];
19 for (const [path, text] of Object.entries(bundleModules)) {
20 try {
21 out.push(parseBundle(text));
22 } catch (err) {
23 console.warn(`skipping ${path}: ${err instanceof Error ? err.message : String(err)}`);
24 }
25 }
26 out.sort((a, b) => a.name.localeCompare(b.name));
27 return out;
28}