vexflow 5.2.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/build/cjs/vexflow-bravura.js +2 -2
- package/build/cjs/vexflow-bravura.js.map +1 -1
- package/build/cjs/vexflow-core.js +2 -2
- package/build/cjs/vexflow-core.js.map +1 -1
- package/build/cjs/vexflow-debug-with-tests.js +6502 -1708
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +5622 -1618
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow.js +2 -2
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/src/accidental.js +10 -3
- package/build/esm/src/alternatingtremolo.js +68 -0
- package/build/esm/src/annotation.js +19 -3
- package/build/esm/src/articulation.js +28 -6
- package/build/esm/src/beam.js +171 -28
- package/build/esm/src/bend.js +79 -23
- package/build/esm/src/clef.js +3 -0
- package/build/esm/src/continuouslayout.js +681 -0
- package/build/esm/src/continuousspan.js +159 -0
- package/build/esm/src/curve.js +48 -55
- package/build/esm/src/dot.js +13 -4
- package/build/esm/src/easyscore/composition.js +52 -2
- package/build/esm/src/easyscore/policies.js +39 -8
- package/build/esm/src/element.js +4 -0
- package/build/esm/src/engravinggeometry.js +157 -0
- package/build/esm/src/engravingprofile.js +44 -0
- package/build/esm/src/factory.js +31 -11
- package/build/esm/src/font.js +9 -1
- package/build/esm/src/formatter.js +9 -1
- package/build/esm/src/fretdiagram.js +77 -0
- package/build/esm/src/gracenote.js +43 -38
- package/build/esm/src/gracenotegroup.js +53 -56
- package/build/esm/src/guitargesture.js +33 -0
- package/build/esm/src/guitarmodifiers.js +26 -0
- package/build/esm/src/index.js +10 -0
- package/build/esm/src/instrumentprofile.js +123 -0
- package/build/esm/src/keysignature.js +24 -2
- package/build/esm/src/modifiercontext.js +11 -0
- package/build/esm/src/notationspelling.js +73 -0
- package/build/esm/src/note.js +3 -0
- package/build/esm/src/notehead.js +11 -6
- package/build/esm/src/ornament.js +43 -18
- package/build/esm/src/pagebreaks.js +58 -0
- package/build/esm/src/pedalmarking.js +39 -17
- package/build/esm/src/phraselayout.js +503 -0
- package/build/esm/src/phraseribbon.js +28 -0
- package/build/esm/src/proportionalformatter.js +54 -6
- package/build/esm/src/publication.js +402 -0
- package/build/esm/src/publicationview.js +114 -0
- package/build/esm/src/scorenavigation.js +172 -0
- package/build/esm/src/sheet.js +14 -2
- package/build/esm/src/stave.js +33 -16
- package/build/esm/src/stavebarline.js +5 -7
- package/build/esm/src/staveconnector.js +1 -0
- package/build/esm/src/stavehairpin.js +53 -27
- package/build/esm/src/stavenote.js +134 -116
- package/build/esm/src/stavetie.js +66 -9
- package/build/esm/src/stem.js +26 -11
- package/build/esm/src/strokes.js +4 -0
- package/build/esm/src/system.js +19 -4
- package/build/esm/src/systembreaks.js +42 -0
- package/build/esm/src/tabnote.js +6 -1
- package/build/esm/src/textbracket.js +24 -5
- package/build/esm/src/tickcontext.js +19 -0
- package/build/esm/src/timesignature.js +20 -6
- package/build/esm/src/tuplet.js +58 -17
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vexflow.js +20 -0
- package/build/esm/src/voice.js +7 -3
- package/build/esm/tests/bend_tests.js +14 -1
- package/build/esm/tests/curve_tests.js +14 -4
- package/build/esm/tests/demo_repertoire_tests.js +27 -0
- package/build/esm/tests/demos/drums.js +54 -0
- package/build/esm/tests/demos/electric.js +63 -0
- package/build/esm/tests/demos/greensleeves.js +90 -0
- package/build/esm/tests/demos/joy.js +61 -0
- package/build/esm/tests/demos/kesh.js +80 -0
- package/build/esm/tests/demos/prelude.js +59 -0
- package/build/esm/tests/demos/quartertones.js +50 -0
- package/build/esm/tests/demos/saints.js +65 -0
- package/build/esm/tests/engraving/continuous-studies.mjs +140 -0
- package/build/esm/tests/engraving/instrument-studies.mjs +273 -0
- package/build/esm/tests/engraving/phrase-studies.mjs +63 -0
- package/build/esm/tests/engraving/publication-studies.mjs +87 -0
- package/build/esm/tests/engraving/score-layout.mjs +75 -0
- package/build/esm/tests/engraving/score-persistence.mjs +262 -0
- package/build/esm/tests/engraving/specialist-studies.mjs +347 -0
- package/build/esm/tests/engraving/studies.mjs +367 -0
- package/build/esm/tests/formatter_tests.js +10 -1
- package/build/esm/tests/index.js +1 -0
- package/build/esm/tests/node/audit-dependencies-tests.mjs +42 -0
- package/build/esm/tests/node/continuous-score-tests.mjs +282 -0
- package/build/esm/tests/node/easyscore-tests.mjs +71 -0
- package/build/esm/tests/node/engraving-layout-tests.mjs +449 -0
- package/build/esm/tests/node/instrument-profile-tests.mjs +224 -0
- package/build/esm/tests/node/local-engraving-tests.mjs +128 -0
- package/build/esm/tests/node/phrase-layout-tests.mjs +281 -0
- package/build/esm/tests/node/proportional-spacing-tests.mjs +64 -0
- package/build/esm/tests/node/publication-tests.mjs +219 -0
- package/build/esm/tests/node/rendering-tests.mjs +6 -2
- package/build/esm/tests/threevoice_tests.js +11 -1
- package/build/esm/tests/vexflow_test_helpers.js +19 -10
- package/build/esm/tools/audit-dependencies.mjs +61 -0
- package/build/esm/tools/easyscore-structure.mjs +1 -1
- package/build/esm/tools/explorer/catalog/entries.mjs +2 -1
- package/build/esm/tools/explorer/catalog/expression.mjs +14 -9
- package/build/esm/tools/explorer/catalog/guitar.mjs +238 -0
- package/build/esm/tools/explorer/catalog/layout.mjs +8 -6
- package/build/esm/tools/explorer/catalog/notes.mjs +16 -14
- package/build/esm/tools/explorer/catalog/staves.mjs +12 -6
- package/build/esm/tools/explorer/catalog/strings.mjs +10 -7
- package/build/esm/tools/score-fixtures.mjs +23 -6
- package/build/types/src/accidental.d.ts +4 -0
- package/build/types/src/alternatingtremolo.d.ts +13 -0
- package/build/types/src/annotation.d.ts +9 -0
- package/build/types/src/articulation.d.ts +9 -1
- package/build/types/src/beam.d.ts +16 -0
- package/build/types/src/bend.d.ts +8 -0
- package/build/types/src/clef.d.ts +3 -0
- package/build/types/src/continuouslayout.d.ts +103 -0
- package/build/types/src/continuousspan.d.ts +60 -0
- package/build/types/src/curve.d.ts +20 -0
- package/build/types/src/dot.d.ts +5 -0
- package/build/types/src/easyscore/composition.d.ts +27 -0
- package/build/types/src/easyscore/policies.d.ts +1 -1
- package/build/types/src/element.d.ts +2 -0
- package/build/types/src/engravinggeometry.d.ts +31 -0
- package/build/types/src/engravingprofile.d.ts +20 -0
- package/build/types/src/factory.d.ts +6 -1
- package/build/types/src/formatter.d.ts +3 -3
- package/build/types/src/fretdiagram.d.ts +23 -0
- package/build/types/src/gracenote.d.ts +7 -0
- package/build/types/src/gracenotegroup.d.ts +7 -2
- package/build/types/src/guitargesture.d.ts +26 -0
- package/build/types/src/guitarmodifiers.d.ts +3 -0
- package/build/types/src/index.d.ts +12 -0
- package/build/types/src/instrumentprofile.d.ts +124 -0
- package/build/types/src/keysignature.d.ts +9 -0
- package/build/types/src/modifiercontext.d.ts +4 -0
- package/build/types/src/notationspelling.d.ts +25 -0
- package/build/types/src/note.d.ts +15 -0
- package/build/types/src/notehead.d.ts +5 -0
- package/build/types/src/ornament.d.ts +10 -1
- package/build/types/src/pagebreaks.d.ts +26 -0
- package/build/types/src/pedalmarking.d.ts +9 -0
- package/build/types/src/phraselayout.d.ts +87 -0
- package/build/types/src/phraseribbon.d.ts +7 -0
- package/build/types/src/proportionalformatter.d.ts +11 -2
- package/build/types/src/publication.d.ts +61 -0
- package/build/types/src/publicationview.d.ts +27 -0
- package/build/types/src/scorenavigation.d.ts +33 -0
- package/build/types/src/sheet.d.ts +5 -0
- package/build/types/src/stave.d.ts +13 -0
- package/build/types/src/stavehairpin.d.ts +18 -0
- package/build/types/src/stavenote.d.ts +20 -2
- package/build/types/src/stavetie.d.ts +9 -0
- package/build/types/src/stem.d.ts +10 -1
- package/build/types/src/system.d.ts +8 -1
- package/build/types/src/systembreaks.d.ts +9 -0
- package/build/types/src/textbracket.d.ts +7 -0
- package/build/types/src/tickcontext.d.ts +5 -0
- package/build/types/src/timesignature.d.ts +6 -0
- package/build/types/src/tuplet.d.ts +5 -48
- package/build/types/src/vexflow.d.ts +20 -0
- package/build/types/src/voice.d.ts +2 -0
- package/changelog/CHANGELOG.md +25 -0
- package/package.json +15 -3
- package/tests/all.html +277 -0
- package/tests/demo_petzold_tests.ts +435 -0
- package/tests/demos/drums.ts +55 -0
- package/tests/demos/drums.webp +0 -0
- package/tests/demos/electric.ts +70 -0
- package/tests/demos/electric.webp +0 -0
- package/tests/demos/greensleeves.ts +97 -0
- package/tests/demos/greensleeves.webp +0 -0
- package/tests/demos/joy.ts +65 -0
- package/tests/demos/joy.webp +0 -0
- package/tests/demos/kesh.ts +86 -0
- package/tests/demos/kesh.webp +0 -0
- package/tests/demos/prelude.ts +65 -0
- package/tests/demos/prelude.webp +0 -0
- package/tests/demos/quartertones.ts +51 -0
- package/tests/demos/quartertones.webp +0 -0
- package/tests/demos/saints.ts +70 -0
- package/tests/demos/saints.webp +0 -0
- package/tests/flow.html +550 -239
- package/tests/fonts.css +493 -0
- package/tests/minuet.webp +0 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
export function registerStudies() {
|
|
2
|
+
const VF = globalThis.VexFlow;
|
|
3
|
+
QUnit.module('M0 studies');
|
|
4
|
+
function chord(options, input, clef, signs) {
|
|
5
|
+
const factory = VF.Test.makeFactory(options, 220, 150);
|
|
6
|
+
const score = factory.EasyScore();
|
|
7
|
+
const notes = score.notes(input, { clef });
|
|
8
|
+
factory
|
|
9
|
+
.System({ width: 195 })
|
|
10
|
+
.addStave({ voices: [score.voice(notes, { mode: 'soft' })] })
|
|
11
|
+
.addClef(clef);
|
|
12
|
+
factory.draw();
|
|
13
|
+
const note = notes[0];
|
|
14
|
+
const actual = note
|
|
15
|
+
.getModifiers()
|
|
16
|
+
.filter((mark) => mark instanceof VF.Accidental)
|
|
17
|
+
.map((mark) => mark.type);
|
|
18
|
+
options.assert.deepEqual(actual, signs, 'Explicit accidental sequence');
|
|
19
|
+
options.assert.equal(note.noteHeads.length, note.getKeys().length, 'Every pitch has a head');
|
|
20
|
+
const root = document.getElementById(options.elementId);
|
|
21
|
+
const boxes = [...root.querySelectorAll('.vf-stavenote text')].map((glyph) => {
|
|
22
|
+
const { x, y, width, height } = glyph.getBBox();
|
|
23
|
+
return { glyph: glyph.textContent.codePointAt(0).toString(16), x, y, width, height };
|
|
24
|
+
});
|
|
25
|
+
const headGlyphs = new Set(note.noteHeads.map((head) => head.getText().codePointAt(0).toString(16)));
|
|
26
|
+
const heads = boxes.filter((box) => headGlyphs.has(box.glyph));
|
|
27
|
+
const headPositions = new Set(heads.map((head) => head.x));
|
|
28
|
+
options.assert.equal(heads.length, note.getKeys().length, 'Every pitch draws its head glyph');
|
|
29
|
+
const quality = headPositions.size === heads.length ? 'Distinct head positions' : 'Coincident head positions';
|
|
30
|
+
root.dataset.measurement = JSON.stringify({ actual, boxes, quality });
|
|
31
|
+
}
|
|
32
|
+
VF.Test.runTests('Altered whole-note unison', (o) => chord(o, '(B4 B#4)/w', 'treble', ['#']));
|
|
33
|
+
VF.Test.runTests('Natural and flat in bass clef', (o) => chord(o, '(Bn3 Bb3)/w', 'bass', ['n', 'b']));
|
|
34
|
+
VF.Test.runTests('Three spellings on one line', (o) => chord(o, '(D#5 Dn5 Db5)/q', 'treble', ['#', 'n', 'b']));
|
|
35
|
+
VF.Test.runTests('Mixed subdivisions after a triplet', (options) => {
|
|
36
|
+
const factory = VF.Test.makeFactory(options, 480, 160);
|
|
37
|
+
const score = factory.EasyScore();
|
|
38
|
+
const notes = score.notes('C5/q, D5/q, E5/q, F5/8, G5/16, A5/16, B5/q');
|
|
39
|
+
score.tuplet(notes.slice(0, 3));
|
|
40
|
+
const beams = VF.Beam.generateBeams(notes);
|
|
41
|
+
factory
|
|
42
|
+
.System({ width: 450 })
|
|
43
|
+
.addStave({ voices: [score.voice(notes)] })
|
|
44
|
+
.addClef('treble');
|
|
45
|
+
factory.draw();
|
|
46
|
+
for (const beam of beams)
|
|
47
|
+
beam.setContext(factory.getContext()).draw();
|
|
48
|
+
const groups = beams.map((beam) => beam.getNotes().map((note) => notes.indexOf(note)));
|
|
49
|
+
document.getElementById(options.elementId).dataset.measurement = JSON.stringify({ groups, expected: [[3, 4, 5]] });
|
|
50
|
+
options.assert.deepEqual(groups, [[3, 4, 5]], 'The three short notes form one beat');
|
|
51
|
+
options.assert.equal(notes.length, 7, 'Seven attacks fill one strict 4/4 measure');
|
|
52
|
+
});
|
|
53
|
+
VF.Test.runTests('Repeated contour at two widths', (options) => {
|
|
54
|
+
const factory = VF.Test.makeFactory(options, 560, 260);
|
|
55
|
+
const score = factory.EasyScore();
|
|
56
|
+
const beams = [];
|
|
57
|
+
for (const [width, y] of [
|
|
58
|
+
[300, 15],
|
|
59
|
+
[500, 140],
|
|
60
|
+
]) {
|
|
61
|
+
const notes = score.notes('A4/8, B4, C4, D4, G4, A4, B4, C4', { stem: 'up' });
|
|
62
|
+
factory
|
|
63
|
+
.System({ width, y })
|
|
64
|
+
.addStave({ voices: [score.voice(notes)] })
|
|
65
|
+
.addClef('treble');
|
|
66
|
+
for (const start of [0, 4])
|
|
67
|
+
beams.push(factory.Beam({ notes: notes.slice(start, start + 4) }));
|
|
68
|
+
}
|
|
69
|
+
factory.draw();
|
|
70
|
+
const slopes = beams.map((beam) => beam.slope);
|
|
71
|
+
options.assert.ok(slopes.every(Number.isFinite), 'Finite screen-coordinate slopes');
|
|
72
|
+
document.getElementById(options.elementId).dataset.measurement = JSON.stringify({ slopes });
|
|
73
|
+
});
|
|
74
|
+
VF.Test.runTests('Lyric after a skipped attack', (options) => {
|
|
75
|
+
const factory = VF.Test.makeFactory(options, 360, 160);
|
|
76
|
+
const score = factory.EasyScore();
|
|
77
|
+
const notes = score.notes('G4/q, A4/q, C5/h');
|
|
78
|
+
for (const [i, word] of [
|
|
79
|
+
[0, 'sum'],
|
|
80
|
+
[2, 'mer'],
|
|
81
|
+
]) {
|
|
82
|
+
notes[i].addModifier(new VF.Annotation(word).setTextBaseline(125), 0);
|
|
83
|
+
}
|
|
84
|
+
factory
|
|
85
|
+
.System({ width: 335 })
|
|
86
|
+
.addStave({ voices: [score.voice(notes)] })
|
|
87
|
+
.addClef('treble');
|
|
88
|
+
factory.draw();
|
|
89
|
+
const root = document.getElementById(options.elementId);
|
|
90
|
+
const lyrics = [...root.querySelectorAll('text')].filter((el) => ['sum', 'mer'].includes(el.textContent));
|
|
91
|
+
options.assert.deepEqual(lyrics.map((el) => el.textContent), ['sum', 'mer'], 'Syllables stay in event order');
|
|
92
|
+
options.assert.deepEqual(lyrics.map((el) => Number(el.getAttribute('y'))), [125, 125], 'Authored common baseline');
|
|
93
|
+
root.dataset.measurement = JSON.stringify({
|
|
94
|
+
lyrics: lyrics.map((el) => {
|
|
95
|
+
const { x, y, width, height } = el.getBBox();
|
|
96
|
+
return { id: el.textContent, group: 'verse', x, y, width, height };
|
|
97
|
+
}),
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
VF.Test.runTests('Two head shapes at one onset', (options) => {
|
|
101
|
+
const factory = VF.Test.makeFactory(options, 230, 150);
|
|
102
|
+
const score = factory.EasyScore();
|
|
103
|
+
const note = score.make.note({ keys: ['f/4', 'g/5/x2'], duration: 'w' });
|
|
104
|
+
factory
|
|
105
|
+
.System({ width: 210 })
|
|
106
|
+
.addStave({ voices: [score.voice([note])] })
|
|
107
|
+
.addClef('percussion');
|
|
108
|
+
factory.draw();
|
|
109
|
+
options.assert.equal(new Set(note.noteHeads.map((head) => head.getText())).size, 2, 'Distinct typed head glyphs');
|
|
110
|
+
options.assert.notOk(score.parseNotation('(F4 G5/m)/8, G5/m').success, 'The legacy compact spelling is rejected');
|
|
111
|
+
const foreign = VF.EasyScore.create({ renderer: { elementId: null } }).notes('C4/w')[0];
|
|
112
|
+
options.assert.throws(() => score.make.curve({ from: note, to: foreign }), /owner|factory|belong/i, 'A span cannot resolve an endpoint in another score');
|
|
113
|
+
const signs = score.notes('C#4/q, Cb4/q').map((n) => n.getModifiers()[0].type);
|
|
114
|
+
options.assert.deepEqual(signs, ['#', 'b'], 'Spelled probe preserves the requested accidental sequence');
|
|
115
|
+
options.assert.notDeepEqual(signs, ['#', '#'], 'Substituting sharp for flat is detected');
|
|
116
|
+
});
|
|
117
|
+
VF.Test.runTests('Horizontal beams inside the staff', (options) => {
|
|
118
|
+
const factory = VF.Test.makeFactory(options, 380, 145);
|
|
119
|
+
const score = factory.EasyScore();
|
|
120
|
+
const notes = score.notes('C4/8, C4, D4, D4, E4, E4, F4, F4', { stem: 'up' });
|
|
121
|
+
const stave = factory
|
|
122
|
+
.System({ width: 350 })
|
|
123
|
+
.addStave({ voices: [score.voice(notes)] })
|
|
124
|
+
.addClef('treble');
|
|
125
|
+
const beams = [0, 2, 4, 6].map((first) => factory.Beam({ notes: notes.slice(first, first + 2) }));
|
|
126
|
+
factory.draw();
|
|
127
|
+
const lines = [0, 1, 2, 3, 4].map((i) => stave.getYForLine(i));
|
|
128
|
+
const tips = beams.map((beam) => beam.getNotes()[0].getStemExtents().topY);
|
|
129
|
+
options.assert.ok(beams.every((beam) => Math.abs(beam.slope) < 1e-6), 'Repeated pitches have horizontal beams');
|
|
130
|
+
document.getElementById(options.elementId).dataset.measurement = JSON.stringify({ lines, tips });
|
|
131
|
+
});
|
|
132
|
+
QUnit.module('M1 studies');
|
|
133
|
+
VF.Test.runTests('Notehead between beamed attacks', (options) => {
|
|
134
|
+
const factory = VF.Test.makeFactory(options, 400, 140);
|
|
135
|
+
const score = factory.EasyScore();
|
|
136
|
+
const notes = score.notes('C4/8, C4/8', { stem: 'up' });
|
|
137
|
+
const other = factory.StaveNote({ keys: ['c/5'], duration: '16', stemDirection: 1 });
|
|
138
|
+
const voices = [notes, [factory.GhostNote('16'), other, factory.GhostNote('8')]];
|
|
139
|
+
const beam = factory.Beam({ notes });
|
|
140
|
+
factory
|
|
141
|
+
.System({ x: 10, y: 0, width: 370 })
|
|
142
|
+
.addStave({ voices: voices.map((v) => score.voice(v, { mode: 'soft' })) });
|
|
143
|
+
factory.draw();
|
|
144
|
+
const headBottom = other.getYs()[0] + other.noteHeads[0].getTextMetrics().actualBoundingBoxDescent;
|
|
145
|
+
const clearancePx = beam.getBeamYToDraw() - headBottom;
|
|
146
|
+
options.assert.ok(Number.isFinite(clearancePx), 'Measured clearance from head to horizontal beam');
|
|
147
|
+
document.getElementById(options.elementId).dataset.measurement = JSON.stringify({ clearancePx });
|
|
148
|
+
});
|
|
149
|
+
VF.Test.runTests('Sloped beam after narrowing a retained system', (options) => {
|
|
150
|
+
const factory = VF.Test.makeFactory(options, 540, 140);
|
|
151
|
+
const score = factory.EasyScore();
|
|
152
|
+
const notes = score.notes('A4/8, B4, C4, D4', { stem: 'up' });
|
|
153
|
+
const beam = factory.Beam({ notes });
|
|
154
|
+
const system = factory.System({ x: 10, y: 0, width: 520 });
|
|
155
|
+
system.addStave({ voices: [score.voice(notes, { mode: 'soft' })] });
|
|
156
|
+
factory.draw({ retain: true });
|
|
157
|
+
factory.getContext().clear();
|
|
158
|
+
system.setWidth(300);
|
|
159
|
+
factory.draw({ retain: true });
|
|
160
|
+
const stemTipErrorsPx = notes.map((note) => {
|
|
161
|
+
const beamY = beam.getBeamYToDraw() + beam.slope * (note.getStemX() - notes[0].getStemX());
|
|
162
|
+
return note.getStemExtents().topY - beamY;
|
|
163
|
+
});
|
|
164
|
+
options.assert.ok(stemTipErrorsPx.every(Number.isFinite), 'Measured each stem tip against the refitted line');
|
|
165
|
+
document.getElementById(options.elementId).dataset.measurement = JSON.stringify({ stemTipErrorsPx });
|
|
166
|
+
});
|
|
167
|
+
QUnit.module('M2 studies');
|
|
168
|
+
VF.Test.runTests('Four close voices and an unequal onset', (options) => {
|
|
169
|
+
const factory = VF.Test.makeFactory(options, 420, 155);
|
|
170
|
+
const score = factory.EasyScore();
|
|
171
|
+
const voices = ['F5/q, G5/q', 'E5/8, C5/8, D5/q', 'D5/q, E5/q', 'C5/q, B4/q'].map((input, i) => score.voice(score.notes(input, { stem: i % 2 ? 'down' : 'up' }), { mode: 'soft' }));
|
|
172
|
+
factory.System({ width: 390 }).addStave({ voices }).addClef('treble');
|
|
173
|
+
factory.draw();
|
|
174
|
+
const x = voices.map((v) => v.getTickables()[0].getNoteHeadBeginX());
|
|
175
|
+
options.assert.ok(x.every(Number.isFinite), 'Every voice has a head position');
|
|
176
|
+
document.getElementById(options.elementId).dataset.measurement = JSON.stringify({ x });
|
|
177
|
+
});
|
|
178
|
+
VF.Test.runTests('Beam contour and staff contact', (options) => {
|
|
179
|
+
const factory = VF.Test.makeFactory(options, 550, 265);
|
|
180
|
+
const score = factory.EasyScore();
|
|
181
|
+
const beams = [];
|
|
182
|
+
for (const [width, y] of [
|
|
183
|
+
[300, 10],
|
|
184
|
+
[520, 135],
|
|
185
|
+
]) {
|
|
186
|
+
const notes = score.notes('G4/8, A4, B4, C4, E4, E4, F4, F4', { stem: 'up' });
|
|
187
|
+
factory
|
|
188
|
+
.System({ width, y })
|
|
189
|
+
.addStave({ voices: [score.voice(notes)] })
|
|
190
|
+
.addClef('treble');
|
|
191
|
+
for (const group of [notes.slice(0, 4), notes.slice(4, 6), notes.slice(6)]) {
|
|
192
|
+
const beam = factory.Beam({ notes: group });
|
|
193
|
+
beam.renderOptions.contourSlope = true;
|
|
194
|
+
beams.push(beam);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
factory.draw();
|
|
198
|
+
const slopes = beams.map((beam) => beam.slope);
|
|
199
|
+
options.assert.ok(slopes.every(Number.isFinite), 'Every beam has a finite slope');
|
|
200
|
+
document.getElementById(options.elementId).dataset.measurement = JSON.stringify({ slopes });
|
|
201
|
+
});
|
|
202
|
+
VF.Test.runTests('Long fall and delayed turn after redraw', (options) => {
|
|
203
|
+
const factory = VF.Test.makeFactory(options, 440, 175);
|
|
204
|
+
const score = factory.EasyScore();
|
|
205
|
+
const notes = score.notes('G4/q, A4/q, B4/h');
|
|
206
|
+
notes[0].addModifier(new VF.Ornament('fallLong'), 0);
|
|
207
|
+
notes[1].addModifier(new VF.Ornament('turn').setDelayed(true).setUpperAccidental('#'), 0);
|
|
208
|
+
const system = factory.System({ width: 410, y: 20 });
|
|
209
|
+
system.addStave({ voices: [score.voice(notes)] }).addClef('treble');
|
|
210
|
+
factory.draw({ retain: true });
|
|
211
|
+
factory.getContext().clear();
|
|
212
|
+
system.setWidth(320);
|
|
213
|
+
factory.draw({ retain: true });
|
|
214
|
+
options.assert.ok(notes.every((n) => n.isRendered()), 'Retained notes rendered');
|
|
215
|
+
});
|
|
216
|
+
VF.Test.runTests('Grace groups on both sides of a host', (options) => {
|
|
217
|
+
const f = VF.Test.makeFactory(options, 515, 135), es = f.EasyScore();
|
|
218
|
+
const notes = es.notes('E5/q, F5/q, G5/h');
|
|
219
|
+
for (const [side, keys] of [
|
|
220
|
+
[VF.Modifier.Position.LEFT, ['d/5']],
|
|
221
|
+
[VF.Modifier.Position.RIGHT, ['g/5', 'f/5']],
|
|
222
|
+
]) {
|
|
223
|
+
const group = f
|
|
224
|
+
.GraceNoteGroup({
|
|
225
|
+
notes: keys.map((key) => f.GraceNote({ keys: [key], duration: '16', slash: true })),
|
|
226
|
+
slur: true,
|
|
227
|
+
})
|
|
228
|
+
.setPosition(side);
|
|
229
|
+
if (keys.length > 1)
|
|
230
|
+
group.beamNotes();
|
|
231
|
+
notes[0].addModifier(group, 0);
|
|
232
|
+
}
|
|
233
|
+
f.System({ width: 490 })
|
|
234
|
+
.addStave({ voices: [es.voice(notes)] })
|
|
235
|
+
.addClef('treble');
|
|
236
|
+
f.draw();
|
|
237
|
+
options.assert.equal(notes[0].getModifiers().length, 2, 'Both grace groups remain attached to the first note');
|
|
238
|
+
});
|
|
239
|
+
VF.Test.runTests('Tuplet over a turn with auxiliary signs', (options) => {
|
|
240
|
+
const f = VF.Test.makeFactory(options, 515, 170), es = f.EasyScore();
|
|
241
|
+
const notes = es.notes('G4/8, A4/8, B4/8, C5/q');
|
|
242
|
+
notes[1].addModifier(new VF.Ornament('turn').setPosition(VF.Modifier.Position.ABOVE).setUpperAccidental('#').setLowerAccidental('b'), 0);
|
|
243
|
+
const tuplet = f.Tuplet({ notes: notes.slice(0, 3), options: { bracketed: true } });
|
|
244
|
+
f.System({ width: 490, y: 60 })
|
|
245
|
+
.addStave({ voices: [es.voice(notes, { mode: 'soft' })] })
|
|
246
|
+
.addClef('treble');
|
|
247
|
+
f.draw();
|
|
248
|
+
options.assert.ok(Number.isFinite(tuplet.getYPosition()), 'Bracket has a resolved staff position');
|
|
249
|
+
});
|
|
250
|
+
VF.Test.runTests('Measured spacing with a short final attack', (options) => {
|
|
251
|
+
var _a, _b;
|
|
252
|
+
const f = VF.Test.makeFactory(options, 515, 160), es = f.EasyScore();
|
|
253
|
+
const notes = es.notes('E4/h, A4/q, F#4/8, G4/16, A4/32, B4/64, C5/64');
|
|
254
|
+
const group = f
|
|
255
|
+
.GraceNoteGroup({ notes: ['f/4', 'g/4'].map((key) => f.GraceNote({ keys: [key], duration: '16' })) })
|
|
256
|
+
.beamNotes();
|
|
257
|
+
notes[1].addModifier(group, 0);
|
|
258
|
+
notes[2].addModifier(new VF.ChordSymbol().addText('Dmaj7'), 0);
|
|
259
|
+
const details = { spacing: { mode: 'optical' } };
|
|
260
|
+
try {
|
|
261
|
+
new VF.Formatter(details);
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
if (error.code !== 'BadArgument')
|
|
265
|
+
throw error;
|
|
266
|
+
delete details.spacing;
|
|
267
|
+
}
|
|
268
|
+
f.System({ width: 490, y: 20, details })
|
|
269
|
+
.addStave({ voices: [es.voice(notes)] })
|
|
270
|
+
.addClef('treble');
|
|
271
|
+
f.draw();
|
|
272
|
+
const x = notes.map((n) => n.getNoteHeadBeginX());
|
|
273
|
+
options.assert.ok(x.every((value, i) => !i || value > x[i - 1]), 'Each successive attack advances');
|
|
274
|
+
document.getElementById(options.elementId).dataset.measurement = JSON.stringify({
|
|
275
|
+
mode: (_b = (_a = details.spacing) === null || _a === void 0 ? void 0 : _a.mode) !== null && _b !== void 0 ? _b : 'default',
|
|
276
|
+
x,
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
QUnit.module('M3 studies');
|
|
280
|
+
for (const [kind, name] of [
|
|
281
|
+
['choir', 'Two verses over a skipped attack'],
|
|
282
|
+
['piano', 'Slur, crescendo, ottava and pedal'],
|
|
283
|
+
]) {
|
|
284
|
+
VF.Test.runTests(name, (options) => {
|
|
285
|
+
var _a, _b;
|
|
286
|
+
const f = VF.Test.makeFactory(options, 670, 330);
|
|
287
|
+
const { layout } = globalThis.makePhraseStudy(VF, f, kind);
|
|
288
|
+
f.draw();
|
|
289
|
+
const diagnostics = (_a = layout === null || layout === void 0 ? void 0 : layout.diagnostics) !== null && _a !== void 0 ? _a : [];
|
|
290
|
+
options.assert.deepEqual(diagnostics, [], 'No unresolved phrase collisions');
|
|
291
|
+
document.getElementById(options.elementId).dataset.measurement = JSON.stringify({
|
|
292
|
+
diagnostics,
|
|
293
|
+
passes: (_b = layout === null || layout === void 0 ? void 0 : layout.passes) !== null && _b !== void 0 ? _b : 0,
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
QUnit.module('M4 studies');
|
|
298
|
+
for (const [kind, width, height, mode, name] of [
|
|
299
|
+
['choir', 740, 220, 'balanced', 'Vocal phrase on a wide system'],
|
|
300
|
+
['choir', 260, 540, 'balanced', 'Vocal phrase across narrow systems'],
|
|
301
|
+
['keyboard', 490, 640, 'balanced', 'Grand staff with beam, wedge and pedal'],
|
|
302
|
+
['chord', 375, 300, 'balanced', 'Split chord and arpeggio on two staves'],
|
|
303
|
+
['ensemble', 430, 510, 'balanced', 'Silent and returning ensemble staves'],
|
|
304
|
+
['breaks', 415, 305, 'greedy', 'Greedy breaks on a short melody'],
|
|
305
|
+
['breaks', 415, 305, 'balanced', 'Balanced breaks on the same melody'],
|
|
306
|
+
]) {
|
|
307
|
+
VF.Test.runTests(name, (options) => {
|
|
308
|
+
var _a, _b, _c;
|
|
309
|
+
const f = VF.Test.makeFactory(options, width + 32, height);
|
|
310
|
+
const c = globalThis.makeContinuousStudy(VF, f, kind, width, mode);
|
|
311
|
+
f.draw();
|
|
312
|
+
const layout = (_b = (_a = c.sheet).getContinuousLayout) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
313
|
+
options.assert.ok(c.sheet.getRows().length > 0, 'At least one formatted row');
|
|
314
|
+
document.getElementById(options.elementId).dataset.measurement = JSON.stringify({
|
|
315
|
+
rows: c.sheet.getRows().map((r) => [r.systems.length, r.width, r.height]),
|
|
316
|
+
spans: (_c = layout === null || layout === void 0 ? void 0 : layout.fragments.map((f) => [f.id, f.part, f.x1, f.y1, f.x2, f.y2])) !== null && _c !== void 0 ? _c : [],
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
QUnit.module('M5 studies');
|
|
321
|
+
for (const paper of ['A4', 'Letter'])
|
|
322
|
+
for (const part of [false, true]) {
|
|
323
|
+
VF.Test.runTests((part ? 'Cello part' : 'Chamber score') + ' on ' + paper, (test) => {
|
|
324
|
+
const root = document.getElementById(test.elementId);
|
|
325
|
+
const { source, options } = globalThis.publicationStudy(part, paper);
|
|
326
|
+
if (VF.Publication) {
|
|
327
|
+
const result = new VF.Publication(source).render(root, options);
|
|
328
|
+
test.assert.deepEqual(result.diagnostics, [], 'No engraving or page overflow');
|
|
329
|
+
root.style.cssText = 'display:flex;align-items:flex-start;gap:5px;background:white;width:max-content';
|
|
330
|
+
for (const page of result.pages)
|
|
331
|
+
page.svg.style.cssText = 'width:300px;height:auto;border:1px solid #aaa';
|
|
332
|
+
root.dataset.measurement = JSON.stringify({ pages: result.pages.map((p) => p.systems) });
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
const factory = VF.Test.makeFactory(test, 950, part ? 350 : 600);
|
|
336
|
+
if (part) {
|
|
337
|
+
source.staves = source.staves.filter((s) => s.id === 'vc');
|
|
338
|
+
source.continuous.groups = [];
|
|
339
|
+
source.continuous.spans = source.continuous.spans.filter((s) => s.id === 'cello-swell');
|
|
340
|
+
}
|
|
341
|
+
source.sheet = { width: 925, x: 10, y: 5 };
|
|
342
|
+
factory.EasyScore().compose(source);
|
|
343
|
+
factory.draw();
|
|
344
|
+
test.assert.ok(root.querySelector('svg'), 'Continuous reference rendered');
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
QUnit.module('M6 studies');
|
|
349
|
+
for (const [kind, name] of Object.entries({
|
|
350
|
+
kit: 'Kit groove and instrument legend',
|
|
351
|
+
line: 'One-line side drum',
|
|
352
|
+
lead: 'Harbor song over a repeated turnaround',
|
|
353
|
+
guitar: 'Drop D with a second-fret capo',
|
|
354
|
+
techniques: 'Alternating chords and playing instructions',
|
|
355
|
+
micro: 'Quarter tones and Persian accidentals',
|
|
356
|
+
spelling: 'Clarinet pickup across the bar',
|
|
357
|
+
meter: 'Three against two and a cadenza',
|
|
358
|
+
})) {
|
|
359
|
+
VF.Test.runTests(name, (test) => {
|
|
360
|
+
const factory = VF.Test.makeFactory(test, 710, { kit: 305, line: 152, lead: 345, guitar: 303, techniques: 307, micro: 280, spelling: 166, meter: 556 }[kind]);
|
|
361
|
+
const { notes } = globalThis.makeInstrumentStudy(VF, factory, kind);
|
|
362
|
+
const attacks = notes.map((n) => [n.getNoteHeadBeginX(), n.getTicks().value()]);
|
|
363
|
+
test.assert.ok(attacks.length && attacks.flat().every(Number.isFinite), 'Every attack has a position and duration');
|
|
364
|
+
document.getElementById(test.elementId).dataset.measurement = JSON.stringify({ attacks });
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
@@ -395,7 +395,16 @@ function alignedMixedElements(options) {
|
|
|
395
395
|
stave2.setContext(context).drawWithStyle();
|
|
396
396
|
tuplet.setContext(context).drawWithStyle();
|
|
397
397
|
tuplet2.setContext(context).drawWithStyle();
|
|
398
|
-
|
|
398
|
+
const outerText = (note) => note
|
|
399
|
+
.getModifiers()
|
|
400
|
+
.find((m) => m.getText() === 'ttt')
|
|
401
|
+
.getBoundingBox();
|
|
402
|
+
const below = outerText(notes[0]);
|
|
403
|
+
const lowerGap = tuplet.getYPosition() - (below.getY() + below.getH());
|
|
404
|
+
const upperGap = outerText(notes2[1]).getY() - tuplet2.getYPosition();
|
|
405
|
+
const space = stave.getSpacingBetweenLines();
|
|
406
|
+
options.assert.ok(lowerGap >= space && lowerGap < 2 * space, 'Lower bracket clears the text');
|
|
407
|
+
options.assert.ok(Math.abs(upperGap - lowerGap) <= space / 2, 'Both brackets have comparable clearance');
|
|
399
408
|
}
|
|
400
409
|
function justifyStaveNotes(options) {
|
|
401
410
|
const f = VexFlowTests.makeFactory(options, 520, 280);
|
package/build/esm/tests/index.js
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { isExcepted } from '../../tools/audit-dependencies.mjs';
|
|
4
|
+
function fixture() {
|
|
5
|
+
const report = {
|
|
6
|
+
auditReportVersion: 2,
|
|
7
|
+
metadata: { vulnerabilities: { total: 2 } },
|
|
8
|
+
vulnerabilities: {
|
|
9
|
+
tool: { nodes: ['node_modules/tool'], via: ['picomatch'] },
|
|
10
|
+
picomatch: {
|
|
11
|
+
nodes: ['node_modules/picomatch'],
|
|
12
|
+
via: [{ url: 'https://github.com/advisories/GHSA-fc5q-39xc-vjpf' }],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
const packages = {
|
|
17
|
+
'node_modules/tool': { dev: true },
|
|
18
|
+
'node_modules/picomatch': { dev: true, version: '4.0.5' },
|
|
19
|
+
};
|
|
20
|
+
return { report, packages };
|
|
21
|
+
}
|
|
22
|
+
const reviewDate = Date.UTC(2026, 10, 18);
|
|
23
|
+
test('accepts the reviewed advisory and its inherited findings only during the review period', () => {
|
|
24
|
+
const { report, packages } = fixture();
|
|
25
|
+
assert.ok(isExcepted(report, packages, reviewDate));
|
|
26
|
+
assert.equal(isExcepted(report, packages, Date.UTC(2026, 11, 18)), false);
|
|
27
|
+
});
|
|
28
|
+
test('rejects changes in scope, new advisories, and incomplete audit results', () => {
|
|
29
|
+
for (const change of [
|
|
30
|
+
({ packages }) => delete packages['node_modules/picomatch'].dev,
|
|
31
|
+
({ packages }) => (packages['node_modules/picomatch'].version = '4.0.6'),
|
|
32
|
+
({ report }) => (report.vulnerabilities.picomatch.fixAvailable = true),
|
|
33
|
+
({ report }) => report.vulnerabilities.picomatch.via.push({ url: 'another advisory' }),
|
|
34
|
+
({ report }) => report.vulnerabilities.tool.via.push({ url: 'another advisory' }),
|
|
35
|
+
({ report }) => (report.vulnerabilities.tool.via = ['missing']),
|
|
36
|
+
({ report }) => (report.error = { summary: 'audit unavailable' }),
|
|
37
|
+
]) {
|
|
38
|
+
const data = fixture();
|
|
39
|
+
change(data);
|
|
40
|
+
assert.equal(isExcepted(data.report, data.packages, reviewDate), false);
|
|
41
|
+
}
|
|
42
|
+
});
|