vexflow 5.4.0 → 5.6.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/build/cjs/vexflow-bravura.js +2 -2
  2. package/build/cjs/vexflow-bravura.js.map +1 -1
  3. package/build/cjs/vexflow-core.js +2 -2
  4. package/build/cjs/vexflow-core.js.map +1 -1
  5. package/build/cjs/vexflow-debug-with-tests.js +1740 -372
  6. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  7. package/build/cjs/vexflow-debug.js +565 -258
  8. package/build/cjs/vexflow-debug.js.map +1 -1
  9. package/build/cjs/vexflow.js +2 -2
  10. package/build/cjs/vexflow.js.map +1 -1
  11. package/build/esm/src/annotation.js +2 -1
  12. package/build/esm/src/continuouslayout.js +107 -16
  13. package/build/esm/src/continuousspan.js +9 -1
  14. package/build/esm/src/easyscore/composition.js +83 -18
  15. package/build/esm/src/factory.js +2 -9
  16. package/build/esm/src/formatter.js +1 -1
  17. package/build/esm/src/fretdiagram.js +6 -2
  18. package/build/esm/src/gracenotegroup.js +4 -3
  19. package/build/esm/src/guitarmodifiers.js +4 -1
  20. package/build/esm/src/metrics.js +24 -5
  21. package/build/esm/src/note.js +1 -0
  22. package/build/esm/src/notehead.js +21 -10
  23. package/build/esm/src/phraselayout.js +13 -5
  24. package/build/esm/src/publication.js +10 -5
  25. package/build/esm/src/publicationview.js +3 -2
  26. package/build/esm/src/stave.js +4 -2
  27. package/build/esm/src/stavenote.js +56 -13
  28. package/build/esm/src/stavesection.js +15 -10
  29. package/build/esm/src/stavetie.js +3 -2
  30. package/build/esm/src/strokes.js +1 -1
  31. package/build/esm/src/svgcontext.js +11 -3
  32. package/build/esm/src/tabnote.js +6 -8
  33. package/build/esm/src/tabtie.js +3 -0
  34. package/build/esm/src/version.js +3 -3
  35. package/build/esm/tests/chordsymbol_tests.js +4 -1
  36. package/build/esm/tests/demo_petzold_tests.js +26 -14
  37. package/build/esm/tests/demo_repertoire_tests.js +5 -1
  38. package/build/esm/tests/demos/ballade.js +15 -0
  39. package/build/esm/tests/demos/electric.js +1 -3
  40. package/build/esm/tests/demos/fugue.js +19 -0
  41. package/build/esm/tests/demos/greensleeves.js +1 -2
  42. package/build/esm/tests/demos/kesh.js +2 -3
  43. package/build/esm/tests/demos/saints.js +17 -5
  44. package/build/esm/tests/engraving/continuous-studies.mjs +24 -0
  45. package/build/esm/tests/engraving/publication-studies.mjs +30 -0
  46. package/build/esm/tests/font_tests.js +8 -0
  47. package/build/esm/tests/gracenote_tests.js +1 -1
  48. package/build/esm/tests/gracetabnote_tests.js +19 -3
  49. package/build/esm/tests/node/chord-kerning-tests.mjs +2 -2
  50. package/build/esm/tests/node/continuous-score-tests.mjs +157 -2
  51. package/build/esm/tests/node/easyscore-tests.mjs +38 -0
  52. package/build/esm/tests/node/engraving-layout-tests.mjs +33 -0
  53. package/build/esm/tests/node/instrument-profile-tests.mjs +40 -0
  54. package/build/esm/tests/node/local-engraving-tests.mjs +58 -0
  55. package/build/esm/tests/node/metrics-tests.mjs +2 -0
  56. package/build/esm/tests/node/phrase-layout-tests.mjs +58 -5
  57. package/build/esm/tests/node/publication-tests.mjs +158 -2
  58. package/build/esm/tests/node/svg-export-tests.mjs +50 -21
  59. package/build/esm/tests/scores/ballade.js +399 -0
  60. package/build/esm/tests/scores/drums.js +93 -0
  61. package/build/esm/tests/scores/electric.js +83 -0
  62. package/build/esm/tests/scores/falseta.js +46 -0
  63. package/build/esm/tests/scores/fugue.js +366 -0
  64. package/build/esm/tests/scores/guitar.js +32 -0
  65. package/build/esm/tests/scores/kesh.js +146 -0
  66. package/build/esm/tests/scores/prelude.js +84 -0
  67. package/build/esm/tests/scores/quartertones.js +78 -0
  68. package/build/esm/tests/scores/saints.js +70 -0
  69. package/build/esm/tests/scores/sumer.js +126 -0
  70. package/build/esm/tests/scores/viewer.js +162 -0
  71. package/build/esm/tests/tabnote_tests.js +43 -0
  72. package/build/esm/tests/vexflow_test_helpers.js +1 -0
  73. package/build/esm/tools/explorer/catalog/expression.mjs +16 -6
  74. package/build/esm/tools/explorer/catalog/guitar.mjs +2 -2
  75. package/build/types/src/continuouslayout.d.ts +4 -0
  76. package/build/types/src/continuousspan.d.ts +10 -2
  77. package/build/types/src/easyscore/composition.d.ts +19 -0
  78. package/build/types/src/fretdiagram.d.ts +2 -0
  79. package/build/types/src/instrumentprofile.d.ts +4 -0
  80. package/build/types/src/note.d.ts +2 -0
  81. package/build/types/src/notehead.d.ts +2 -0
  82. package/build/types/src/publication.d.ts +3 -1
  83. package/build/types/src/stave.d.ts +4 -2
  84. package/build/types/src/stavenote.d.ts +10 -0
  85. package/build/types/src/stavesection.d.ts +3 -0
  86. package/build/types/src/svgcontext.d.ts +2 -0
  87. package/build/types/src/typeguard.d.ts +1 -0
  88. package/changelog/CHANGELOG.md +16 -0
  89. package/package.json +4 -1
  90. package/tests/all.html +9 -0
  91. package/tests/demo_petzold_tests.ts +30 -16
  92. package/tests/demos/ballade.ts +36 -0
  93. package/tests/demos/ballade.webp +0 -0
  94. package/tests/demos/electric.ts +1 -3
  95. package/tests/demos/electric.webp +0 -0
  96. package/tests/demos/fugue.ts +27 -0
  97. package/tests/demos/fugue.webp +0 -0
  98. package/tests/demos/greensleeves.ts +1 -3
  99. package/tests/demos/greensleeves.webp +0 -0
  100. package/tests/demos/kesh.ts +2 -4
  101. package/tests/demos/kesh.webp +0 -0
  102. package/tests/demos/saints.ts +20 -7
  103. package/tests/demos/saints.webp +0 -0
  104. package/tests/flow.html +165 -52
  105. package/tests/minuet.webp +0 -0
  106. package/tests/scores/ballade.js +445 -0
  107. package/tests/scores/drums.js +101 -0
  108. package/tests/scores/drums.webp +0 -0
  109. package/tests/scores/electric.js +93 -0
  110. package/tests/scores/electric.webp +0 -0
  111. package/tests/scores/falseta.js +53 -0
  112. package/tests/scores/falseta.webp +0 -0
  113. package/tests/scores/fugue.js +433 -0
  114. package/tests/scores/guitar.js +34 -0
  115. package/tests/scores/index.html +48 -0
  116. package/tests/scores/kesh.js +171 -0
  117. package/tests/scores/kesh.webp +0 -0
  118. package/tests/scores/prelude.js +90 -0
  119. package/tests/scores/prelude.webp +0 -0
  120. package/tests/scores/quartertones.js +83 -0
  121. package/tests/scores/quartertones.webp +0 -0
  122. package/tests/scores/saints.js +85 -0
  123. package/tests/scores/saints.webp +0 -0
  124. package/tests/scores/sumer.js +139 -0
  125. package/tests/scores/sumer.webp +0 -0
  126. package/tests/scores/viewer.css +132 -0
  127. package/tests/scores/viewer.js +150 -0
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * VexFlow 5.4.0 2026-11-19T00:43:30.372Z 30054199edf019f97dcea2f2939430198f387f49
2
+ * VexFlow 5.6.0 2026-11-19T20:58:10.569Z 39cf287f300f0ef6bd9b63cbf1d01ef0bbbd1c10
3
3
  * Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/vexflow/blob/main/AUTHORS.md).
4
4
  */
5
5
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -29,9 +29,9 @@ __webpack_require__.r(__webpack_exports__);
29
29
  /* harmony export */ VERSION: () => (/* binding */ VERSION)
30
30
  /* harmony export */ });
31
31
  // Gruntfile.js uses string-replace-loader to replace these values during build time.
32
- const VERSION = '5.4.0';
33
- const ID = '30054199edf019f97dcea2f2939430198f387f49';
34
- const DATE = '2026-11-19T00:43:30.372Z';
32
+ const VERSION = '5.6.0';
33
+ const ID = '39cf287f300f0ef6bd9b63cbf1d01ef0bbbd1c10';
34
+ const DATE = '2026-11-19T20:58:10.569Z';
35
35
 
36
36
 
37
37
  /***/ },
@@ -911,7 +911,9 @@ class Annotation extends _modifier__WEBPACK_IMPORTED_MODULE_2__.Modifier {
911
911
  if (hasStem && stemDirection === _stem__WEBPACK_IMPORTED_MODULE_3__.Stem.UP) {
912
912
  // If the stem is above the stave already, go with default line width vs. actual
913
913
  // since the lines between don't really matter.
914
- spacing = stemExt.topY < stave.getTopLineTopY() ? _tables__WEBPACK_IMPORTED_MODULE_4__.Tables.STAVE_LINE_DISTANCE : spacing;
914
+ // Tab articulations stack in actual string spaces, including above an up-stem.
915
+ if (!(0,_typeguard__WEBPACK_IMPORTED_MODULE_5__.isTabNote)(note) && stemExt.topY < stave.getTopLineTopY())
916
+ spacing = _tables__WEBPACK_IMPORTED_MODULE_4__.Tables.STAVE_LINE_DISTANCE;
915
917
  y = Math.min(y, stemExt.topY - spacing * (this.textLine + 1));
916
918
  }
917
919
  } /* CENTER_STEM */
@@ -4027,24 +4029,25 @@ __webpack_require__.r(__webpack_exports__);
4027
4029
  /* harmony export */ ContinuousLayout: () => (/* binding */ ContinuousLayout)
4028
4030
  /* harmony export */ });
4029
4031
  /* harmony import */ var _accidental__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./accidental */ "./src/accidental.ts");
4030
- /* harmony import */ var _clef__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./clef */ "./src/clef.ts");
4031
- /* harmony import */ var _continuousspan__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./continuousspan */ "./src/continuousspan.ts");
4032
- /* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./element */ "./src/element.ts");
4033
- /* harmony import */ var _engravinggeometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./engravinggeometry */ "./src/engravinggeometry.ts");
4034
- /* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./fraction */ "./src/fraction.ts");
4035
- /* harmony import */ var _glyphs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./glyphs */ "./src/glyphs.ts");
4036
- /* harmony import */ var _keysignature__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./keysignature */ "./src/keysignature.ts");
4037
- /* harmony import */ var _multimeasurerest__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multimeasurerest */ "./src/multimeasurerest.ts");
4038
- /* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./note */ "./src/note.ts");
4039
- /* harmony import */ var _stavebarline__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stavebarline */ "./src/stavebarline.ts");
4040
- /* harmony import */ var _staveconnector__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./staveconnector */ "./src/staveconnector.ts");
4041
- /* harmony import */ var _stavemodifier__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./stavemodifier */ "./src/stavemodifier.ts");
4042
- /* harmony import */ var _stavenote__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stavenote */ "./src/stavenote.ts");
4043
- /* harmony import */ var _stem__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./stem */ "./src/stem.ts");
4044
- /* harmony import */ var _systembreaks__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./systembreaks */ "./src/systembreaks.ts");
4045
- /* harmony import */ var _tabnote__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tabnote */ "./src/tabnote.ts");
4046
- /* harmony import */ var _timesignature__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./timesignature */ "./src/timesignature.ts");
4047
- /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./util */ "./src/util.ts");
4032
+ /* harmony import */ var _annotation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./annotation */ "./src/annotation.ts");
4033
+ /* harmony import */ var _clef__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clef */ "./src/clef.ts");
4034
+ /* harmony import */ var _continuousspan__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./continuousspan */ "./src/continuousspan.ts");
4035
+ /* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./element */ "./src/element.ts");
4036
+ /* harmony import */ var _engravinggeometry__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./engravinggeometry */ "./src/engravinggeometry.ts");
4037
+ /* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./fraction */ "./src/fraction.ts");
4038
+ /* harmony import */ var _glyphs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./glyphs */ "./src/glyphs.ts");
4039
+ /* harmony import */ var _keysignature__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./keysignature */ "./src/keysignature.ts");
4040
+ /* harmony import */ var _multimeasurerest__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multimeasurerest */ "./src/multimeasurerest.ts");
4041
+ /* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./note */ "./src/note.ts");
4042
+ /* harmony import */ var _stavebarline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./stavebarline */ "./src/stavebarline.ts");
4043
+ /* harmony import */ var _staveconnector__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./staveconnector */ "./src/staveconnector.ts");
4044
+ /* harmony import */ var _stavemodifier__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stavemodifier */ "./src/stavemodifier.ts");
4045
+ /* harmony import */ var _stavenote__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./stavenote */ "./src/stavenote.ts");
4046
+ /* harmony import */ var _stem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./stem */ "./src/stem.ts");
4047
+ /* harmony import */ var _systembreaks__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./systembreaks */ "./src/systembreaks.ts");
4048
+ /* harmony import */ var _tabnote__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./tabnote */ "./src/tabnote.ts");
4049
+ /* harmony import */ var _timesignature__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./timesignature */ "./src/timesignature.ts");
4050
+ /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./util */ "./src/util.ts");
4048
4051
  // Row-dependent notation for a responsive EasyScore composition. Source measures and notes keep their identity.
4049
4052
 
4050
4053
 
@@ -4065,8 +4068,29 @@ __webpack_require__.r(__webpack_exports__);
4065
4068
 
4066
4069
 
4067
4070
 
4071
+
4068
4072
  function invalid(message) {
4069
- throw new _util__WEBPACK_IMPORTED_MODULE_18__.RuntimeError('BadContinuousScore', message);
4073
+ throw new _util__WEBPACK_IMPORTED_MODULE_19__.RuntimeError('BadContinuousScore', message);
4074
+ }
4075
+ /** Resolve each end independently because chord positions can be reordered between attacks. */
4076
+ function resolveTabTie(span, first, last) {
4077
+ var _a, _b, _c, _d, _e;
4078
+ const start = first.getPositions();
4079
+ const end = last.getPositions();
4080
+ for (const head of [span.fromHead, span.toHead]) {
4081
+ if (head !== undefined && (!Number.isInteger(head) || head < 0))
4082
+ invalid('Invalid tab tie position index.');
4083
+ }
4084
+ const selected = span.fromHead === undefined && span.toHead !== undefined ? end[span.toHead] : start[(_a = span.fromHead) !== null && _a !== void 0 ? _a : 0];
4085
+ const string = (_b = span.string) !== null && _b !== void 0 ? _b : selected === null || selected === void 0 ? void 0 : selected.str;
4086
+ if (string === undefined || !Number.isInteger(string) || string < 1 || string > first.checkStave().getNumLines())
4087
+ invalid('A tab tie needs a string on its staff.');
4088
+ const fromHead = (_c = span.fromHead) !== null && _c !== void 0 ? _c : start.findIndex((p) => p.str === string);
4089
+ const toHead = (_d = span.toHead) !== null && _d !== void 0 ? _d : end.findIndex((p) => p.str === string);
4090
+ const from = start[fromHead], to = end[toHead];
4091
+ if (!from || !to || from.str !== string || to.str !== string || String(from.fret) !== String(to.fret))
4092
+ invalid('Tab tie endpoints must play the same string and fret.');
4093
+ return Object.assign(Object.assign({}, span), { fromHead, toHead, string, side: (_e = span.side) !== null && _e !== void 0 ? _e : 'above' });
4070
4094
  }
4071
4095
  /** A row has one shared staff map. A compressed rest maps back to every original measure. */
4072
4096
  class ContinuousLayout {
@@ -4075,7 +4099,7 @@ class ContinuousLayout {
4075
4099
  const key = (symbol ? 'glyph:' : 'text:') + text;
4076
4100
  let mark = this.headerLabels.get(key);
4077
4101
  if (!mark) {
4078
- mark = new _element__WEBPACK_IMPORTED_MODULE_3__.Element(symbol ? 'Repetition' : 'Annotation').setText(text);
4102
+ mark = new _element__WEBPACK_IMPORTED_MODULE_4__.Element(symbol ? 'Repetition' : 'Annotation').setText(text);
4079
4103
  if (symbol)
4080
4104
  mark.setFontSize(18);
4081
4105
  this.headerLabels.set(key, mark);
@@ -4086,7 +4110,7 @@ class ContinuousLayout {
4086
4110
  var _a;
4087
4111
  const boundary = this.boundaries.get(i), kind = (_a = boundary === null || boundary === void 0 ? void 0 : boundary.navigation) === null || _a === void 0 ? void 0 : _a.kind;
4088
4112
  const nav = kind
4089
- ? { segno: _glyphs__WEBPACK_IMPORTED_MODULE_6__.Glyphs.segno, coda: _glyphs__WEBPACK_IMPORTED_MODULE_6__.Glyphs.coda, dalSegno: 'D.S.', toCoda: 'To Coda', daCapo: 'D.C.', fine: 'Fine' }[kind]
4113
+ ? { segno: _glyphs__WEBPACK_IMPORTED_MODULE_7__.Glyphs.segno, coda: _glyphs__WEBPACK_IMPORTED_MODULE_7__.Glyphs.coda, dalSegno: 'D.S.', toCoda: 'To Coda', daCapo: 'D.C.', fine: 'Fine' }[kind]
4090
4114
  : '';
4091
4115
  const texts = [
4092
4116
  this.options.measureNumbers && atStart ? String(i + 1) : '',
@@ -4117,6 +4141,8 @@ class ContinuousLayout {
4117
4141
  this.headerLabels = new Map();
4118
4142
  this.splitChords = [];
4119
4143
  this.spelledSpans = new Set();
4144
+ /** A leading tab fret needs room for the incoming tie after the repeated clef. */
4145
+ this.tabTiePadding = new Map();
4120
4146
  this.arrivals = new Map();
4121
4147
  this.options = (_a = spec.continuous) !== null && _a !== void 0 ? _a : {};
4122
4148
  for (const voice of score.voices.flat(2))
@@ -4150,7 +4176,7 @@ class ContinuousLayout {
4150
4176
  invalid('Invalid staff group.');
4151
4177
  return Object.assign(Object.assign({}, g), { first, last });
4152
4178
  });
4153
- const label = (text) => (text ? new _element__WEBPACK_IMPORTED_MODULE_3__.Element('Annotation').setText(text) : undefined);
4179
+ const label = (text) => (text ? new _element__WEBPACK_IMPORTED_MODULE_4__.Element('Annotation').setText(text) : undefined);
4154
4180
  const names = spec.staves.map((s) => { var _a; return ({ full: label(s.name), short: label((_a = s.shortName) !== null && _a !== void 0 ? _a : s.name) }); });
4155
4181
  this.names = score.systems.map((_, i) => spec.staves.map((s, j) => {
4156
4182
  var _a;
@@ -4164,36 +4190,36 @@ class ContinuousLayout {
4164
4190
  const stave = score.staves[i][j];
4165
4191
  const boundary = this.boundaries.get(i);
4166
4192
  if (boundary === null || boundary === void 0 ? void 0 : boundary.repeatStart)
4167
- stave.setBegBarType(_stavebarline__WEBPACK_IMPORTED_MODULE_10__.BarlineType.REPEAT_BEGIN);
4193
+ stave.setBegBarType(_stavebarline__WEBPACK_IMPORTED_MODULE_11__.BarlineType.REPEAT_BEGIN);
4168
4194
  if (boundary === null || boundary === void 0 ? void 0 : boundary.repeatEnd)
4169
- stave.setEndBarType(_stavebarline__WEBPACK_IMPORTED_MODULE_10__.BarlineType.REPEAT_END);
4195
+ stave.setEndBarType(_stavebarline__WEBPACK_IMPORTED_MODULE_11__.BarlineType.REPEAT_END);
4170
4196
  const start = [], end = [];
4171
- const present = (category) => stave.getModifiers(_stavemodifier__WEBPACK_IMPORTED_MODULE_12__.StaveModifierPosition.BEGIN, category).length > 0;
4172
- if (!present(_clef__WEBPACK_IMPORTED_MODULE_1__.Clef.CATEGORY))
4173
- start.push(new _clef__WEBPACK_IMPORTED_MODULE_1__.Clef(state.clef));
4174
- if (state.clef !== 'tab' && state.key !== 'C' && !present(_keysignature__WEBPACK_IMPORTED_MODULE_7__.KeySignature.CATEGORY))
4175
- start.push(new _keysignature__WEBPACK_IMPORTED_MODULE_7__.KeySignature(state.key));
4197
+ const present = (category) => stave.getModifiers(_stavemodifier__WEBPACK_IMPORTED_MODULE_13__.StaveModifierPosition.BEGIN, category).length > 0;
4198
+ if (!present(_clef__WEBPACK_IMPORTED_MODULE_2__.Clef.CATEGORY))
4199
+ start.push(new _clef__WEBPACK_IMPORTED_MODULE_2__.Clef(state.clef));
4200
+ if (state.clef !== 'tab' && state.key !== 'C' && !present(_keysignature__WEBPACK_IMPORTED_MODULE_8__.KeySignature.CATEGORY))
4201
+ start.push(new _keysignature__WEBPACK_IMPORTED_MODULE_8__.KeySignature(state.key));
4176
4202
  // Meter is carried silently at a repeated row start. Explicit changes remain native modifiers.
4177
4203
  const next = (_a = starts[i + 1]) === null || _a === void 0 ? void 0 : _a[j], current = ends[i][j];
4178
4204
  if (next && this.options.courtesy !== false) {
4179
4205
  if (next.clef !== current.clef)
4180
- end.push(new _clef__WEBPACK_IMPORTED_MODULE_1__.Clef(next.clef, 'small'));
4206
+ end.push(new _clef__WEBPACK_IMPORTED_MODULE_2__.Clef(next.clef, 'small'));
4181
4207
  if (next.clef !== 'tab' && next.key !== current.key)
4182
- end.push(new _keysignature__WEBPACK_IMPORTED_MODULE_7__.KeySignature(next.key, current.key));
4183
- if (next.time !== current.time)
4184
- end.push(new _timesignature__WEBPACK_IMPORTED_MODULE_17__.TimeSignature(next.time));
4208
+ end.push(new _keysignature__WEBPACK_IMPORTED_MODULE_8__.KeySignature(next.key, current.key));
4209
+ if (next.showTimeSignature && next.time !== current.time)
4210
+ end.push(new _timesignature__WEBPACK_IMPORTED_MODULE_18__.TimeSignature(next.time));
4185
4211
  }
4186
- end.forEach((m) => m.setPosition(_stavemodifier__WEBPACK_IMPORTED_MODULE_12__.StaveModifierPosition.END));
4212
+ end.forEach((m) => m.setPosition(_stavemodifier__WEBPACK_IMPORTED_MODULE_13__.StaveModifierPosition.END));
4187
4213
  return { start, end };
4188
4214
  }));
4189
4215
  const locations = new Map();
4190
4216
  score.notes.forEach((parts, measure) => parts.flat(2).forEach((n) => {
4191
- if (n instanceof _note__WEBPACK_IMPORTED_MODULE_9__.Note)
4217
+ if (n instanceof _note__WEBPACK_IMPORTED_MODULE_10__.Note)
4192
4218
  locations.set(n, { note: n, measure, staff: score.staves[measure].indexOf(n.checkStave()) });
4193
4219
  }));
4194
4220
  const seen = new Set();
4195
4221
  const onset = (n) => {
4196
- const time = new _fraction__WEBPACK_IMPORTED_MODULE_5__.Fraction(0, 1);
4222
+ const time = new _fraction__WEBPACK_IMPORTED_MODULE_6__.Fraction(0, 1);
4197
4223
  for (const tick of n.getVoice().getTickables()) {
4198
4224
  if (tick === n)
4199
4225
  break;
@@ -4216,8 +4242,8 @@ class ContinuousLayout {
4216
4242
  !b ||
4217
4243
  a.measure !== b.measure ||
4218
4244
  a.staff >= b.staff ||
4219
- !(a.note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_13__.StaveNote) ||
4220
- !(b.note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_13__.StaveNote) ||
4245
+ !(a.note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_14__.StaveNote) ||
4246
+ !(b.note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_14__.StaveNote) ||
4221
4247
  a.note.isRest() ||
4222
4248
  b.note.isRest() ||
4223
4249
  !['h', 'q', '2', '4'].includes(a.note.getDuration()) ||
@@ -4252,8 +4278,11 @@ class ContinuousLayout {
4252
4278
  !last ||
4253
4279
  first.measure > last.measure)
4254
4280
  invalid('Expected a unique span ID and ordered composition anchors.');
4281
+ let spec = Object.assign({}, span);
4282
+ if (span.string !== undefined && !(span.kind === 'tie' && first.note instanceof _tabnote__WEBPACK_IMPORTED_MODULE_17__.TabNote))
4283
+ invalid('A string selector requires a tab tie.');
4255
4284
  if (span.kind === 'palmMute') {
4256
- if (!(first.note instanceof _tabnote__WEBPACK_IMPORTED_MODULE_16__.TabNote) || !(last.note instanceof _tabnote__WEBPACK_IMPORTED_MODULE_16__.TabNote) || first.staff !== last.staff)
4285
+ if (!(first.note instanceof _tabnote__WEBPACK_IMPORTED_MODULE_17__.TabNote) || !(last.note instanceof _tabnote__WEBPACK_IMPORTED_MODULE_17__.TabNote) || first.staff !== last.staff)
4257
4286
  invalid('A palm mute needs two TAB anchors on the same staff.');
4258
4287
  if (!((_g = span.strings) === null || _g === void 0 ? void 0 : _g.length) ||
4259
4288
  new Set(span.strings).size !== span.strings.length ||
@@ -4262,9 +4291,21 @@ class ContinuousLayout {
4262
4291
  for (const note of [first.note, last.note])
4263
4292
  if (!note.getPositions().some((p) => span.strings.includes(p.str)))
4264
4293
  invalid('Each palm-mute anchor must play a targeted string.');
4294
+ spec.strings = [...span.strings];
4295
+ }
4296
+ else if (first.note instanceof _tabnote__WEBPACK_IMPORTED_MODULE_17__.TabNote && last.note instanceof _tabnote__WEBPACK_IMPORTED_MODULE_17__.TabNote) {
4297
+ if (first.staff !== last.staff || (span.kind !== 'tie' && span.kind !== 'volta'))
4298
+ invalid('Tab ties and endings need anchors on the same tab staff.');
4299
+ if (span.kind === 'tie') {
4300
+ spec = resolveTabTie(span, first.note, last.note);
4301
+ if (first.measure !== last.measure && onset(last.note).numerator === 0) {
4302
+ const stave = last.note.checkStave();
4303
+ this.tabTiePadding.set(stave, stave.space(1.5));
4304
+ }
4305
+ }
4265
4306
  }
4266
4307
  else {
4267
- if (!(first.note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_13__.StaveNote) || !(last.note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_13__.StaveNote))
4308
+ if (!(first.note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_14__.StaveNote) || !(last.note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_14__.StaveNote))
4268
4309
  invalid('Continuous spans need staff-note anchors.');
4269
4310
  for (const [head, n] of [
4270
4311
  [(_h = span.fromHead) !== null && _h !== void 0 ? _h : 0, first.note],
@@ -4275,7 +4316,15 @@ class ContinuousLayout {
4275
4316
  }
4276
4317
  if (first.measure === last.measure && onset(first.note).greaterThan(onset(last.note)))
4277
4318
  invalid('Reversed span.');
4278
- if (span.kind === 'tie' && first.measure !== last.measure) {
4319
+ if (span.syllableId !== undefined &&
4320
+ (typeof span.syllableId !== 'string' ||
4321
+ span.syllableId.length === 0 ||
4322
+ span.kind !== 'lyric' ||
4323
+ first.staff !== last.staff ||
4324
+ span.text !== undefined ||
4325
+ span.labelFontSize !== undefined))
4326
+ invalid('An anchored lyric extender needs a syllable ID and two notes on the same staff. Its annotation supplies the text and font.');
4327
+ if (span.kind === 'tie' && first.note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_14__.StaveNote && first.measure !== last.measure) {
4279
4328
  const fi = (_k = span.fromHead) !== null && _k !== void 0 ? _k : 0, li = (_l = span.toHead) !== null && _l !== void 0 ? _l : 0;
4280
4329
  if (first.note.getKeys()[fi].toLowerCase() !== last.note.getKeys()[li].toLowerCase())
4281
4330
  invalid('Tied heads must have the same written pitch.');
@@ -4289,8 +4338,7 @@ class ContinuousLayout {
4289
4338
  }
4290
4339
  }
4291
4340
  seen.add(span.id);
4292
- const spec = span.kind === 'palmMute' ? Object.assign(Object.assign({}, span), { strings: [...span.strings] }) : Object.assign({}, span);
4293
- this.spans.push({ spec, first, last, label: (0,_continuousspan__WEBPACK_IMPORTED_MODULE_2__.spanLabel)(spec) });
4341
+ this.spans.push({ spec, first, last, label: (0,_continuousspan__WEBPACK_IMPORTED_MODULE_3__.spanLabel)(spec) });
4294
4342
  }
4295
4343
  }
4296
4344
  /** Only undecorated, wholly resting measures can disappear into a numbered rest. */
@@ -4303,11 +4351,16 @@ class ContinuousLayout {
4303
4351
  return false;
4304
4352
  if (this.score.staves[i].some((s) => s
4305
4353
  .getModifiers()
4306
- .some((m) => !(m instanceof _stavebarline__WEBPACK_IMPORTED_MODULE_10__.Barline) || ![_stavebarline__WEBPACK_IMPORTED_MODULE_10__.BarlineType.SINGLE, _stavebarline__WEBPACK_IMPORTED_MODULE_10__.BarlineType.NONE].includes(m.getType()))))
4354
+ .some((m) => !(m instanceof _stavebarline__WEBPACK_IMPORTED_MODULE_11__.Barline) || ![_stavebarline__WEBPACK_IMPORTED_MODULE_11__.BarlineType.SINGLE, _stavebarline__WEBPACK_IMPORTED_MODULE_11__.BarlineType.NONE].includes(m.getType()))))
4307
4355
  return false;
4308
4356
  return this.score.notes[i]
4309
4357
  .flat(2)
4310
- .every((n) => n instanceof _stavenote__WEBPACK_IMPORTED_MODULE_13__.StaveNote && n.isRest() && !n.getModifiers().length && !n.getBeam() && !n.getTupletStack().length);
4358
+ .every((n) => n instanceof _stavenote__WEBPACK_IMPORTED_MODULE_14__.StaveNote &&
4359
+ n.isRest() &&
4360
+ n.restLine === undefined &&
4361
+ !n.getModifiers().length &&
4362
+ !n.getBeam() &&
4363
+ !n.getTupletStack().length);
4311
4364
  }
4312
4365
  /** Add cached signs for the candidate boundaries and reserve actual end-modifier width. */
4313
4366
  boundaryWidth(i, start, end) {
@@ -4324,8 +4377,8 @@ class ContinuousLayout {
4324
4377
  return Math.max(...staves.map((s, j) => {
4325
4378
  var _a, _b;
4326
4379
  const marks = this.marks[i][j];
4327
- s.setBoundaryModifiers([...(start ? marks.start : []), ...(end ? marks.end : [])]);
4328
- const bar = s.getModifiers(_stavemodifier__WEBPACK_IMPORTED_MODULE_12__.StaveModifierPosition.END, _stavebarline__WEBPACK_IMPORTED_MODULE_10__.Barline.CATEGORY)[0];
4380
+ s.setBoundaryModifiers([...(start ? marks.start : []), ...(end ? marks.end : [])], start ? this.tabTiePadding.get(s) : 0);
4381
+ const bar = s.getModifiers(_stavemodifier__WEBPACK_IMPORTED_MODULE_13__.StaveModifierPosition.END, _stavebarline__WEBPACK_IMPORTED_MODULE_11__.Barline.CATEGORY)[0];
4329
4382
  return Math.max(s.getX() + s.getWidth() - s.getNoteEndX(), -((_b = (_a = bar === null || bar === void 0 ? void 0 : bar.getLayoutMetrics()) === null || _a === void 0 ? void 0 : _a.xMin) !== null && _b !== void 0 ? _b : 0));
4330
4383
  }));
4331
4384
  }
@@ -4391,7 +4444,8 @@ class ContinuousLayout {
4391
4444
  const used = new Set();
4392
4445
  for (let i = first; i <= last; i++) {
4393
4446
  this.score.notes[i].flat(2).forEach((n) => {
4394
- if (n instanceof _note__WEBPACK_IMPORTED_MODULE_9__.Note && (!(n instanceof _stavenote__WEBPACK_IMPORTED_MODULE_13__.StaveNote) || !n.isRest() || n.getModifiers().length))
4447
+ if (n instanceof _note__WEBPACK_IMPORTED_MODULE_10__.Note &&
4448
+ (!(n instanceof _stavenote__WEBPACK_IMPORTED_MODULE_14__.StaveNote) || !n.isRest() || n.restLine !== undefined || n.getModifiers().length))
4395
4449
  used.add(this.score.staves[i].indexOf(n.checkStave()));
4396
4450
  });
4397
4451
  }
@@ -4419,13 +4473,24 @@ class ContinuousLayout {
4419
4473
  }
4420
4474
  format(options) {
4421
4475
  var _a;
4476
+ // A verse can be attached after composition. Resolve its current mark before every reflow.
4477
+ for (const span of this.spans) {
4478
+ if (!span.spec.syllableId)
4479
+ continue;
4480
+ const matches = span.first.note
4481
+ .getModifiers()
4482
+ .filter((m) => m instanceof _annotation__WEBPACK_IMPORTED_MODULE_1__.Annotation && m.getAttribute('id') === span.spec.syllableId);
4483
+ if (matches.length !== 1)
4484
+ invalid('Expected one lyric annotation on the source note: ' + span.spec.syllableId);
4485
+ span.syllable = matches[0];
4486
+ }
4422
4487
  this.hidden.clear();
4423
4488
  this.diagnostics.length = 0;
4424
4489
  this.fragments.length = 0;
4425
4490
  this.rows.length = 0;
4426
4491
  this.drawing = [];
4427
4492
  const units = this.units(options.measurePadding);
4428
- const groups = (0,_systembreaks__WEBPACK_IMPORTED_MODULE_15__.chooseSystemBreaks)(units, options.width, options.measureGap, (i) => this.indent(units[i].first), (_a = this.options.mode) !== null && _a !== void 0 ? _a : 'balanced');
4493
+ const groups = (0,_systembreaks__WEBPACK_IMPORTED_MODULE_16__.chooseSystemBreaks)(units, options.width, options.measureGap, (i) => this.indent(units[i].first), (_a = this.options.mode) !== null && _a !== void 0 ? _a : 'balanced');
4429
4494
  let y = options.y;
4430
4495
  for (const indices of groups) {
4431
4496
  const row = this.layoutRow(indices.map((i) => units[i]), options, y);
@@ -4439,7 +4504,7 @@ class ContinuousLayout {
4439
4504
  for (const f of parts) {
4440
4505
  f.progress = [prior / total, (prior + f.x2 - f.x1) / total];
4441
4506
  prior += f.x2 - f.x1;
4442
- this.drawing.push((ctx) => (0,_continuousspan__WEBPACK_IMPORTED_MODULE_2__.drawSpan)(ctx, f, s.label));
4507
+ this.drawing.push((ctx) => (0,_continuousspan__WEBPACK_IMPORTED_MODULE_3__.drawSpan)(ctx, f, s.label));
4443
4508
  }
4444
4509
  }
4445
4510
  return this.rows;
@@ -4458,9 +4523,9 @@ class ContinuousLayout {
4458
4523
  };
4459
4524
  take(stave.getYForLine(0) - stave.space(1.6), stave.getYForLine(stave.getNumLines() - 1) + stave.space(1.6));
4460
4525
  for (const m of stave.getModifiers()) {
4461
- const boxes = m instanceof _clef__WEBPACK_IMPORTED_MODULE_1__.Clef || m instanceof _timesignature__WEBPACK_IMPORTED_MODULE_17__.TimeSignature
4526
+ const boxes = m instanceof _clef__WEBPACK_IMPORTED_MODULE_2__.Clef || m instanceof _timesignature__WEBPACK_IMPORTED_MODULE_18__.TimeSignature
4462
4527
  ? [m.getInkBounds()]
4463
- : m instanceof _keysignature__WEBPACK_IMPORTED_MODULE_7__.KeySignature
4528
+ : m instanceof _keysignature__WEBPACK_IMPORTED_MODULE_8__.KeySignature
4464
4529
  ? m.getInkParts()
4465
4530
  : [];
4466
4531
  for (const box of boxes)
@@ -4468,15 +4533,15 @@ class ContinuousLayout {
4468
4533
  }
4469
4534
  if (u.first === u.last)
4470
4535
  for (const n of this.score.notes[u.first].flat(2)) {
4471
- if (n instanceof _tabnote__WEBPACK_IMPORTED_MODULE_16__.TabNote && n.getStave() === stave && n.hasStem()) {
4536
+ if (n instanceof _tabnote__WEBPACK_IMPORTED_MODULE_17__.TabNote && n.getStave() === stave && n.hasStem()) {
4472
4537
  const { topY, baseY } = n.getStemExtents();
4473
4538
  take(Math.min(topY, baseY), Math.max(topY, baseY));
4474
4539
  }
4475
- if (!(n instanceof _stavenote__WEBPACK_IMPORTED_MODULE_13__.StaveNote) || n.getStave() !== stave)
4540
+ if (!(n instanceof _stavenote__WEBPACK_IMPORTED_MODULE_14__.StaveNote) || n.getStave() !== stave)
4476
4541
  continue;
4477
4542
  const bridge = (_a = n
4478
4543
  .getBeam()) === null || _a === void 0 ? void 0 : _a.getNotes().some((p) => p.getStave() !== stave);
4479
- for (const box of bridge ? n.getHeadInk() : (0,_engravinggeometry__WEBPACK_IMPORTED_MODULE_4__.measureEngraving)(n).parts)
4544
+ for (const box of bridge ? n.getHeadInk() : (0,_engravinggeometry__WEBPACK_IMPORTED_MODULE_5__.measureEngraving)(n).parts)
4480
4545
  take(box.y, box.y + box.h);
4481
4546
  if (n.getBeam() && !bridge) {
4482
4547
  const box = n.getBeam().getBoundingBox();
@@ -4550,7 +4615,16 @@ class ContinuousLayout {
4550
4615
  for (const s of spans) {
4551
4616
  if (s.spec.kind === 'tie' || s.spec.kind === 'slur')
4552
4617
  continue;
4553
- const side = (0,_continuousspan__WEBPACK_IMPORTED_MODULE_2__.spanAbove)(s.spec), staff = s.first.staff, key = staff + '-' + side;
4618
+ if (s.syllable) {
4619
+ // A continuation row may have no sung words of its own. Include the extender in that staff's envelope.
4620
+ const stave = this.score.staves[first][s.first.staff];
4621
+ const relativeY = this.lyricBaseline(s.syllable, stave) - stave.getY();
4622
+ const bounds = ink[s.first.staff];
4623
+ bounds.top = Math.min(bounds.top, relativeY);
4624
+ bounds.bottom = Math.max(bounds.bottom, relativeY + 2);
4625
+ continue;
4626
+ }
4627
+ const side = (0,_continuousspan__WEBPACK_IMPORTED_MODULE_3__.spanAbove)(s.spec), staff = s.first.staff, key = staff + '-' + side;
4554
4628
  const ends = (_a = laneEnds.get(key)) !== null && _a !== void 0 ? _a : [];
4555
4629
  let lane = ends.findIndex((v) => v < s.first.measure);
4556
4630
  if (lane < 0)
@@ -4600,11 +4674,11 @@ class ContinuousLayout {
4600
4674
  if (chord.measure < first || chord.measure > last)
4601
4675
  continue;
4602
4676
  const a = chord.upper, b = chord.lower, x = a.getStemX(), top = Math.max(...a.getYs()), bottom = Math.min(...b.getYs());
4603
- if (Math.abs(x - b.getStemX()) > _stem__WEBPACK_IMPORTED_MODULE_14__.Stem.WIDTH)
4677
+ if (Math.abs(x - b.getStemX()) > _stem__WEBPACK_IMPORTED_MODULE_15__.Stem.WIDTH)
4604
4678
  this.diagnostics.push({ code: 'SplitStemAlignment', measures: [chord.measure + 1], source: chord.id });
4605
4679
  else
4606
4680
  this.drawing.push((ctx) => {
4607
- ctx.fillRect(x - _stem__WEBPACK_IMPORTED_MODULE_14__.Stem.WIDTH / 2, top, _stem__WEBPACK_IMPORTED_MODULE_14__.Stem.WIDTH, bottom - top);
4681
+ ctx.fillRect(x - _stem__WEBPACK_IMPORTED_MODULE_15__.Stem.WIDTH / 2, top, _stem__WEBPACK_IMPORTED_MODULE_15__.Stem.WIDTH, bottom - top);
4608
4682
  });
4609
4683
  }
4610
4684
  for (const s of spans) {
@@ -4612,35 +4686,61 @@ class ContinuousLayout {
4612
4686
  const lane = (_b = lanes.get(s)) !== null && _b !== void 0 ? _b : 0;
4613
4687
  const yBase = origin +
4614
4688
  offsets[staff] +
4615
- ((0,_continuousspan__WEBPACK_IMPORTED_MODULE_2__.spanAbove)(s.spec) ? ink[staff].top - lane * 25 - 4 : ink[staff].bottom + lane * 25 + 14);
4689
+ ((0,_continuousspan__WEBPACK_IMPORTED_MODULE_3__.spanAbove)(s.spec) ? ink[staff].top - lane * 25 - 4 : ink[staff].bottom + lane * 25 + 14);
4616
4690
  this.addFragment(s, units, row, yBase);
4617
4691
  }
4618
4692
  return row;
4619
4693
  }
4694
+ /** Carry the source syllable's distance from its top staff line to each continuation. */
4695
+ lyricBaseline(word, stave) {
4696
+ const source = word.checkAttachedNote().checkStave();
4697
+ const spaces = (word.computeY().y + word.getYShift() - source.getYForLine(0)) / source.space(1);
4698
+ return stave.getYForLine(0) + stave.space(spaces);
4699
+ }
4620
4700
  /** Keep continuation hooks and labels on the correct end when a span crosses a row. */
4621
4701
  addFragment(s, units, row, baseline) {
4622
- var _a, _b;
4702
+ var _a, _b, _c;
4623
4703
  const first = units[0].first, last = units[units.length - 1].first;
4624
4704
  const starts = s.first.measure >= first, ends = s.last.measure <= units[units.length - 1].last;
4625
- const { kind } = s.spec, above = (0,_continuousspan__WEBPACK_IMPORTED_MODULE_2__.spanAbove)(s.spec);
4705
+ const { kind } = s.spec, above = (0,_continuousspan__WEBPACK_IMPORTED_MODULE_3__.spanAbove)(s.spec);
4626
4706
  const startStaff = this.score.staves[first][s.first.staff], endStaff = this.score.staves[last][ends ? s.last.staff : s.first.staff];
4627
4707
  const space = startStaff.space(1), sign = above ? -1 : 1;
4628
4708
  let x1 = starts ? s.first.note.getAbsoluteX() : startStaff.getNoteStartX() + 2;
4629
4709
  let x2 = ends ? s.last.note.getAbsoluteX() + s.last.note.getGlyphWidth() : endStaff.getNoteEndX() - 3;
4630
4710
  let y1 = baseline, y2 = baseline;
4711
+ if (s.syllable) {
4712
+ y1 = y2 = this.lyricBaseline(s.syllable, startStaff);
4713
+ if (starts) {
4714
+ const ink = s.syllable.getTextInk(s.syllable.computeX().x, s.syllable.computeY().y);
4715
+ x1 = ink.x + ink.w + space * 0.35;
4716
+ }
4717
+ if (ends)
4718
+ x2 = s.last.note.getNoteHeadBeginX() + s.last.note.getGlyphWidth();
4719
+ }
4631
4720
  if (kind === 'tie' || kind === 'slur') {
4632
4721
  if (starts)
4633
4722
  x1 = s.first.note.getTieRightX();
4634
4723
  if (ends)
4635
4724
  x2 = s.last.note.getTieLeftX();
4636
- y1 =
4637
- (starts
4638
- ? s.first.note.getYs()[(_a = s.spec.fromHead) !== null && _a !== void 0 ? _a : 0]
4639
- : (0,_continuousspan__WEBPACK_IMPORTED_MODULE_2__.continuationPitch)(s.first, startStaff, s.spec.fromHead)) +
4640
- sign * space * (starts ? 0.5 : 1.1);
4641
- y2 =
4642
- (ends ? s.last.note.getYs()[(_b = s.spec.toHead) !== null && _b !== void 0 ? _b : 0] : (0,_continuousspan__WEBPACK_IMPORTED_MODULE_2__.continuationPitch)(s.last, endStaff, s.spec.toHead)) +
4643
- sign * space * (ends ? 0.5 : 1.1);
4725
+ if (s.spec.string !== undefined) {
4726
+ // Follow the same physical string at both row edges, with clearance for the fret numbers.
4727
+ if (!starts)
4728
+ x1 -= (_a = this.tabTiePadding.get(startStaff)) !== null && _a !== void 0 ? _a : 0;
4729
+ const line = s.spec.string - 1;
4730
+ const clearance = sign * space * 0.3;
4731
+ y1 = (starts ? s.first.note.checkStave() : startStaff).getYForLine(line) + clearance;
4732
+ y2 = (ends ? s.last.note.checkStave() : endStaff).getYForLine(line) + clearance;
4733
+ }
4734
+ else {
4735
+ y1 =
4736
+ (starts
4737
+ ? s.first.note.getYs()[(_b = s.spec.fromHead) !== null && _b !== void 0 ? _b : 0]
4738
+ : (0,_continuousspan__WEBPACK_IMPORTED_MODULE_3__.continuationPitch)(s.first, startStaff, s.spec.fromHead)) +
4739
+ sign * space * (starts ? 0.5 : 1.1);
4740
+ y2 =
4741
+ (ends ? s.last.note.getYs()[(_c = s.spec.toHead) !== null && _c !== void 0 ? _c : 0] : (0,_continuousspan__WEBPACK_IMPORTED_MODULE_3__.continuationPitch)(s.last, endStaff, s.spec.toHead)) +
4742
+ sign * space * (ends ? 0.5 : 1.1);
4743
+ }
4644
4744
  }
4645
4745
  if (kind === 'volta') {
4646
4746
  x1 = starts ? this.score.staves[s.first.measure][s.first.staff].getX() + 1 : startStaff.getX() + 1;
@@ -4660,19 +4760,19 @@ class ContinuousLayout {
4660
4760
  const fragment = Object.assign(Object.assign({ id: s.spec.id, kind, row: this.rows.length, part: starts ? (ends ? 'single' : 'first') : ends ? 'last' : 'middle', x1,
4661
4761
  x2,
4662
4762
  y1,
4663
- y2, progress: [0, 1] }, (kind === 'palmMute' && Object.assign(Object.assign({ strings: s.spec.strings }, (starts && { from: s.spec.from })), (ends && { to: s.spec.to })))), { above,
4763
+ y2, progress: [0, 1] }, ((kind === 'palmMute' || s.spec.string !== undefined) && Object.assign(Object.assign({ strings: s.spec.string !== undefined ? [s.spec.string] : s.spec.strings }, (starts && { from: s.spec.from })), (ends && { to: s.spec.to })))), { above,
4664
4764
  space });
4665
4765
  if (kind === 'tie' || kind === 'slur') {
4666
4766
  const events = units.flatMap((u) => {
4667
4767
  const staves = this.score.staves[u.first];
4668
4768
  return this.score.notes[u.first]
4669
4769
  .flat(2)
4670
- .filter((n) => n instanceof _stavenote__WEBPACK_IMPORTED_MODULE_13__.StaveNote &&
4770
+ .filter((n) => n instanceof _stavenote__WEBPACK_IMPORTED_MODULE_14__.StaveNote &&
4671
4771
  (n.getStave() === staves[s.first.staff] || n.getStave() === staves[s.last.staff]));
4672
4772
  });
4673
4773
  const obstacles = events
4674
4774
  .filter((n) => n !== s.first.note && n !== s.last.note)
4675
- .flatMap((n) => (0,_engravinggeometry__WEBPACK_IMPORTED_MODULE_4__.measureEngraving)(n).parts);
4775
+ .flatMap((n) => (0,_engravinggeometry__WEBPACK_IMPORTED_MODULE_5__.measureEngraving)(n).parts);
4676
4776
  if (kind === 'slur') {
4677
4777
  const endpoint = (n, y) => n.hasStem() && n.getStemDirection() === -sign ? n.getStemExtents().topY + sign * space * 0.4 : y;
4678
4778
  if (starts)
@@ -4688,7 +4788,7 @@ class ContinuousLayout {
4688
4788
  if (!ends)
4689
4789
  fragment.y2 = edge;
4690
4790
  }
4691
- if (!(0,_continuousspan__WEBPACK_IMPORTED_MODULE_2__.fitSpan)(fragment, obstacles))
4791
+ if (!(0,_continuousspan__WEBPACK_IMPORTED_MODULE_3__.fitSpan)(fragment, obstacles))
4692
4792
  this.diagnostics.push({ code: 'CurveCollision', measures: row.measures, source: s.spec.id });
4693
4793
  }
4694
4794
  this.fragments.push(fragment);
@@ -4708,12 +4808,12 @@ class ContinuousLayout {
4708
4808
  if (members.length < 2)
4709
4809
  continue;
4710
4810
  const top = members[0], bottom = members[members.length - 1];
4711
- const connector = new _staveconnector__WEBPACK_IMPORTED_MODULE_11__.StaveConnector(head[top], head[bottom]).setType(g.type).setXShift(-index * 8);
4811
+ const connector = new _staveconnector__WEBPACK_IMPORTED_MODULE_12__.StaveConnector(head[top], head[bottom]).setType(g.type).setXShift(-index * 8);
4712
4812
  this.drawing.push((ctx) => connector.setContext(ctx).drawWithStyle());
4713
4813
  if (g.barlines)
4714
4814
  for (const u of units) {
4715
4815
  const staves = this.score.staves[u.first];
4716
- const line = new _staveconnector__WEBPACK_IMPORTED_MODULE_11__.StaveConnector(staves[top], staves[bottom]).setType('singleRight');
4816
+ const line = new _staveconnector__WEBPACK_IMPORTED_MODULE_12__.StaveConnector(staves[top], staves[bottom]).setType('singleRight');
4717
4817
  this.drawing.push((ctx) => line.setContext(ctx).drawWithStyle());
4718
4818
  }
4719
4819
  }
@@ -4735,7 +4835,7 @@ class ContinuousLayout {
4735
4835
  }
4736
4836
  if (u.last > u.first)
4737
4837
  for (const j of visible) {
4738
- const count = u.last - u.first + 1, rest = new _multimeasurerest__WEBPACK_IMPORTED_MODULE_8__.MultiMeasureRest(count, { numberOfMeasures: count }).setStave(staves[j]);
4838
+ const count = u.last - u.first + 1, rest = new _multimeasurerest__WEBPACK_IMPORTED_MODULE_9__.MultiMeasureRest(count, { numberOfMeasures: count }).setStave(staves[j]);
4739
4839
  this.drawing.push((ctx) => rest.setContext(ctx).drawWithStyle());
4740
4840
  }
4741
4841
  }
@@ -4777,7 +4877,15 @@ function spanLabel(spec) {
4777
4877
  const text = (_b = (_a = spec.text) !== null && _a !== void 0 ? _a : (spec.kind === 'palmMute' ? 'P.M. ' + spec.strings.join(',') : undefined)) !== null && _b !== void 0 ? _b : { volta: '1.', ottava: '8va', trill: _glyphs__WEBPACK_IMPORTED_MODULE_1__.Glyphs.ornamentTrill, tuplet: '3' }[spec.kind];
4778
4878
  if (!text)
4779
4879
  return;
4780
- return new _element__WEBPACK_IMPORTED_MODULE_0__.Element(spec.kind === 'trill' ? 'Ornament' : 'Annotation').setText(text);
4880
+ let category = 'Annotation';
4881
+ if (spec.kind === 'trill')
4882
+ category = 'Ornament';
4883
+ if (spec.kind === 'lyric' || spec.kind === 'hyphen')
4884
+ category = 'Annotation.lyric';
4885
+ const label = new _element__WEBPACK_IMPORTED_MODULE_0__.Element(category).setText(text);
4886
+ if (spec.labelFontSize !== undefined)
4887
+ label.setFontSize(spec.labelFontSize);
4888
+ return label;
4781
4889
  }
4782
4890
  function spanAbove(span) {
4783
4891
  return span.side ? span.side === 'above' : ['slur', 'volta', 'ottava', 'trill', 'tuplet'].includes(span.kind);
@@ -6428,15 +6536,19 @@ __webpack_require__.r(__webpack_exports__);
6428
6536
  /* harmony export */ compose: () => (/* binding */ compose)
6429
6537
  /* harmony export */ });
6430
6538
  /* harmony import */ var _continuouslayout__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../continuouslayout */ "./src/continuouslayout.ts");
6431
- /* harmony import */ var _factory__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../factory */ "./src/factory.ts");
6432
- /* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../fraction */ "./src/fraction.ts");
6433
- /* harmony import */ var _modifier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../modifier */ "./src/modifier.ts");
6434
- /* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../note */ "./src/note.ts");
6435
- /* harmony import */ var _stemmablenote__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../stemmablenote */ "./src/stemmablenote.ts");
6436
- /* harmony import */ var _tickable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../tickable */ "./src/tickable.ts");
6437
- /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../util */ "./src/util.ts");
6438
- /* harmony import */ var _voice__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../voice */ "./src/voice.ts");
6439
- /* harmony import */ var _policies__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./policies */ "./src/easyscore/policies.ts");
6539
+ /* harmony import */ var _dot__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../dot */ "./src/dot.ts");
6540
+ /* harmony import */ var _factory__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../factory */ "./src/factory.ts");
6541
+ /* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../fraction */ "./src/fraction.ts");
6542
+ /* harmony import */ var _metrics__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../metrics */ "./src/metrics.ts");
6543
+ /* harmony import */ var _modifier__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../modifier */ "./src/modifier.ts");
6544
+ /* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../note */ "./src/note.ts");
6545
+ /* harmony import */ var _stavebarline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../stavebarline */ "./src/stavebarline.ts");
6546
+ /* harmony import */ var _stavenote__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../stavenote */ "./src/stavenote.ts");
6547
+ /* harmony import */ var _stemmablenote__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../stemmablenote */ "./src/stemmablenote.ts");
6548
+ /* harmony import */ var _tickable__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../tickable */ "./src/tickable.ts");
6549
+ /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../util */ "./src/util.ts");
6550
+ /* harmony import */ var _voice__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../voice */ "./src/voice.ts");
6551
+ /* harmony import */ var _policies__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./policies */ "./src/easyscore/policies.ts");
6440
6552
  var __rest = (undefined && undefined.__rest) || function (s, e) {
6441
6553
  var t = {};
6442
6554
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -6458,6 +6570,10 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
6458
6570
 
6459
6571
 
6460
6572
 
6573
+
6574
+
6575
+
6576
+
6461
6577
  /** Construct and validate the host's complete grace group inside the composition transaction. */
6462
6578
  function buildGraceGroup(score, { side, notes, slur, beam }) {
6463
6579
  if (!['before', 'after'].includes(side) || !notes.length)
@@ -6474,18 +6590,18 @@ function buildGraceGroup(score, { side, notes, slur, beam }) {
6474
6590
  return child;
6475
6591
  });
6476
6592
  const group = score.make.graceNoteGroup({ notes: children, slur });
6477
- group.setPosition(side === 'after' ? _modifier__WEBPACK_IMPORTED_MODULE_3__.Modifier.Position.RIGHT : _modifier__WEBPACK_IMPORTED_MODULE_3__.Modifier.Position.LEFT);
6593
+ group.setPosition(side === 'after' ? _modifier__WEBPACK_IMPORTED_MODULE_5__.Modifier.Position.RIGHT : _modifier__WEBPACK_IMPORTED_MODULE_5__.Modifier.Position.LEFT);
6478
6594
  if (beam)
6479
6595
  group.beamNotes();
6480
6596
  return group;
6481
6597
  }
6482
6598
  /** Fail with a consistent construction error before drawing. */
6483
6599
  function invalid(message) {
6484
- throw new _util__WEBPACK_IMPORTED_MODULE_7__.RuntimeError('BadComposition', message);
6600
+ throw new _util__WEBPACK_IMPORTED_MODULE_11__.RuntimeError('BadComposition', message);
6485
6601
  }
6486
6602
  /** Return exact native ticks for a declared meter, including a pickup span. */
6487
6603
  function ticksFor(time) {
6488
- return new _voice__WEBPACK_IMPORTED_MODULE_8__.Voice(time).getTotalTicks().clone();
6604
+ return new _voice__WEBPACK_IMPORTED_MODULE_12__.Voice(time).getTotalTicks().clone();
6489
6605
  }
6490
6606
  /** Scope staff defaults and build one voice's notation, without assigning a Voice yet. */
6491
6607
  function buildVoice(score, spec, initial, display) {
@@ -6508,15 +6624,15 @@ function buildVoice(score, spec, initial, display) {
6508
6624
  generated.add(mark);
6509
6625
  });
6510
6626
  }
6511
- else if (item instanceof _tickable__WEBPACK_IMPORTED_MODULE_6__.Tickable) {
6512
- if (_factory__WEBPACK_IMPORTED_MODULE_1__.Factory.getOwner(item) !== score.factory)
6627
+ else if (item instanceof _tickable__WEBPACK_IMPORTED_MODULE_10__.Tickable) {
6628
+ if (_factory__WEBPACK_IMPORTED_MODULE_2__.Factory.getOwner(item) !== score.factory)
6513
6629
  invalid('Adopt native notes before composing them.');
6514
6630
  try {
6515
6631
  item.getVoice();
6516
6632
  invalid('Composition requires notes that are not already in a voice.');
6517
6633
  }
6518
6634
  catch (error) {
6519
- if (!(error instanceof _util__WEBPACK_IMPORTED_MODULE_7__.RuntimeError) || error.code !== 'NoVoice')
6635
+ if (!(error instanceof _util__WEBPACK_IMPORTED_MODULE_11__.RuntimeError) || error.code !== 'NoVoice')
6520
6636
  throw error;
6521
6637
  }
6522
6638
  notes.push(item);
@@ -6530,15 +6646,21 @@ function buildVoice(score, spec, initial, display) {
6530
6646
  notes.push(score.make.clefNote({ type: state.clef, options: { size: 'small' } }));
6531
6647
  if (item.change.key)
6532
6648
  notes.push(score.make.keySigNote({ key: state.key, cancelKey: previous.key, clef: state.clef }));
6533
- if (item.change.time)
6649
+ if (state.showTimeSignature && (item.change.time || !previous.showTimeSignature))
6534
6650
  notes.push(score.make.timeSigNote({ time: state.time }));
6535
6651
  }
6536
6652
  score.set({ clef: state.clef, time: state.time });
6537
6653
  }
6538
6654
  else {
6539
- const note = 'tab' in item
6655
+ const tab = 'tab' in item;
6656
+ const note = tab
6540
6657
  ? score.make.tabNote(item.tab, item.drawStem)
6541
6658
  : score.make.note('note' in item ? item.note : item);
6659
+ // Each pitched head gets its own dots. Rhythmic tab shares one set at the stem.
6660
+ if (!tab || item.drawStem) {
6661
+ for (let i = 0; i < note.writtenDots; i++)
6662
+ _dot__WEBPACK_IMPORTED_MODULE_1__.Dot.buildAndAttach([note], { all: !tab });
6663
+ }
6542
6664
  if ('grace' in item && item.grace) {
6543
6665
  score.attach(note, buildGraceGroup(score, item.grace), 0);
6544
6666
  }
@@ -6558,12 +6680,12 @@ function buildVoice(score, spec, initial, display) {
6558
6680
  group.start + group.count > timed.length)
6559
6681
  invalid('Tuplet range is outside its voice.');
6560
6682
  const members = timed.slice(group.start, group.start + group.count);
6561
- if (!members.every((note) => note instanceof _note__WEBPACK_IMPORTED_MODULE_4__.Note))
6683
+ if (!members.every((note) => note instanceof _note__WEBPACK_IMPORTED_MODULE_6__.Note))
6562
6684
  invalid('Tuplets require native notes.');
6563
6685
  score.make.tuplet({ notes: members, options: group.options });
6564
6686
  }
6565
6687
  if (spec.autoBeam) {
6566
- if (!timed.every((note) => note instanceof _stemmablenote__WEBPACK_IMPORTED_MODULE_5__.StemmableNote))
6688
+ if (!timed.every((note) => note instanceof _stemmablenote__WEBPACK_IMPORTED_MODULE_9__.StemmableNote))
6567
6689
  invalid('Automatic beams require stemmable notes.');
6568
6690
  score.set({ time: initial.time });
6569
6691
  score.autoBeam(timed, typeof spec.autoBeam === 'boolean' ? {} : spec.autoBeam);
@@ -6576,7 +6698,7 @@ function stateChanges(voice) {
6576
6698
  return voice.changes.map(({ index, state }) => ({
6577
6699
  at: voice.notes
6578
6700
  .slice(0, index)
6579
- .reduce((sum, note) => (note.shouldIgnoreTicks() ? sum : sum.add(note.getTicks())), new _fraction__WEBPACK_IMPORTED_MODULE_2__.Fraction(0, 1)),
6701
+ .reduce((sum, note) => (note.shouldIgnoreTicks() ? sum : sum.add(note.getTicks())), new _fraction__WEBPACK_IMPORTED_MODULE_3__.Fraction(0, 1)),
6580
6702
  state,
6581
6703
  }));
6582
6704
  }
@@ -6586,7 +6708,7 @@ function addSignatures(score, stave, state, previous) {
6586
6708
  score.attachToStave(stave, score.make.clef(state.clef));
6587
6709
  if (state.clef !== 'tab' && (!previous || previous.key !== state.key))
6588
6710
  score.attachToStave(stave, score.make.keySignature(state.key, previous === null || previous === void 0 ? void 0 : previous.key));
6589
- if (!previous || previous.time !== state.time)
6711
+ if (state.showTimeSignature && (!(previous === null || previous === void 0 ? void 0 : previous.showTimeSignature) || previous.time !== state.time))
6590
6712
  score.attachToStave(stave, score.make.timeSignature(state.time));
6591
6713
  }
6592
6714
  /** Resolve owned notes only after the entire composition is constructed. */
@@ -6615,19 +6737,71 @@ function buildSpans(score, spec, measures, diagnostics) {
6615
6737
  return score.make.hairpin({ from, to, type: span.type, options: span.options });
6616
6738
  });
6617
6739
  }
6740
+ /** Rebuild the same native chord and lyric lanes for screen systems and independent publication views. */
6741
+ function addLeadMarks(score, system, measure, voices) {
6742
+ var _a, _b, _c, _d, _e;
6743
+ if (!((_a = measure.chords) === null || _a === void 0 ? void 0 : _a.length) && !((_b = measure.verses) === null || _b === void 0 ? void 0 : _b.length))
6744
+ return;
6745
+ const members = new Set(voices.flat());
6746
+ const anchor = (id) => {
6747
+ const note = score.getNote(id);
6748
+ if (!members.has(note))
6749
+ invalid(`Lead mark anchor ${id} belongs to another staff or measure.`);
6750
+ return note;
6751
+ };
6752
+ const chordLanes = new Map();
6753
+ for (const chord of (_c = measure.chords) !== null && _c !== void 0 ? _c : []) {
6754
+ const note = anchor(chord.note);
6755
+ if (!chord.text)
6756
+ invalid('A chord label needs text.');
6757
+ const mark = score.make.annotation({ text: chord.text, vJustify: 'top', font: _metrics__WEBPACK_IMPORTED_MODULE_4__.Metrics.getFontInfo('ChordSymbol') });
6758
+ score.attach(note, mark);
6759
+ if (note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_8__.StaveNote) {
6760
+ const stave = note.checkStave();
6761
+ const lane = (_d = chordLanes.get(stave)) !== null && _d !== void 0 ? _d : [];
6762
+ lane.push(mark);
6763
+ chordLanes.set(stave, lane);
6764
+ }
6765
+ }
6766
+ for (const [stave, marks] of chordLanes)
6767
+ system.getPhraseLayout().addLane(stave, marks, { side: 'above' });
6768
+ const lyricAnchor = (id) => {
6769
+ const note = anchor(id);
6770
+ if (!(note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_8__.StaveNote))
6771
+ invalid('A lyric needs a pitched staff note.');
6772
+ return note;
6773
+ };
6774
+ for (const verse of (_e = measure.verses) !== null && _e !== void 0 ? _e : []) {
6775
+ if (!verse.length)
6776
+ invalid('A verse needs at least one syllable.');
6777
+ const syllables = verse.map(({ note, text, hyphenAfter, extendTo }) => ({
6778
+ note: lyricAnchor(note),
6779
+ text,
6780
+ hyphenAfter,
6781
+ extendTo: extendTo === undefined ? undefined : lyricAnchor(extendTo),
6782
+ }));
6783
+ system.getPhraseLayout().addVerse(syllables[0].note.checkStave(), syllables);
6784
+ }
6785
+ }
6786
+ /** Carry the previous written state through omitted measure fields. */
6787
+ function measureState(measure, previous) {
6788
+ var _a, _b, _c, _d;
6789
+ return {
6790
+ clef: (_a = measure.clef) !== null && _a !== void 0 ? _a : previous.clef,
6791
+ key: (_b = measure.key) !== null && _b !== void 0 ? _b : previous.key,
6792
+ time: (_c = measure.time) !== null && _c !== void 0 ? _c : previous.time,
6793
+ showTimeSignature: (_d = measure.showTimeSignature) !== null && _d !== void 0 ? _d : previous.showTimeSignature,
6794
+ };
6795
+ }
6618
6796
  /** Build one staff measure before joining it to the shared native System. */
6619
6797
  function buildStaffMeasure(score, spec, staff, index, previous, tracking) {
6620
- var _a, _b, _c, _d;
6798
+ var _a;
6621
6799
  const assignments = new Map();
6622
6800
  const measure = staff.measures[index];
6623
6801
  if (!measure.voices.length)
6624
6802
  invalid('Every stave measure needs at least one voice.');
6625
- const state = {
6626
- clef: (_a = measure.clef) !== null && _a !== void 0 ? _a : previous.clef,
6627
- key: (_b = measure.key) !== null && _b !== void 0 ? _b : previous.key,
6628
- time: (_c = measure.time) !== null && _c !== void 0 ? _c : previous.time,
6629
- };
6630
- const span = (_d = measure.span) !== null && _d !== void 0 ? _d : state.time;
6803
+ const state = measureState(measure, previous);
6804
+ const span = (_a = measure.span) !== null && _a !== void 0 ? _a : state.time;
6631
6805
  const ticks = ticksFor(span);
6632
6806
  const built = measure.voices.map((voice, voiceIndex) => buildVoice(score, voice, state, voiceIndex === 0));
6633
6807
  const changes = stateChanges(built[0]);
@@ -6635,14 +6809,14 @@ function buildStaffMeasure(score, spec, staff, index, previous, tracking) {
6635
6809
  for (const voice of built) {
6636
6810
  if (signature(stateChanges(voice)) !== signature(changes))
6637
6811
  invalid('Inline staff changes must agree in all voices.');
6638
- const actual = voice.notes.reduce((sum, note) => (note.shouldIgnoreTicks() ? sum : sum.add(note.getTicks())), new _fraction__WEBPACK_IMPORTED_MODULE_2__.Fraction(0, 1));
6812
+ const actual = voice.notes.reduce((sum, note) => (note.shouldIgnoreTicks() ? sum : sum.add(note.getTicks())), new _fraction__WEBPACK_IMPORTED_MODULE_3__.Fraction(0, 1));
6639
6813
  if (!actual.equals(ticks))
6640
6814
  invalid(`Measure ${index + 1} on ${staff.id} does not fill its declared span.`);
6641
6815
  for (const note of voice.notes) {
6642
6816
  if (tracking.seen.has(note))
6643
6817
  invalid('A note cannot belong to two composition voices.');
6644
6818
  tracking.seen.add(note);
6645
- if (note instanceof _note__WEBPACK_IMPORTED_MODULE_4__.Note)
6819
+ if (note instanceof _note__WEBPACK_IMPORTED_MODULE_6__.Note)
6646
6820
  tracking.noteMeasures.set(note, index);
6647
6821
  }
6648
6822
  voice.assignments.forEach((id, note) => assignments.set(note, id));
@@ -6663,6 +6837,13 @@ function buildStaffMeasure(score, spec, staff, index, previous, tracking) {
6663
6837
  const stave = staff.kind === 'tab'
6664
6838
  ? score.make.tabStave({ options: staff.options })
6665
6839
  : score.make.stave({ options: Object.assign(Object.assign({}, staff.options), { clef: state.clef }) });
6840
+ if (measure.endBarline !== undefined) {
6841
+ if (!Number.isInteger(measure.endBarline) ||
6842
+ !_stavebarline__WEBPACK_IMPORTED_MODULE_7__.BarlineType[measure.endBarline] ||
6843
+ measure.endBarline === _stavebarline__WEBPACK_IMPORTED_MODULE_7__.BarlineType.REPEAT_BEGIN)
6844
+ invalid('Invalid end barline.');
6845
+ stave.setEndBarType(measure.endBarline);
6846
+ }
6666
6847
  addSignatures(score, stave, state, index && spec.signatures !== 'every-measure' ? previous : undefined);
6667
6848
  return {
6668
6849
  stave,
@@ -6701,13 +6882,13 @@ function compose(score, spec) {
6701
6882
  for (const voice of measure.voices)
6702
6883
  if (typeof voice.notes !== 'string')
6703
6884
  for (const item of voice.notes)
6704
- if (item instanceof _note__WEBPACK_IMPORTED_MODULE_4__.Note)
6885
+ if (item instanceof _note__WEBPACK_IMPORTED_MODULE_6__.Note)
6705
6886
  nativeInputs.push(item);
6706
6887
  if (nativeInputs.length &&
6707
6888
  (spec.accidentals === 'key-aware' ||
6708
6889
  spec.staves.some((stave) => stave.measures.some((measure) => measure.voices.some((voice) => { var _a; return voice.autoBeam || ((_a = voice.tuplets) === null || _a === void 0 ? void 0 : _a.length); })))))
6709
6890
  invalid('Apply rhythm and accidental policies before adopting native inputs, or use typed note descriptions.');
6710
- const priorStaves = new Map(nativeInputs.map((note) => [note, note.getStave()]));
6891
+ const priorNative = new Map(nativeInputs.map((note) => [note, { stave: note.getStave(), modifiers: note.getModifiers().length }]));
6711
6892
  // Avoid assigning the same note to more than one voice, even when references are supplied directly.
6712
6893
  const seen = new Set();
6713
6894
  try {
@@ -6729,22 +6910,19 @@ function compose(score, spec) {
6729
6910
  message: 'Signatures appear at the first measure and explicit changes. Sheet does not repeat them at wrapped row starts.',
6730
6911
  });
6731
6912
  const states = spec.staves.map((stave) => {
6732
- var _a, _b, _c;
6913
+ var _a, _b, _c, _d;
6733
6914
  return ({
6734
6915
  clef: (_a = stave.clef) !== null && _a !== void 0 ? _a : (stave.kind === 'tab' ? 'tab' : 'treble'),
6735
6916
  key: (_b = stave.key) !== null && _b !== void 0 ? _b : 'C',
6736
6917
  time: (_c = stave.time) !== null && _c !== void 0 ? _c : '4/4',
6918
+ showTimeSignature: (_d = stave.showTimeSignature) !== null && _d !== void 0 ? _d : true,
6737
6919
  });
6738
6920
  });
6739
6921
  const starts = [], ends = [];
6740
6922
  const placed = spec.continuous ? new Set() : undefined;
6741
6923
  const noteMeasures = new Map();
6742
6924
  for (let index = 0; index < count; index++) {
6743
- starts.push(spec.staves.map((staff, j) => {
6744
- var _a, _b, _c;
6745
- const m = staff.measures[index], p = states[j];
6746
- return { clef: (_a = m.clef) !== null && _a !== void 0 ? _a : p.clef, key: (_b = m.key) !== null && _b !== void 0 ? _b : p.key, time: (_c = m.time) !== null && _c !== void 0 ? _c : p.time };
6747
- }));
6925
+ starts.push(spec.staves.map((staff, j) => measureState(staff.measures[index], states[j])));
6748
6926
  const system = result.sheet.addSystem(spec.system);
6749
6927
  result.systems.push(system);
6750
6928
  const parts = spec.staves.map((staff, staffIndex) => {
@@ -6768,8 +6946,9 @@ function compose(score, spec) {
6768
6946
  });
6769
6947
  if (spec.accidentals === 'key-aware') {
6770
6948
  const generated = new Set(policies.flatMap((policy) => [...policy.generated]));
6771
- policies.forEach((policy, staffIndex) => (0,_policies__WEBPACK_IMPORTED_MODULE_9__.applyCompositionAccidentals)(score, voices.flat(), policy.key, policy.changes, generated, staves[staffIndex], spec.graceAccidentals === 'ordered', placed));
6949
+ policies.forEach((policy, staffIndex) => (0,_policies__WEBPACK_IMPORTED_MODULE_13__.applyCompositionAccidentals)(score, voices.flat(), policy.key, policy.changes, generated, staves[staffIndex], spec.graceAccidentals === 'ordered', placed));
6772
6950
  }
6951
+ spec.staves.forEach((staff, j) => addLeadMarks(score, system, staff.measures[index], notes[j]));
6773
6952
  ends.push(states.slice());
6774
6953
  result.staves.push(staves);
6775
6954
  result.voices.push(voices);
@@ -6786,7 +6965,8 @@ function compose(score, spec) {
6786
6965
  for (const note of nativeInputs)
6787
6966
  if (seen.has(note)) {
6788
6967
  note.clearVoice();
6789
- const stave = priorStaves.get(note);
6968
+ const { stave, modifiers } = priorNative.get(note);
6969
+ note.getModifiers().splice(modifiers);
6790
6970
  if (stave)
6791
6971
  note.setStave(stave);
6792
6972
  else
@@ -8923,21 +9103,13 @@ class Factory {
8923
9103
  return this.own(annotation);
8924
9104
  }
8925
9105
  ChordSymbol(params) {
9106
+ var _a, _b, _c;
8926
9107
  const p = Object.assign({ vJustify: 'top', hJustify: 'center' }, params);
8927
9108
  const chordSymbol = new _chordsymbol__WEBPACK_IMPORTED_MODULE_6__.ChordSymbol();
8928
9109
  chordSymbol.setHorizontal(p.hJustify);
8929
9110
  chordSymbol.setVertical(p.vJustify);
8930
- // There is a default font based on the engraving font. Only set then
8931
- // font if it is specific, else use the default
8932
- if (typeof p.fontFamily === 'string' && typeof p.fontSize === 'number') {
8933
- if (typeof p.fontWeight === 'string')
8934
- chordSymbol.setFont(p.fontFamily, p.fontSize, p.fontWeight);
8935
- else
8936
- chordSymbol.setFont(p.fontFamily, p.fontSize, '');
8937
- }
8938
- else if (typeof p.fontSize === 'number') {
8939
- chordSymbol.setFontSize(p.fontSize);
8940
- }
9111
+ // Override individual properties so a custom family can still follow the score's chord size.
9112
+ chordSymbol.setFont((_a = p.fontFamily) !== null && _a !== void 0 ? _a : chordSymbol.fontInfo.family, (_b = p.fontSize) !== null && _b !== void 0 ? _b : chordSymbol.fontInfo.size, (_c = p.fontWeight) !== null && _c !== void 0 ? _c : chordSymbol.fontInfo.weight, chordSymbol.fontInfo.style);
8941
9113
  chordSymbol.setContext(this.context);
8942
9114
  return this.own(chordSymbol);
8943
9115
  }
@@ -9997,7 +10169,7 @@ class Formatter {
9997
10169
  }
9998
10170
  // If activated rests not on default can be rendered as specified.
9999
10171
  const line = currTickable.getLineForRest();
10000
- if (line !== 3) {
10172
+ if (currTickable.restLine !== undefined || line !== 3) {
10001
10173
  return;
10002
10174
  }
10003
10175
  if (alignAllNotes || currTickable.getBeam()) {
@@ -10951,6 +11123,10 @@ __webpack_require__.r(__webpack_exports__);
10951
11123
 
10952
11124
 
10953
11125
  class FretDiagram extends _element__WEBPACK_IMPORTED_MODULE_1__.Element {
11126
+ /** The registry and font metrics both use the diagram category. */
11127
+ static get CATEGORY() {
11128
+ return "FretDiagram" /* Category.FretDiagram */;
11129
+ }
10954
11130
  constructor(spec) {
10955
11131
  var _a, _b;
10956
11132
  super();
@@ -10992,9 +11168,10 @@ class FretDiagram extends _element__WEBPACK_IMPORTED_MODULE_1__.Element {
10992
11168
  ctx.save();
10993
11169
  const group = ctx.openGroup('fret-diagram', this.getAttribute('id'));
10994
11170
  group === null || group === void 0 ? void 0 : group.setAttribute('aria-label', 'Chord frame, low to high: ' + this.frets.join(', ') + (this.barre ? ', barre at fret ' + this.barre.fret : ''));
10995
- ctx.setFont('sans-serif', 9);
10996
- if (this.first > 1)
11171
+ if (this.first > 1) {
11172
+ ctx.setFont(this.fontInfo);
10997
11173
  ctx.fillText(String(this.first), this.getX() + 2, top + 9);
11174
+ }
10998
11175
  for (let row = 0; row <= this.rows; row++) {
10999
11176
  ctx.setLineWidth(row === 0 && this.first === 1 ? 2.5 : 1);
11000
11177
  line(left, top + row * 11, right, top + row * 11);
@@ -17493,12 +17670,14 @@ class GraceNoteGroup extends _modifier__WEBPACK_IMPORTED_MODULE_2__.Modifier {
17493
17670
  note.checkStave();
17494
17671
  this.preFormat();
17495
17672
  this.alignSubNotesWithNote(this.getGraceNotes(), note, this.position);
17496
- if (this.afterWidth) {
17673
+ // Tab fret numbers extend left of their tick. A before-grace must clear that edge as well.
17674
+ const fretOverhang = (0,_typeguard__WEBPACK_IMPORTED_MODULE_7__.isTabNote)(note) ? note.getLeftDisplacedHeadPx() : 0;
17675
+ if (this.afterWidth || fretOverhang) {
17497
17676
  for (const grace of this.graceNotes) {
17498
17677
  const tick = grace.getTickContext();
17499
17678
  tick.setXOffset(this.position === _modifier__WEBPACK_IMPORTED_MODULE_2__.Modifier.Position.RIGHT
17500
17679
  ? note.getTickContext().getX() + this.afterOffset
17501
- : tick.getXOffset() + this.afterWidth);
17680
+ : tick.getXOffset() + this.afterWidth - fretOverhang);
17502
17681
  }
17503
17682
  }
17504
17683
  this.beams.forEach((beam) => beam.postFormat());
@@ -17660,34 +17839,38 @@ __webpack_require__.r(__webpack_exports__);
17660
17839
  /* harmony export */ });
17661
17840
  /* harmony import */ var _annotation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./annotation */ "./src/annotation.ts");
17662
17841
  /* harmony import */ var _bend__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bend */ "./src/bend.ts");
17663
- /* harmony import */ var _strokes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./strokes */ "./src/strokes.ts");
17664
- /* harmony import */ var _typeguard__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./typeguard */ "./src/typeguard.ts");
17665
- /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util */ "./src/util.ts");
17842
+ /* harmony import */ var _metrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./metrics */ "./src/metrics.ts");
17843
+ /* harmony import */ var _strokes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./strokes */ "./src/strokes.ts");
17844
+ /* harmony import */ var _typeguard__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./typeguard */ "./src/typeguard.ts");
17845
+ /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./util */ "./src/util.ts");
17666
17846
  // Engrave structured guitar actions using native note modifiers on either backend.
17667
17847
 
17668
17848
 
17669
17849
 
17670
17850
 
17671
17851
 
17852
+
17672
17853
  /** Both arrow conventions describe the same order of physical strings. */
17673
17854
  function printedStroke(stroke) {
17674
17855
  const down = (stroke.direction === 'bass-to-treble') !== (stroke.arrows === 'hand');
17675
17856
  if (stroke.roll)
17676
- return down ? _strokes__WEBPACK_IMPORTED_MODULE_2__.Stroke.Type.RASGUEADO_DOWN : _strokes__WEBPACK_IMPORTED_MODULE_2__.Stroke.Type.RASGUEADO_UP;
17677
- return down ? _strokes__WEBPACK_IMPORTED_MODULE_2__.Stroke.Type.BRUSH_DOWN : _strokes__WEBPACK_IMPORTED_MODULE_2__.Stroke.Type.BRUSH_UP;
17857
+ return down ? _strokes__WEBPACK_IMPORTED_MODULE_3__.Stroke.Type.RASGUEADO_DOWN : _strokes__WEBPACK_IMPORTED_MODULE_3__.Stroke.Type.RASGUEADO_UP;
17858
+ return down ? _strokes__WEBPACK_IMPORTED_MODULE_3__.Stroke.Type.BRUSH_DOWN : _strokes__WEBPACK_IMPORTED_MODULE_3__.Stroke.Type.BRUSH_UP;
17678
17859
  }
17679
17860
  /** Attach native modifiers once, after a new note has initialized its heads or string positions. */
17680
17861
  function attachGuitarGestures(note) {
17681
17862
  for (const entry of note.notation) {
17682
17863
  const { stroke, bend } = entry;
17683
17864
  if (stroke) {
17684
- note.addModifier(new _strokes__WEBPACK_IMPORTED_MODULE_2__.Stroke(printedStroke(stroke), { allVoices: false }), 0);
17685
- note.addModifier(new _annotation__WEBPACK_IMPORTED_MODULE_0__.Annotation(stroke.finger + (stroke.golpe ? ' + golpe' : '')).setVerticalJustification(_annotation__WEBPACK_IMPORTED_MODULE_0__.Annotation.VerticalJustify.TOP), 0);
17865
+ note.addModifier(new _strokes__WEBPACK_IMPORTED_MODULE_3__.Stroke(printedStroke(stroke), { allVoices: false }), 0);
17866
+ note.addModifier(new _annotation__WEBPACK_IMPORTED_MODULE_0__.Annotation(stroke.finger + (stroke.golpe ? ' + golpe' : ''))
17867
+ .setFont(_metrics__WEBPACK_IMPORTED_MODULE_2__.Metrics.getFontInfo('Annotation.guitarStroke'))
17868
+ .setVerticalJustification(_annotation__WEBPACK_IMPORTED_MODULE_0__.Annotation.VerticalJustify.TOP), 0);
17686
17869
  }
17687
- if (bend && (0,_typeguard__WEBPACK_IMPORTED_MODULE_3__.isTabNote)(note)) {
17870
+ if (bend && (0,_typeguard__WEBPACK_IMPORTED_MODULE_4__.isTabNote)(note)) {
17688
17871
  const index = note.getPositions().findIndex((p) => p.str === bend.string);
17689
17872
  if (index < 0)
17690
- throw new _util__WEBPACK_IMPORTED_MODULE_4__.RuntimeError('BadArguments', 'The bent string must occur in the chord.');
17873
+ throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArguments', 'The bent string must occur in the chord.');
17691
17874
  note.addModifier(_bend__WEBPACK_IMPORTED_MODULE_1__.Bend.timed(bend), index);
17692
17875
  }
17693
17876
  }
@@ -18725,8 +18908,13 @@ class Metrics {
18725
18908
  static clear(key) {
18726
18909
  _textmetricscache__WEBPACK_IMPORTED_MODULE_0__.TextMetricsCache.clear();
18727
18910
  if (key) {
18728
- this.cacheFont.delete(key);
18729
- this.cacheStyle.delete(key);
18911
+ // Nested roles such as Annotation.lyric inherit values from the parent category.
18912
+ for (const cache of [this.cacheFont, this.cacheStyle]) {
18913
+ for (const category of cache.keys()) {
18914
+ if (category === key || category.startsWith(key + '.'))
18915
+ cache.delete(category);
18916
+ }
18917
+ }
18730
18918
  }
18731
18919
  else {
18732
18920
  this.cacheFont.clear();
@@ -18838,6 +19026,12 @@ const MetricsDefaults = {
18838
19026
  Annotation: {
18839
19027
  isText: true,
18840
19028
  fontSize: 10,
19029
+ guitarStroke: {
19030
+ fontSize: 11,
19031
+ },
19032
+ lyric: {
19033
+ fontSize: 12,
19034
+ },
18841
19035
  },
18842
19036
  Bend: {
18843
19037
  isText: true,
@@ -18849,12 +19043,16 @@ const MetricsDefaults = {
18849
19043
  },
18850
19044
  ChordSymbol: {
18851
19045
  isText: true,
18852
- fontSize: 12,
19046
+ fontSize: 14,
18853
19047
  spacing: 0.05,
18854
19048
  subscriptOffset: 0.2,
18855
19049
  superscriptOffset: -0.4,
18856
19050
  superSubRatio: 0.6,
18857
19051
  },
19052
+ FretDiagram: {
19053
+ isText: true,
19054
+ fontSize: 9,
19055
+ },
18858
19056
  FretHandFinger: {
18859
19057
  isText: true,
18860
19058
  fontSize: 9,
@@ -18956,7 +19154,7 @@ const MetricsDefaults = {
18956
19154
  Stroke: {
18957
19155
  text: {
18958
19156
  isText: true,
18959
- fontSize: 10,
19157
+ fontSize: 11,
18960
19158
  fontStyle: 'italic',
18961
19159
  fontWeight: 'bold',
18962
19160
  },
@@ -18964,7 +19162,7 @@ const MetricsDefaults = {
18964
19162
  TabNote: {
18965
19163
  text: {
18966
19164
  isText: true,
18967
- fontSize: 9,
19165
+ fontSize: 11,
18968
19166
  },
18969
19167
  },
18970
19168
  TabSlide: {
@@ -18981,6 +19179,11 @@ const MetricsDefaults = {
18981
19179
  TabTie: {
18982
19180
  isText: true,
18983
19181
  fontSize: 10,
19182
+ techniqueLetter: {
19183
+ fontFamily: 'Arial, Helvetica, sans-serif',
19184
+ fontSize: 11,
19185
+ fontWeight: 'bold',
19186
+ },
18984
19187
  },
18985
19188
  TextBracket: {
18986
19189
  isText: true,
@@ -20254,6 +20457,7 @@ class Note extends _tickable__WEBPACK_IMPORTED_MODULE_5__.Tickable {
20254
20457
  // per-pitch properties
20255
20458
  this.keyProps = [];
20256
20459
  this.duration = parsedNoteStruct.duration;
20460
+ this.writtenDots = parsedNoteStruct.dots;
20257
20461
  this.noteType = parsedNoteStruct.type;
20258
20462
  this.customTypes = parsedNoteStruct.customTypes;
20259
20463
  if (noteStruct.durationOverride) {
@@ -20617,18 +20821,21 @@ __webpack_require__.r(__webpack_exports__);
20617
20821
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
20618
20822
  /* harmony export */ NoteHead: () => (/* binding */ NoteHead)
20619
20823
  /* harmony export */ });
20620
- /* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./note */ "./src/note.ts");
20621
- /* harmony import */ var _stem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stem */ "./src/stem.ts");
20622
- /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util */ "./src/util.ts");
20824
+ /* harmony import */ var _glyphs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glyphs */ "./src/glyphs.ts");
20825
+ /* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./note */ "./src/note.ts");
20826
+ /* harmony import */ var _stem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stem */ "./src/stem.ts");
20827
+ /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./util */ "./src/util.ts");
20623
20828
  // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
20624
20829
  // MIT License
20830
+ // Notehead geometry and selection of rest glyphs for the attached stave.
20831
+
20625
20832
 
20626
20833
 
20627
20834
 
20628
20835
  // eslint-disable-next-line
20629
20836
  function L(...args) {
20630
20837
  if (NoteHead.DEBUG)
20631
- (0,_util__WEBPACK_IMPORTED_MODULE_2__.log)('VexFlow.NoteHead', args);
20838
+ (0,_util__WEBPACK_IMPORTED_MODULE_3__.log)('VexFlow.NoteHead', args);
20632
20839
  }
20633
20840
  /**
20634
20841
  * `NoteHeads` are typically not manipulated
@@ -20636,7 +20843,7 @@ function L(...args) {
20636
20843
  *
20637
20844
  * See `tests/notehead_tests.ts` for usage examples.
20638
20845
  */
20639
- class NoteHead extends _note__WEBPACK_IMPORTED_MODULE_0__.Note {
20846
+ class NoteHead extends _note__WEBPACK_IMPORTED_MODULE_1__.Note {
20640
20847
  static get CATEGORY() {
20641
20848
  return "NoteHead" /* Category.NoteHead */;
20642
20849
  }
@@ -20646,8 +20853,8 @@ class NoteHead extends _note__WEBPACK_IMPORTED_MODULE_0__.Note {
20646
20853
  this.customGlyph = false;
20647
20854
  // map notehead SMuFL codes to the corresponding SMuFL code with ledger line
20648
20855
  this.ledger = {
20649
- '\ue4e3' /*restWhole*/: '\ue4f4' /*restWholeLegerLine*/,
20650
- '\ue4e4' /*restHalf*/: '\ue4f5' /*restHalfLegerLine*/,
20856
+ [_glyphs__WEBPACK_IMPORTED_MODULE_0__.Glyphs.restWhole]: _glyphs__WEBPACK_IMPORTED_MODULE_0__.Glyphs.restWholeLegerLine,
20857
+ [_glyphs__WEBPACK_IMPORTED_MODULE_0__.Glyphs.restHalf]: _glyphs__WEBPACK_IMPORTED_MODULE_0__.Glyphs.restHalfLegerLine,
20651
20858
  };
20652
20859
  this.index = noteStruct.index;
20653
20860
  this.x = noteStruct.x || 0;
@@ -20656,27 +20863,34 @@ class NoteHead extends _note__WEBPACK_IMPORTED_MODULE_0__.Note {
20656
20863
  this.noteType = noteStruct.noteType;
20657
20864
  this.displacementColumn = (_a = noteStruct.displacementColumn) !== null && _a !== void 0 ? _a : (noteStruct.displaced ? 1 : 0);
20658
20865
  if (!Number.isSafeInteger(this.displacementColumn) || this.displacementColumn < 0)
20659
- throw new _util__WEBPACK_IMPORTED_MODULE_2__.RuntimeError('BadArguments', 'Head displacement column must be a nonnegative integer.');
20866
+ throw new _util__WEBPACK_IMPORTED_MODULE_3__.RuntimeError('BadArguments', 'Head displacement column must be a nonnegative integer.');
20660
20867
  this.displaced = this.displacementColumn !== 0;
20661
- this.stemDirection = noteStruct.stemDirection || _stem__WEBPACK_IMPORTED_MODULE_1__.Stem.UP;
20868
+ this.stemDirection = noteStruct.stemDirection || _stem__WEBPACK_IMPORTED_MODULE_2__.Stem.UP;
20662
20869
  this.line = noteStruct.line || 0;
20663
20870
  // Get glyph code based on duration and note type. This could be
20664
20871
  // regular notes, rests, or other custom codes.
20665
- this.glyphProps = _note__WEBPACK_IMPORTED_MODULE_0__.Note.getGlyphProps(this.duration, this.noteType);
20666
- (0,_util__WEBPACK_IMPORTED_MODULE_2__.defined)(this.glyphProps, 'BadArguments', `No glyph found for duration '${this.duration}' and type '${this.noteType}'`);
20667
- // Swap out the glyph with ledger lines
20668
- if ((this.line > 5 || this.line < 0) && this.ledger[this.glyphProps.codeHead]) {
20669
- this.glyphProps.codeHead = this.ledger[this.glyphProps.codeHead];
20670
- }
20671
- this.text = this.glyphProps.codeHead;
20672
- if (noteStruct.customGlyphCode) {
20673
- this.customGlyph = true;
20674
- this.text = noteStruct.customGlyphCode;
20675
- }
20872
+ this.glyphProps = _note__WEBPACK_IMPORTED_MODULE_1__.Note.getGlyphProps(this.duration, this.noteType);
20873
+ (0,_util__WEBPACK_IMPORTED_MODULE_3__.defined)(this.glyphProps, 'BadArguments', `No glyph found for duration '${this.duration}' and type '${this.noteType}'`);
20874
+ this.text = noteStruct.customGlyphCode || this.glyphProps.codeHead;
20875
+ this.customGlyph = !!noteStruct.customGlyphCode;
20876
+ this.updateRestGlyph();
20676
20877
  this.setStyle((_b = noteStruct.style) !== null && _b !== void 0 ? _b : {});
20677
20878
  this.slashed = noteStruct.slashed || false;
20678
20879
  this.renderOptions = Object.assign({}, this.renderOptions);
20679
20880
  }
20881
+ /** Select the supporting ledger at the actual note position, preserving custom head glyphs. */
20882
+ updateRestGlyph() {
20883
+ var _a, _b;
20884
+ const plain = this.glyphProps.codeHead;
20885
+ const ledger = this.ledger[plain];
20886
+ if (!ledger || (this.text !== plain && this.text !== ledger))
20887
+ return;
20888
+ // getYForNote anchors key line 5 at the top on staves of every size.
20889
+ const bottomLine = 6 - ((_b = (_a = this.stave) === null || _a === void 0 ? void 0 : _a.getNumLines()) !== null && _b !== void 0 ? _b : 5);
20890
+ const glyph = this.line > 5 || this.line < bottomLine ? ledger : plain;
20891
+ if (this.text !== glyph)
20892
+ this.setText(glyph);
20893
+ }
20680
20894
  /** Get the width of the notehead. */
20681
20895
  getWidth() {
20682
20896
  return this.width;
@@ -20692,6 +20906,9 @@ class NoteHead extends _note__WEBPACK_IMPORTED_MODULE_0__.Note {
20692
20906
  /** Set the stave line the notehead is placed on. */
20693
20907
  setLine(line) {
20694
20908
  this.line = line;
20909
+ if (this.stave)
20910
+ return this.setStave(this.stave);
20911
+ this.updateRestGlyph();
20695
20912
  return this;
20696
20913
  }
20697
20914
  /** Get the canvas `x` coordinate position of the notehead. */
@@ -20704,12 +20921,13 @@ class NoteHead extends _note__WEBPACK_IMPORTED_MODULE_0__.Note {
20704
20921
  }
20705
20922
  /** Offset shared by drawing, head geometry and ledger lines. */
20706
20923
  getDisplacementX() {
20707
- return this.displacementColumn * (this.width - _stem__WEBPACK_IMPORTED_MODULE_1__.Stem.WIDTH / 2) * this.stemDirection;
20924
+ return this.displacementColumn * (this.width - _stem__WEBPACK_IMPORTED_MODULE_2__.Stem.WIDTH / 2) * this.stemDirection;
20708
20925
  }
20709
20926
  /** Set notehead to a provided `stave`. */
20710
20927
  setStave(stave) {
20711
20928
  const line = this.getLine();
20712
20929
  this.stave = stave;
20930
+ this.updateRestGlyph();
20713
20931
  if (this.stave) {
20714
20932
  this.setY(this.stave.getYForNote(line));
20715
20933
  this.setContext(this.stave.getContext());
@@ -21842,15 +22060,16 @@ __webpack_require__.r(__webpack_exports__);
21842
22060
  /* harmony import */ var _engravinggeometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./engravinggeometry */ "./src/engravinggeometry.ts");
21843
22061
  /* harmony import */ var _ghostnote__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ghostnote */ "./src/ghostnote.ts");
21844
22062
  /* harmony import */ var _keysignature__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./keysignature */ "./src/keysignature.ts");
21845
- /* harmony import */ var _modifier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./modifier */ "./src/modifier.ts");
21846
- /* harmony import */ var _ornament__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ornament */ "./src/ornament.ts");
21847
- /* harmony import */ var _stavebarline__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./stavebarline */ "./src/stavebarline.ts");
21848
- /* harmony import */ var _stavehairpin__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stavehairpin */ "./src/stavehairpin.ts");
21849
- /* harmony import */ var _stavenote__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./stavenote */ "./src/stavenote.ts");
21850
- /* harmony import */ var _stavetie__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./stavetie */ "./src/stavetie.ts");
21851
- /* harmony import */ var _textbracket__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./textbracket */ "./src/textbracket.ts");
21852
- /* harmony import */ var _timesignature__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./timesignature */ "./src/timesignature.ts");
21853
- /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./util */ "./src/util.ts");
22063
+ /* harmony import */ var _metrics__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./metrics */ "./src/metrics.ts");
22064
+ /* harmony import */ var _modifier__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./modifier */ "./src/modifier.ts");
22065
+ /* harmony import */ var _ornament__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ornament */ "./src/ornament.ts");
22066
+ /* harmony import */ var _stavebarline__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stavebarline */ "./src/stavebarline.ts");
22067
+ /* harmony import */ var _stavehairpin__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./stavehairpin */ "./src/stavehairpin.ts");
22068
+ /* harmony import */ var _stavenote__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./stavenote */ "./src/stavenote.ts");
22069
+ /* harmony import */ var _stavetie__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stavetie */ "./src/stavetie.ts");
22070
+ /* harmony import */ var _textbracket__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./textbracket */ "./src/textbracket.ts");
22071
+ /* harmony import */ var _timesignature__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./timesignature */ "./src/timesignature.ts");
22072
+ /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./util */ "./src/util.ts");
21854
22073
  // Place attachments and lyrics within one formatted system. All solver coordinates are renderer pixels.
21855
22074
 
21856
22075
 
@@ -21868,6 +22087,7 @@ __webpack_require__.r(__webpack_exports__);
21868
22087
 
21869
22088
 
21870
22089
 
22090
+
21871
22091
  const supportedText = new RegExp('^[\\p{Script=Latin}\\p{Script=Greek}\\p{Script=Cyrillic}\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}\\p{Script=Hangul}\\p{M}\\p{N}\\p{P}\\p{Zs}]*$', 'u');
21872
22092
  /** Signed clearance tests use visible parts, never pairwise collisions within a single glyph or note. */
21873
22093
  function overlaps(a, b, gap) {
@@ -21945,6 +22165,7 @@ class PhraseLayout {
21945
22165
  const marks = syllables.map((s, i) => {
21946
22166
  var _a;
21947
22167
  return new _annotation__WEBPACK_IMPORTED_MODULE_0__.Annotation(s.text)
22168
+ .setFont(_metrics__WEBPACK_IMPORTED_MODULE_7__.Metrics.getFontInfo('Annotation.lyric'))
21948
22169
  .setVerticalJustification(options.side === 'above' ? 'top' : 'bottom')
21949
22170
  .setConnectorPadding(s.hyphenAfter || ((_a = syllables[i - 1]) === null || _a === void 0 ? void 0 : _a.hyphenAfter) ? stave.space(0.4) : 0);
21950
22171
  });
@@ -21960,9 +22181,10 @@ class PhraseLayout {
21960
22181
  mark.setLayoutBaseline(undefined);
21961
22182
  for (const route of this.routes)
21962
22183
  route.setLayoutRise(0);
21963
- for (const [note, line] of this.restLines)
21964
- if (note.getKeyLine(0) === line.after)
22184
+ for (const [note, line] of this.restLines) {
22185
+ if (note.restLine === undefined && note.getKeyLine(0) === line.after)
21965
22186
  note.setKeyLine(0, line.before);
22187
+ }
21966
22188
  this.restLines.clear();
21967
22189
  }
21968
22190
  report(code, ...owners) {
@@ -22008,8 +22230,8 @@ class PhraseLayout {
22008
22230
  for (const m of n.getModifiers()) {
22009
22231
  if (this.managed.has(m))
22010
22232
  continue;
22011
- if ((m instanceof _articulation__WEBPACK_IMPORTED_MODULE_1__.Articulation || m instanceof _ornament__WEBPACK_IMPORTED_MODULE_8__.Ornament) &&
22012
- [_modifier__WEBPACK_IMPORTED_MODULE_7__.Modifier.Position.ABOVE, _modifier__WEBPACK_IMPORTED_MODULE_7__.Modifier.Position.BELOW].includes(m.getPosition()))
22233
+ if ((m instanceof _articulation__WEBPACK_IMPORTED_MODULE_1__.Articulation || m instanceof _ornament__WEBPACK_IMPORTED_MODULE_9__.Ornament) &&
22234
+ [_modifier__WEBPACK_IMPORTED_MODULE_8__.Modifier.Position.ABOVE, _modifier__WEBPACK_IMPORTED_MODULE_8__.Modifier.Position.BELOW].includes(m.getPosition()))
22013
22235
  marks.push(m);
22014
22236
  else
22015
22237
  this.measure(m, stave);
@@ -22032,11 +22254,11 @@ class PhraseLayout {
22032
22254
  }
22033
22255
  for (const stave of staves) {
22034
22256
  for (const modifier of stave.getModifiers()) {
22035
- if (modifier instanceof _clef__WEBPACK_IMPORTED_MODULE_3__.Clef || modifier instanceof _timesignature__WEBPACK_IMPORTED_MODULE_14__.TimeSignature)
22257
+ if (modifier instanceof _clef__WEBPACK_IMPORTED_MODULE_3__.Clef || modifier instanceof _timesignature__WEBPACK_IMPORTED_MODULE_15__.TimeSignature)
22036
22258
  this.addParts(modifier, stave, [modifier.getInkBounds()]);
22037
22259
  else if (modifier instanceof _keysignature__WEBPACK_IMPORTED_MODULE_6__.KeySignature)
22038
22260
  this.addParts(modifier, stave, modifier.getInkParts());
22039
- else if (!(modifier instanceof _stavebarline__WEBPACK_IMPORTED_MODULE_9__.Barline))
22261
+ else if (!(modifier instanceof _stavebarline__WEBPACK_IMPORTED_MODULE_10__.Barline))
22040
22262
  this.report('UnsupportedGeometry', modifier);
22041
22263
  }
22042
22264
  }
@@ -22050,8 +22272,13 @@ class PhraseLayout {
22050
22272
  for (const { owner, stave } of this.fixed)
22051
22273
  if (!tuplets.has(owner))
22052
22274
  this.measure(owner, stave);
22275
+ // Record authored rest positions first so automatic rests can clear them in either voice order.
22276
+ for (const n of rests)
22277
+ if (n.restLine !== undefined)
22278
+ this.placeRest(n);
22053
22279
  for (const n of rests)
22054
- this.placeRest(n);
22280
+ if (n.restLine === undefined)
22281
+ this.placeRest(n);
22055
22282
  for (const m of marks)
22056
22283
  this.placeAttachment(m);
22057
22284
  for (const t of tuplets)
@@ -22073,7 +22300,8 @@ class PhraseLayout {
22073
22300
  this.report('UnsupportedGeometry', note);
22074
22301
  let parts = original.parts;
22075
22302
  const hits = this.hits(parts, stave, gap);
22076
- if (hits.length && !this.pins.has(note)) {
22303
+ const pinned = note.restLine !== undefined || this.pins.has(note);
22304
+ if (hits.length && !pinned) {
22077
22305
  // Try whole staff spaces, nearest first, on both sides of the authored rest.
22078
22306
  const sign = note.getStemDirection();
22079
22307
  for (const step of [1, -1, 2, -2, 3, -3, 4, -4]) {
@@ -22091,11 +22319,11 @@ class PhraseLayout {
22091
22319
  }
22092
22320
  const remaining = this.hits(parts, stave, gap);
22093
22321
  if (remaining.length)
22094
- this.report(this.pins.has(note) ? 'PinnedCollision' : 'UnresolvedCollision', note, remaining[0].owner);
22322
+ this.report(pinned ? 'PinnedCollision' : 'UnresolvedCollision', note, remaining[0].owner);
22095
22323
  this.addParts(note, stave, parts);
22096
22324
  }
22097
22325
  placeAttachment(mark) {
22098
- const stave = mark.checkAttachedNote().checkStave(), gap = stave.space(0.2), above = mark.getPosition() === _modifier__WEBPACK_IMPORTED_MODULE_7__.Modifier.Position.ABOVE;
22326
+ const stave = mark.checkAttachedNote().checkStave(), gap = stave.space(0.2), above = mark.getPosition() === _modifier__WEBPACK_IMPORTED_MODULE_8__.Modifier.Position.ABOVE;
22099
22327
  mark.setLayoutShiftY(0);
22100
22328
  let parts = (0,_engravinggeometry__WEBPACK_IMPORTED_MODULE_4__.measureEngraving)(mark).parts;
22101
22329
  for (let step = 1; step <= 12 && !this.pins.has(mark) && this.hits(parts, stave, gap).length; step++) {
@@ -22113,7 +22341,7 @@ class PhraseLayout {
22113
22341
  const routes = this.routes
22114
22342
  .flatMap((span) => {
22115
22343
  var _a, _b;
22116
- if (span instanceof _stavetie__WEBPACK_IMPORTED_MODULE_12__.StaveTie && span.text)
22344
+ if (span instanceof _stavetie__WEBPACK_IMPORTED_MODULE_13__.StaveTie && span.text)
22117
22345
  this.report('UnsupportedGeometry', span);
22118
22346
  const { firstNote: first, lastNote: last } = span.getNotes();
22119
22347
  if (!first ||
@@ -22122,7 +22350,7 @@ class PhraseLayout {
22122
22350
  !membership.has(last) ||
22123
22351
  first.getStave() !== last.getStave() ||
22124
22352
  last.getAbsoluteX() <= first.getAbsoluteX() ||
22125
- (span instanceof _stavetie__WEBPACK_IMPORTED_MODULE_12__.StaveTie &&
22353
+ (span instanceof _stavetie__WEBPACK_IMPORTED_MODULE_13__.StaveTie &&
22126
22354
  (((_a = span.getNotes().firstIndexes) === null || _a === void 0 ? void 0 : _a.some((i) => !Number.isInteger(i) || i < 0 || i >= first.getYs().length)) ||
22127
22355
  ((_b = span.getNotes().lastIndexes) === null || _b === void 0 ? void 0 : _b.some((i) => !Number.isInteger(i) || i < 0 || i >= last.getYs().length))))) {
22128
22356
  this.report('InvalidAnchor', span);
@@ -22130,7 +22358,7 @@ class PhraseLayout {
22130
22358
  }
22131
22359
  return [{ span, first, last, stave: first.checkStave(), x: first.getAbsoluteX(), end: last.getAbsoluteX() }];
22132
22360
  })
22133
- .sort((a, b) => Number(b.span instanceof _stavetie__WEBPACK_IMPORTED_MODULE_12__.StaveTie) - Number(a.span instanceof _stavetie__WEBPACK_IMPORTED_MODULE_12__.StaveTie) || a.end - a.x - (b.end - b.x));
22361
+ .sort((a, b) => Number(b.span instanceof _stavetie__WEBPACK_IMPORTED_MODULE_13__.StaveTie) - Number(a.span instanceof _stavetie__WEBPACK_IMPORTED_MODULE_13__.StaveTie) || a.end - a.x - (b.end - b.x));
22134
22362
  for (const [index, r] of routes.entries()) {
22135
22363
  const { span, stave } = r;
22136
22364
  const crossing = routes
@@ -22143,7 +22371,7 @@ class PhraseLayout {
22143
22371
  const fixed = this.obstacles.filter((o) => o.stave === stave && o.owner !== stave && o.owner !== r.first && o.owner !== r.last);
22144
22372
  const gap = stave.space(0.2);
22145
22373
  let bestRise = 0, bestCost = Infinity;
22146
- const limit = pinned || crossing ? 0 : span instanceof _stavetie__WEBPACK_IMPORTED_MODULE_12__.StaveTie ? 6 : 16;
22374
+ const limit = pinned || crossing ? 0 : span instanceof _stavetie__WEBPACK_IMPORTED_MODULE_13__.StaveTie ? 6 : 16;
22147
22375
  for (let step = 0; step <= limit; step++) {
22148
22376
  const rise = stave.space(step / 2);
22149
22377
  span.setLayoutRise(rise);
@@ -22172,13 +22400,13 @@ class PhraseLayout {
22172
22400
  try {
22173
22401
  if (mark instanceof _annotation__WEBPACK_IMPORTED_MODULE_0__.Annotation)
22174
22402
  anchors = [mark.checkAttachedNote()];
22175
- else if (mark instanceof _textbracket__WEBPACK_IMPORTED_MODULE_13__.TextBracket)
22403
+ else if (mark instanceof _textbracket__WEBPACK_IMPORTED_MODULE_14__.TextBracket)
22176
22404
  anchors = [mark.start, mark.stop];
22177
22405
  else
22178
22406
  anchors = mark.getNotes();
22179
22407
  }
22180
22408
  catch (error) {
22181
- if (!(error instanceof _util__WEBPACK_IMPORTED_MODULE_15__.RuntimeError))
22409
+ if (!(error instanceof _util__WEBPACK_IMPORTED_MODULE_16__.RuntimeError))
22182
22410
  throw error;
22183
22411
  return false;
22184
22412
  }
@@ -22239,7 +22467,7 @@ class PhraseLayout {
22239
22467
  const middle = boxes.length ? boxes.reduce((sum, b) => sum + b.y + b.h / 2 - y, 0) / boxes.length : 0;
22240
22468
  const trims = new Map();
22241
22469
  for (const m of marks)
22242
- if (m instanceof _stavehairpin__WEBPACK_IMPORTED_MODULE_10__.StaveHairpin) {
22470
+ if (m instanceof _stavehairpin__WEBPACK_IMPORTED_MODULE_11__.StaveHairpin) {
22243
22471
  const { left, right } = m.getLayoutEdges();
22244
22472
  let l = 0, r = 0;
22245
22473
  for (const b of boxes) {
@@ -22267,7 +22495,7 @@ class PhraseLayout {
22267
22495
  y += shift;
22268
22496
  }
22269
22497
  for (const m of marks) {
22270
- if (m instanceof _stavehairpin__WEBPACK_IMPORTED_MODULE_10__.StaveHairpin)
22498
+ if (m instanceof _stavehairpin__WEBPACK_IMPORTED_MODULE_11__.StaveHairpin)
22271
22499
  m.setLayoutBaseline(y + middle, ...trims.get(m));
22272
22500
  else
22273
22501
  m.setLayoutBaseline(y);
@@ -22292,7 +22520,7 @@ class PhraseLayout {
22292
22520
  format(staves, voices) {
22293
22521
  var _a;
22294
22522
  const ticks = voices.flatMap((v) => v.getTickables());
22295
- const notes = ticks.filter((n) => n instanceof _stavenote__WEBPACK_IMPORTED_MODULE_11__.StaveNote);
22523
+ const notes = ticks.filter((n) => n instanceof _stavenote__WEBPACK_IMPORTED_MODULE_12__.StaveNote);
22296
22524
  const members = new Set(notes);
22297
22525
  const beams = new Set(notes.map((n) => n.getBeam()).filter((b) => !!b));
22298
22526
  for (let pass = 1; pass <= this.iterationLimit; pass++) {
@@ -22301,7 +22529,7 @@ class PhraseLayout {
22301
22529
  this.connectors = [];
22302
22530
  this.diagnostics.length = 0;
22303
22531
  this.messages.clear();
22304
- this.collect(notes, staves, ticks.filter((n) => !(n instanceof _stavenote__WEBPACK_IMPORTED_MODULE_11__.StaveNote)));
22532
+ this.collect(notes, staves, ticks.filter((n) => !(n instanceof _stavenote__WEBPACK_IMPORTED_MODULE_12__.StaveNote)));
22305
22533
  const isPinned = (l) => l.options.baselineSpaces !== undefined ||
22306
22534
  l.marks.some((m) => m instanceof _annotation__WEBPACK_IMPORTED_MODULE_0__.Annotation && m.getTextBaseline() !== undefined);
22307
22535
  const automatic = [];
@@ -22749,10 +22977,13 @@ function dimensions(o) {
22749
22977
  return Object.assign(Object.assign({}, size), { margin, musicWidth: width, scale: staff / (4 * _tables__WEBPACK_IMPORTED_MODULE_7__.Tables.STAVE_LINE_DISTANCE), gap, extra });
22750
22978
  }
22751
22979
  /** The staging SVG must participate in browser font measurement, including for detached destinations. */
22752
- function compose(host, spec) {
22980
+ function compose(host, spec, hooks = []) {
22753
22981
  const ctx = new _svgcontext__WEBPACK_IMPORTED_MODULE_6__.SVGContext(host);
22754
22982
  const factory = new _factory__WEBPACK_IMPORTED_MODULE_0__.Factory({ renderer: { elementId: null, width: 1, height: 1 } }).setContext(ctx);
22755
- const score = factory.EasyScore().compose(spec);
22983
+ const easyScore = factory.EasyScore();
22984
+ for (const hook of hooks)
22985
+ easyScore.addCommitHook(hook);
22986
+ const score = easyScore.compose(spec);
22756
22987
  return { ctx, factory, score };
22757
22988
  }
22758
22989
  /** Preserve inherited renderer styles while moving actual graphics to their owning system. */
@@ -22766,6 +22997,9 @@ function musicGroup(svg) {
22766
22997
  /** SVG text boxes include an entire music font's ascent. Use glyph ink to keep cues close to their notes. */
22767
22998
  function inkBox(el, context) {
22768
22999
  var _a, _b;
23000
+ // Invisible pointer targets can extend well beyond a modifier's ink. They must not move notes to another system.
23001
+ if (el.getAttribute('opacity') === '0')
23002
+ return;
22769
23003
  let box;
22770
23004
  if (el.tagName === 'g') {
22771
23005
  const children = Array.from(el.children).flatMap((c) => { var _a; return (_a = inkBox(c, context)) !== null && _a !== void 0 ? _a : []; });
@@ -22914,7 +23148,7 @@ function addInsets(host, spec, o, score, rows, diagnostics) {
22914
23148
  sheet: { x: 0, y: 0, width: stave.getWidth() / scale, measurePadding: 4 },
22915
23149
  continuous: {},
22916
23150
  };
22917
- const inset = compose(host, insetSpec);
23151
+ const inset = compose(host, insetSpec, o.noteHooks);
22918
23152
  inset.factory.draw();
22919
23153
  row.references.push(Object.assign(Object.assign({}, r), { events: semanticEvents(inset.score, insetSpec, 1).map((e) => (Object.assign(Object.assign({}, e), { measure: r.measure }))) }));
22920
23154
  const g = musicGroup(inset.ctx.svg);
@@ -23091,12 +23325,12 @@ class Publication {
23091
23325
  (((_a = this.source.spans) === null || _a === void 0 ? void 0 : _a.length) ||
23092
23326
  ((_c = (_b = this.source.continuous) === null || _b === void 0 ? void 0 : _b.spans) === null || _c === void 0 ? void 0 : _c.length) ||
23093
23327
  ((_e = (_d = this.source.continuous) === null || _d === void 0 ? void 0 : _d.splitChords) === null || _e === void 0 ? void 0 : _e.length))
23094
- ? compose(host, this.source).score
23328
+ ? compose(host, this.source, options.noteHooks).score
23095
23329
  : undefined;
23096
23330
  // A one-unit inset keeps edge strokes inside the requested margin.
23097
23331
  const width = size.musicWidth / size.scale - 2;
23098
23332
  const spec = (0,_publicationview__WEBPACK_IMPORTED_MODULE_4__.projectScore)(this.source, options, width, ref, (id, measures) => diagnostics.push({ code: 'ExcludedAnchor', measures, detail: id }));
23099
- const { ctx, factory, score } = compose(host, spec);
23333
+ const { ctx, factory, score } = compose(host, spec, options.noteHooks);
23100
23334
  factory.draw();
23101
23335
  const layout = score.sheet.getContinuousLayout();
23102
23336
  for (const d of layout.diagnostics)
@@ -23258,12 +23492,13 @@ function homeStaff(staff, selected) {
23258
23492
  }
23259
23493
  /** Carry written clef, key and meter into a one-measure inset, including preceding inline changes. */
23260
23494
  function insetStaff(staff, measure) {
23261
- var _a, _b, _c;
23262
- const state = { clef: staff.clef, key: staff.key, time: staff.time };
23495
+ var _a, _b, _c, _d;
23496
+ const state = { clef: staff.clef, key: staff.key, time: staff.time, showTimeSignature: staff.showTimeSignature };
23263
23497
  for (const m of staff.measures.slice(0, measure - 1)) {
23264
23498
  state.clef = (_a = m.clef) !== null && _a !== void 0 ? _a : state.clef;
23265
23499
  state.key = (_b = m.key) !== null && _b !== void 0 ? _b : state.key;
23266
23500
  state.time = (_c = m.time) !== null && _c !== void 0 ? _c : state.time;
23501
+ state.showTimeSignature = (_d = m.showTimeSignature) !== null && _d !== void 0 ? _d : state.showTimeSignature;
23267
23502
  for (const v of m.voices.slice(0, 1))
23268
23503
  if (typeof v.notes !== 'string')
23269
23504
  for (const item of v.notes)
@@ -24144,8 +24379,9 @@ class Stave extends _element__WEBPACK_IMPORTED_MODULE_2__.Element {
24144
24379
  static get CATEGORY() {
24145
24380
  return "Stave" /* Category.Stave */;
24146
24381
  }
24147
- /** Replace only the derived row-start and courtesy signs on a responsive sheet. */
24148
- setBoundaryModifiers(modifiers) {
24382
+ /** Replace the derived row-start and courtesy signs and their note clearance. */
24383
+ setBoundaryModifiers(modifiers, notePadding = 0) {
24384
+ this.boundaryNotePadding = notePadding;
24149
24385
  this.boundaryModifiers = modifiers;
24150
24386
  for (const mark of modifiers)
24151
24387
  mark.setStave(this);
@@ -24164,6 +24400,8 @@ class Stave extends _element__WEBPACK_IMPORTED_MODULE_2__.Element {
24164
24400
  var _a;
24165
24401
  super();
24166
24402
  this.boundaryModifiers = [];
24403
+ /** Space after the row-start signs for a continuation arriving at the first note. */
24404
+ this.boundaryNotePadding = 0;
24167
24405
  this.x = x;
24168
24406
  this.y = y;
24169
24407
  this.width = width;
@@ -24627,7 +24865,7 @@ class Stave extends _element__WEBPACK_IMPORTED_MODULE_2__.Element {
24627
24865
  if (padding + width === 0)
24628
24866
  offset--;
24629
24867
  }
24630
- this.startX = x;
24868
+ this.startX = x + this.boundaryNotePadding;
24631
24869
  x = this.x + this.width;
24632
24870
  const widths = {
24633
24871
  left: 0,
@@ -25945,6 +26183,11 @@ __webpack_require__.r(__webpack_exports__);
25945
26183
 
25946
26184
 
25947
26185
 
26186
+ /** Bravura's SMuFL stemUpSE and stemDownNW anchors, in staff spaces from the glyph origin. */
26187
+ const bravuraSlashAnchors = {
26188
+ [_glyphs__WEBPACK_IMPORTED_MODULE_1__.Glyphs.noteheadSlashVerticalEnds]: { up: [1.46, 0.656], down: [0, -0.664] },
26189
+ [_glyphs__WEBPACK_IMPORTED_MODULE_1__.Glyphs.noteheadSlashWhiteHalf]: { up: [3.12, 1], down: [0, -1] },
26190
+ };
25948
26191
  // To enable logging for this class. Set `VexFlow.StaveNote.DEBUG` to `true`.
25949
26192
  // eslint-disable-next-line
25950
26193
  function L(...args) {
@@ -26025,7 +26268,19 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_8__.StemmableNot
26025
26268
  const visible = notesList.filter((item) => item.note.renderOptions.draw !== false);
26026
26269
  if (visible.length < 2)
26027
26270
  return true;
26028
- if (visible.length > 3) {
26271
+ const positioned = visible.some(({ note }) => note.restLine !== undefined);
26272
+ if (positioned && visible.length <= 3) {
26273
+ // Move only automatic rests. Visit obstacles in travel order so each shift clears earlier ones.
26274
+ for (const rest of visible.filter((v) => v.isrest && v.note.restLine === undefined)) {
26275
+ const direction = rest.note.getStemDirection();
26276
+ const peers = visible.filter((v) => v !== rest).sort((a, b) => direction * (a.minLine - b.minLine));
26277
+ for (const peer of peers) {
26278
+ if (rest.minLine <= peer.maxLine && peer.minLine <= rest.maxLine)
26279
+ shiftRestVertical(rest, peer, direction);
26280
+ }
26281
+ }
26282
+ }
26283
+ if (visible.length > 3 || positioned) {
26029
26284
  // Keep overlapping stem/head envelopes in separate columns. Pitch order makes
26030
26285
  // placement independent of voice insertion for voices at distinct pitches.
26031
26286
  const columns = [];
@@ -26267,6 +26522,8 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_8__.StemmableNot
26267
26522
  else {
26268
26523
  this.setStemDirection((_e = noteStruct.stemDirection) !== null && _e !== void 0 ? _e : _stem__WEBPACK_IMPORTED_MODULE_7__.Stem.UP);
26269
26524
  }
26525
+ if (noteStruct.restLine !== undefined)
26526
+ this.setRestLine(noteStruct.restLine);
26270
26527
  if (this.notation.length)
26271
26528
  (0,_guitarmodifiers__WEBPACK_IMPORTED_MODULE_2__.attachGuitarGestures)(this);
26272
26529
  }
@@ -26493,21 +26750,32 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_8__.StemmableNot
26493
26750
  hasFlag() {
26494
26751
  return super.hasFlag() && !this.isRest();
26495
26752
  }
26496
- getStemX() {
26753
+ /** Use explicit font metadata first, then the bundled anchors for Bravura rhythm slashes. */
26754
+ stemAnchor(head, direction) {
26497
26755
  var _a;
26756
+ const family = head.fontInfo.family;
26757
+ if (((_a = this.engraving) === null || _a === void 0 ? void 0 : _a.musicFont) === family) {
26758
+ const anchor = this.engraving.stemAnchor(head.text, direction);
26759
+ if (anchor)
26760
+ return anchor;
26761
+ }
26762
+ const slash = bravuraSlashAnchors[head.text];
26763
+ if (slash && /^\s*(?:Bravura|"Bravura"|'Bravura')\s*(?:,|$)/i.test(family))
26764
+ return slash[direction];
26765
+ }
26766
+ getStemX() {
26498
26767
  if (this.noteType === 'r') {
26499
26768
  return this.getCenterGlyphX();
26500
26769
  }
26501
26770
  else {
26502
26771
  const up = this.stemDirection === _stem__WEBPACK_IMPORTED_MODULE_7__.Stem.UP;
26503
- const head = this.engraving && this._noteHeads.find((h) => !h.isDisplaced());
26504
- if (head && ((_a = this.engraving) === null || _a === void 0 ? void 0 : _a.musicFont) === head.fontInfo.family) {
26505
- const anchor = this.engraving.stemAnchor(head.text, up ? 'up' : 'down');
26506
- if (anchor)
26507
- return (this.getNoteHeadBeginX() +
26508
- head.getXShift() +
26509
- (anchor[0] * head.fontSizeInPixels) / 4 +
26510
- ((up ? -1 : 1) * _stem__WEBPACK_IMPORTED_MODULE_7__.Stem.WIDTH) / 2);
26772
+ const head = this._noteHeads.find((h) => !h.isDisplaced());
26773
+ const anchor = head && this.stemAnchor(head, up ? 'up' : 'down');
26774
+ if (head && anchor) {
26775
+ return (this.getNoteHeadBeginX() +
26776
+ head.getXShift() +
26777
+ (anchor[0] * head.fontSizeInPixels) / 4 +
26778
+ ((up ? -1 : 1) * _stem__WEBPACK_IMPORTED_MODULE_7__.Stem.WIDTH) / 2);
26511
26779
  }
26512
26780
  // We adjust the origin of the stem because we want the stem left-aligned
26513
26781
  // with the notehead if stemmed-down, and right-aligned if stemmed-up
@@ -26671,6 +26939,26 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_8__.StemmableNot
26671
26939
  this._noteHeads[index].setStyle(style);
26672
26940
  return this;
26673
26941
  }
26942
+ /** The explicit key line, or undefined when rest placement is automatic. */
26943
+ get restLine() {
26944
+ return this.lineBeforeRestPin === undefined ? undefined : this.getKeyLine(0);
26945
+ }
26946
+ /** Pin this rest to a line. Passing undefined releases it for automatic placement. */
26947
+ setRestLine(line) {
26948
+ var _a;
26949
+ if (!this.isRest() || (line !== undefined && !Number.isFinite(line)))
26950
+ throw new _util__WEBPACK_IMPORTED_MODULE_10__.RuntimeError('BadArguments', 'Rest positioning requires a rest and a finite line.');
26951
+ if (line !== undefined) {
26952
+ (_a = this.lineBeforeRestPin) !== null && _a !== void 0 ? _a : (this.lineBeforeRestPin = this.getKeyLine(0));
26953
+ return this.setKeyLine(0, line);
26954
+ }
26955
+ if (this.lineBeforeRestPin !== undefined) {
26956
+ const previous = this.lineBeforeRestPin;
26957
+ this.lineBeforeRestPin = undefined;
26958
+ this.setKeyLine(0, previous);
26959
+ }
26960
+ return this;
26961
+ }
26674
26962
  setKeyLine(index, line) {
26675
26963
  this.keyProps[index].line = line;
26676
26964
  this.reset();
@@ -26743,9 +27031,7 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_8__.StemmableNot
26743
27031
  this._noteHeads.forEach((nh) => {
26744
27032
  const offset = _tables__WEBPACK_IMPORTED_MODULE_9__.Tables.noteHeadStemYOffsets[nh.text];
26745
27033
  const anchor = offset ? offset[anchorKey] : 0;
26746
- const fontAnchor = this.engraving && this.engraving.musicFont === nh.fontInfo.family
26747
- ? this.engraving.stemAnchor(nh.text, anchorKey)
26748
- : undefined;
27034
+ const fontAnchor = this.stemAnchor(nh, anchorKey);
26749
27035
  // SMuFL specifies four staff spaces per em. Follow the glyph scale for grace notes too.
26750
27036
  const y = nh.getY() - (fontAnchor ? (fontAnchor[1] * nh.fontSizeInPixels) / 4 : anchor * _tables__WEBPACK_IMPORTED_MODULE_9__.Tables.STAVE_LINE_DISTANCE);
26751
27037
  yTop = Math.min(y, yTop);
@@ -27154,13 +27440,16 @@ __webpack_require__.r(__webpack_exports__);
27154
27440
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
27155
27441
  /* harmony export */ StaveSection: () => (/* binding */ StaveSection)
27156
27442
  /* harmony export */ });
27157
- /* harmony import */ var _metrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./metrics */ "./src/metrics.ts");
27158
- /* harmony import */ var _stavemodifier__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stavemodifier */ "./src/stavemodifier.ts");
27443
+ /* harmony import */ var _boundingbox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingbox */ "./src/boundingbox.ts");
27444
+ /* harmony import */ var _metrics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./metrics */ "./src/metrics.ts");
27445
+ /* harmony import */ var _stavemodifier__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stavemodifier */ "./src/stavemodifier.ts");
27159
27446
  // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
27160
27447
  // @author: Larry Kuhns 2011
27448
+ // Draw rehearsal lettering and its optional frame from the same positioned text.
27449
+
27161
27450
 
27162
27451
 
27163
- class StaveSection extends _stavemodifier__WEBPACK_IMPORTED_MODULE_1__.StaveModifier {
27452
+ class StaveSection extends _stavemodifier__WEBPACK_IMPORTED_MODULE_2__.StaveModifier {
27164
27453
  static get CATEGORY() {
27165
27454
  return "StaveSection" /* Category.StaveSection */;
27166
27455
  }
@@ -27170,29 +27459,33 @@ class StaveSection extends _stavemodifier__WEBPACK_IMPORTED_MODULE_1__.StaveModi
27170
27459
  this.x = x;
27171
27460
  this.yShift = yShift;
27172
27461
  this.drawRect = drawRect;
27173
- this.padding = _metrics__WEBPACK_IMPORTED_MODULE_0__.Metrics.get('StaveSection.padding');
27462
+ this.padding = _metrics__WEBPACK_IMPORTED_MODULE_1__.Metrics.get('StaveSection.padding');
27174
27463
  }
27175
27464
  setDrawRect(drawRect) {
27176
27465
  this.drawRect = drawRect;
27177
27466
  return this;
27178
27467
  }
27468
+ /** Report the same ink and padding before drawing as after a stave has moved. */
27469
+ getBoundingBox() {
27470
+ if (this.stave) {
27471
+ this.x = this.stave.getX() + this.stave.getModifierXShift(this.getPosition()) + this.padding;
27472
+ this.y = this.stave.getYForTopText(1.5) - this.padding;
27473
+ }
27474
+ const ink = this.getTextInk(this.x, this.y);
27475
+ if (!this.drawRect)
27476
+ return ink;
27477
+ return new _boundingbox__WEBPACK_IMPORTED_MODULE_0__.BoundingBox(ink.x - this.padding, ink.y - this.padding, ink.w + 2 * this.padding, ink.h + 2 * this.padding);
27478
+ }
27179
27479
  draw() {
27180
- const stave = this.checkStave();
27181
- const ctx = stave.checkContext();
27480
+ const ctx = this.checkStave().checkContext();
27481
+ const bounds = this.getBoundingBox();
27182
27482
  this.setRendered();
27183
- this.x = stave.getX() + stave.getModifierXShift(this.getPosition());
27184
- const headroom = -1 * this.textMetrics.actualBoundingBoxDescent;
27185
- const width = this.width + 2 * this.padding; // add left & right padding
27186
- const height = this.height + 2 * this.padding; // add top & bottom padding
27187
- // Seems to be a good default y
27188
- const y = stave.getYForTopText(1.5) + this.yShift;
27189
- const x = this.x + this.xShift;
27190
27483
  if (this.drawRect) {
27191
27484
  ctx.beginPath();
27192
- ctx.rect(x, y - height + headroom, width, height);
27485
+ ctx.rect(bounds.x, bounds.y, bounds.w, bounds.h);
27193
27486
  ctx.stroke();
27194
27487
  }
27195
- this.renderText(ctx, this.xShift + this.padding, y - this.padding);
27488
+ this.renderText(ctx, 0, 0);
27196
27489
  }
27197
27490
  }
27198
27491
 
@@ -27618,12 +27911,13 @@ class StaveTie extends _element__WEBPACK_IMPORTED_MODULE_1__.Element {
27618
27911
  renderTieText(firstX, lastX) {
27619
27912
  var _a, _b, _c;
27620
27913
  const ctx = this.checkContext();
27621
- let centerX = (firstX + lastX) / 2;
27622
- centerX -= ctx.measureText(this.text).width / 2;
27623
27914
  const stave = (_b = (_a = this.notes.firstNote) === null || _a === void 0 ? void 0 : _a.checkStave()) !== null && _b !== void 0 ? _b : (_c = this.notes.lastNote) === null || _c === void 0 ? void 0 : _c.checkStave();
27624
27915
  if (stave) {
27916
+ ctx.save();
27625
27917
  ctx.setFont(this.fontInfo);
27918
+ const centerX = (firstX + lastX - ctx.measureText(this.text).width) / 2;
27626
27919
  ctx.fillText(this.text, centerX + this.renderOptions.textShiftX, stave.getYForTopText() - 1);
27920
+ ctx.restore();
27627
27921
  }
27628
27922
  }
27629
27923
  /**
@@ -28618,7 +28912,8 @@ class Stroke extends _modifier__WEBPACK_IMPORTED_MODULE_4__.Modifier {
28618
28912
  let yPositions = note.getYs();
28619
28913
  let topY = start.y;
28620
28914
  let botY = start.y;
28621
- const x = start.x - 5;
28915
+ // Leave a visible gap between a tab fret's string mask and the tip of a broad arrow.
28916
+ const x = start.x - 5 - ((0,_typeguard__WEBPACK_IMPORTED_MODULE_5__.isTabNote)(note) ? _metrics__WEBPACK_IMPORTED_MODULE_3__.Metrics.get('NoteHead.minPadding') : 0);
28622
28917
  const lineSpace = note.checkStave().getSpacingBetweenLines();
28623
28918
  const notes = this.checkModifierContext().getMembers(note.getCategory());
28624
28919
  for (let i = 0; i < notes.length; i++) {
@@ -29196,17 +29491,25 @@ class SVGContext extends _rendercontext__WEBPACK_IMPORTED_MODULE_3__.RenderConte
29196
29491
  }
29197
29492
  save() {
29198
29493
  this.stateStack.push({
29494
+ font: this.fontCSSString,
29199
29495
  state: (0,_util__WEBPACK_IMPORTED_MODULE_6__.structuredClone)(this.state),
29200
29496
  attributes: (0,_util__WEBPACK_IMPORTED_MODULE_6__.structuredClone)(this.attributes),
29201
29497
  });
29202
29498
  return this;
29203
29499
  }
29204
29500
  restore() {
29501
+ var _a;
29205
29502
  const savedState = this.stateStack.pop();
29206
29503
  if (savedState) {
29207
- const state = savedState;
29208
- this.state = (0,_util__WEBPACK_IMPORTED_MODULE_6__.structuredClone)(state.state);
29209
- this.attributes = (0,_util__WEBPACK_IMPORTED_MODULE_6__.structuredClone)(state.attributes);
29504
+ this.state = (0,_util__WEBPACK_IMPORTED_MODULE_6__.structuredClone)(savedState.state);
29505
+ this.attributes = (0,_util__WEBPACK_IMPORTED_MODULE_6__.structuredClone)(savedState.attributes);
29506
+ this.fontCSSString =
29507
+ (_a = savedState.font) !== null && _a !== void 0 ? _a : _font__WEBPACK_IMPORTED_MODULE_1__.Font.toCSSString({
29508
+ family: this.attributes['font-family'],
29509
+ size: this.attributes['font-size'],
29510
+ weight: this.attributes['font-weight'],
29511
+ style: this.attributes['font-style'],
29512
+ });
29210
29513
  }
29211
29514
  return this;
29212
29515
  }
@@ -30683,6 +30986,9 @@ class TabNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_8__.StemmableNote
30683
30986
  this.fretElement.push(el);
30684
30987
  this.width = Math.max(el.getWidth(), this.width);
30685
30988
  }
30989
+ // The tick lies at the middle of a fret. Reserve its two halves on the corresponding sides.
30990
+ this.setLeftDisplacedHeadPx(this.width / 2);
30991
+ this.setRightDisplacedHeadPx(this.width / 2);
30686
30992
  }
30687
30993
  // Set the `stave` to the note
30688
30994
  setStave(stave) {
@@ -30711,19 +31017,16 @@ class TabNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_8__.StemmableNote
30711
31017
  if (this.ys.length === 0) {
30712
31018
  throw new _util__WEBPACK_IMPORTED_MODULE_10__.RuntimeError('NoYValues', 'No Y-Values calculated for this note.');
30713
31019
  }
30714
- let x = 0;
31020
+ // Frets straddle the tick. Keep side modifiers outside the widest member of the chord.
31021
+ let x = this.getAbsoluteX();
30715
31022
  if (position === _modifier__WEBPACK_IMPORTED_MODULE_5__.Modifier.Position.LEFT) {
30716
- x = -1 * 2; // FIXME: modifier padding, move to font file
31023
+ x = this.getTieLeftX();
30717
31024
  }
30718
31025
  else if (position === _modifier__WEBPACK_IMPORTED_MODULE_5__.Modifier.Position.RIGHT) {
30719
- x = this.width + 2; // FIXME: modifier padding, move to font file
30720
- }
30721
- else if (position === _modifier__WEBPACK_IMPORTED_MODULE_5__.Modifier.Position.BELOW || position === _modifier__WEBPACK_IMPORTED_MODULE_5__.Modifier.Position.ABOVE) {
30722
- const noteGlyphWidth = this.width;
30723
- x = noteGlyphWidth / 2;
31026
+ x = this.getTieRightX();
30724
31027
  }
30725
31028
  return {
30726
- x: this.getAbsoluteX() + x,
31029
+ x,
30727
31030
  y: this.ys[index],
30728
31031
  };
30729
31032
  }
@@ -31009,15 +31312,16 @@ __webpack_require__.r(__webpack_exports__);
31009
31312
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31010
31313
  /* harmony export */ TabTie: () => (/* binding */ TabTie)
31011
31314
  /* harmony export */ });
31012
- /* harmony import */ var _stavetie__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./stavetie */ "./src/stavetie.ts");
31315
+ /* harmony import */ var _metrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./metrics */ "./src/metrics.ts");
31316
+ /* harmony import */ var _stavetie__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stavetie */ "./src/stavetie.ts");
31013
31317
  // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
31014
31318
  // MIT License
31015
31319
  //
31016
31320
  // ## Description
31017
- // This class implements varies types of ties between contiguous notes. The
31018
- // ties include: regular ties, hammer ons, pull offs, and slides.
31321
+ // Tablature ties carry technique letters between frets, including hammer-ons and pull-offs.
31322
+
31019
31323
 
31020
- class TabTie extends _stavetie__WEBPACK_IMPORTED_MODULE_0__.StaveTie {
31324
+ class TabTie extends _stavetie__WEBPACK_IMPORTED_MODULE_1__.StaveTie {
31021
31325
  static get CATEGORY() {
31022
31326
  return "TabTie" /* Category.TabTie */;
31023
31327
  }
@@ -31040,6 +31344,9 @@ class TabTie extends _stavetie__WEBPACK_IMPORTED_MODULE_0__.StaveTie {
31040
31344
  */
31041
31345
  constructor(notes, text) {
31042
31346
  super(notes, text);
31347
+ // A one-letter tab technique has a distinct face from a written direction or a slide abbreviation.
31348
+ if (text && /^[a-z]$/i.test(text))
31349
+ this.setFont(_metrics__WEBPACK_IMPORTED_MODULE_0__.Metrics.getFontInfo('TabTie.techniqueLetter'));
31043
31350
  this.renderOptions.cp1 = 9;
31044
31351
  this.renderOptions.cp2 = 11;
31045
31352
  this.renderOptions.yShift = 3;