Add ChartDocument + writeChartFolder orchestrator - #78
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
9104edd to
139de95
Compare
2ccf928 to
eb008b5
Compare
5c8ed73 to
da67ddc
Compare
eb008b5 to
b9d8a8c
Compare
b9d8a8c to
a73f3ba
Compare
da67ddc to
8d80779
Compare
a73f3ba to
423a085
Compare
8d80779 to
d20ac10
Compare
d20ac10 to
adf91a9
Compare
423a085 to
39d1697
Compare
| import type { ParsedChart } from './parse-chart-and-ini' | ||
| import { writeIniFile } from '../ini/ini-writer' | ||
|
|
||
| export interface ChartAsset { |
There was a problem hiding this comment.
There are lots of references in the codebase to
{ fileName: string; data: Uint8Array }
In a separate PR before this in the stack, create a type in interfaces.ts called File, and update every callsite through the codebase to reference File or File[]. Then update this PR to use that instead of ChartAsset.
| * `song.ini` entries in `assets` — those would be additive, producing a | ||
| * malformed folder with two chart files. | ||
| */ | ||
| export function writeChartFolder(doc: ChartDocument): ChartAsset[] { |
There was a problem hiding this comment.
This should verify that there aren't any other song.ini or .chart/.mid files passed in assets. If there are, they should be removed first.
@Geomitron, I'm making a choice to just overwrite, because I think it'll be pretty common that people don't remove these to pass in just their assets.
adf91a9 to
48c5edf
Compare
ce12eba to
8a1bd74
Compare
079b471 to
1e055a2
Compare
1e055a2 to
f3dfd0d
Compare
8a1bd74 to
f4d6359
Compare
Bundles a ParsedChart with non-chart files (audio, album art, extras)
into a single value, and provides the write-side companion to
parseChartAndIni's input shape:
files (in) ChartDocument (out)
---------------- -----------------------
notes.chart or notes.mid → parsedChart
song.ini → parsedChart.metadata
song.ogg, album.png, ... → assets (passthrough)
writeChartFolder produces the reverse transformation:
- notes.chart or notes.mid from writeChartFile / writeMidiFile based on
parsedChart.format
- song.ini from writeIniFile(parsedChart.metadata) — chart_offset is
naturally skipped since writeIniFile only emits keys in defaultMetadata
- every entry in doc.assets, in order
No separate `metadata` field on ChartDocument — it lives on
parsedChart.metadata (the consolidated shape produced by parseChartAndIni).
Tests: 9 cases covering format selection, ini content (chart_offset not
leaked, extraIniFields preserved), asset passthrough + ordering, and
full round-trip through parseChartAndIni for both .chart and .mid with
assets.
442 total scan-chart tests passing.
f3dfd0d to
6862111
Compare
f4d6359 to
d265589
Compare

Bundles a ParsedChart with non-chart files (audio, album art, extras)
into a single value, and provides the write-side companion to
parseChartAndIni's input shape:
writeChartFolder produces the reverse transformation:
parsedChart.format
naturally skipped since writeIniFile only emits keys in defaultMetadata
No separate
metadatafield on ChartDocument — it lives onparsedChart.metadata (the consolidated shape produced by parseChartAndIni).
Tests: 9 cases covering format selection, ini content (chart_offset not
leaked, extraIniFields preserved), asset passthrough + ordering, and
full round-trip through parseChartAndIni for both .chart and .mid with
assets.
442 total scan-chart tests passing.