From 3beaa1d2ec4785172679de5743c2e764e9f14da6 Mon Sep 17 00:00:00 2001 From: c0dev0id Date: Mon, 6 Jul 2026 21:11:55 +0200 Subject: [PATCH] refactor: rename Offset.motifs to motifRefs --- static/ast-parser.js | 4 ++-- static/components/PaneFO.js | 4 ++-- test-parser.mjs | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/static/ast-parser.js b/static/ast-parser.js index faaf9ca..cd0528e 100644 --- a/static/ast-parser.js +++ b/static/ast-parser.js @@ -470,14 +470,14 @@ function buildOffset(node) { type: 'offset', tick: node.props.tick, stemNotes: [], - motifs: [], + motifRefs: [], unknownProps: collectUnknownProps(node.props, new Set(['tick'])), }; for (const child of node.children) { if (child.parentSlot === 'line' && child.slot === 'stem_note') offset.stemNotes.push(buildStemNote(child)); else if (child.parentSlot === 'line' && child.slot === 'motif') - offset.motifs.push({ label: child.positionals[0], chord: child.props.chord ?? null }); + offset.motifRefs.push({ label: child.positionals[0], chord: child.props.chord ?? null }); } return offset; } diff --git a/static/components/PaneFO.js b/static/components/PaneFO.js index b069826..fd501d9 100644 --- a/static/components/PaneFO.js +++ b/static/components/PaneFO.js @@ -251,8 +251,8 @@ export const PaneFO = { fields: [ { key: 'tick', value: node.tick, editable: false }, { key: 'stem notes', value: node.stemNotes.map(snLabel).join(', ') || '—', editable: false }, - node.motifs?.length - ? { key: 'motifs', value: node.motifs.map(m => m.chord ? `${m.label}(${m.chord})` : m.label).join(', '), editable: false } + node.motifRefs?.length + ? { key: 'motifRefs', value: node.motifRefs.map(m => m.chord ? `${m.label}(${m.chord})` : m.label).join(', '), editable: false } : null, ...unknownPropFields(node), ].filter(Boolean), diff --git a/test-parser.mjs b/test-parser.mjs index 02f92a6..44b2411 100644 --- a/test-parser.mjs +++ b/test-parser.mjs @@ -631,11 +631,11 @@ const LM_FIXTURE = `00 bar '001P1L1M1' `; const lmOffset = buildModel(parseAstLog(LM_FIXTURE)).bars[0].voices['pi'].offsets[0]; ok('line.motif: offset has 1 stem note', lmOffset.stemNotes.length === 1); -ok('line.motif: offset.motifs has 2 entries', lmOffset.motifs.length === 2); -ok('line.motif: first motif label', lmOffset.motifs[0].label === 'coct'); -ok('line.motif: second motif label', lmOffset.motifs[1].label === 'oct'); -ok('line.motif: second motif chord', lmOffset.motifs[1].chord === 'C2'); -ok('line.motif: first motif chord null', lmOffset.motifs[0].chord === null); +ok('line.motif: offset.motifRefs has 2 entries', lmOffset.motifRefs.length === 2); +ok('line.motif: first motifRef label', lmOffset.motifRefs[0].label === 'coct'); +ok('line.motif: second motifRef label', lmOffset.motifRefs[1].label === 'oct'); +ok('line.motif: second motifRef chord', lmOffset.motifRefs[1].chord === 'C2'); +ok('line.motif: first motifRef chord null', lmOffset.motifRefs[0].chord === null); section('stem_note.write_to and chainText'); const WT_FIXTURE = `00 bar '001P1L1M1' @@ -704,8 +704,8 @@ const voicesWithMotifs = model.bars.flatMap(b => Object.values(b.voices)).filter ok('fixture voices have motif objects', voicesWithMotifs.every(v => v.motifs.every(m => typeof m === 'object' && 'label' in m))); const offsetsWithStemNotes = model.bars.flatMap(b => Object.values(b.voices)).flatMap(v => v.offsets).filter(o => o.stemNotes.length > 0); ok('fixture offsets have stem note objects', offsetsWithStemNotes.every(o => o.stemNotes.every(sn => 'pitch' in sn && 'clauses' in sn))); -const offsetsWithMotifInvocations = model.bars.flatMap(b => Object.values(b.voices)).flatMap(v => v.offsets).filter(o => o.motifs?.length > 0); -ok('fixture offset motif invocations are objects', offsetsWithMotifInvocations.every(o => o.motifs.every(m => 'label' in m))); +const offsetsWithMotifInvocations = model.bars.flatMap(b => Object.values(b.voices)).flatMap(v => v.offsets).filter(o => o.motifRefs?.length > 0); +ok('fixture offset motif invocations are objects', offsetsWithMotifInvocations.every(o => o.motifRefs.every(m => 'label' in m))); const stemNotesWithChainText = offsetsWithStemNotes.flatMap(o => o.stemNotes).filter(sn => sn.chainText); ok('fixture stem notes with chain text have clauses', stemNotesWithChainText.every(sn => sn.clauses.length > 0));