import { parseSettingsSource, SettingsEntry } from './settingsIndex'; // [Gitea #463] The settings source, as text, in its own lazily loaded chunk: // fetched the first time someone searches, never at startup. const sources = import.meta.glob(['../**/*.tsx', '!../**/*.test.tsx'], { query: '?raw', import: 'default', }) as Record Promise>; let index: Promise | undefined; export const loadSettingsIndex = (): Promise => { index ??= Promise.all( Object.entries(sources).map(async ([path, load]) => // '../general/General.tsx' -> '/general/General.tsx' (what the parser matches) parseSettingsSource(path.replace(/^\.\./, ''), await load()), ), ).then((all) => all.flat()); return index; };