All files / player-browser/src/chart bga-subregions.ts

100% Statements 19/19
75% Branches 6/8
100% Functions 2/2
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20          333x 333x 333x 333x 333x 333x 333x 5193x 5193x 5182x 5182x   333x    
import { parseBMSExBMP, parseBmsBGA, type BMSSubRegionBGA } from '@be-music/chart-model';
import { normalizeObjectKey, resolveBMSBase, type BeMusicJSON } from '@be-music/chart-source';
 
/** Effective aliases only: an authored image declaration takes precedence even when its asset fails to load. */
export function collectBGASubRegions(chart: BeMusicJSON): Map<string, BMSSubRegionBGA> {
  const regions = new Map<string, BMSSubRegionBGA>();
  const base = resolveBMSBase(chart);
  const allowLongKeys = chart.sourceFormat === 'bmson';
  const direct = new Set(chart.bmson.bga.header.map((entry) => entry.name));
  for (const [key, path] of Object.entries(chart.resources.bmp)) Eif (path) direct.add(key);
  for (const [key, raw] of Object.entries(chart.bms.exBMP)) if (parseBMSExBMP(raw)) direct.add(key);
  for (const [rawSlot, raw] of Object.entries(chart.bms.bga)) {
    const slot = normalizeObjectKey(rawSlot, base, allowLongKeys);
    if (direct.has(slot)) continue;
    const region = parseBmsBGA(raw, base, allowLongKeys);
    Eif (region) regions.set(slot, region);
  }
  return regions;
}