feat: improve combination search and offline build

This commit is contained in:
2026-08-18 20:59:20 +09:00
parent ee3498d146
commit d0f7654998
20 changed files with 552 additions and 99 deletions
+24
View File
@@ -0,0 +1,24 @@
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<string, string>;
const sourceByFilename = new Map(
Object.entries(chartSources).map(([path, source]) => [path.split('/').at(-1) ?? path, source])
);
const parsedCharts = new Map<string, ExactSongChart>();
export async function loadExactSongChart(path: string): Promise<ExactSongChart> {
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;
}