Round-trip extraChartSongFields / unrecognizedSyncTrackEvents / unrecognizedEventsTrackMidiEvents - #87
Open
elicwhite wants to merge 1 commit into
Open
Conversation
This was referenced Apr 21, 2026
Owner
Author
elicwhite
marked this pull request as ready for review
April 21, 2026 23:20
…ognizedEventsTrackMidiEvents
The parser preserves three post-writer-stack round-trip buckets that the
writers weren't yet emitting:
- `metadata.extraChartSongFields` (unknown `[Song]` keys, .chart source)
- `unrecognizedSyncTrackEvents` (non-B/TS `[SyncTrack]` lines, .chart)
- `unrecognizedEventsTrackMidiEvents` (non-text MIDI events on the EVENTS
track — e.g. RB practice-mode
assist-sample notes 24/25/26)
Emit them:
- `writeChartFile` appends `extraChartSongFields` at the tail of `[Song]`
(values written verbatim — no quoting added or stripped). Editors and
consumers should treat these as opaque and never synthesize them; this
is strictly a round-trip aid for tools like Moonscraper that author
deprecated fields (`Player2`, `HoPo`, `PreviewEnd`, audio-stream
filenames, etc.). Any audio file discovery should go through folder
scan, not via `[Song].*Stream` values.
- `writeChartFile` emits `unrecognizedSyncTrackEvents` alongside tempos +
time signatures in `[SyncTrack]`, sorted by tick (TS < B < raw at the
same tick for determinism). Text is written verbatim as
`${tick} = ${text}`, so tempo anchors (`A <microseconds>`) and any
future SyncTrack event types survive a parse → write loop without
parser updates.
- `writeMidiFile` appends `unrecognizedEventsTrackMidiEvents` to the
EVENTS track after sections / end events / unrecognized text events /
coda. Events arrive with absolute-tick `deltaTime` (scan-chart's
post-process) and get re-deltified by `finalizeMidiTrack`.
`.chart`-only fields (`extraChartSongFields`, `unrecognizedSyncTrackEvents`)
are dropped when writing to `.mid`, and `unrecognizedEventsTrackMidiEvents`
is dropped when writing to `.chart` — tests pin both contracts so a future
writer change doesn't accidentally smuggle them through as something else.
11 new tests in `round-trip-unrecognized-extras.test.ts` cover legacy-field
preservation, tempo-anchor round-trip, forward-compat for unknown SyncTrack
types, co-occurrence with tempos/TS at the same tick, practice-assist note
round-trip on `.mid`, and the cross-format drop contracts. All 1020 tests
pass (1009 existing + 11 new).
elicwhite
force-pushed
the
chart-document
branch
from
April 22, 2026 16:34
f4d6359 to
d265589
Compare
elicwhite
force-pushed
the
round-trip-unrecognized-extras
branch
from
April 22, 2026 16:34
c5ba3df to
06c15d7
Compare
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The parser preserves three post-writer-stack round-trip buckets that the
writers weren't yet emitting:
metadata.extraChartSongFields(unknown[Song]keys, .chart source)unrecognizedSyncTrackEvents(non-B/TS[SyncTrack]lines, .chart)unrecognizedEventsTrackMidiEvents(non-text MIDI events on the EVENTStrack — e.g. RB practice-mode
assist-sample notes 24/25/26)
Emit them:
writeChartFileappendsextraChartSongFieldsat the tail of[Song](values written verbatim — no quoting added or stripped). Editors and
consumers should treat these as opaque and never synthesize them; this
is strictly a round-trip aid for tools like Moonscraper that author
deprecated fields (
Player2,HoPo,PreviewEnd, audio-streamfilenames, etc.). Any audio file discovery should go through folder
scan, not via
[Song].*Streamvalues.writeChartFileemitsunrecognizedSyncTrackEventsalongside tempos +time signatures in
[SyncTrack], sorted by tick (TS < B < raw at thesame tick for determinism). Text is written verbatim as
${tick} = ${text}, so tempo anchors (A <microseconds>) and anyfuture SyncTrack event types survive a parse → write loop without
parser updates.
writeMidiFileappendsunrecognizedEventsTrackMidiEventsto theEVENTS track after sections / end events / unrecognized text events /
coda. Events arrive with absolute-tick
deltaTime(scan-chart'spost-process) and get re-deltified by
finalizeMidiTrack..chart-only fields (extraChartSongFields,unrecognizedSyncTrackEvents)are dropped when writing to
.mid, andunrecognizedEventsTrackMidiEventsis dropped when writing to
.chart— tests pin both contracts so a futurewriter change doesn't accidentally smuggle them through as something else.
11 new tests in
round-trip-unrecognized-extras.test.tscover legacy-fieldpreservation, tempo-anchor round-trip, forward-compat for unknown SyncTrack
types, co-occurrence with tempos/TS at the same tick, practice-assist note
round-trip on
.mid, and the cross-format drop contracts. All 1020 testspass (1009 existing + 11 new).