vexflow 5.0.0 → 5.1.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.
Files changed (127) hide show
  1. package/LICENSE +3 -3
  2. package/README.md +32 -50
  3. package/build/cjs/vexflow-bravura.js +2 -2
  4. package/build/cjs/vexflow-bravura.js.map +1 -1
  5. package/build/cjs/vexflow-core.js +2 -2
  6. package/build/cjs/vexflow-core.js.map +1 -1
  7. package/build/cjs/vexflow-debug-with-tests.js +3685 -1386
  8. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  9. package/build/cjs/vexflow-debug.js +2443 -980
  10. package/build/cjs/vexflow-debug.js.map +1 -1
  11. package/build/cjs/vexflow.js +2 -2
  12. package/build/cjs/vexflow.js.map +1 -1
  13. package/build/esm/src/accidental.js +1 -0
  14. package/build/esm/src/annotation.js +31 -8
  15. package/build/esm/src/beam.js +4 -2
  16. package/build/esm/src/chordsymbol.js +3 -1
  17. package/build/esm/src/clef.js +3 -1
  18. package/build/esm/src/curve.js +68 -11
  19. package/build/esm/src/easyscore.js +40 -1
  20. package/build/esm/src/element.js +42 -9
  21. package/build/esm/src/factory.js +46 -9
  22. package/build/esm/src/flag.js +3 -1
  23. package/build/esm/src/font.js +17 -0
  24. package/build/esm/src/formatter.js +34 -36
  25. package/build/esm/src/fraction.js +4 -1
  26. package/build/esm/src/glyphnote.js +3 -1
  27. package/build/esm/src/gracenotegroup.js +18 -1
  28. package/build/esm/src/index.js +2 -0
  29. package/build/esm/src/keysignature.js +3 -1
  30. package/build/esm/src/metrics.js +55 -1
  31. package/build/esm/src/modifiercontext.js +15 -1
  32. package/build/esm/src/note.js +2 -2
  33. package/build/esm/src/notehead.js +3 -1
  34. package/build/esm/src/ornament.js +3 -1
  35. package/build/esm/src/pedalmarking.js +44 -5
  36. package/build/esm/src/registry.js +16 -6
  37. package/build/esm/src/rendercontext.js +10 -0
  38. package/build/esm/src/sheet.js +117 -0
  39. package/build/esm/src/stave.js +13 -8
  40. package/build/esm/src/stavebarline.js +53 -1
  41. package/build/esm/src/staveline.js +2 -0
  42. package/build/esm/src/stavenote.js +54 -19
  43. package/build/esm/src/stavetie.js +3 -1
  44. package/build/esm/src/stem.js +2 -1
  45. package/build/esm/src/stemmablenote.js +9 -0
  46. package/build/esm/src/stringnumber.js +0 -1
  47. package/build/esm/src/strokes.js +10 -0
  48. package/build/esm/src/svgcontext.js +14 -4
  49. package/build/esm/src/svgexport.js +68 -0
  50. package/build/esm/src/system.js +14 -0
  51. package/build/esm/src/tables.js +69 -37
  52. package/build/esm/src/tabnote.js +20 -1
  53. package/build/esm/src/textbracket.js +5 -4
  54. package/build/esm/src/textdynamics.js +5 -0
  55. package/build/esm/src/textnote.js +3 -3
  56. package/build/esm/src/tickable.js +56 -22
  57. package/build/esm/src/timesignature.js +30 -9
  58. package/build/esm/src/timesignote.js +3 -1
  59. package/build/esm/src/tuning.js +2 -2
  60. package/build/esm/src/tuplet.js +79 -29
  61. package/build/esm/src/util.js +1 -0
  62. package/build/esm/src/version.js +3 -3
  63. package/build/esm/src/vexflow.js +14 -2
  64. package/build/esm/src/voice.js +44 -8
  65. package/build/esm/tests/accidental_tests.js +52 -0
  66. package/build/esm/tests/annotation_tests.js +38 -0
  67. package/build/esm/tests/articulation_tests.js +34 -0
  68. package/build/esm/tests/beam_tests.js +17 -0
  69. package/build/esm/tests/curve_tests.js +81 -0
  70. package/build/esm/tests/font_tests.js +32 -1
  71. package/build/esm/tests/formatter_tests.js +58 -23
  72. package/build/esm/tests/gracenote_tests.js +58 -0
  73. package/build/esm/tests/gracetabnote_tests.js +40 -0
  74. package/build/esm/tests/keysignature_tests.js +14 -3
  75. package/build/esm/tests/node/package-input-tests.mjs +149 -0
  76. package/build/esm/tests/node/render-metrics-tests.mjs +78 -0
  77. package/build/esm/tests/node/rendering-tests.mjs +75 -0
  78. package/build/esm/tests/node/sheet-tests.mjs +202 -0
  79. package/build/esm/tests/node/svg-export-tests.mjs +182 -0
  80. package/build/esm/tests/pedalmarking_tests.js +25 -0
  81. package/build/esm/tests/rests_tests.js +6 -0
  82. package/build/esm/tests/stave_tests.js +6 -3
  83. package/build/esm/tests/stavenote_tests.js +100 -55
  84. package/build/esm/tests/strokes_tests.js +19 -5
  85. package/build/esm/tests/timesignature_tests.js +19 -0
  86. package/build/esm/tests/tuplet_tests.js +273 -12
  87. package/build/esm/tests/unison_tests.js +13 -13
  88. package/build/esm/tests/voice_tests.js +34 -0
  89. package/build/esm/tools/render-metrics.mjs +49 -0
  90. package/build/esm/tools/score-fixtures.mjs +94 -0
  91. package/build/esm/tools/sheet-fixture.mjs +90 -0
  92. package/build/esm/tools/visual-regression.mjs +106 -0
  93. package/build/types/src/annotation.d.ts +17 -1
  94. package/build/types/src/curve.d.ts +24 -7
  95. package/build/types/src/easyscore.d.ts +8 -0
  96. package/build/types/src/element.d.ts +5 -0
  97. package/build/types/src/factory.d.ts +18 -1
  98. package/build/types/src/font.d.ts +2 -0
  99. package/build/types/src/formatter.d.ts +23 -14
  100. package/build/types/src/gracenotegroup.d.ts +5 -0
  101. package/build/types/src/index.d.ts +2 -0
  102. package/build/types/src/metrics.d.ts +2 -0
  103. package/build/types/src/modifiercontext.d.ts +4 -0
  104. package/build/types/src/pedalmarking.d.ts +4 -1
  105. package/build/types/src/registry.d.ts +2 -0
  106. package/build/types/src/rendercontext.d.ts +12 -0
  107. package/build/types/src/sheet.d.ts +49 -0
  108. package/build/types/src/stave.d.ts +4 -4
  109. package/build/types/src/stavebarline.d.ts +10 -0
  110. package/build/types/src/stavenote.d.ts +11 -0
  111. package/build/types/src/strokes.d.ts +4 -0
  112. package/build/types/src/svgcontext.d.ts +5 -0
  113. package/build/types/src/svgexport.d.ts +22 -0
  114. package/build/types/src/system.d.ts +4 -0
  115. package/build/types/src/tables.d.ts +9 -0
  116. package/build/types/src/tabnote.d.ts +4 -0
  117. package/build/types/src/textbracket.d.ts +1 -1
  118. package/build/types/src/textdynamics.d.ts +3 -0
  119. package/build/types/src/tickable.d.ts +27 -10
  120. package/build/types/src/timesignature.d.ts +4 -0
  121. package/build/types/src/tuplet.d.ts +8 -0
  122. package/build/types/src/util.d.ts +1 -0
  123. package/build/types/src/vexflow.d.ts +8 -1
  124. package/build/types/src/voice.d.ts +6 -0
  125. package/changelog/CHANGELOG.md +94 -0
  126. package/package.json +42 -26
  127. package/tests/flow.html +15 -7
@@ -1,6 +1,6 @@
1
1
  import { BoundingBox, Bounds } from './boundingbox';
2
2
  import { Element, ElementStyle } from './element';
3
- import { BarlineType } from './stavebarline';
3
+ import { BarlineType, RepeatBracketType } from './stavebarline';
4
4
  import { StaveModifier } from './stavemodifier';
5
5
  import { StaveTempoOptions } from './stavetempo';
6
6
  export interface StaveLineConfig {
@@ -88,8 +88,8 @@ export declare class Stave extends Element {
88
88
  getYForGlyphs(): number;
89
89
  addModifier(modifier: StaveModifier, position?: number): this;
90
90
  addEndModifier(modifier: StaveModifier): this;
91
- setBegBarType(type: number | BarlineType): this;
92
- setEndBarType(type: number | BarlineType): this;
91
+ setBegBarType(type: number | BarlineType, repeatBracket?: RepeatBracketType): this;
92
+ setEndBarType(type: number | BarlineType, repeatBracket?: RepeatBracketType): this;
93
93
  setClef(clefSpec: string, size?: string, annotation?: string, position?: number): this;
94
94
  getClef(): string;
95
95
  setEndClef(clefSpec: string, size?: string, annotation?: string): this;
@@ -103,7 +103,7 @@ export declare class Stave extends Element {
103
103
  *
104
104
  * Example:
105
105
  * `stave.addKeySignature('Db');`
106
- * @param keySpec new key specification `[A-G][b|#]?`
106
+ * @param keySpec new key specification `[A-G][b|#]?` or `[flats|sharps]_[0-14]?`
107
107
  * @param cancelKeySpec
108
108
  * @param position
109
109
  * @returns
@@ -9,20 +9,30 @@ export declare enum BarlineType {
9
9
  REPEAT_BOTH = 6,
10
10
  NONE = 7
11
11
  }
12
+ export declare enum RepeatBracketType {
13
+ NONE = 0,
14
+ STRAIGHT = 1,
15
+ CURVED = 2
16
+ }
12
17
  export declare class Barline extends StaveModifier {
13
18
  static get CATEGORY(): string;
14
19
  protected widths: Record<string, number>;
15
20
  protected paddings: Record<string, number>;
16
21
  protected layoutMetricsMap: Record<number, LayoutMetrics>;
22
+ protected repeatBrackets: RepeatBracketType;
17
23
  protected thickness: number;
18
24
  protected type: BarlineType;
19
25
  static get type(): typeof BarlineType;
20
26
  static get typeString(): Record<string, BarlineType>;
21
27
  constructor(type: BarlineType | string);
28
+ setRepeatBracket(val: RepeatBracketType): void;
29
+ getRepeatBrackets(): RepeatBracketType;
22
30
  getType(): number;
23
31
  setType(type: string | number): this;
24
32
  draw(): void;
25
33
  drawVerticalBar(stave: Stave, x: number, doubleBar?: boolean): void;
26
34
  drawVerticalEndBar(stave: Stave, x: number): void;
35
+ drawStraightBrackets(stave: Stave, startX: number, startY: number, yDirection: number, xDirection: number): void;
36
+ drawCurvedBrackets(stave: Stave, startX: number, startY: number, yDirection: number, xDirection: number): void;
27
37
  drawRepeatBar(stave: Stave, x: number, begin: boolean): void;
28
38
  }
@@ -119,6 +119,15 @@ export declare class StaveNote extends StemmableNote {
119
119
  * @property {number} highestNonDisplacedLine
120
120
  * @property {number} lowestNonDisplacedLine
121
121
  */
122
+ /**
123
+ * Get Y bounds for the stem, adjusted for SMuFL stem anchor offsets defined in
124
+ * Tables.noteHeadStemYOffsets. This ensures stems attach at the correct point
125
+ * on the notehead (e.g. the arm tip of an X notehead) rather than the center.
126
+ */
127
+ protected getStemYBounds(): {
128
+ yTop: number;
129
+ yBottom: number;
130
+ };
122
131
  /**
123
132
  * Get the staff line and y value for the highest & lowest noteheads
124
133
  * @returns {noteHeadBounds}
@@ -130,6 +139,8 @@ export declare class StaveNote extends StemmableNote {
130
139
  drawLedgerLines(): void;
131
140
  drawModifiers(noteheadParam: NoteHead): void;
132
141
  shouldDrawFlag(): boolean;
142
+ /** Share flag coordinates between measurement and drawing. */
143
+ private getFlagPosition;
133
144
  drawFlag(): void;
134
145
  drawNoteHeads(): void;
135
146
  drawStem(stemOptions?: StemOptions): void;
@@ -1,3 +1,4 @@
1
+ import { BoundingBox } from './boundingbox';
1
2
  import { Modifier } from './modifier';
2
3
  import { ModifierContextState } from './modifiercontext';
3
4
  import { Note } from './note';
@@ -22,10 +23,13 @@ export declare class Stroke extends Modifier {
22
23
  renderOptions: {
23
24
  fontScale: number;
24
25
  };
26
+ protected boundingBox: BoundingBox;
25
27
  constructor(type: number, options?: {
26
28
  allVoices: boolean;
27
29
  });
28
30
  getPosition(): number;
29
31
  addEndNote(note: Note): this;
30
32
  draw(): void;
33
+ /** Get the boundingBox. */
34
+ getBoundingBox(): BoundingBox;
31
35
  }
@@ -1,6 +1,7 @@
1
1
  import { Element } from './element';
2
2
  import { FontInfo } from './font';
3
3
  import { RenderContext, TextMeasure } from './rendercontext';
4
+ import { SVGFont } from './svgexport';
4
5
  export type Attributes = {
5
6
  [name: string]: string | number | undefined;
6
7
  'font-family'?: string;
@@ -19,6 +20,10 @@ export interface State {
19
20
  */
20
21
  export declare class SVGContext extends RenderContext {
21
22
  protected static measureTextElement: Element;
23
+ /** Serialize a drawing. Supplying fonts converts all text to portable paths. */
24
+ static toSVG(svg: SVGSVGElement, fonts?: SVGFont[]): string;
25
+ /** Export without modifying the live drawing. See docs/portable-svg.md for font setup. */
26
+ toSVG(fonts?: SVGFont[]): string;
22
27
  element: HTMLElement;
23
28
  svg: SVGSVGElement;
24
29
  width: number;
@@ -0,0 +1,22 @@
1
+ /** The small part of an opentype.js Font needed for portable SVG export. */
2
+ export interface SVGOutlineFont {
3
+ charToGlyphIndex(character: string): number;
4
+ getAdvanceWidth(text: string, size: number): number;
5
+ getPath(text: string, x: number, y: number, size: number): {
6
+ toPathData(decimalPlaces: number): string;
7
+ };
8
+ }
9
+ /** A loaded font face. Supply the same fonts used to lay out the score. */
10
+ export interface SVGFont {
11
+ family: string;
12
+ font: SVGOutlineFont;
13
+ /** Defaults to normal. Supply a separate face for bold text. */
14
+ weight?: string | number;
15
+ /** Defaults to normal. Supply a separate face for italic text. */
16
+ style?: string;
17
+ }
18
+ /**
19
+ * Clone a VexFlow SVG and replace all text with paths. Fail if any glyph is missing.
20
+ * This accepts SVGs produced by SVGContext, not arbitrary SVG text layouts or CSS.
21
+ */
22
+ export declare function svgWithFontPaths(svg: SVGSVGElement, fonts: SVGFont[]): SVGSVGElement;
@@ -85,6 +85,10 @@ export declare class System extends Element {
85
85
  getStaves(): Stave[];
86
86
  /** Get associated voices. */
87
87
  getVoices(): Voice[];
88
+ /** Set a fixed layout width, or request the minimum width when omitted. */
89
+ setWidth(width?: number): this;
90
+ /** Width assigned by the latest layout. */
91
+ getWidth(): number;
88
92
  /** Set associated context. */
89
93
  setContext(context: RenderContext): this;
90
94
  /**
@@ -14,6 +14,15 @@ export declare class Tables {
14
14
  static TABLATURE_FONT_SCALE: number;
15
15
  static SLASH_NOTEHEAD_WIDTH: number;
16
16
  static STAVE_LINE_DISTANCE: number;
17
+ /**
18
+ * SMuFL stem anchor Y offsets for noteheads, in staff spaces (positive = above notehead center).
19
+ * Sourced from Bravura metadata `glyphsWithAnchors`: `stemUpSE[1]` (up) and `stemDownNW[1]` (down).
20
+ * Used to position the stem base at the correct SMuFL attachment point rather than the notehead center.
21
+ */
22
+ static readonly noteHeadStemYOffsets: Record<string, {
23
+ up: number;
24
+ down: number;
25
+ }>;
17
26
  static TEXT_HEIGHT_OFFSET_HACK: number;
18
27
  static clefProperties(clef: string): {
19
28
  lineShift: number;
@@ -14,6 +14,8 @@ export declare class TabNote extends StemmableNote {
14
14
  protected ghost: boolean;
15
15
  protected fretElement: Element[];
16
16
  protected positions: TabNotePosition[];
17
+ /** Explicit fret size; otherwise use text metrics and this note's grace scale. */
18
+ protected fretFontSize?: string | number;
17
19
  constructor(noteStruct: TabNoteStruct, drawStem?: boolean);
18
20
  greatestString: () => number;
19
21
  leastString: () => number;
@@ -22,6 +24,8 @@ export declare class TabNote extends StemmableNote {
22
24
  hasStem(): boolean;
23
25
  getStemExtension(): number;
24
26
  static tabToElement(fret: string): Element;
27
+ /** Resize fret text as well as the parent. Set sizes before formatting the voice. */
28
+ setFontSize(size?: string | number): this;
25
29
  updateWidth(): void;
26
30
  setStave(stave: Stave): this;
27
31
  getPositions(): TabNotePosition[];
@@ -17,7 +17,7 @@ export declare class TextBracket extends Element {
17
17
  static get CATEGORY(): string;
18
18
  renderOptions: {
19
19
  dashed: boolean;
20
- color: string;
20
+ color?: string;
21
21
  lineWidth: number;
22
22
  underlineSuperscript: boolean;
23
23
  showBracket: boolean;
@@ -1,3 +1,4 @@
1
+ import { BoundingBox } from './boundingbox';
1
2
  import { Note } from './note';
2
3
  import { TextNoteStruct } from './textnote';
3
4
  /**
@@ -29,6 +30,8 @@ export declare class TextDynamics extends Note {
29
30
  setLine(line: number): this;
30
31
  /** Preformat the dynamics text. */
31
32
  preFormat(): this;
33
+ /** Measure at the same page coordinates used by draw(), after voice formatting. */
34
+ getBoundingBox(): BoundingBox;
32
35
  /** Draw the dynamics text on the rendering context. */
33
36
  draw(): void;
34
37
  }
@@ -28,7 +28,6 @@ export declare abstract class Tickable extends Element {
28
28
  static get CATEGORY(): string;
29
29
  protected ignoreTicks: boolean;
30
30
  protected tupletStack: Tuplet[];
31
- protected tuplet?: Tuplet;
32
31
  protected ticks: Fraction;
33
32
  protected centerXShift: number;
34
33
  protected voice?: Voice;
@@ -69,18 +68,36 @@ export declare abstract class Tickable extends Element {
69
68
  getVoice(): Voice;
70
69
  /** Set the associated voice. */
71
70
  setVoice(voice: Voice): void;
72
- /** Get the tuplet. */
71
+ /** Get the Tuplet if any.
72
+ * If there are multiple Tuplets, the most recently added one is returned. */
73
73
  getTuplet(): Tuplet | undefined;
74
- /** Return a list of Tuplets. */
75
- getTupletStack(): Tuplet[];
74
+ /** Return a readonly array of Tuplets (might be empty). */
75
+ getTupletStack(): readonly Tuplet[];
76
76
  /**
77
+ * Remove the given tuplet; raises an Error if the tuplet is not in the TupletStack.
78
+ */
79
+ removeTuplet(tuplet: Tuplet): this;
80
+ /**
81
+ * Remove all tuplets from the tickable.
82
+ */
83
+ clearTuplets(): this;
84
+ /**
85
+ * Deprecated, to be removed in v6. Use `removeTuplet(tuplet)` or `clearTuplets()` instead.
77
86
  * Reset the specific Tuplet (if this is not provided, all tuplets are reset).
78
87
  * Remove any prior tuplets from the tick calculation and
79
88
  * reset the intrinsic tick value.
80
89
  */
81
90
  resetTuplet(tuplet?: Tuplet): this;
82
- /** Attach to new tuplet. */
91
+ /** Set the tuplet to the given Tuplet. If there are existing tuplets clears them first. */
83
92
  setTuplet(tuplet: Tuplet): this;
93
+ /** Add the given Tuplet to the tupletStack without clearing it first. */
94
+ addTuplet(tuplet: Tuplet): this;
95
+ /**
96
+ * Sets all the tuplets on the tickable to the given tupletStack. Note that
97
+ * a new array is created on the tickable, so manipulating the array that is
98
+ * passed in will not affect the tupletStack used by the tickable.
99
+ */
100
+ setTupletStack(tupletStack: Tuplet[]): this;
84
101
  /**
85
102
  * Add self to the provided ModifierContext `mc`.
86
103
  * If this tickable has modifiers, set modifierContext.
@@ -89,7 +106,6 @@ export declare abstract class Tickable extends Element {
89
106
  addToModifierContext(mc: ModifierContext): this;
90
107
  /**
91
108
  * Optional, if tickable has modifiers, associate a Modifier.
92
- * @param mod the modifier
93
109
  */
94
110
  addModifier(modifier: Modifier, index?: number): this;
95
111
  /** Get the list of associated modifiers. */
@@ -107,13 +123,14 @@ export declare abstract class Tickable extends Element {
107
123
  /** Set postformatted status. */
108
124
  set postFormatted(value: boolean);
109
125
  get postFormatted(): boolean;
110
- /** Return the intrinsic ticks. */
126
+ /** Return the intrinsic ticks as an integer. */
111
127
  getIntrinsicTicks(): number;
112
- /** Set the intrinsic ticks. */
128
+ /** Set the intrinsic ticks as an integer. */
113
129
  setIntrinsicTicks(intrinsicTicks: number): void;
114
- /** Get the tick multiplier. */
130
+ /** Get the tick multiplier as a Fraction. Defaults to Fraction(1, 1). */
115
131
  getTickMultiplier(): Fraction;
116
- /** Apply a tick multiplier. */
132
+ /** Apply a tick multiplier, by multiplying the current tickMultiplier by
133
+ * the numerator and denominator given here. Updates ticks. */
117
134
  applyTickMultiplier(numerator: number, denominator: number): void;
118
135
  /** Set the duration. */
119
136
  setDuration(duration: Fraction): void;
@@ -1,3 +1,4 @@
1
+ import { BoundingBox } from './boundingbox';
1
2
  import { Element } from './element';
2
3
  import { RenderContext } from './rendercontext';
3
4
  import { Stave } from './stave';
@@ -16,6 +17,8 @@ export declare class TimeSignature extends StaveModifier {
16
17
  static get CATEGORY(): string;
17
18
  bottomLine: number;
18
19
  topLine: number;
20
+ protected topRenderY: number;
21
+ protected botRenderY: number;
19
22
  protected timeSpec: string;
20
23
  protected line: number;
21
24
  protected topText: Element;
@@ -68,4 +71,5 @@ export declare class TimeSignature extends StaveModifier {
68
71
  */
69
72
  draw(): void;
70
73
  drawAt(ctx: RenderContext, stave: Stave, x: number): void;
74
+ getBoundingBox(): BoundingBox;
71
75
  }
@@ -39,8 +39,13 @@
39
39
  * yOffset: int, default 0
40
40
  * manually offset a tuplet, for instance to avoid collisions
41
41
  * with articulations, etc...
42
+ *
43
+ * suffix: string
44
+ * suffix to show after ratio.
45
+ * NOTE: any of the Glyphs.met... work well for note glyphs
42
46
  * }
43
47
  */
48
+ import { BoundingBox } from './boundingbox';
44
49
  import { Element } from './element';
45
50
  import { Note } from './note';
46
51
  export interface TupletOptions {
@@ -51,6 +56,7 @@ export interface TupletOptions {
51
56
  ratioed?: boolean;
52
57
  yOffset?: number;
53
58
  textYOffset?: number;
59
+ suffix?: string;
54
60
  }
55
61
  export declare const enum TupletLocation {
56
62
  BOTTOM = -1,
@@ -61,6 +67,7 @@ export declare class Tuplet extends Element {
61
67
  notes: Note[];
62
68
  protected options: Required<TupletOptions>;
63
69
  protected textElement: Element;
70
+ protected suffixElement: Element;
64
71
  static get LOCATION_TOP(): number;
65
72
  static get LOCATION_BOTTOM(): number;
66
73
  static get NESTING_OFFSET(): number;
@@ -87,4 +94,5 @@ export declare class Tuplet extends Element {
87
94
  getNestedTupletCount(): number;
88
95
  getYPosition(): number;
89
96
  draw(): void;
97
+ getBoundingBox(): BoundingBox;
90
98
  }
@@ -1,3 +1,4 @@
1
+ export { structuredClone } from 'structured-clone-es';
1
2
  /** `RuntimeError` will be thrown by VexFlow classes in case of error. */
2
3
  export declare class RuntimeError extends Error {
3
4
  code: string;
@@ -43,8 +43,9 @@ import { Registry } from './registry';
43
43
  import { RenderContext } from './rendercontext';
44
44
  import { Renderer, RendererBackends, RendererLineEndType } from './renderer';
45
45
  import { RepeatNote } from './repeatnote';
46
+ import { Sheet } from './sheet';
46
47
  import { Stave } from './stave';
47
- import { Barline, BarlineType } from './stavebarline';
48
+ import { Barline, BarlineType, RepeatBracketType } from './stavebarline';
48
49
  import { StaveConnector } from './staveconnector';
49
50
  import { StaveHairpin } from './stavehairpin';
50
51
  import { StaveLine } from './staveline';
@@ -144,6 +145,7 @@ export declare class VexFlow {
144
145
  static Stroke: typeof Stroke;
145
146
  static SVGContext: typeof SVGContext;
146
147
  static System: typeof System;
148
+ static Sheet: typeof Sheet;
147
149
  static TabNote: typeof TabNote;
148
150
  static TabSlide: typeof TabSlide;
149
151
  static TabStave: typeof TabStave;
@@ -176,6 +178,7 @@ export declare class VexFlow {
176
178
  static RendererBackends: typeof RendererBackends;
177
179
  static RendererLineEndType: typeof RendererLineEndType;
178
180
  static BarlineType: typeof BarlineType;
181
+ static RepeatBracketType: typeof RepeatBracketType;
179
182
  static StaveModifierPosition: typeof StaveModifierPosition;
180
183
  static VoltaType: typeof VoltaType;
181
184
  static TextBracketPosition: typeof TextBracketPosition;
@@ -218,6 +221,10 @@ export declare class VexFlow {
218
221
  * See `demos/fonts/` for more examples.
219
222
  */
220
223
  static setFonts(...fontNames: string[]): void;
224
+ /** Choose text faces independently. Music fonts remain available for mixed glyph strings. */
225
+ static setTextFonts(...fontNames: string[]): void;
226
+ /** Return the text-first stack used by new text elements. */
227
+ static getTextFonts(): string[];
221
228
  static getFonts(): string[];
222
229
  static get RENDER_PRECISION_PLACES(): number;
223
230
  static set RENDER_PRECISION_PLACES(precision: number);
@@ -33,6 +33,8 @@ export declare class Voice extends Element {
33
33
  protected mode: VoiceMode;
34
34
  protected expTicksUsed?: number;
35
35
  protected preFormatted: boolean;
36
+ /** Durations can change after insertion, for example when attaching tuplets. */
37
+ private ticksDirty;
36
38
  protected options: {
37
39
  softmaxFactor: number;
38
40
  };
@@ -90,6 +92,10 @@ export declare class Voice extends Element {
90
92
  protected reCalculateExpTicksUsed(): number;
91
93
  /** Get the softmax-scaled value of a tick duration. 'tickValue' is a number. */
92
94
  softmax(tickValue: number): number;
95
+ /** Invalidate cached duration totals when a member's duration changes. */
96
+ invalidateTicks(): void;
97
+ /** Recount once after a batch of duration edits; avoid partial-tuplet validation. */
98
+ private refreshTicks;
93
99
  /** Add a tickable to the voice. */
94
100
  addTickable(tickable: Tickable): this;
95
101
  /** Add an array of tickables to the voice. */
@@ -0,0 +1,94 @@
1
+ # 5.1.0
2
+
3
+ ## Features
4
+
5
+ - Add `Sheet` and `EasyScore.measures()` for multi-measure scores that wrap to a chosen width.
6
+ - Add retained Factory drawing and inherited score styles for reflow and theme changes.
7
+ - Add portable SVG export with text and music glyphs converted to paths.
8
+ - Add separate text-font selection and explicit lyric baselines.
9
+ - Add optional repeat brackets, more key signatures, and tuplet label suffixes.
10
+ - Support longa, maxima, and 256th, 512th, and 1024th note durations.
11
+ - Add the [VexFlow Explorer](https://vexflow.com/explorer/) with editable examples, a glyph atlas, and visual inspection tools.
12
+
13
+ ## Fixes
14
+
15
+ - Fix native ESM imports and package entry points.
16
+ - Correct accidental ordering across voices and rest collisions.
17
+ - Improve grace-note spacing, pedal placement, and ties near lyrics.
18
+ - Fix nested tuplet timing and refresh voice totals when durations change.
19
+ - Improve bounding boxes and keep repeated drawing stable.
20
+ - Correct stem placement on cross noteheads.
21
+ - Reject malformed durations, meters, and fractions. Protect Registry indexes from prototype-related keys.
22
+ - Update dependencies, including critical security fixes in development tooling.
23
+
24
+ ## Upgrade notes
25
+
26
+ - `setTuplet()` now replaces existing tuplets. Use `addTuplet()` to stack them.
27
+ - `getTupletStack()` returns a readonly array in TypeScript. Use the tuplet methods to change it.
28
+ - `resetTuplet()` is deprecated. Use `removeTuplet()` or `clearTuplets()`.
29
+ - Text now prefers a text font. Call `setTextFonts()` after `setFonts()` to choose a custom face.
30
+ - Invalid inputs may now throw instead of being accepted. Layout fixes can change existing renderings.
31
+
32
+ ## Development
33
+
34
+ - Add geometry, overlap, color, and image-difference regression checks.
35
+ - Add rendering benchmarks and update the Node/jsdom test setup.
36
+ - Keep explorer output and generated reports out of the npm package.
37
+
38
+ # 5.0.0
39
+
40
+ - `vex.ts` and `flow.ts` modules are merged into vexflow.ts, which exports the `VexFlow` class.
41
+
42
+ # 4.0.1
43
+
44
+ Detailed changes are listed on the wiki: https://github.com/0xfe/vexflow/wiki/Changelog-ver-4.0
45
+
46
+ ## Features
47
+
48
+ - VexFlow is written in **TypeScript** with a ES6 target.
49
+ - Supports ES module in addition to CommonJS environments.
50
+ - Improved automatic layout of notes.
51
+ - Improved handling of music fonts and text fonts.
52
+ - Supports lazy loading of music fonts.
53
+ - Improved `setFont(...)` method in Element class.
54
+
55
+ ## Breaking
56
+
57
+ - The tsconfig.json `compilerOptions.target` has been updated to ES6 / ES2015.
58
+ - `Stave.setNumLines(n: number)` requires a number. Previously, a string would also work. See: [stave.ts](https://github.com/0xfe/vexflow/blob/master/src/stave.ts) and [#1083](https://github.com/0xfe/vexflow/issues/1083).
59
+ - `Note.addModifier(modifier: Modifier, index?: number): this` now throws a RuntimeError if the parameters are reversed.
60
+ - `TickContext.getTickableForVoice(voiceIndex: number): Tickable` was previously named `getTickablesForVoice(voiceIndex: number): Note`. We removed the `s` because the method returns a single Tickable. You will need to update calls to this function if you are upgrading from a build from between April 2020 to August 2021.
61
+ - `Element` and its subclasses have a static `CATEGORY` string property, used by VexFlow internally to differentiate objects. This string has been standardized to be singular, with UpperCamelCase capitalization.
62
+ - Examples:
63
+ - `Accidental.CATEGORY` is now `'Accidental'` instead of `'accidentals'`.
64
+ - `Modifier.CATEGORY` is now `'Modifier'` instead of `'none'`.
65
+ - **ChordSymbol**
66
+ - `ChordSymbol.NO_TEXT_FORMAT` was previously named `ChordSymbol.NOTEXTFORMAT`.
67
+ - `ChordSymbol.metrics` was previously named `ChordSymbol.chordSymbolMetrics`.
68
+ - `StaveNote.LEDGER_LINE_OFFSET` was previously named `StaveNote.DEFAULT_LEDGER_LINE_OFFSET`.
69
+ - **Fonts**
70
+
71
+ - `TextFontMetrics` has been merged into `FontGlyph` due to substantial overlap.
72
+ - `Flow.NOTATION_FONT_SCALE` was previously named `Flow.DEFAULT_NOTATION_FONT_SCALE`.
73
+ - `setFont(...)` in `CanvasContext` and `SVGContext` previously took arguments: `family`, `size`, `weight`. The `weight` argument allowed strings like `'italic bold'`. This no longer works, and `'italic'` must now be passed into the `style` argument.
74
+
75
+ - **Build Process**
76
+ - Gruntfile environment variable `VEX_DEVTOOL` was previously named `VEX_GENMAP`. This environment variable sets the [webpack devtool configuration option](https://webpack.js.org/configuration/devtool/).
77
+
78
+ # 3.0.9 / 2020-04-21
79
+
80
+ - Support [Bravura](https://github.com/steinbergmedia/bravura), the reference font for [Standard Music Font Layout](https://w3c.github.io/smufl/latest/index.html).
81
+
82
+ # 1.2.84 / 2017-08-01
83
+
84
+ - `Accidental.ApplyAccidentals()` no longer breaks on `Notes` that ignore ticks (ie: `TimeSigNote`)
85
+ - `Accidental.applyAccidentals()` now applies accidentals to `GraceNotes`
86
+ - Fix a `BoundingBox#mergeWith` case when one box contains another
87
+ - Fix blurry canvas rendering on retina screens
88
+ - Rebuild noteheads after `StaveNote#setKeyLine` is called
89
+ - Ensure `StaveNote.extraLeftPx` and `StaveNote.extraRightPx` get recalculated in `StaveNote#reset`
90
+ - `Factory` exposes a lot more elements -- **API is subject to change**
91
+ - `Factory` constructor `options.renderer.selector` renamed to `options.renderer.elementId` to more appropriately reflect the what the string represents
92
+ - Sori and koron microtonal accidentals have been added
93
+ - Tests have been refactored to use `Factory` and `EasyScore`
94
+ - The font transformation tool (`transform.html`) has been refactored, and generates a font by combining both the `Gonville` and `Microtonal` fonts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vexflow",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "A JavaScript library for rendering music notation and guitar tablature.",
5
5
  "exports": {
6
6
  ".": {
@@ -36,7 +36,10 @@
36
36
  },
37
37
  "license": "MIT",
38
38
  "files": [
39
- "build",
39
+ "build/cjs",
40
+ "build/esm",
41
+ "build/types",
42
+ "changelog/CHANGELOG.md",
40
43
  "tests/flow.html",
41
44
  "tests/flow.css",
42
45
  "tests/qunit/qunit.css",
@@ -47,13 +50,13 @@
47
50
  "url": "https://github.com/vexflow/vexflow/issues"
48
51
  },
49
52
  "devDependencies": {
50
- "@eslint/compat": "^1.2.6",
51
- "@eslint/eslintrc": "^3.2.0",
52
- "@eslint/js": "^9.19.0",
53
- "@types/node": "^22.13.1",
53
+ "@eslint/compat": "^1.2.9",
54
+ "@eslint/eslintrc": "^3.3.1",
55
+ "@eslint/js": "^9.28.0",
56
+ "@types/node": "^22.15.30",
54
57
  "@types/qunit": "^2.19.12",
55
- "@typescript-eslint/eslint-plugin": "^8.23.0",
56
- "@typescript-eslint/parser": "^8.23.0",
58
+ "@typescript-eslint/eslint-plugin": "^8.33.1",
59
+ "@typescript-eslint/parser": "^8.33.1",
57
60
  "@vexflow-fonts/academico": "^1.0.1",
58
61
  "@vexflow-fonts/bravura": "^1.0.2",
59
62
  "@vexflow-fonts/bravuratext": "^1.0.0",
@@ -81,16 +84,16 @@
81
84
  "@vexflow-fonts/robotoslab": "^1.0.0",
82
85
  "@vexflow-fonts/sebastian": "^1.0.1",
83
86
  "@vexflow-fonts/sebastiantext": "^1.0.0",
84
- "canvas": "^3.1.0",
87
+ "canvas": "3.2.3",
85
88
  "circular-dependency-plugin": "^5.2.2",
86
89
  "concurrently": "^9.1.2",
87
- "eslint": "^9.19.0",
88
- "eslint-config-prettier": "^10.0.1",
90
+ "eslint": "^9.28.0",
91
+ "eslint-config-prettier": "^10.1.5",
89
92
  "eslint-plugin-import": "^2.31.0",
90
- "eslint-plugin-prettier": "^5.2.3",
93
+ "eslint-plugin-prettier": "^5.4.1",
91
94
  "eslint-plugin-simple-import-sort": "^12.1.1",
92
- "fork-ts-checker-webpack-plugin": "^9.0.2",
93
- "globals": "^15.14.0",
95
+ "fork-ts-checker-webpack-plugin": "^9.1.0",
96
+ "globals": "^16.2.0",
94
97
  "grunt": "^1.6.1",
95
98
  "grunt-cli": "^1.5.0",
96
99
  "grunt-contrib-clean": "^2.0.1",
@@ -98,22 +101,22 @@
98
101
  "grunt-contrib-qunit": "^10.1.1",
99
102
  "grunt-eslint": "^25.0.0",
100
103
  "grunt-webpack": "^7.0.0",
101
- "jsdom": "^26.0.0",
102
- "jspdf": "^2.5.2",
104
+ "jsdom": "^26.1.0",
105
+ "jspdf": "^4.0.0",
103
106
  "opener": "^1.5.2",
104
107
  "opentype.js": "^1.3.4",
105
- "prettier": "^3.4.2",
106
- "puppeteer": "^24.2.0",
108
+ "prettier": "^3.5.3",
109
+ "puppeteer": "^25.17.0",
107
110
  "qunit": "^2.24.1",
108
111
  "recursive-copy": "^2.0.14",
109
- "release-it": "^18.1.2",
112
+ "release-it": "^19.0.3",
110
113
  "string-replace-loader": "^3.1.0",
111
- "svg2pdf.js": "^2.2.4",
112
- "terser-webpack-plugin": "^5.3.11",
114
+ "svg2pdf.js": "^2.5.0",
115
+ "terser-webpack-plugin": "^5.3.14",
113
116
  "ts-loader": "^9.5.2",
114
- "tsc-watch": "^6.2.1",
115
- "typescript": "^5.7.3",
116
- "webpack": "^5.97.1"
117
+ "tsc-watch": "^7.1.1",
118
+ "typescript": "^5.8.3",
119
+ "webpack": "^5.99.9"
117
120
  },
118
121
  "scripts": {
119
122
  "start": "grunt",
@@ -124,7 +127,11 @@
124
127
  "generate:current": "grunt generate:current",
125
128
  "generate:reference": "grunt generate:reference",
126
129
  "diff:reference": "grunt diff:reference",
127
- "lint": "grunt eslint"
130
+ "lint": "grunt eslint",
131
+ "explorer": "node tools/explorer/cli.mjs serve",
132
+ "explorer:build": "node tools/explorer/cli.mjs build",
133
+ "explorer:test": "node tools/explorer/test.mjs",
134
+ "explorer:upload": "node tools/explorer/upload.mjs"
128
135
  },
129
136
  "homepage": "https://vexflow.com/",
130
137
  "keywords": [
@@ -133,5 +140,14 @@
133
140
  "piano",
134
141
  "guitar",
135
142
  "tablature"
136
- ]
143
+ ],
144
+ "dependencies": {
145
+ "structured-clone-es": "^1.0.0"
146
+ },
147
+ "overrides": {
148
+ "undici": "6.23.0",
149
+ "concurrently": {
150
+ "shell-quote": "1.11.0"
151
+ }
152
+ }
137
153
  }