Skip to content

Add ChartDocument + writeChartFolder orchestrator - #78

Open
elicwhite wants to merge 1 commit into
round-trip-integrationfrom
chart-document
Open

Add ChartDocument + writeChartFolder orchestrator#78
elicwhite wants to merge 1 commit into
round-trip-integrationfrom
chart-document

Conversation

@elicwhite

Copy link
Copy Markdown
Owner

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.

@elicwhite
elicwhite force-pushed the round-trip-integration branch from 9104edd to 139de95 Compare April 20, 2026 05:09
@elicwhite
elicwhite force-pushed the chart-document branch 2 times, most recently from 2ccf928 to eb008b5 Compare April 20, 2026 05:10
@elicwhite
elicwhite force-pushed the round-trip-integration branch 2 times, most recently from 5c8ed73 to da67ddc Compare April 20, 2026 05:19
@elicwhite
elicwhite marked this pull request as ready for review April 20, 2026 16:09
@elicwhite
elicwhite force-pushed the round-trip-integration branch from da67ddc to 8d80779 Compare April 21, 2026 04:29
@elicwhite
elicwhite force-pushed the round-trip-integration branch from 8d80779 to d20ac10 Compare April 21, 2026 04:48
Comment thread src/chart/chart-document.ts Outdated
import type { ParsedChart } from './parse-chart-and-ini'
import { writeIniFile } from '../ini/ini-writer'

export interface ChartAsset {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/chart/chart-document.ts Outdated
* `song.ini` entries in `assets` — those would be additive, producing a
* malformed folder with two chart files.
*/
export function writeChartFolder(doc: ChartDocument): ChartAsset[] {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant