import type { ExactSongChart } from '$lib/engine/index.ts'; const chartSources = import.meta.glob('../static/data/charts/*.json', { eager: true, query: '?raw', import: 'default' }) as Record; const sourceByFilename = new Map( Object.entries(chartSources).map(([path, source]) => [path.split('/').at(-1) ?? path, source]) ); const parsedCharts = new Map(); export async function loadExactSongChart(path: string): Promise { const filename = path.split('/').at(-1) ?? path; const cached = parsedCharts.get(filename); if (cached) return cached; const source = sourceByFilename.get(filename); if (!source) throw new Error(`포함된 채보 데이터를 찾지 못했습니다: ${filename}`); const chart = JSON.parse(source) as ExactSongChart; parsedCharts.set(filename, chart); return chart; }