vexflow 5.1.2 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/build/cjs/vexflow-bravura.js +2 -2
- package/build/cjs/vexflow-bravura.js.map +1 -1
- package/build/cjs/vexflow-core.js +2 -2
- package/build/cjs/vexflow-core.js.map +1 -1
- package/build/cjs/vexflow-debug-with-tests.js +2633 -415
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +2478 -382
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow.js +2 -2
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/src/accidental.js +3 -0
- package/build/esm/src/articulation.js +27 -14
- package/build/esm/src/beam.js +12 -2
- package/build/esm/src/clef.js +3 -0
- package/build/esm/src/clefnote.js +5 -1
- package/build/esm/src/dot.js +1 -1
- package/build/esm/src/easyscore/composition.js +297 -0
- package/build/esm/src/easyscore/elementindex.js +81 -0
- package/build/esm/src/easyscore/elements.js +324 -0
- package/build/esm/src/easyscore/policies.js +69 -0
- package/build/esm/src/easyscore/rhythm.js +42 -0
- package/build/esm/src/easyscore.js +448 -26
- package/build/esm/src/element.js +13 -2
- package/build/esm/src/factory.js +256 -60
- package/build/esm/src/formatter.js +32 -4
- package/build/esm/src/keysignature.js +9 -1
- package/build/esm/src/keysignote.js +2 -2
- package/build/esm/src/note.js +5 -0
- package/build/esm/src/parenthesis.js +1 -1
- package/build/esm/src/parser.js +6 -1
- package/build/esm/src/proportionalformatter.js +186 -0
- package/build/esm/src/registry.js +27 -0
- package/build/esm/src/sheet.js +20 -3
- package/build/esm/src/stave.js +9 -2
- package/build/esm/src/stavenote.js +12 -12
- package/build/esm/src/stemmablenote.js +6 -1
- package/build/esm/src/tickable.js +5 -0
- package/build/esm/src/tuplet.js +3 -2
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vexflow.js +2 -1
- package/build/esm/tests/beam_tests.js +35 -0
- package/build/esm/tests/easyscore_tests.js +40 -0
- package/build/esm/tests/easyscore_types.js +65 -0
- package/build/esm/tests/formatter_tests.js +41 -0
- package/build/esm/tests/node/easyscore-rendering-tests.mjs +332 -0
- package/build/esm/tests/node/easyscore-tests.mjs +953 -0
- package/build/esm/tests/node/proportional-spacing-tests.mjs +214 -0
- package/build/esm/tools/easyscore-api-audit.mjs +58 -0
- package/build/esm/tools/easyscore-composition.mjs +62 -0
- package/build/esm/tools/easyscore-example.mjs +16 -0
- package/build/esm/tools/easyscore-families.mjs +61 -0
- package/build/esm/tools/easyscore-references-example.mjs +26 -0
- package/build/esm/tools/easyscore-rhythm.mjs +58 -0
- package/build/esm/tools/easyscore-structure.mjs +88 -0
- package/build/esm/tools/explorer/catalog/entries.mjs +6 -0
- package/build/esm/tools/explorer/catalog/expression.mjs +68 -0
- package/build/esm/tools/explorer/catalog/helpers.mjs +29 -0
- package/build/esm/tools/explorer/catalog/layout.mjs +109 -0
- package/build/esm/tools/explorer/catalog/notes.mjs +61 -0
- package/build/esm/tools/explorer/catalog/staves.mjs +85 -0
- package/build/esm/tools/explorer/catalog/strings.mjs +25 -0
- package/build/esm/tools/explorer/catalog.mjs +14 -0
- package/build/types/src/accidental.d.ts +2 -0
- package/build/types/src/articulation.d.ts +6 -0
- package/build/types/src/beam.d.ts +2 -0
- package/build/types/src/clef.d.ts +2 -0
- package/build/types/src/easyscore/composition.d.ts +107 -0
- package/build/types/src/easyscore/elementindex.d.ts +30 -0
- package/build/types/src/easyscore/elements.d.ts +156 -0
- package/build/types/src/easyscore/policies.d.ts +12 -0
- package/build/types/src/easyscore/rhythm.d.ts +9 -0
- package/build/types/src/easyscore.d.ts +153 -11
- package/build/types/src/element.d.ts +5 -1
- package/build/types/src/factory.d.ts +91 -8
- package/build/types/src/formatter.d.ts +7 -1
- package/build/types/src/keysignature.d.ts +3 -0
- package/build/types/src/keysignote.d.ts +1 -1
- package/build/types/src/note.d.ts +2 -0
- package/build/types/src/parser.d.ts +5 -0
- package/build/types/src/proportionalformatter.d.ts +30 -0
- package/build/types/src/registry.d.ts +4 -0
- package/build/types/src/stave.d.ts +2 -0
- package/build/types/src/stavenote.d.ts +1 -1
- package/build/types/src/stemmablenote.d.ts +6 -1
- package/build/types/src/tickable.d.ts +2 -0
- package/build/types/src/vexflow.d.ts +2 -1
- package/changelog/CHANGELOG.md +35 -0
- package/package.json +7 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VexFlow 5.
|
|
2
|
+
* VexFlow 5.2.0 2026-11-17T02:51:04.170Z 8b18873122b9b765ee130661d77692b3606fbcaf
|
|
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) {
|
|
@@ -80,7 +80,7 @@ function L(...args) {
|
|
|
80
80
|
class Accidental extends _modifier__WEBPACK_IMPORTED_MODULE_2__.Modifier {
|
|
81
81
|
/** Accidentals category string. */
|
|
82
82
|
static get CATEGORY() {
|
|
83
|
-
return
|
|
83
|
+
return "Accidental" /* Category.Accidental */;
|
|
84
84
|
}
|
|
85
85
|
/** Arrange accidentals inside a ModifierContext. */
|
|
86
86
|
static format(accidentals, state) {
|
|
@@ -497,6 +497,10 @@ class Accidental extends _modifier__WEBPACK_IMPORTED_MODULE_2__.Modifier {
|
|
|
497
497
|
this.reset();
|
|
498
498
|
return this;
|
|
499
499
|
}
|
|
500
|
+
/** Identify explicit cautionary signs without inspecting protected engraving state. */
|
|
501
|
+
isCautionary() {
|
|
502
|
+
return this.cautionary;
|
|
503
|
+
}
|
|
500
504
|
/** Render accidental onto canvas. */
|
|
501
505
|
draw() {
|
|
502
506
|
const { type, position, index } = this;
|
|
@@ -872,6 +876,8 @@ function L(...args) {
|
|
|
872
876
|
(0,_util__WEBPACK_IMPORTED_MODULE_5__.log)('VexFlow.Articulation', args);
|
|
873
877
|
}
|
|
874
878
|
const { ABOVE, BELOW } = _modifier__WEBPACK_IMPORTED_MODULE_1__.Modifier.Position;
|
|
879
|
+
/** SMuFL values accepted by the native articulation constructor, cached for notation validation. */
|
|
880
|
+
const easyScoreGlyphs = new Set(Object.values(_glyphs__WEBPACK_IMPORTED_MODULE_0__.Glyphs));
|
|
875
881
|
function roundToNearestHalf(mathFn, value) {
|
|
876
882
|
return mathFn(value / 0.5) * 0.5;
|
|
877
883
|
}
|
|
@@ -1015,7 +1021,7 @@ function getInitialOffset(note, position) {
|
|
|
1015
1021
|
class Articulation extends _modifier__WEBPACK_IMPORTED_MODULE_1__.Modifier {
|
|
1016
1022
|
/** Articulations category string. */
|
|
1017
1023
|
static get CATEGORY() {
|
|
1018
|
-
return
|
|
1024
|
+
return "Articulation" /* Category.Articulation */;
|
|
1019
1025
|
}
|
|
1020
1026
|
/**
|
|
1021
1027
|
* FIXME:
|
|
@@ -1097,24 +1103,39 @@ class Articulation extends _modifier__WEBPACK_IMPORTED_MODULE_1__.Modifier {
|
|
|
1097
1103
|
state.rightShift += overlap / 2;
|
|
1098
1104
|
return true;
|
|
1099
1105
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
const articNameToCode = {
|
|
1106
|
+
/** Resolve EasyScore aliases, native codes, or named SMuFL glyphs without constructing a modifier. */
|
|
1107
|
+
static parseEasyScore(articulations) {
|
|
1108
|
+
const aliases = {
|
|
1104
1109
|
staccato: 'a.',
|
|
1105
1110
|
tenuto: 'a-',
|
|
1106
1111
|
accent: 'a>',
|
|
1112
|
+
fermata: 'a@',
|
|
1113
|
+
marcato: 'a^',
|
|
1114
|
+
staccatissimo: 'av',
|
|
1107
1115
|
};
|
|
1108
|
-
articulations
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
.
|
|
1116
|
+
const singleCode = articulations.trim().replace(/\.(above|below|left|right)$/, '');
|
|
1117
|
+
const items = _tables__WEBPACK_IMPORTED_MODULE_3__.Tables.articulationCodes(singleCode) ? [articulations] : articulations.split(',');
|
|
1118
|
+
return items.map((value) => {
|
|
1119
|
+
var _a;
|
|
1120
|
+
// A native code can itself contain a dot (a.). Only consume a named position suffix.
|
|
1121
|
+
const match = /^(.*)\.(above|below|left|right)$/.exec(value.trim());
|
|
1122
|
+
const name = match ? match[1] : value.trim();
|
|
1123
|
+
const type = Object.hasOwnProperty.call(aliases, name) ? aliases[name] : name;
|
|
1124
|
+
const glyph = Object.hasOwnProperty.call(_glyphs__WEBPACK_IMPORTED_MODULE_0__.Glyphs, type) ? _glyphs__WEBPACK_IMPORTED_MODULE_0__.Glyphs[type] : type;
|
|
1125
|
+
if (!Object.hasOwnProperty.call((_a = _tables__WEBPACK_IMPORTED_MODULE_3__.Tables.articulationCodes(type)) !== null && _a !== void 0 ? _a : {}, 'betweenLines') &&
|
|
1126
|
+
!easyScoreGlyphs.has(glyph)) {
|
|
1127
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArguments', `Unknown EasyScore articulation: ${name}`);
|
|
1128
|
+
}
|
|
1129
|
+
return { type: glyph, position: match ? _modifier__WEBPACK_IMPORTED_MODULE_1__.Modifier.PositionString[match[2]] : undefined };
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
/** Attach validated EasyScore articulations once, after note construction. */
|
|
1133
|
+
static easyScoreHook({ articulations }, note, builder) {
|
|
1134
|
+
if (!articulations)
|
|
1135
|
+
return;
|
|
1136
|
+
Articulation.parseEasyScore(articulations).forEach((params) => {
|
|
1137
|
+
note.addModifier(builder.getFactory().Articulation(params), 0);
|
|
1138
|
+
});
|
|
1118
1139
|
}
|
|
1119
1140
|
/**
|
|
1120
1141
|
* Create a new articulation.
|
|
@@ -1315,9 +1336,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1315
1336
|
/* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fraction */ "./src/fraction.ts");
|
|
1316
1337
|
/* harmony import */ var _stem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stem */ "./src/stem.ts");
|
|
1317
1338
|
/* harmony import */ var _tables__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tables */ "./src/tables.ts");
|
|
1318
|
-
/* harmony import */ var
|
|
1319
|
-
/* harmony import */ var
|
|
1320
|
-
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
1339
|
+
/* harmony import */ var _typeguard__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./typeguard */ "./src/typeguard.ts");
|
|
1340
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
1321
1341
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
1322
1342
|
// MIT License
|
|
1323
1343
|
|
|
@@ -1326,7 +1346,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1326
1346
|
|
|
1327
1347
|
|
|
1328
1348
|
|
|
1329
|
-
|
|
1330
1349
|
function calculateStemDirection(notes) {
|
|
1331
1350
|
let lineSum = 0;
|
|
1332
1351
|
notes.forEach((note) => {
|
|
@@ -1354,7 +1373,7 @@ const BEAM_BOTH = 'B';
|
|
|
1354
1373
|
/** `Beams` span over a set of `StemmableNotes`. */
|
|
1355
1374
|
class Beam extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
1356
1375
|
static get CATEGORY() {
|
|
1357
|
-
return
|
|
1376
|
+
return "Beam" /* Category.Beam */;
|
|
1358
1377
|
}
|
|
1359
1378
|
/** Get the direction of the beam */
|
|
1360
1379
|
getStemDirection() {
|
|
@@ -1451,7 +1470,7 @@ class Beam extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
1451
1470
|
// Convert beam groups to tick amounts
|
|
1452
1471
|
const tickGroups = config.groups.map((group) => {
|
|
1453
1472
|
if (!group.multiply) {
|
|
1454
|
-
throw new
|
|
1473
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('InvalidBeamGroups', 'The beam groups must be an array of VexFlow.Fractions');
|
|
1455
1474
|
}
|
|
1456
1475
|
return group.clone().multiply(_tables__WEBPACK_IMPORTED_MODULE_3__.Tables.RESOLUTION, 1);
|
|
1457
1476
|
});
|
|
@@ -1578,6 +1597,17 @@ class Beam extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
1578
1597
|
}
|
|
1579
1598
|
function formatStems() {
|
|
1580
1599
|
noteGroups.forEach((group) => {
|
|
1600
|
+
if (config.stemPolicy === 'preserve')
|
|
1601
|
+
return;
|
|
1602
|
+
if (config.stemPolicy === 'explicit') {
|
|
1603
|
+
const explicit = new Set(group.filter((note) => !note.isRest() && !note.isAutoStem()).map((note) => note.getStemDirection()));
|
|
1604
|
+
// Cross-staff groups retain mixed explicit directions. Automatic notes follow a sole explicit direction.
|
|
1605
|
+
if (explicit.size > 1)
|
|
1606
|
+
return;
|
|
1607
|
+
const direction = explicit.size ? [...explicit][0] : calculateStemDirection(group);
|
|
1608
|
+
group.filter((note) => note.isAutoStem()).forEach((note) => note.setStemDirection(direction, true));
|
|
1609
|
+
return;
|
|
1610
|
+
}
|
|
1581
1611
|
let stemDirection;
|
|
1582
1612
|
if (config.maintainStemDirections) {
|
|
1583
1613
|
const note = findFirstNote(group);
|
|
@@ -1605,7 +1635,7 @@ class Beam extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
1605
1635
|
}
|
|
1606
1636
|
function applyStemDirection(group, direction) {
|
|
1607
1637
|
group.forEach((note) => {
|
|
1608
|
-
note.setStemDirection(direction);
|
|
1638
|
+
note.setStemDirection(direction, config.stemDirection === undefined && note.isAutoStem());
|
|
1609
1639
|
});
|
|
1610
1640
|
}
|
|
1611
1641
|
// Get all of the tuplets in all of the note groups
|
|
@@ -1653,7 +1683,7 @@ class Beam extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
1653
1683
|
// Reformat tuplets
|
|
1654
1684
|
allTuplets.forEach((tuplet) => {
|
|
1655
1685
|
// Set the tuplet location based on the stem direction
|
|
1656
|
-
const direction = tuplet.notes[0].stemDirection === _stem__WEBPACK_IMPORTED_MODULE_2__.Stem.DOWN ?
|
|
1686
|
+
const direction = tuplet.notes[0].stemDirection === _stem__WEBPACK_IMPORTED_MODULE_2__.Stem.DOWN ? -1 /* TupletLocation.BOTTOM */ : 1 /* TupletLocation.TOP */;
|
|
1657
1687
|
tuplet.setTupletLocation(direction);
|
|
1658
1688
|
// If any of the notes in the tuplet are not beamed, draw a bracket.
|
|
1659
1689
|
let bracketed = false;
|
|
@@ -1679,26 +1709,26 @@ class Beam extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
1679
1709
|
*/
|
|
1680
1710
|
this.forcedPartialDirections = {};
|
|
1681
1711
|
if (!notes || notes.length === 0) {
|
|
1682
|
-
throw new
|
|
1712
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArguments', 'No notes provided for beam.');
|
|
1683
1713
|
}
|
|
1684
1714
|
if (notes.length === 1) {
|
|
1685
|
-
throw new
|
|
1715
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArguments', 'Too few notes for beam.');
|
|
1686
1716
|
}
|
|
1687
1717
|
// Validate beam line, direction and ticks.
|
|
1688
1718
|
this._ticks = notes[0].getIntrinsicTicks();
|
|
1689
1719
|
if (this._ticks >= _tables__WEBPACK_IMPORTED_MODULE_3__.Tables.durationToTicks('4')) {
|
|
1690
1720
|
// Q(MSAC) -- what about beamed half-note measured tremolos?
|
|
1691
|
-
throw new
|
|
1721
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArguments', 'Beams can only be applied to notes shorter than a quarter note.');
|
|
1692
1722
|
}
|
|
1693
1723
|
let i; // shared iterator
|
|
1694
1724
|
let note;
|
|
1695
1725
|
this._stemDirection = notes[0].getStemDirection();
|
|
1696
1726
|
let stemDirection = this._stemDirection;
|
|
1697
1727
|
// Figure out optimal stem direction based on given notes
|
|
1698
|
-
if (autoStem && (0,
|
|
1728
|
+
if (autoStem && (0,_typeguard__WEBPACK_IMPORTED_MODULE_4__.isStaveNote)(notes[0])) {
|
|
1699
1729
|
stemDirection = calculateStemDirection(notes);
|
|
1700
1730
|
}
|
|
1701
|
-
else if (autoStem && (0,
|
|
1731
|
+
else if (autoStem && (0,_typeguard__WEBPACK_IMPORTED_MODULE_4__.isTabNote)(notes[0])) {
|
|
1702
1732
|
// Auto Stem TabNotes
|
|
1703
1733
|
const stemWeight = notes.reduce((memo, note) => memo + note.getStemDirection(), 0);
|
|
1704
1734
|
stemDirection = stemWeight > -1 ? _stem__WEBPACK_IMPORTED_MODULE_2__.Stem.UP : _stem__WEBPACK_IMPORTED_MODULE_2__.Stem.DOWN;
|
|
@@ -1707,7 +1737,7 @@ class Beam extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
1707
1737
|
for (i = 0; i < notes.length; ++i) {
|
|
1708
1738
|
note = notes[i];
|
|
1709
1739
|
if (autoStem) {
|
|
1710
|
-
note.setStemDirection(stemDirection);
|
|
1740
|
+
note.setStemDirection(stemDirection, true);
|
|
1711
1741
|
this._stemDirection = stemDirection;
|
|
1712
1742
|
}
|
|
1713
1743
|
note.setBeam(this);
|
|
@@ -2105,7 +2135,7 @@ class Beam extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
2105
2135
|
ctx.fill();
|
|
2106
2136
|
}
|
|
2107
2137
|
else {
|
|
2108
|
-
throw new
|
|
2138
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('NoLastBeamX', 'lastBeamX undefined.');
|
|
2109
2139
|
}
|
|
2110
2140
|
}
|
|
2111
2141
|
beamY += beamThickness * 1.5;
|
|
@@ -2124,7 +2154,7 @@ class Beam extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
2124
2154
|
if (this.postFormatted)
|
|
2125
2155
|
return;
|
|
2126
2156
|
// Calculate a smart slope if we're not forcing the beams to be flat.
|
|
2127
|
-
if ((0,
|
|
2157
|
+
if ((0,_typeguard__WEBPACK_IMPORTED_MODULE_4__.isTabNote)(this.notes[0]) || this.renderOptions.flatBeams) {
|
|
2128
2158
|
this.calculateFlatSlope();
|
|
2129
2159
|
}
|
|
2130
2160
|
else {
|
|
@@ -3406,8 +3436,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3406
3436
|
/* harmony import */ var _glyphs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glyphs */ "./src/glyphs.ts");
|
|
3407
3437
|
/* harmony import */ var _metrics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./metrics */ "./src/metrics.ts");
|
|
3408
3438
|
/* harmony import */ var _stavemodifier__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stavemodifier */ "./src/stavemodifier.ts");
|
|
3409
|
-
/* harmony import */ var
|
|
3410
|
-
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
3439
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
3411
3440
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
3412
3441
|
// MIT License
|
|
3413
3442
|
// Co-author: Benjamin W. Bohl
|
|
@@ -3415,11 +3444,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3415
3444
|
|
|
3416
3445
|
|
|
3417
3446
|
|
|
3418
|
-
|
|
3419
3447
|
// eslint-disable-next-line
|
|
3420
3448
|
function L(...args) {
|
|
3421
3449
|
if (Clef.DEBUG)
|
|
3422
|
-
(0,
|
|
3450
|
+
(0,_util__WEBPACK_IMPORTED_MODULE_3__.log)('VexFlow.Clef', args);
|
|
3423
3451
|
}
|
|
3424
3452
|
/**
|
|
3425
3453
|
* Clef implements various types of clefs that can be rendered on a stave.
|
|
@@ -3428,7 +3456,7 @@ function L(...args) {
|
|
|
3428
3456
|
*/
|
|
3429
3457
|
class Clef extends _stavemodifier__WEBPACK_IMPORTED_MODULE_2__.StaveModifier {
|
|
3430
3458
|
static get CATEGORY() {
|
|
3431
|
-
return
|
|
3459
|
+
return "Clef" /* Category.Clef */;
|
|
3432
3460
|
}
|
|
3433
3461
|
/**
|
|
3434
3462
|
* Every clef name is associated with a glyph code from the font file
|
|
@@ -3502,6 +3530,10 @@ class Clef extends _stavemodifier__WEBPACK_IMPORTED_MODULE_2__.StaveModifier {
|
|
|
3502
3530
|
this.setType(type, size, annotation);
|
|
3503
3531
|
L('Creating clef:', type);
|
|
3504
3532
|
}
|
|
3533
|
+
/** Return the named clef so staff attachments can retain musical state. */
|
|
3534
|
+
getType() {
|
|
3535
|
+
return this.type;
|
|
3536
|
+
}
|
|
3505
3537
|
/** Set clef type, size and annotation. */
|
|
3506
3538
|
setType(type, size = 'default', annotation) {
|
|
3507
3539
|
this.type = type;
|
|
@@ -3570,17 +3602,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3570
3602
|
/* harmony export */ });
|
|
3571
3603
|
/* harmony import */ var _clef__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./clef */ "./src/clef.ts");
|
|
3572
3604
|
/* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./note */ "./src/note.ts");
|
|
3573
|
-
/* harmony import */ var _typeguard__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./typeguard */ "./src/typeguard.ts");
|
|
3574
3605
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
3575
3606
|
// @author: Taehoon Moon 2014
|
|
3576
3607
|
// MIT License
|
|
3577
3608
|
|
|
3578
3609
|
|
|
3579
|
-
|
|
3580
3610
|
/** ClefNote implements clef annotations in measures. */
|
|
3581
3611
|
class ClefNote extends _note__WEBPACK_IMPORTED_MODULE_1__.Note {
|
|
3582
3612
|
static get CATEGORY() {
|
|
3583
|
-
return
|
|
3613
|
+
return "ClefNote" /* Category.ClefNote */;
|
|
3584
3614
|
}
|
|
3585
3615
|
constructor(type, size = 'default', annotation) {
|
|
3586
3616
|
super({ duration: 'b' });
|
|
@@ -3611,7 +3641,11 @@ class ClefNote extends _note__WEBPACK_IMPORTED_MODULE_1__.Note {
|
|
|
3611
3641
|
this.clef.renderText(ctx, 0, 0);
|
|
3612
3642
|
}
|
|
3613
3643
|
getBoundingBox() {
|
|
3614
|
-
|
|
3644
|
+
const box = this.clef.getBoundingBox();
|
|
3645
|
+
const stave = this.getStave();
|
|
3646
|
+
if (stave)
|
|
3647
|
+
box.setY(stave.getYForLine(this.clef.line) + this.clef.getYShift() - this.clef.getTextMetrics().actualBoundingBoxAscent);
|
|
3648
|
+
return box;
|
|
3615
3649
|
}
|
|
3616
3650
|
}
|
|
3617
3651
|
|
|
@@ -3992,7 +4026,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3992
4026
|
|
|
3993
4027
|
class Dot extends _modifier__WEBPACK_IMPORTED_MODULE_1__.Modifier {
|
|
3994
4028
|
static get CATEGORY() {
|
|
3995
|
-
return
|
|
4029
|
+
return "Dot" /* Category.Dot */;
|
|
3996
4030
|
}
|
|
3997
4031
|
/** Returns the dots associated to a Note. */
|
|
3998
4032
|
static getDots(note) {
|
|
@@ -4106,7 +4140,8 @@ class Dot extends _modifier__WEBPACK_IMPORTED_MODULE_1__.Modifier {
|
|
|
4106
4140
|
}
|
|
4107
4141
|
setNote(note) {
|
|
4108
4142
|
this.note = note;
|
|
4109
|
-
|
|
4143
|
+
// Keep native font data; parsing CSS here would require a browser document in Node.
|
|
4144
|
+
this.setFont(note.fontInfo);
|
|
4110
4145
|
return this;
|
|
4111
4146
|
}
|
|
4112
4147
|
setDotShiftY(y) {
|
|
@@ -4143,18 +4178,31 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4143
4178
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4144
4179
|
/* harmony export */ Builder: () => (/* binding */ Builder),
|
|
4145
4180
|
/* harmony export */ EasyScore: () => (/* binding */ EasyScore),
|
|
4181
|
+
/* harmony export */ EasyScoreError: () => (/* binding */ EasyScoreError),
|
|
4146
4182
|
/* harmony export */ EasyScoreGrammar: () => (/* binding */ EasyScoreGrammar),
|
|
4147
4183
|
/* harmony export */ Piece: () => (/* binding */ Piece)
|
|
4148
4184
|
/* harmony export */ });
|
|
4149
4185
|
/* harmony import */ var _articulation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./articulation */ "./src/articulation.ts");
|
|
4150
|
-
/* harmony import */ var
|
|
4151
|
-
/* harmony import */ var
|
|
4152
|
-
/* harmony import */ var
|
|
4153
|
-
/* harmony import */ var
|
|
4154
|
-
/* harmony import */ var
|
|
4155
|
-
/* harmony import */ var
|
|
4186
|
+
/* harmony import */ var _clef__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./clef */ "./src/clef.ts");
|
|
4187
|
+
/* harmony import */ var _dot__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dot */ "./src/dot.ts");
|
|
4188
|
+
/* harmony import */ var _easyscore_composition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./easyscore/composition */ "./src/easyscore/composition.ts");
|
|
4189
|
+
/* harmony import */ var _easyscore_elementindex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easyscore/elementindex */ "./src/easyscore/elementindex.ts");
|
|
4190
|
+
/* harmony import */ var _easyscore_elements__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./easyscore/elements */ "./src/easyscore/elements.ts");
|
|
4191
|
+
/* harmony import */ var _easyscore_rhythm__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./easyscore/rhythm */ "./src/easyscore/rhythm.ts");
|
|
4192
|
+
/* harmony import */ var _factory__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./factory */ "./src/factory.ts");
|
|
4193
|
+
/* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./fraction */ "./src/fraction.ts");
|
|
4194
|
+
/* harmony import */ var _frethandfinger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./frethandfinger */ "./src/frethandfinger.ts");
|
|
4195
|
+
/* harmony import */ var _music__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./music */ "./src/music.ts");
|
|
4196
|
+
/* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./note */ "./src/note.ts");
|
|
4197
|
+
/* harmony import */ var _parser__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./parser */ "./src/parser.ts");
|
|
4198
|
+
/* harmony import */ var _stem__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stem */ "./src/stem.ts");
|
|
4199
|
+
/* harmony import */ var _tables__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tables */ "./src/tables.ts");
|
|
4200
|
+
/* harmony import */ var _tabnote__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./tabnote */ "./src/tabnote.ts");
|
|
4201
|
+
/* harmony import */ var _tickable__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tickable */ "./src/tickable.ts");
|
|
4202
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
4203
|
+
/* harmony import */ var _voice__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./voice */ "./src/voice.ts");
|
|
4156
4204
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
4157
|
-
//
|
|
4205
|
+
// Compose native notation through EasyScore, with pure diagnostics and staged strict construction.
|
|
4158
4206
|
// MIT License
|
|
4159
4207
|
|
|
4160
4208
|
|
|
@@ -4163,11 +4211,23 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4163
4211
|
|
|
4164
4212
|
|
|
4165
4213
|
|
|
4214
|
+
|
|
4215
|
+
|
|
4216
|
+
|
|
4217
|
+
|
|
4218
|
+
|
|
4219
|
+
|
|
4220
|
+
|
|
4221
|
+
|
|
4222
|
+
|
|
4223
|
+
|
|
4224
|
+
|
|
4225
|
+
|
|
4166
4226
|
// To enable logging for this class. Set `VexFlow.EasyScore.DEBUG` to `true`.
|
|
4167
4227
|
// eslint-disable-next-line
|
|
4168
4228
|
function L(...args) {
|
|
4169
4229
|
if (EasyScore.DEBUG)
|
|
4170
|
-
(0,
|
|
4230
|
+
(0,_util__WEBPACK_IMPORTED_MODULE_17__.log)('VexFlow.EasyScore', args);
|
|
4171
4231
|
}
|
|
4172
4232
|
class EasyScoreGrammar {
|
|
4173
4233
|
constructor(builder) {
|
|
@@ -4184,7 +4244,7 @@ class EasyScoreGrammar {
|
|
|
4184
4244
|
PIECE() {
|
|
4185
4245
|
return {
|
|
4186
4246
|
expect: [this.CHORDORNOTE, this.PARAMS],
|
|
4187
|
-
run: () => this.builder.commitPiece(),
|
|
4247
|
+
run: (state) => this.builder.commitPiece(state && { start: state.start, end: state.end }),
|
|
4188
4248
|
};
|
|
4189
4249
|
}
|
|
4190
4250
|
PIECES() {
|
|
@@ -4352,6 +4412,7 @@ class Piece {
|
|
|
4352
4412
|
class Builder {
|
|
4353
4413
|
constructor(factory) {
|
|
4354
4414
|
this.commitHooks = [];
|
|
4415
|
+
// A factory-less builder is also used by syntax-only parsing.
|
|
4355
4416
|
this.factory = factory;
|
|
4356
4417
|
this.reset();
|
|
4357
4418
|
}
|
|
@@ -4363,7 +4424,7 @@ class Builder {
|
|
|
4363
4424
|
this.resetPiece();
|
|
4364
4425
|
}
|
|
4365
4426
|
getFactory() {
|
|
4366
|
-
return this.factory;
|
|
4427
|
+
return (0,_util__WEBPACK_IMPORTED_MODULE_17__.defined)(this.factory, 'NoFactory', 'Create EasyScore with a Factory before constructing notes.');
|
|
4367
4428
|
}
|
|
4368
4429
|
getElements() {
|
|
4369
4430
|
return this.elements;
|
|
@@ -4419,7 +4480,9 @@ class Builder {
|
|
|
4419
4480
|
}
|
|
4420
4481
|
L('endChord');
|
|
4421
4482
|
}
|
|
4422
|
-
commitPiece() {
|
|
4483
|
+
commitPiece(source) {
|
|
4484
|
+
var _a;
|
|
4485
|
+
this.piece.source = source;
|
|
4423
4486
|
L('commitPiece');
|
|
4424
4487
|
const { factory } = this;
|
|
4425
4488
|
if (!factory)
|
|
@@ -4427,14 +4490,14 @@ class Builder {
|
|
|
4427
4490
|
const options = Object.assign(Object.assign({}, this.options), this.piece.options);
|
|
4428
4491
|
// reset() sets this.options.stem & this.options.clef but we check to make sure nothing has changed.
|
|
4429
4492
|
// e.g., auto | up | down
|
|
4430
|
-
const stem = (0,
|
|
4493
|
+
const stem = (0,_util__WEBPACK_IMPORTED_MODULE_17__.defined)(options.stem, 'BadArguments', 'options.stem is not defined').toLowerCase();
|
|
4431
4494
|
// e.g., treble | bass
|
|
4432
|
-
const clef = (0,
|
|
4495
|
+
const clef = (0,_util__WEBPACK_IMPORTED_MODULE_17__.defined)(options.clef, 'BadArguments', 'options.clef is not defined').toLowerCase();
|
|
4433
4496
|
const { chord, duration, dots, type } = this.piece;
|
|
4434
4497
|
// Create a string[] that will be assigned to the .keys property of the StaveNote.
|
|
4435
4498
|
// Each string in the array represents a note pitch and is of the form: {NoteName}{Accidental}/{Octave}
|
|
4436
4499
|
// Only standard accidentals are included in the .keys property. Microtonal accidentals are not included.
|
|
4437
|
-
const standardAccidentals =
|
|
4500
|
+
const standardAccidentals = _music__WEBPACK_IMPORTED_MODULE_10__.Music.accidentals;
|
|
4438
4501
|
const keys = chord.map((notePiece) => {
|
|
4439
4502
|
var _a;
|
|
4440
4503
|
return notePiece.key +
|
|
@@ -4442,13 +4505,20 @@ class Builder {
|
|
|
4442
4505
|
'/' +
|
|
4443
4506
|
notePiece.octave;
|
|
4444
4507
|
});
|
|
4508
|
+
const nativeOptions = {
|
|
4509
|
+
octaveShift: options.octaveShift === undefined ? undefined : Number(options.octaveShift),
|
|
4510
|
+
strokePx: options.strokePx === undefined ? undefined : Number(options.strokePx),
|
|
4511
|
+
line: options.line === undefined ? undefined : Number(options.line),
|
|
4512
|
+
alignCenter: String(options.alignCenter) === 'true',
|
|
4513
|
+
durationOverride: options.durationOverride,
|
|
4514
|
+
};
|
|
4445
4515
|
const autoStem = stem === 'auto'; // StaveNoteStruct expects the underscore & lowercase.
|
|
4446
4516
|
// Build a GhostNote or StaveNote using the information we gathered.
|
|
4447
4517
|
const note = (type === null || type === void 0 ? void 0 : type.toLowerCase()) === 'g'
|
|
4448
|
-
? factory.GhostNote({ duration, dots })
|
|
4449
|
-
: factory.StaveNote({ keys, duration, dots, type, clef, autoStem });
|
|
4518
|
+
? factory.GhostNote(Object.assign(Object.assign({}, nativeOptions), { duration, dots }))
|
|
4519
|
+
: factory.StaveNote(Object.assign(Object.assign({}, nativeOptions), { keys, duration, dots, type, clef, autoStem }));
|
|
4450
4520
|
if (!autoStem)
|
|
4451
|
-
note.setStemDirection(stem === 'up' ?
|
|
4521
|
+
note.setStemDirection(stem === 'up' ? _stem__WEBPACK_IMPORTED_MODULE_13__.Stem.UP : _stem__WEBPACK_IMPORTED_MODULE_13__.Stem.DOWN);
|
|
4452
4522
|
// Attach accidentals.
|
|
4453
4523
|
const accidentals = [];
|
|
4454
4524
|
chord.forEach((notePiece, index) => {
|
|
@@ -4464,13 +4534,37 @@ class Builder {
|
|
|
4464
4534
|
});
|
|
4465
4535
|
// Attach dots.
|
|
4466
4536
|
for (let i = 0; i < dots; i++)
|
|
4467
|
-
|
|
4537
|
+
_dot__WEBPACK_IMPORTED_MODULE_2__.Dot.buildAndAttach([note], { all: true });
|
|
4468
4538
|
this.commitHooks.forEach((commitHook) => commitHook(options, note, this));
|
|
4539
|
+
(_a = this.onNote) === null || _a === void 0 ? void 0 : _a.call(this, note, source);
|
|
4469
4540
|
this.elements.notes.push(note);
|
|
4470
4541
|
this.elements.accidentals.push(accidentals);
|
|
4471
4542
|
this.resetPiece();
|
|
4472
4543
|
}
|
|
4473
4544
|
}
|
|
4545
|
+
/** The same diagnostics are available to callers that prefer exceptions. */
|
|
4546
|
+
class EasyScoreError extends _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError {
|
|
4547
|
+
constructor(diagnostics) {
|
|
4548
|
+
super('EasyScoreError', diagnostics.map((d) => `${d.message} (${d.line}:${d.column})`).join('; '));
|
|
4549
|
+
this.diagnostics = diagnostics;
|
|
4550
|
+
}
|
|
4551
|
+
}
|
|
4552
|
+
/** Collect pieces without calling Factory constructors or commit hooks. */
|
|
4553
|
+
class NotationBuilder extends Builder {
|
|
4554
|
+
constructor() {
|
|
4555
|
+
super(...arguments);
|
|
4556
|
+
this.pieces = [];
|
|
4557
|
+
}
|
|
4558
|
+
commitPiece(source = { start: 0, end: 0 }) {
|
|
4559
|
+
this.pieces.push(Object.assign(Object.assign({}, this.piece), { source }));
|
|
4560
|
+
this.resetPiece();
|
|
4561
|
+
}
|
|
4562
|
+
}
|
|
4563
|
+
/** Convert a source range into the common diagnostic shape. */
|
|
4564
|
+
function diagnostic(line, code, message, source) {
|
|
4565
|
+
const prefix = line.slice(0, source.start);
|
|
4566
|
+
return Object.assign(Object.assign({}, source), { code, message, line: prefix.split('\n').length, column: source.start - prefix.lastIndexOf('\n') });
|
|
4567
|
+
}
|
|
4474
4568
|
/**
|
|
4475
4569
|
* Commit hook used by EasyScore.setOptions().
|
|
4476
4570
|
*/
|
|
@@ -4493,7 +4587,177 @@ function setClass(options, note) {
|
|
|
4493
4587
|
* EasyScore implements a parser for a simple language to generate VexFlow objects.
|
|
4494
4588
|
*/
|
|
4495
4589
|
class EasyScore {
|
|
4590
|
+
/** Inspect notation provenance without installing a global Registry. Useful for visual tooling. */
|
|
4591
|
+
static getSource(element) {
|
|
4592
|
+
return _easyscore_elementindex__WEBPACK_IMPORTED_MODULE_4__.EasyScoreReferences.sourceOf(element);
|
|
4593
|
+
}
|
|
4594
|
+
/** Look up a native object in this score. Missing IDs return undefined. */
|
|
4595
|
+
getElement(id) {
|
|
4596
|
+
return this.references.get(id);
|
|
4597
|
+
}
|
|
4598
|
+
/** Resolve a named note for typed relationship APIs. Missing IDs and non-notes throw. */
|
|
4599
|
+
getNote(id) {
|
|
4600
|
+
const element = this.getElement(id);
|
|
4601
|
+
if (!(element instanceof _note__WEBPACK_IMPORTED_MODULE_11__.Note))
|
|
4602
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', `No note with ID: ${id}`);
|
|
4603
|
+
return element;
|
|
4604
|
+
}
|
|
4605
|
+
/** Return a defensive copy of a generated element's source, or undefined for native objects. */
|
|
4606
|
+
getSource(element) {
|
|
4607
|
+
return this.references.getSource(element);
|
|
4608
|
+
}
|
|
4609
|
+
/** Explicitly join a native extension to this score's ownership and drawing lifecycle. */
|
|
4610
|
+
adopt(element, role) {
|
|
4611
|
+
return this.transaction(() => this.references.add(this.factory.adopt(element, role)));
|
|
4612
|
+
}
|
|
4613
|
+
/** Stage local references together with Factory queues and ambient registry entries. */
|
|
4614
|
+
transaction(build) {
|
|
4615
|
+
return this.references.transaction(() => (this.factory ? this.factory.transaction(build) : build()));
|
|
4616
|
+
}
|
|
4617
|
+
/** Create a strict EasyScore facade with its own Factory. Load fonts before constructing notation. */
|
|
4618
|
+
static create(options, scoreOptions = {}) {
|
|
4619
|
+
return new _factory__WEBPACK_IMPORTED_MODULE_7__.Factory(options).EasyScore(Object.assign({ throwOnError: true, strictOptions: true }, scoreOptions));
|
|
4620
|
+
}
|
|
4621
|
+
/** Attach a modifier once. Native custom modifiers are welcome; foreign Factory objects are rejected. */
|
|
4622
|
+
attach(note, modifier, index = 0) {
|
|
4623
|
+
this.requireOwned(note);
|
|
4624
|
+
this.checkIndex(note, index);
|
|
4625
|
+
const owner = _factory__WEBPACK_IMPORTED_MODULE_7__.Factory.getOwner(modifier);
|
|
4626
|
+
if (owner && owner !== this.factory)
|
|
4627
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'Modifier belongs to another Factory.');
|
|
4628
|
+
let attached;
|
|
4629
|
+
try {
|
|
4630
|
+
attached = modifier.getNote();
|
|
4631
|
+
}
|
|
4632
|
+
catch (error) {
|
|
4633
|
+
// Only the native unattached-modifier error means there is no existing owner.
|
|
4634
|
+
if (!(error instanceof _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError) || error.code !== 'NoNote')
|
|
4635
|
+
throw error;
|
|
4636
|
+
}
|
|
4637
|
+
if (attached) {
|
|
4638
|
+
if (attached === note && modifier.getIndex() === index && note.getModifiers().includes(modifier))
|
|
4639
|
+
return note;
|
|
4640
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'Modifier is already attached. Create a separate modifier.');
|
|
4641
|
+
}
|
|
4642
|
+
return this.transaction(() => {
|
|
4643
|
+
this.adopt(modifier, 'modifier');
|
|
4644
|
+
return note.addModifier(modifier, index);
|
|
4645
|
+
});
|
|
4646
|
+
}
|
|
4647
|
+
/** Attach staff notation once; the stave owns its drawing lifecycle. */
|
|
4648
|
+
attachToStave(stave, modifier, position) {
|
|
4649
|
+
this.requireOwned(stave);
|
|
4650
|
+
const owner = _factory__WEBPACK_IMPORTED_MODULE_7__.Factory.getOwner(modifier);
|
|
4651
|
+
if (owner && owner !== this.factory)
|
|
4652
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'Modifier belongs to another Factory.');
|
|
4653
|
+
if (position !== undefined && (!Number.isInteger(position) || position < 0 || position > 6))
|
|
4654
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'Invalid stave modifier position.');
|
|
4655
|
+
if (modifier.getStave()) {
|
|
4656
|
+
if (modifier.getStave() === stave &&
|
|
4657
|
+
stave.getModifiers().includes(modifier) &&
|
|
4658
|
+
(position === undefined || position === modifier.getPosition()))
|
|
4659
|
+
return stave;
|
|
4660
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'Stave modifier is already attached.');
|
|
4661
|
+
}
|
|
4662
|
+
return this.transaction(() => {
|
|
4663
|
+
this.adopt(modifier, 'staveModifier');
|
|
4664
|
+
stave.addModifier(modifier, position);
|
|
4665
|
+
return stave;
|
|
4666
|
+
});
|
|
4667
|
+
}
|
|
4668
|
+
/** Apply temporary defaults to synchronous managed construction; restore them on success or failure. */
|
|
4669
|
+
withDefaults(defaults, construct) {
|
|
4670
|
+
const previous = this.defaults;
|
|
4671
|
+
try {
|
|
4672
|
+
this.set(defaults);
|
|
4673
|
+
return this.build(construct);
|
|
4674
|
+
}
|
|
4675
|
+
finally {
|
|
4676
|
+
this.defaults = previous;
|
|
4677
|
+
}
|
|
4678
|
+
}
|
|
4679
|
+
/** Construct aligned measures and resolve forward references before layout or drawing. */
|
|
4680
|
+
compose(spec) {
|
|
4681
|
+
return (0,_easyscore_composition__WEBPACK_IMPORTED_MODULE_3__.compose)(this, spec);
|
|
4682
|
+
}
|
|
4683
|
+
/** Build a normal System; its staff API and formatter options stay available. */
|
|
4684
|
+
system(options = {}) {
|
|
4685
|
+
return this.transaction(() => this.references.add(this.factory.System(options)));
|
|
4686
|
+
}
|
|
4687
|
+
/** Create a native responsive Sheet. Its systems remain managed by this Factory. */
|
|
4688
|
+
sheet(options = {}) {
|
|
4689
|
+
return this.transaction(() => this.factory.Sheet(options));
|
|
4690
|
+
}
|
|
4691
|
+
/**
|
|
4692
|
+
* Stage a group of synchronous construction calls. Failed groups release their new objects and IDs.
|
|
4693
|
+
* Existing-object setters and application side effects remain the caller's responsibility.
|
|
4694
|
+
*/
|
|
4695
|
+
build(construct) {
|
|
4696
|
+
const snapshot = {
|
|
4697
|
+
elements: this.builder.elements,
|
|
4698
|
+
options: this.builder.options,
|
|
4699
|
+
piece: this.builder.piece,
|
|
4700
|
+
rollingDuration: this.builder.rollingDuration,
|
|
4701
|
+
};
|
|
4702
|
+
try {
|
|
4703
|
+
return this.transaction(() => {
|
|
4704
|
+
const result = construct(this);
|
|
4705
|
+
if (result && typeof result === 'object' && 'then' in result) {
|
|
4706
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'EasyScore.build() requires a synchronous callback.');
|
|
4707
|
+
}
|
|
4708
|
+
return result;
|
|
4709
|
+
});
|
|
4710
|
+
}
|
|
4711
|
+
catch (error) {
|
|
4712
|
+
Object.assign(this.builder, snapshot);
|
|
4713
|
+
throw error;
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4716
|
+
/** Apply the Factory foreground defaults without changing global metrics or fonts. */
|
|
4717
|
+
setStyle(style) {
|
|
4718
|
+
this.factory.setStyle(style);
|
|
4719
|
+
return this;
|
|
4720
|
+
}
|
|
4721
|
+
/** Delegate drawing and the existing opt-in retained lifecycle to Factory. */
|
|
4722
|
+
draw(options = {}) {
|
|
4723
|
+
this.factory.draw(options);
|
|
4724
|
+
}
|
|
4725
|
+
/** Release queued notation and the builder's last result. */
|
|
4726
|
+
reset() {
|
|
4727
|
+
this.factory.reset();
|
|
4728
|
+
this.builder.reset();
|
|
4729
|
+
this.references.clear();
|
|
4730
|
+
return this;
|
|
4731
|
+
}
|
|
4732
|
+
/** Endpoints and voice notes must share this facade's Factory. */
|
|
4733
|
+
requireOwned(note) {
|
|
4734
|
+
if (_factory__WEBPACK_IMPORTED_MODULE_7__.Factory.getOwner(note) !== this.factory) {
|
|
4735
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'Note belongs to another Factory or was constructed outside this Factory.');
|
|
4736
|
+
}
|
|
4737
|
+
}
|
|
4738
|
+
/** Reject invalid chord-head references before attaching or queuing notation. */
|
|
4739
|
+
checkIndex(note, index) {
|
|
4740
|
+
if (!Number.isInteger(index) ||
|
|
4741
|
+
index < 0 ||
|
|
4742
|
+
index >= (note instanceof _tabnote__WEBPACK_IMPORTED_MODULE_15__.TabNote ? note.getPositions().length : Math.max(1, note.getKeys().length))) {
|
|
4743
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', `Invalid chord index: ${index}`);
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4496
4746
|
constructor(options = {}) {
|
|
4747
|
+
this.references = new _easyscore_elementindex__WEBPACK_IMPORTED_MODULE_4__.EasyScoreReferences();
|
|
4748
|
+
/** Typed constructors return native objects and share the facade's transaction boundary. */
|
|
4749
|
+
this.make = new _easyscore_elements__WEBPACK_IMPORTED_MODULE_5__.EasyScoreElements({
|
|
4750
|
+
factory: () => this.factory,
|
|
4751
|
+
manage: (construct) => this.transaction(() => this.references.add(construct())),
|
|
4752
|
+
owned: (element) => this.requireOwned(element),
|
|
4753
|
+
checkIndex: (note, index) => this.checkIndex(note, index),
|
|
4754
|
+
beamStems: (notes) => this.resolveBeamStems(notes),
|
|
4755
|
+
noteDefaults: () => ({
|
|
4756
|
+
clef: this.defaults.clef,
|
|
4757
|
+
autoStem: this.defaults.stem === 'auto',
|
|
4758
|
+
stemDirection: this.defaults.stem === 'down' ? _stem__WEBPACK_IMPORTED_MODULE_13__.Stem.DOWN : _stem__WEBPACK_IMPORTED_MODULE_13__.Stem.UP,
|
|
4759
|
+
}),
|
|
4760
|
+
});
|
|
4497
4761
|
this.defaults = {
|
|
4498
4762
|
clef: 'treble',
|
|
4499
4763
|
time: '4/4',
|
|
@@ -4521,12 +4785,12 @@ class EasyScore {
|
|
|
4521
4785
|
var _a, _b;
|
|
4522
4786
|
const factory = options.factory; // ! operator, because options.factory was set in Factory.EasyScore().
|
|
4523
4787
|
const builder = (_a = options.builder) !== null && _a !== void 0 ? _a : new Builder(factory);
|
|
4524
|
-
this.options = Object.assign(Object.assign({ commitHooks: [setId, setClass, _articulation__WEBPACK_IMPORTED_MODULE_0__.Articulation.easyScoreHook,
|
|
4788
|
+
this.options = Object.assign(Object.assign({ commitHooks: [setId, setClass, _articulation__WEBPACK_IMPORTED_MODULE_0__.Articulation.easyScoreHook, _frethandfinger__WEBPACK_IMPORTED_MODULE_9__.FretHandFinger.easyScoreHook], throwOnError: false }, options), { factory,
|
|
4525
4789
|
builder });
|
|
4526
4790
|
this.factory = factory;
|
|
4527
4791
|
this.builder = builder;
|
|
4528
4792
|
this.grammar = new EasyScoreGrammar(this.builder);
|
|
4529
|
-
this.parser = new
|
|
4793
|
+
this.parser = new _parser__WEBPACK_IMPORTED_MODULE_12__.Parser(this.grammar);
|
|
4530
4794
|
(_b = this.options.commitHooks) === null || _b === void 0 ? void 0 : _b.forEach((commitHook) => this.addCommitHook(commitHook));
|
|
4531
4795
|
return this;
|
|
4532
4796
|
}
|
|
@@ -4534,21 +4798,179 @@ class EasyScore {
|
|
|
4534
4798
|
this.factory.setContext(context);
|
|
4535
4799
|
return this;
|
|
4536
4800
|
}
|
|
4801
|
+
/** Parse and validate without touching this builder, its hooks, Factory queues, or registries. */
|
|
4802
|
+
parseNotation(line, options = {}) {
|
|
4803
|
+
var _a, _b, _c, _d;
|
|
4804
|
+
const builder = new NotationBuilder();
|
|
4805
|
+
builder.reset(Object.assign({ clef: this.defaults.clef, stem: this.defaults.stem }, options));
|
|
4806
|
+
const result = new _parser__WEBPACK_IMPORTED_MODULE_12__.Parser(new EasyScoreGrammar(builder)).parse(line);
|
|
4807
|
+
if (!result.success) {
|
|
4808
|
+
const start = Math.max(0, (_b = (_a = result.furthestErrorPos) !== null && _a !== void 0 ? _a : result.errorPos) !== null && _b !== void 0 ? _b : 0);
|
|
4809
|
+
return {
|
|
4810
|
+
success: false,
|
|
4811
|
+
pieces: [],
|
|
4812
|
+
diagnostics: [
|
|
4813
|
+
diagnostic(line, 'SyntaxError', 'Invalid EasyScore notation', {
|
|
4814
|
+
start,
|
|
4815
|
+
end: Math.min(line.length, start + 1),
|
|
4816
|
+
}),
|
|
4817
|
+
],
|
|
4818
|
+
};
|
|
4819
|
+
}
|
|
4820
|
+
const diagnostics = [];
|
|
4821
|
+
for (const piece of builder.pieces) {
|
|
4822
|
+
try {
|
|
4823
|
+
const options = Object.assign(Object.assign({}, builder.options), piece.options);
|
|
4824
|
+
this.validatePiece(piece, options);
|
|
4825
|
+
// Validation sees copies, so extensions cannot rewrite the parser's output accidentally.
|
|
4826
|
+
(_d = (_c = this.options).validate) === null || _d === void 0 ? void 0 : _d.call(_c, {
|
|
4827
|
+
piece: Object.assign(Object.assign({}, piece), { chord: piece.chord.map((note) => (Object.assign({}, note))), options: Object.assign({}, piece.options), source: Object.assign({}, piece.source) }),
|
|
4828
|
+
options: Object.assign({}, options),
|
|
4829
|
+
});
|
|
4830
|
+
}
|
|
4831
|
+
catch (error) {
|
|
4832
|
+
diagnostics.push(diagnostic(line, 'InvalidNotation', error instanceof Error ? error.message : String(error), piece.source));
|
|
4833
|
+
}
|
|
4834
|
+
}
|
|
4835
|
+
return { success: diagnostics.length === 0, pieces: diagnostics.length ? [] : builder.pieces, diagnostics };
|
|
4836
|
+
}
|
|
4837
|
+
/** Validate built-in fields before allocating notes. Extension values are left to application hooks. */
|
|
4838
|
+
validatePiece(piece, options) {
|
|
4839
|
+
var _a;
|
|
4840
|
+
_tables__WEBPACK_IMPORTED_MODULE_14__.Tables.durationToTicks(piece.duration);
|
|
4841
|
+
if (!['auto', 'up', 'down'].includes(String(options.stem).toLowerCase())) {
|
|
4842
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', `Invalid stem: ${options.stem}`);
|
|
4843
|
+
}
|
|
4844
|
+
if (!Object.hasOwnProperty.call(_clef__WEBPACK_IMPORTED_MODULE_1__.Clef.types, String(options.clef).toLowerCase())) {
|
|
4845
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', `Invalid clef: ${options.clef}`);
|
|
4846
|
+
}
|
|
4847
|
+
for (const name of ['octaveShift', 'strokePx', 'line']) {
|
|
4848
|
+
if (options[name] !== undefined && !Number.isFinite(Number(options[name]))) {
|
|
4849
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', `Invalid numeric option: ${name}`);
|
|
4850
|
+
}
|
|
4851
|
+
}
|
|
4852
|
+
if (options.alignCenter !== undefined && ![true, false, 'true', 'false'].includes(options.alignCenter)) {
|
|
4853
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'alignCenter must be true or false.');
|
|
4854
|
+
}
|
|
4855
|
+
if (options.durationOverride !== undefined &&
|
|
4856
|
+
(!(options.durationOverride instanceof _fraction__WEBPACK_IMPORTED_MODULE_8__.Fraction) ||
|
|
4857
|
+
!Number.isFinite(options.durationOverride.value()) ||
|
|
4858
|
+
options.durationOverride.value() <= 0)) {
|
|
4859
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'durationOverride must be a positive finite Fraction.');
|
|
4860
|
+
}
|
|
4861
|
+
if (options.articulations && this.builder.commitHooks.includes(_articulation__WEBPACK_IMPORTED_MODULE_0__.Articulation.easyScoreHook)) {
|
|
4862
|
+
_articulation__WEBPACK_IMPORTED_MODULE_0__.Articulation.parseEasyScore(options.articulations);
|
|
4863
|
+
}
|
|
4864
|
+
if (this.options.strictOptions) {
|
|
4865
|
+
const known = new Set([
|
|
4866
|
+
'stem',
|
|
4867
|
+
'clef',
|
|
4868
|
+
'duration',
|
|
4869
|
+
'id',
|
|
4870
|
+
'class',
|
|
4871
|
+
'articulations',
|
|
4872
|
+
'fingerings',
|
|
4873
|
+
'octaveShift',
|
|
4874
|
+
'strokePx',
|
|
4875
|
+
'line',
|
|
4876
|
+
'alignCenter',
|
|
4877
|
+
'durationOverride',
|
|
4878
|
+
...((_a = this.options.extensions) !== null && _a !== void 0 ? _a : []),
|
|
4879
|
+
]);
|
|
4880
|
+
for (const name of Object.keys(options)) {
|
|
4881
|
+
if (!known.has(name))
|
|
4882
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', `Unknown EasyScore option: ${name}`);
|
|
4883
|
+
}
|
|
4884
|
+
}
|
|
4885
|
+
}
|
|
4886
|
+
/** Observe source ranges only during this parse, including legacy partial results. */
|
|
4537
4887
|
parse(line, options = {}) {
|
|
4538
|
-
this.builder.
|
|
4539
|
-
const
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4888
|
+
const previous = this.builder.onNote;
|
|
4889
|
+
const context = this.sourceContext;
|
|
4890
|
+
this.builder.onNote = (note, span) => {
|
|
4891
|
+
var _a, _b, _c;
|
|
4892
|
+
previous === null || previous === void 0 ? void 0 : previous(note, span);
|
|
4893
|
+
const source = span && Object.assign({ input: (_a = context === null || context === void 0 ? void 0 : context.input) !== null && _a !== void 0 ? _a : line, start: span.start + ((_b = context === null || context === void 0 ? void 0 : context.offset) !== null && _b !== void 0 ? _b : 0), end: span.end + ((_c = context === null || context === void 0 ? void 0 : context.offset) !== null && _c !== void 0 ? _c : 0) }, (context && { measure: context.measure }));
|
|
4894
|
+
this.references.add(note, source);
|
|
4895
|
+
note.getModifiers().forEach((modifier) => this.references.add(modifier, source));
|
|
4896
|
+
};
|
|
4897
|
+
try {
|
|
4898
|
+
return this.parseInput(line, options);
|
|
4899
|
+
}
|
|
4900
|
+
finally {
|
|
4901
|
+
this.builder.onNote = previous;
|
|
4902
|
+
}
|
|
4903
|
+
}
|
|
4904
|
+
/** Strict construction is transactional; the legacy non-throwing parser retains partial output. */
|
|
4905
|
+
parseInput(line, options) {
|
|
4906
|
+
var _a, _b;
|
|
4907
|
+
if (!this.options.throwOnError) {
|
|
4908
|
+
this.builder.reset(options);
|
|
4909
|
+
return this.parser.parse(line);
|
|
4910
|
+
}
|
|
4911
|
+
// parse() retains Builder's defaults; notes() supplies EasyScore's defaults explicitly.
|
|
4912
|
+
const parsed = this.parseNotation(line, Object.assign({ clef: 'treble', stem: 'auto' }, options));
|
|
4913
|
+
if (!parsed.success)
|
|
4914
|
+
throw new EasyScoreError(parsed.diagnostics);
|
|
4915
|
+
const snapshot = {
|
|
4916
|
+
elements: this.builder.elements,
|
|
4917
|
+
options: this.builder.options,
|
|
4918
|
+
piece: this.builder.piece,
|
|
4919
|
+
rollingDuration: this.builder.rollingDuration,
|
|
4920
|
+
};
|
|
4921
|
+
const build = () => {
|
|
4922
|
+
this.builder.reset(options);
|
|
4923
|
+
const result = this.parser.parse(line);
|
|
4924
|
+
if (!result.success)
|
|
4925
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'Error parsing line: ' + line);
|
|
4926
|
+
return result;
|
|
4927
|
+
};
|
|
4928
|
+
try {
|
|
4929
|
+
return this.transaction(build);
|
|
4930
|
+
}
|
|
4931
|
+
catch (error) {
|
|
4932
|
+
const source = (_b = (_a = parsed.pieces[this.builder.elements.notes.length]) === null || _a === void 0 ? void 0 : _a.source) !== null && _b !== void 0 ? _b : { start: 0, end: line.length };
|
|
4933
|
+
Object.assign(this.builder, snapshot);
|
|
4934
|
+
throw new EasyScoreError([
|
|
4935
|
+
diagnostic(line, 'ConstructionError', error instanceof Error ? error.message : String(error), source),
|
|
4936
|
+
]);
|
|
4543
4937
|
}
|
|
4544
|
-
return result;
|
|
4545
4938
|
}
|
|
4939
|
+
/**
|
|
4940
|
+
* Resolve automatic stems for the whole group while respecting explicit stems.
|
|
4941
|
+
* autoStem: true overrides explicit directions; false preserves all directions.
|
|
4942
|
+
*/
|
|
4546
4943
|
beam(notes, options) {
|
|
4547
|
-
|
|
4944
|
+
var _a;
|
|
4945
|
+
if (this.options.strictOptions)
|
|
4946
|
+
this.make.beam({ notes, options });
|
|
4947
|
+
else {
|
|
4948
|
+
const autoStem = (_a = options === null || options === void 0 ? void 0 : options.autoStem) !== null && _a !== void 0 ? _a : this.resolveBeamStems(notes);
|
|
4949
|
+
this.transaction(() => this.references.add(this.factory.Beam({ notes, options: Object.assign(Object.assign({}, options), { autoStem }) })));
|
|
4950
|
+
}
|
|
4548
4951
|
return notes;
|
|
4549
4952
|
}
|
|
4953
|
+
/** Generate and own native beam groups without changing rhythmic duration. */
|
|
4954
|
+
autoBeam(notes, options = {}) {
|
|
4955
|
+
return (0,_easyscore_rhythm__WEBPACK_IMPORTED_MODULE_6__.autoBeam)(this, notes, options);
|
|
4956
|
+
}
|
|
4957
|
+
/** Explicit pitched stems constrain the group; conflicting explicit stems remain mixed. */
|
|
4958
|
+
resolveBeamStems(notes) {
|
|
4959
|
+
const directions = new Set(notes.filter((note) => !note.isRest() && !note.isAutoStem()).map((note) => note.getStemDirection()));
|
|
4960
|
+
// With no explicit direction, Beam chooses from the complete group's pitches.
|
|
4961
|
+
if (directions.size === 0)
|
|
4962
|
+
return true;
|
|
4963
|
+
if (directions.size === 1) {
|
|
4964
|
+
const direction = directions.values().next().value;
|
|
4965
|
+
notes.filter((note) => note.isAutoStem()).forEach((note) => note.setStemDirection(direction, true));
|
|
4966
|
+
}
|
|
4967
|
+
return false;
|
|
4968
|
+
}
|
|
4550
4969
|
tuplet(notes, options) {
|
|
4551
|
-
this.
|
|
4970
|
+
if (this.options.strictOptions)
|
|
4971
|
+
this.make.tuplet({ notes, options });
|
|
4972
|
+
else
|
|
4973
|
+
this.transaction(() => this.references.add(this.factory.Tuplet({ notes, options })));
|
|
4552
4974
|
return notes;
|
|
4553
4975
|
}
|
|
4554
4976
|
notes(line, options = {}) {
|
|
@@ -4556,13 +4978,81 @@ class EasyScore {
|
|
|
4556
4978
|
this.parse(line, options);
|
|
4557
4979
|
return this.builder.getElements().notes;
|
|
4558
4980
|
}
|
|
4981
|
+
/** Mix notation fragments, full native note structs, and already-owned native tickables. */
|
|
4982
|
+
sequence(items, options = {}) {
|
|
4983
|
+
return this.build(() => items.flatMap((item) => {
|
|
4984
|
+
if (typeof item === 'string')
|
|
4985
|
+
return this.notes(item, options);
|
|
4986
|
+
if (item instanceof _tickable__WEBPACK_IMPORTED_MODULE_16__.Tickable) {
|
|
4987
|
+
this.requireOwned(item);
|
|
4988
|
+
if (item instanceof _note__WEBPACK_IMPORTED_MODULE_11__.Note && _factory__WEBPACK_IMPORTED_MODULE_7__.Factory.getGroup(item))
|
|
4989
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'Grouped notes cannot be sequence entries.');
|
|
4990
|
+
return [item];
|
|
4991
|
+
}
|
|
4992
|
+
return [this.make.note(item)];
|
|
4993
|
+
}));
|
|
4994
|
+
}
|
|
4559
4995
|
/**
|
|
4560
4996
|
* Parse bar-separated measures. Durations carry across bars; notes() is unchanged.
|
|
4561
4997
|
* A bar may have adjacent commas. Quoted option values may contain literal bars.
|
|
4562
4998
|
* Empty measures and invalid notation throw, rather than returning partial music.
|
|
4563
4999
|
*/
|
|
4564
5000
|
measures(line, options = {}) {
|
|
5001
|
+
const measures = this.splitMeasures(line);
|
|
5002
|
+
// Validate every measure before constructing any of them. A transaction also covers hook/constructor failures.
|
|
5003
|
+
let duration = options.duration;
|
|
5004
|
+
for (const [index, { text, offset }] of measures.entries()) {
|
|
5005
|
+
const parsed = this.parseNotation(text, Object.assign(Object.assign({}, options), { duration }));
|
|
5006
|
+
if (!parsed.success)
|
|
5007
|
+
throw new EasyScoreError(parsed.diagnostics.map((d) => (Object.assign(Object.assign({}, diagnostic(line, d.code, d.message, { start: offset + d.start, end: offset + d.end })), { measure: index + 1 }))));
|
|
5008
|
+
duration = parsed.pieces[parsed.pieces.length - 1].duration;
|
|
5009
|
+
}
|
|
5010
|
+
const build = () => {
|
|
5011
|
+
duration = options.duration;
|
|
5012
|
+
return measures.map(({ text, offset }, index) => {
|
|
5013
|
+
const previous = this.sourceContext;
|
|
5014
|
+
this.sourceContext = { input: line, offset, measure: index + 1 };
|
|
5015
|
+
try {
|
|
5016
|
+
const result = this.parse(text, Object.assign(Object.assign({ clef: this.defaults.clef, stem: this.defaults.stem }, options), { duration }));
|
|
5017
|
+
if (!result.success)
|
|
5018
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', `Invalid EasyScore measure: ${text}`);
|
|
5019
|
+
duration = this.builder.rollingDuration;
|
|
5020
|
+
return this.builder.getElements().notes;
|
|
5021
|
+
}
|
|
5022
|
+
catch (error) {
|
|
5023
|
+
const diagnostics = error instanceof EasyScoreError
|
|
5024
|
+
? error.diagnostics
|
|
5025
|
+
: [
|
|
5026
|
+
diagnostic(text, 'ConstructionError', error instanceof Error ? error.message : String(error), {
|
|
5027
|
+
start: 0,
|
|
5028
|
+
end: text.length,
|
|
5029
|
+
}),
|
|
5030
|
+
];
|
|
5031
|
+
throw new EasyScoreError(diagnostics.map((d) => (Object.assign(Object.assign({}, diagnostic(line, d.code, d.message, { start: offset + d.start, end: offset + d.end })), { measure: index + 1 }))));
|
|
5032
|
+
}
|
|
5033
|
+
finally {
|
|
5034
|
+
this.sourceContext = previous;
|
|
5035
|
+
}
|
|
5036
|
+
});
|
|
5037
|
+
};
|
|
5038
|
+
const snapshot = {
|
|
5039
|
+
elements: this.builder.elements,
|
|
5040
|
+
options: this.builder.options,
|
|
5041
|
+
piece: this.builder.piece,
|
|
5042
|
+
rollingDuration: this.builder.rollingDuration,
|
|
5043
|
+
};
|
|
5044
|
+
try {
|
|
5045
|
+
return this.transaction(build);
|
|
5046
|
+
}
|
|
5047
|
+
catch (error) {
|
|
5048
|
+
Object.assign(this.builder, snapshot);
|
|
5049
|
+
throw error;
|
|
5050
|
+
}
|
|
5051
|
+
}
|
|
5052
|
+
/** Split only unquoted bars and retain each trimmed measure's original source offset. */
|
|
5053
|
+
splitMeasures(line) {
|
|
4565
5054
|
const parts = [];
|
|
5055
|
+
const starts = [0];
|
|
4566
5056
|
let start = 0;
|
|
4567
5057
|
let quote = '';
|
|
4568
5058
|
for (let i = 0; i < line.length; i++) {
|
|
@@ -4577,37 +5067,1057 @@ class EasyScore {
|
|
|
4577
5067
|
else if (char === '|') {
|
|
4578
5068
|
parts.push(line.slice(start, i));
|
|
4579
5069
|
start = i + 1;
|
|
5070
|
+
starts.push(start);
|
|
4580
5071
|
}
|
|
4581
5072
|
}
|
|
4582
5073
|
parts.push(line.slice(start));
|
|
4583
|
-
|
|
5074
|
+
return parts.map((part, index) => {
|
|
4584
5075
|
let text = part.trim();
|
|
4585
5076
|
if (index > 0)
|
|
4586
5077
|
text = text.replace(/^,\s*/, '');
|
|
4587
5078
|
if (index < parts.length - 1)
|
|
4588
5079
|
text = text.replace(/\s*,$/, '');
|
|
4589
5080
|
if (!text)
|
|
4590
|
-
throw new
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', `Invalid EasyScore measure: ${text}`);
|
|
4598
|
-
duration = this.builder.rollingDuration;
|
|
4599
|
-
return this.builder.getElements().notes;
|
|
5081
|
+
throw new EasyScoreError([
|
|
5082
|
+
Object.assign(Object.assign({}, diagnostic(line, 'EmptyMeasure', 'Empty EasyScore measure. Use an explicit rest.', {
|
|
5083
|
+
start: starts[index],
|
|
5084
|
+
end: starts[index] + part.length,
|
|
5085
|
+
})), { measure: index + 1 }),
|
|
5086
|
+
]);
|
|
5087
|
+
return { text, offset: starts[index] + part.indexOf(text) };
|
|
4600
5088
|
});
|
|
4601
5089
|
}
|
|
5090
|
+
/** Configure time, mode, and spacing before inserting tickables. */
|
|
4602
5091
|
voice(notes, options = {}) {
|
|
4603
|
-
|
|
4604
|
-
|
|
5092
|
+
var _a, _b, _c;
|
|
5093
|
+
const mode = typeof options.mode === 'string'
|
|
5094
|
+
? { strict: _voice__WEBPACK_IMPORTED_MODULE_18__.VoiceMode.STRICT, soft: _voice__WEBPACK_IMPORTED_MODULE_18__.VoiceMode.SOFT, full: _voice__WEBPACK_IMPORTED_MODULE_18__.VoiceMode.FULL }[options.mode]
|
|
5095
|
+
: ((_a = options.mode) !== null && _a !== void 0 ? _a : _voice__WEBPACK_IMPORTED_MODULE_18__.VoiceMode.STRICT);
|
|
5096
|
+
if (![_voice__WEBPACK_IMPORTED_MODULE_18__.VoiceMode.STRICT, _voice__WEBPACK_IMPORTED_MODULE_18__.VoiceMode.SOFT, _voice__WEBPACK_IMPORTED_MODULE_18__.VoiceMode.FULL].includes(mode)) {
|
|
5097
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'Invalid voice mode.');
|
|
5098
|
+
}
|
|
5099
|
+
const factor = (_b = options.softmaxFactor) !== null && _b !== void 0 ? _b : (_c = options.options) === null || _c === void 0 ? void 0 : _c.softmaxFactor;
|
|
5100
|
+
if (factor !== undefined && (!Number.isFinite(factor) || factor <= 0)) {
|
|
5101
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'softmaxFactor must be positive and finite.');
|
|
5102
|
+
}
|
|
5103
|
+
if (this.options.strictOptions)
|
|
5104
|
+
notes.forEach((note) => this.requireOwned(note));
|
|
5105
|
+
if (notes.some((note) => note instanceof _note__WEBPACK_IMPORTED_MODULE_11__.Note && _factory__WEBPACK_IMPORTED_MODULE_7__.Factory.getGroup(note))) {
|
|
5106
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'Grouped notes cannot be inserted into a main voice.');
|
|
5107
|
+
}
|
|
5108
|
+
return this.transaction(() => {
|
|
5109
|
+
var _a;
|
|
5110
|
+
const voice = this.factory.Voice({ time: (_a = options.time) !== null && _a !== void 0 ? _a : this.defaults.time });
|
|
5111
|
+
voice.setMode(mode);
|
|
5112
|
+
if (factor !== undefined)
|
|
5113
|
+
voice.setSoftmaxFactor(factor);
|
|
5114
|
+
// Check overflow before addTickables() changes the notes' voice assignments.
|
|
5115
|
+
const ticks = notes.reduce((total, note) => (note.shouldIgnoreTicks() ? total : total.add(note.getTicks())), new _fraction__WEBPACK_IMPORTED_MODULE_8__.Fraction(0, 1));
|
|
5116
|
+
if (mode !== _voice__WEBPACK_IMPORTED_MODULE_18__.VoiceMode.SOFT && ticks.greaterThan(voice.getTotalTicks())) {
|
|
5117
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_17__.RuntimeError('BadArguments', 'Too many ticks for this voice.');
|
|
5118
|
+
}
|
|
5119
|
+
return this.references.add(voice.addTickables(notes));
|
|
5120
|
+
});
|
|
4605
5121
|
}
|
|
4606
5122
|
addCommitHook(commitHook) {
|
|
4607
5123
|
this.builder.addCommitHook(commitHook);
|
|
4608
5124
|
}
|
|
4609
5125
|
}
|
|
4610
|
-
EasyScore.DEBUG = false;
|
|
5126
|
+
EasyScore.DEBUG = false;
|
|
5127
|
+
|
|
5128
|
+
|
|
5129
|
+
/***/ },
|
|
5130
|
+
|
|
5131
|
+
/***/ "./src/easyscore/composition.ts"
|
|
5132
|
+
/*!**************************************!*\
|
|
5133
|
+
!*** ./src/easyscore/composition.ts ***!
|
|
5134
|
+
\**************************************/
|
|
5135
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5136
|
+
|
|
5137
|
+
__webpack_require__.r(__webpack_exports__);
|
|
5138
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
5139
|
+
/* harmony export */ compose: () => (/* binding */ compose)
|
|
5140
|
+
/* harmony export */ });
|
|
5141
|
+
/* harmony import */ var _factory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../factory */ "./src/factory.ts");
|
|
5142
|
+
/* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../fraction */ "./src/fraction.ts");
|
|
5143
|
+
/* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../note */ "./src/note.ts");
|
|
5144
|
+
/* harmony import */ var _stemmablenote__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../stemmablenote */ "./src/stemmablenote.ts");
|
|
5145
|
+
/* harmony import */ var _tickable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../tickable */ "./src/tickable.ts");
|
|
5146
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util */ "./src/util.ts");
|
|
5147
|
+
/* harmony import */ var _voice__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../voice */ "./src/voice.ts");
|
|
5148
|
+
/* harmony import */ var _policies__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./policies */ "./src/easyscore/policies.ts");
|
|
5149
|
+
|
|
5150
|
+
|
|
5151
|
+
|
|
5152
|
+
|
|
5153
|
+
|
|
5154
|
+
|
|
5155
|
+
|
|
5156
|
+
|
|
5157
|
+
/** Fail with a consistent construction error before drawing. */
|
|
5158
|
+
function invalid(message) {
|
|
5159
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadComposition', message);
|
|
5160
|
+
}
|
|
5161
|
+
/** Return exact native ticks for a declared meter, including a pickup span. */
|
|
5162
|
+
function ticksFor(time) {
|
|
5163
|
+
return new _voice__WEBPACK_IMPORTED_MODULE_6__.Voice(time).getTotalTicks().clone();
|
|
5164
|
+
}
|
|
5165
|
+
/** Scope staff defaults and build one voice's notation, without assigning a Voice yet. */
|
|
5166
|
+
function buildVoice(score, spec, initial, display) {
|
|
5167
|
+
var _a;
|
|
5168
|
+
return score.withDefaults({ clef: initial.clef, time: initial.time, stem: (_a = spec.stem) !== null && _a !== void 0 ? _a : 'auto' }, () => {
|
|
5169
|
+
var _a;
|
|
5170
|
+
let state = Object.assign({}, initial);
|
|
5171
|
+
const notes = [];
|
|
5172
|
+
const changes = [];
|
|
5173
|
+
const assignments = new Map();
|
|
5174
|
+
const generated = new Set();
|
|
5175
|
+
for (const item of typeof spec.notes === 'string' ? [spec.notes] : spec.notes) {
|
|
5176
|
+
if (typeof item === 'string') {
|
|
5177
|
+
notes.push(...score.notes(item));
|
|
5178
|
+
score.builder
|
|
5179
|
+
.getElements()
|
|
5180
|
+
.accidentals.flat()
|
|
5181
|
+
.forEach((mark) => {
|
|
5182
|
+
if (mark)
|
|
5183
|
+
generated.add(mark);
|
|
5184
|
+
});
|
|
5185
|
+
}
|
|
5186
|
+
else if (item instanceof _tickable__WEBPACK_IMPORTED_MODULE_4__.Tickable) {
|
|
5187
|
+
if (_factory__WEBPACK_IMPORTED_MODULE_0__.Factory.getOwner(item) !== score.factory)
|
|
5188
|
+
invalid('Adopt native notes before composing them.');
|
|
5189
|
+
try {
|
|
5190
|
+
item.getVoice();
|
|
5191
|
+
invalid('Composition requires notes that are not already in a voice.');
|
|
5192
|
+
}
|
|
5193
|
+
catch (error) {
|
|
5194
|
+
if (!(error instanceof _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError) || error.code !== 'NoVoice')
|
|
5195
|
+
throw error;
|
|
5196
|
+
}
|
|
5197
|
+
notes.push(item);
|
|
5198
|
+
}
|
|
5199
|
+
else if ('change' in item) {
|
|
5200
|
+
const previous = state;
|
|
5201
|
+
state = Object.assign(Object.assign({}, state), item.change);
|
|
5202
|
+
changes.push({ index: notes.length, state: Object.assign({}, state) });
|
|
5203
|
+
if (display) {
|
|
5204
|
+
if (item.change.clef)
|
|
5205
|
+
notes.push(score.make.clefNote({ type: state.clef, options: { size: 'small' } }));
|
|
5206
|
+
if (item.change.key)
|
|
5207
|
+
notes.push(score.make.keySigNote({ key: state.key, cancelKey: previous.key, clef: state.clef }));
|
|
5208
|
+
if (item.change.time)
|
|
5209
|
+
notes.push(score.make.timeSigNote({ time: state.time }));
|
|
5210
|
+
}
|
|
5211
|
+
score.set({ clef: state.clef, time: state.time });
|
|
5212
|
+
}
|
|
5213
|
+
else {
|
|
5214
|
+
const note = 'tab' in item
|
|
5215
|
+
? score.make.tabNote(item.tab, item.drawStem)
|
|
5216
|
+
: score.make.note('note' in item ? item.note : item);
|
|
5217
|
+
if ('id' in item && item.id !== undefined)
|
|
5218
|
+
note.setAttribute('id', item.id);
|
|
5219
|
+
if ('stave' in item && item.stave)
|
|
5220
|
+
assignments.set(note, item.stave);
|
|
5221
|
+
notes.push(note);
|
|
5222
|
+
}
|
|
5223
|
+
}
|
|
5224
|
+
const timed = notes.filter((note) => !note.shouldIgnoreTicks());
|
|
5225
|
+
for (const group of (_a = spec.tuplets) !== null && _a !== void 0 ? _a : []) {
|
|
5226
|
+
if (!Number.isInteger(group.start) ||
|
|
5227
|
+
!Number.isInteger(group.count) ||
|
|
5228
|
+
group.start < 0 ||
|
|
5229
|
+
group.count < 1 ||
|
|
5230
|
+
group.start + group.count > timed.length)
|
|
5231
|
+
invalid('Tuplet range is outside its voice.');
|
|
5232
|
+
const members = timed.slice(group.start, group.start + group.count);
|
|
5233
|
+
if (!members.every((note) => note instanceof _note__WEBPACK_IMPORTED_MODULE_2__.Note))
|
|
5234
|
+
invalid('Tuplets require native notes.');
|
|
5235
|
+
score.make.tuplet({ notes: members, options: group.options });
|
|
5236
|
+
}
|
|
5237
|
+
if (spec.autoBeam) {
|
|
5238
|
+
if (!timed.every((note) => note instanceof _stemmablenote__WEBPACK_IMPORTED_MODULE_3__.StemmableNote))
|
|
5239
|
+
invalid('Automatic beams require stemmable notes.');
|
|
5240
|
+
score.set({ time: initial.time });
|
|
5241
|
+
score.autoBeam(timed, typeof spec.autoBeam === 'boolean' ? {} : spec.autoBeam);
|
|
5242
|
+
}
|
|
5243
|
+
return { notes, state, changes, assignments, generated };
|
|
5244
|
+
});
|
|
5245
|
+
}
|
|
5246
|
+
/** Inline changes must describe the same staff state at the same exact onset in every voice. */
|
|
5247
|
+
function stateChanges(voice) {
|
|
5248
|
+
return voice.changes.map(({ index, state }) => ({
|
|
5249
|
+
at: voice.notes
|
|
5250
|
+
.slice(0, index)
|
|
5251
|
+
.reduce((sum, note) => (note.shouldIgnoreTicks() ? sum : sum.add(note.getTicks())), new _fraction__WEBPACK_IMPORTED_MODULE_1__.Fraction(0, 1)),
|
|
5252
|
+
state,
|
|
5253
|
+
}));
|
|
5254
|
+
}
|
|
5255
|
+
/** Add signatures at explicit boundaries; no hidden row-dependent behavior is introduced. */
|
|
5256
|
+
function addSignatures(score, stave, state, previous) {
|
|
5257
|
+
if (!previous || previous.clef !== state.clef)
|
|
5258
|
+
score.attachToStave(stave, score.make.clef(state.clef));
|
|
5259
|
+
if (state.clef !== 'tab' && (!previous || previous.key !== state.key))
|
|
5260
|
+
score.attachToStave(stave, score.make.keySignature(state.key, previous === null || previous === void 0 ? void 0 : previous.key));
|
|
5261
|
+
if (!previous || previous.time !== state.time)
|
|
5262
|
+
score.attachToStave(stave, score.make.timeSignature(state.time));
|
|
5263
|
+
}
|
|
5264
|
+
/** Resolve owned notes only after the entire composition is constructed. */
|
|
5265
|
+
function buildSpans(score, spec, measures, diagnostics) {
|
|
5266
|
+
var _a;
|
|
5267
|
+
return ((_a = spec.spans) !== null && _a !== void 0 ? _a : []).map((span) => {
|
|
5268
|
+
const from = span.from === undefined ? undefined : score.getNote(span.from);
|
|
5269
|
+
const to = span.to === undefined ? undefined : score.getNote(span.to);
|
|
5270
|
+
for (const note of [from, to])
|
|
5271
|
+
if (note && !measures.has(note))
|
|
5272
|
+
invalid('Span endpoints must belong to this composition.');
|
|
5273
|
+
if (from && to && measures.get(from) !== measures.get(to)) {
|
|
5274
|
+
if (spec.crossMeasureSpans !== 'manual')
|
|
5275
|
+
invalid('Cross-measure spans need explicit manual segmentation.');
|
|
5276
|
+
diagnostics.push({
|
|
5277
|
+
code: 'ManualSpan',
|
|
5278
|
+
message: 'A cross-measure span will not split when Sheet wraps. Replace it with native partial segments before drawing across rows.',
|
|
5279
|
+
});
|
|
5280
|
+
}
|
|
5281
|
+
if (span.kind === 'tie')
|
|
5282
|
+
return score.make.tie(Object.assign(Object.assign({}, span), { from, to }));
|
|
5283
|
+
if (span.kind === 'curve')
|
|
5284
|
+
return score.make.curve({ from, to, options: span.options });
|
|
5285
|
+
if (!from || !to)
|
|
5286
|
+
invalid('Hairpins require both endpoints.');
|
|
5287
|
+
return score.make.hairpin({ from, to, type: span.type, options: span.options });
|
|
5288
|
+
});
|
|
5289
|
+
}
|
|
5290
|
+
/** Build one staff measure before joining it to the shared native System. */
|
|
5291
|
+
function buildStaffMeasure(score, spec, staff, index, previous, tracking) {
|
|
5292
|
+
var _a, _b, _c, _d;
|
|
5293
|
+
const assignments = new Map();
|
|
5294
|
+
const measure = staff.measures[index];
|
|
5295
|
+
if (!measure.voices.length)
|
|
5296
|
+
invalid('Every stave measure needs at least one voice.');
|
|
5297
|
+
const state = {
|
|
5298
|
+
clef: (_a = measure.clef) !== null && _a !== void 0 ? _a : previous.clef,
|
|
5299
|
+
key: (_b = measure.key) !== null && _b !== void 0 ? _b : previous.key,
|
|
5300
|
+
time: (_c = measure.time) !== null && _c !== void 0 ? _c : previous.time,
|
|
5301
|
+
};
|
|
5302
|
+
const span = (_d = measure.span) !== null && _d !== void 0 ? _d : state.time;
|
|
5303
|
+
const ticks = ticksFor(span);
|
|
5304
|
+
const built = measure.voices.map((voice, voiceIndex) => buildVoice(score, voice, state, voiceIndex === 0));
|
|
5305
|
+
const changes = stateChanges(built[0]);
|
|
5306
|
+
const signature = (items) => JSON.stringify(items.map(({ at, state }) => [at.clone().simplify().toString(), state]));
|
|
5307
|
+
for (const voice of built) {
|
|
5308
|
+
if (signature(stateChanges(voice)) !== signature(changes))
|
|
5309
|
+
invalid('Inline staff changes must agree in all voices.');
|
|
5310
|
+
const actual = voice.notes.reduce((sum, note) => (note.shouldIgnoreTicks() ? sum : sum.add(note.getTicks())), new _fraction__WEBPACK_IMPORTED_MODULE_1__.Fraction(0, 1));
|
|
5311
|
+
if (!actual.equals(ticks))
|
|
5312
|
+
invalid(`Measure ${index + 1} on ${staff.id} does not fill its declared span.`);
|
|
5313
|
+
for (const note of voice.notes) {
|
|
5314
|
+
if (tracking.seen.has(note))
|
|
5315
|
+
invalid('A note cannot belong to two composition voices.');
|
|
5316
|
+
tracking.seen.add(note);
|
|
5317
|
+
if (note instanceof _note__WEBPACK_IMPORTED_MODULE_2__.Note)
|
|
5318
|
+
tracking.noteMeasures.set(note, index);
|
|
5319
|
+
}
|
|
5320
|
+
voice.assignments.forEach((id, note) => assignments.set(note, id));
|
|
5321
|
+
}
|
|
5322
|
+
const nativeVoices = built.map((voice, voiceIndex) => score.voice(voice.notes, Object.assign(Object.assign({}, measure.voices[voiceIndex].options), { time: span, mode: 'strict' })));
|
|
5323
|
+
let currentKey = state.key;
|
|
5324
|
+
const keys = [];
|
|
5325
|
+
for (const change of changes)
|
|
5326
|
+
if (change.state.key !== currentKey) {
|
|
5327
|
+
currentKey = change.state.key;
|
|
5328
|
+
keys.push({ at: change.at, key: currentKey });
|
|
5329
|
+
}
|
|
5330
|
+
const policy = {
|
|
5331
|
+
key: state.key,
|
|
5332
|
+
changes: keys,
|
|
5333
|
+
generated: new Set(built.flatMap((voice) => [...voice.generated])),
|
|
5334
|
+
};
|
|
5335
|
+
const stave = staff.kind === 'tab'
|
|
5336
|
+
? score.make.tabStave({ options: staff.options })
|
|
5337
|
+
: score.make.stave({ options: Object.assign(Object.assign({}, staff.options), { clef: state.clef }) });
|
|
5338
|
+
addSignatures(score, stave, state, index && spec.signatures !== 'every-measure' ? previous : undefined);
|
|
5339
|
+
return {
|
|
5340
|
+
stave,
|
|
5341
|
+
voices: nativeVoices,
|
|
5342
|
+
notes: built.map((voice) => voice.notes),
|
|
5343
|
+
assignments,
|
|
5344
|
+
policy,
|
|
5345
|
+
ticks,
|
|
5346
|
+
state: built[0].state,
|
|
5347
|
+
};
|
|
5348
|
+
}
|
|
5349
|
+
/** Compose aligned measure arrays atomically. Formatting and drawing remain explicit native operations. */
|
|
5350
|
+
function compose(score, spec) {
|
|
5351
|
+
var _a, _b;
|
|
5352
|
+
const count = (_b = (_a = spec.staves[0]) === null || _a === void 0 ? void 0 : _a.measures.length) !== null && _b !== void 0 ? _b : 0;
|
|
5353
|
+
if (!count || !spec.staves.length)
|
|
5354
|
+
invalid('A composition needs staves and measures.');
|
|
5355
|
+
if (new Set(spec.staves.map((stave) => stave.id)).size !== spec.staves.length ||
|
|
5356
|
+
spec.staves.some((stave) => !stave.id))
|
|
5357
|
+
invalid('Staff IDs must be unique and nonempty.');
|
|
5358
|
+
if (spec.staves.some((stave) => stave.measures.length !== count))
|
|
5359
|
+
invalid('All staves need the same number of measures.');
|
|
5360
|
+
if (spec.accidentals && !['literal', 'key-aware'].includes(spec.accidentals))
|
|
5361
|
+
invalid('Unknown accidental policy.');
|
|
5362
|
+
if (spec.signatures && !['changes', 'every-measure'].includes(spec.signatures))
|
|
5363
|
+
invalid('Unknown signature policy.');
|
|
5364
|
+
if (spec.crossMeasureSpans && !['reject', 'manual'].includes(spec.crossMeasureSpans))
|
|
5365
|
+
invalid('Unknown span policy.');
|
|
5366
|
+
const nativeInputs = [];
|
|
5367
|
+
for (const stave of spec.staves)
|
|
5368
|
+
for (const measure of stave.measures)
|
|
5369
|
+
for (const voice of measure.voices)
|
|
5370
|
+
if (typeof voice.notes !== 'string')
|
|
5371
|
+
for (const item of voice.notes)
|
|
5372
|
+
if (item instanceof _note__WEBPACK_IMPORTED_MODULE_2__.Note)
|
|
5373
|
+
nativeInputs.push(item);
|
|
5374
|
+
if (nativeInputs.length &&
|
|
5375
|
+
(spec.accidentals === 'key-aware' ||
|
|
5376
|
+
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); })))))
|
|
5377
|
+
invalid('Apply rhythm and accidental policies before adopting native inputs, or use typed note descriptions.');
|
|
5378
|
+
const priorStaves = new Map(nativeInputs.map((note) => [note, note.getStave()]));
|
|
5379
|
+
// Avoid assigning the same note to more than one voice, even when references are supplied directly.
|
|
5380
|
+
const seen = new Set();
|
|
5381
|
+
try {
|
|
5382
|
+
return score.build(() => {
|
|
5383
|
+
const result = {
|
|
5384
|
+
sheet: score.sheet(spec.sheet),
|
|
5385
|
+
systems: [],
|
|
5386
|
+
staves: [],
|
|
5387
|
+
voices: [],
|
|
5388
|
+
notes: [],
|
|
5389
|
+
spans: [],
|
|
5390
|
+
diagnostics: [],
|
|
5391
|
+
getElement: (id) => score.getElement(id),
|
|
5392
|
+
getNote: (id) => score.getNote(id),
|
|
5393
|
+
};
|
|
5394
|
+
if (spec.signatures !== 'every-measure')
|
|
5395
|
+
result.diagnostics.push({
|
|
5396
|
+
code: 'SignaturePolicy',
|
|
5397
|
+
message: 'Signatures appear at the first measure and explicit changes. Sheet does not repeat them at wrapped row starts.',
|
|
5398
|
+
});
|
|
5399
|
+
const states = spec.staves.map((stave) => {
|
|
5400
|
+
var _a, _b, _c;
|
|
5401
|
+
return ({
|
|
5402
|
+
clef: (_a = stave.clef) !== null && _a !== void 0 ? _a : (stave.kind === 'tab' ? 'tab' : 'treble'),
|
|
5403
|
+
key: (_b = stave.key) !== null && _b !== void 0 ? _b : 'C',
|
|
5404
|
+
time: (_c = stave.time) !== null && _c !== void 0 ? _c : '4/4',
|
|
5405
|
+
});
|
|
5406
|
+
});
|
|
5407
|
+
const noteMeasures = new Map();
|
|
5408
|
+
for (let index = 0; index < count; index++) {
|
|
5409
|
+
const system = result.sheet.addSystem(spec.system);
|
|
5410
|
+
result.systems.push(system);
|
|
5411
|
+
const parts = spec.staves.map((staff, staffIndex) => {
|
|
5412
|
+
const part = buildStaffMeasure(score, spec, staff, index, states[staffIndex], { seen, noteMeasures });
|
|
5413
|
+
states[staffIndex] = part.state;
|
|
5414
|
+
system.addStave(Object.assign(Object.assign({ stave: part.stave, voices: part.voices }, (staff.spaceAbove === undefined ? {} : { spaceAbove: staff.spaceAbove })), (staff.spaceBelow === undefined ? {} : { spaceBelow: staff.spaceBelow })));
|
|
5415
|
+
return part;
|
|
5416
|
+
});
|
|
5417
|
+
if (parts.some((part) => !part.ticks.equals(parts[0].ticks)))
|
|
5418
|
+
invalid('Staves must share the same actual measure span.');
|
|
5419
|
+
const staves = parts.map((part) => part.stave);
|
|
5420
|
+
const voices = parts.map((part) => part.voices);
|
|
5421
|
+
const notes = parts.map((part) => part.notes);
|
|
5422
|
+
const policies = parts.map((part) => part.policy);
|
|
5423
|
+
const assignments = new Map(parts.flatMap((part) => [...part.assignments]));
|
|
5424
|
+
assignments.forEach((id, note) => {
|
|
5425
|
+
const target = spec.staves.findIndex((staff) => staff.id === id);
|
|
5426
|
+
if (target < 0)
|
|
5427
|
+
invalid(`Unknown cross-staff target: ${id}`);
|
|
5428
|
+
note.setStave(staves[target]);
|
|
5429
|
+
});
|
|
5430
|
+
if (spec.accidentals === 'key-aware') {
|
|
5431
|
+
const generated = new Set(policies.flatMap((policy) => [...policy.generated]));
|
|
5432
|
+
policies.forEach((policy, staffIndex) => (0,_policies__WEBPACK_IMPORTED_MODULE_7__.applyCompositionAccidentals)(score, voices.flat(), policy.key, policy.changes, generated, staves[staffIndex]));
|
|
5433
|
+
}
|
|
5434
|
+
result.staves.push(staves);
|
|
5435
|
+
result.voices.push(voices);
|
|
5436
|
+
result.notes.push(notes);
|
|
5437
|
+
}
|
|
5438
|
+
result.spans = buildSpans(score, spec, noteMeasures, result.diagnostics);
|
|
5439
|
+
return result;
|
|
5440
|
+
});
|
|
5441
|
+
}
|
|
5442
|
+
catch (error) {
|
|
5443
|
+
// Restore caller-owned note assignments. Rhythm/accidental mutation of native inputs is rejected above.
|
|
5444
|
+
for (const note of nativeInputs)
|
|
5445
|
+
if (seen.has(note)) {
|
|
5446
|
+
note.clearVoice();
|
|
5447
|
+
const stave = priorStaves.get(note);
|
|
5448
|
+
if (stave)
|
|
5449
|
+
note.setStave(stave);
|
|
5450
|
+
else
|
|
5451
|
+
note.clearStave();
|
|
5452
|
+
}
|
|
5453
|
+
throw error;
|
|
5454
|
+
}
|
|
5455
|
+
}
|
|
5456
|
+
|
|
5457
|
+
|
|
5458
|
+
/***/ },
|
|
5459
|
+
|
|
5460
|
+
/***/ "./src/easyscore/elementindex.ts"
|
|
5461
|
+
/*!***************************************!*\
|
|
5462
|
+
!*** ./src/easyscore/elementindex.ts ***!
|
|
5463
|
+
\***************************************/
|
|
5464
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5465
|
+
|
|
5466
|
+
__webpack_require__.r(__webpack_exports__);
|
|
5467
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
5468
|
+
/* harmony export */ EasyScoreReferences: () => (/* binding */ EasyScoreReferences)
|
|
5469
|
+
/* harmony export */ });
|
|
5470
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util */ "./src/util.ts");
|
|
5471
|
+
|
|
5472
|
+
/** One index per EasyScore. Weak provenance also lets visual debuggers inspect an element directly. */
|
|
5473
|
+
class EasyScoreReferences {
|
|
5474
|
+
constructor() {
|
|
5475
|
+
this.ids = new Map();
|
|
5476
|
+
this.entries = new Map();
|
|
5477
|
+
this.scopes = [];
|
|
5478
|
+
}
|
|
5479
|
+
/** Return a copy so tools cannot change the stored source range. */
|
|
5480
|
+
static sourceOf(element) {
|
|
5481
|
+
const source = this.sources.get(element);
|
|
5482
|
+
return source && Object.assign({}, source);
|
|
5483
|
+
}
|
|
5484
|
+
/** Missing IDs are ordinary lookup misses, including after reset. */
|
|
5485
|
+
get(id) {
|
|
5486
|
+
return this.ids.get(id);
|
|
5487
|
+
}
|
|
5488
|
+
/** Only members of this score have instance-local source metadata. */
|
|
5489
|
+
getSource(element) {
|
|
5490
|
+
var _a;
|
|
5491
|
+
const source = (_a = this.entries.get(element)) === null || _a === void 0 ? void 0 : _a.source;
|
|
5492
|
+
return source && Object.assign({}, source);
|
|
5493
|
+
}
|
|
5494
|
+
/** Reject empty or duplicate IDs before registration or native ID mutation. */
|
|
5495
|
+
validate(element, id) {
|
|
5496
|
+
if (!id)
|
|
5497
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_0__.RuntimeError('BadArguments', 'Score elements need a nonempty ID.');
|
|
5498
|
+
const existing = this.ids.get(id);
|
|
5499
|
+
if (existing && existing !== element)
|
|
5500
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_0__.RuntimeError('BadArguments', `Duplicate score element ID: ${id}`);
|
|
5501
|
+
}
|
|
5502
|
+
/** Repeated registration is harmless. Native ID changes keep the index synchronized. */
|
|
5503
|
+
add(element, source) {
|
|
5504
|
+
var _a;
|
|
5505
|
+
const previous = this.entries.get(element);
|
|
5506
|
+
if (previous)
|
|
5507
|
+
return element;
|
|
5508
|
+
const id = element.getAttribute('id');
|
|
5509
|
+
this.validate(element, id);
|
|
5510
|
+
const entry = {
|
|
5511
|
+
id,
|
|
5512
|
+
source: source && Object.assign({}, source),
|
|
5513
|
+
unsubscribe: element.onIdChange((next) => this.validate(element, next), () => {
|
|
5514
|
+
this.ids.delete(entry.id);
|
|
5515
|
+
entry.id = element.getAttribute('id');
|
|
5516
|
+
this.ids.set(entry.id, element);
|
|
5517
|
+
}),
|
|
5518
|
+
};
|
|
5519
|
+
this.entries.set(element, entry);
|
|
5520
|
+
this.ids.set(id, element);
|
|
5521
|
+
if (entry.source)
|
|
5522
|
+
EasyScoreReferences.sources.set(element, entry.source);
|
|
5523
|
+
(_a = this.scopes[this.scopes.length - 1]) === null || _a === void 0 ? void 0 : _a.push(() => this.remove(element));
|
|
5524
|
+
return element;
|
|
5525
|
+
}
|
|
5526
|
+
/** Release exactly this score's subscription and provenance. */
|
|
5527
|
+
remove(element) {
|
|
5528
|
+
const entry = this.entries.get(element);
|
|
5529
|
+
if (!entry)
|
|
5530
|
+
return;
|
|
5531
|
+
entry.unsubscribe();
|
|
5532
|
+
this.ids.delete(entry.id);
|
|
5533
|
+
this.entries.delete(element);
|
|
5534
|
+
if (entry.source === EasyScoreReferences.sources.get(element))
|
|
5535
|
+
EasyScoreReferences.sources.delete(element);
|
|
5536
|
+
}
|
|
5537
|
+
/** Preserve references across draw(); reset explicitly ends the editing session. */
|
|
5538
|
+
clear() {
|
|
5539
|
+
for (const element of this.entries.keys())
|
|
5540
|
+
this.remove(element);
|
|
5541
|
+
}
|
|
5542
|
+
/** Nested failed construction releases subscriptions as well as visible references. */
|
|
5543
|
+
transaction(build) {
|
|
5544
|
+
var _a;
|
|
5545
|
+
const undo = [];
|
|
5546
|
+
this.scopes.push(undo);
|
|
5547
|
+
try {
|
|
5548
|
+
const result = build();
|
|
5549
|
+
this.scopes.pop();
|
|
5550
|
+
(_a = this.scopes[this.scopes.length - 1]) === null || _a === void 0 ? void 0 : _a.push(...undo);
|
|
5551
|
+
return result;
|
|
5552
|
+
}
|
|
5553
|
+
catch (error) {
|
|
5554
|
+
this.scopes.pop();
|
|
5555
|
+
undo.reverse().forEach((revert) => revert());
|
|
5556
|
+
throw error;
|
|
5557
|
+
}
|
|
5558
|
+
}
|
|
5559
|
+
}
|
|
5560
|
+
EasyScoreReferences.sources = new WeakMap();
|
|
5561
|
+
|
|
5562
|
+
|
|
5563
|
+
/***/ },
|
|
5564
|
+
|
|
5565
|
+
/***/ "./src/easyscore/elements.ts"
|
|
5566
|
+
/*!***********************************!*\
|
|
5567
|
+
!*** ./src/easyscore/elements.ts ***!
|
|
5568
|
+
\***********************************/
|
|
5569
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5570
|
+
|
|
5571
|
+
__webpack_require__.r(__webpack_exports__);
|
|
5572
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
5573
|
+
/* harmony export */ EasyScoreElements: () => (/* binding */ EasyScoreElements)
|
|
5574
|
+
/* harmony export */ });
|
|
5575
|
+
/* harmony import */ var _articulation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../articulation */ "./src/articulation.ts");
|
|
5576
|
+
/* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../note */ "./src/note.ts");
|
|
5577
|
+
/* harmony import */ var _stavenote__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../stavenote */ "./src/stavenote.ts");
|
|
5578
|
+
/* harmony import */ var _stemmablenote__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../stemmablenote */ "./src/stemmablenote.ts");
|
|
5579
|
+
/* harmony import */ var _tables__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../tables */ "./src/tables.ts");
|
|
5580
|
+
/* harmony import */ var _tabnote__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../tabnote */ "./src/tabnote.ts");
|
|
5581
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../util */ "./src/util.ts");
|
|
5582
|
+
// Typed notation constructors. Factory owns drawing; EasyScore owns references and construction boundaries.
|
|
5583
|
+
|
|
5584
|
+
|
|
5585
|
+
|
|
5586
|
+
|
|
5587
|
+
|
|
5588
|
+
|
|
5589
|
+
|
|
5590
|
+
/** Explicit methods keep native constructor signatures visible in editor completion. */
|
|
5591
|
+
class EasyScoreElements {
|
|
5592
|
+
constructor(host) {
|
|
5593
|
+
this.host = host;
|
|
5594
|
+
}
|
|
5595
|
+
get factory() {
|
|
5596
|
+
return this.host.factory();
|
|
5597
|
+
}
|
|
5598
|
+
/** Construct a native Stave; attach staff modifiers with attachToStave(). */
|
|
5599
|
+
stave(...args) {
|
|
5600
|
+
return this.host.manage(() => this.factory.Stave(...args));
|
|
5601
|
+
}
|
|
5602
|
+
/** Construct a native TabStave; attach staff modifiers with attachToStave(). */
|
|
5603
|
+
tabStave(...args) {
|
|
5604
|
+
return this.host.manage(() => this.factory.TabStave(...args));
|
|
5605
|
+
}
|
|
5606
|
+
/** Construct a native GlyphNote; attach staff modifiers with attachToStave(). */
|
|
5607
|
+
glyphNote(...args) {
|
|
5608
|
+
return this.host.manage(() => this.factory.GlyphNote(...args));
|
|
5609
|
+
}
|
|
5610
|
+
/** Construct a native RepeatNote; attach staff modifiers with attachToStave(). */
|
|
5611
|
+
repeatNote(...args) {
|
|
5612
|
+
return this.host.manage(() => this.factory.RepeatNote(...args));
|
|
5613
|
+
}
|
|
5614
|
+
/** Construct a native BarNote; attach staff modifiers with attachToStave(). */
|
|
5615
|
+
barNote(...args) {
|
|
5616
|
+
return this.host.manage(() => this.factory.BarNote(...args));
|
|
5617
|
+
}
|
|
5618
|
+
/** Construct a native ClefNote; attach staff modifiers with attachToStave(). */
|
|
5619
|
+
clefNote(...args) {
|
|
5620
|
+
return this.host.manage(() => this.factory.ClefNote(...args));
|
|
5621
|
+
}
|
|
5622
|
+
/** Construct a native KeySigNote; attach staff modifiers with attachToStave(). */
|
|
5623
|
+
keySigNote(...args) {
|
|
5624
|
+
return this.host.manage(() => this.factory.KeySigNote(...args));
|
|
5625
|
+
}
|
|
5626
|
+
/** Construct a native TimeSigNote; attach staff modifiers with attachToStave(). */
|
|
5627
|
+
timeSigNote(...args) {
|
|
5628
|
+
return this.host.manage(() => this.factory.TimeSigNote(...args));
|
|
5629
|
+
}
|
|
5630
|
+
/** Construct a native Clef; attach staff modifiers with attachToStave(). */
|
|
5631
|
+
clef(...args) {
|
|
5632
|
+
return this.host.manage(() => this.factory.Clef(...args));
|
|
5633
|
+
}
|
|
5634
|
+
/** Construct a native KeySignature; attach staff modifiers with attachToStave(). */
|
|
5635
|
+
keySignature(...args) {
|
|
5636
|
+
return this.host.manage(() => this.factory.KeySignature(...args));
|
|
5637
|
+
}
|
|
5638
|
+
/** Construct a native TimeSignature; attach staff modifiers with attachToStave(). */
|
|
5639
|
+
timeSignature(...args) {
|
|
5640
|
+
return this.host.manage(() => this.factory.TimeSignature(...args));
|
|
5641
|
+
}
|
|
5642
|
+
/** Construct a native Barline; attach staff modifiers with attachToStave(). */
|
|
5643
|
+
barline(...args) {
|
|
5644
|
+
return this.host.manage(() => this.factory.Barline(...args));
|
|
5645
|
+
}
|
|
5646
|
+
/** Construct a native Repetition; attach staff modifiers with attachToStave(). */
|
|
5647
|
+
repetition(...args) {
|
|
5648
|
+
return this.host.manage(() => this.factory.Repetition(...args));
|
|
5649
|
+
}
|
|
5650
|
+
/** Construct a native Volta; attach staff modifiers with attachToStave(). */
|
|
5651
|
+
volta(...args) {
|
|
5652
|
+
return this.host.manage(() => this.factory.Volta(...args));
|
|
5653
|
+
}
|
|
5654
|
+
/** Construct a native StaveSection; attach staff modifiers with attachToStave(). */
|
|
5655
|
+
section(...args) {
|
|
5656
|
+
return this.host.manage(() => this.factory.StaveSection(...args));
|
|
5657
|
+
}
|
|
5658
|
+
/** Construct a native StaveTempo; attach staff modifiers with attachToStave(). */
|
|
5659
|
+
tempo(...args) {
|
|
5660
|
+
return this.host.manage(() => this.factory.StaveTempo(...args));
|
|
5661
|
+
}
|
|
5662
|
+
/** Construct a native StaveText; attach staff modifiers with attachToStave(). */
|
|
5663
|
+
staveText(...args) {
|
|
5664
|
+
return this.host.manage(() => this.factory.StaveText(...args));
|
|
5665
|
+
}
|
|
5666
|
+
/** Preserve native fret text and arbitrary string counts; reject invalid positions early. */
|
|
5667
|
+
tabPositions(options) {
|
|
5668
|
+
if (!options.positions.length)
|
|
5669
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Tab notes need positions.');
|
|
5670
|
+
for (const { str, fret } of options.positions) {
|
|
5671
|
+
if (!Number.isSafeInteger(str) ||
|
|
5672
|
+
str < 1 ||
|
|
5673
|
+
(typeof fret === 'number' ? !Number.isFinite(fret) || fret < 0 : typeof fret !== 'string' || !fret.length))
|
|
5674
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Invalid tablature position.');
|
|
5675
|
+
}
|
|
5676
|
+
}
|
|
5677
|
+
/** Construct tablature with all native note fields. */
|
|
5678
|
+
tabNote(options, drawStem = false) {
|
|
5679
|
+
this.tabPositions(options);
|
|
5680
|
+
return this.host.manage(() => this.factory.TabNote(options, drawStem));
|
|
5681
|
+
}
|
|
5682
|
+
/** Grace tablature shares the same group ownership as pitched grace notes. */
|
|
5683
|
+
graceTabNote(options) {
|
|
5684
|
+
this.tabPositions(options);
|
|
5685
|
+
return this.host.manage(() => this.factory.GraceTabNote(options));
|
|
5686
|
+
}
|
|
5687
|
+
/** Preserve the complete native bend phrase, including custom widths. */
|
|
5688
|
+
bend(...args) {
|
|
5689
|
+
if (!args[0].length || args[0].some((part) => part.type !== 0 && part.type !== 1))
|
|
5690
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'A bend needs valid phrase directions.');
|
|
5691
|
+
return this.host.manage(() => this.factory.Bend(...args));
|
|
5692
|
+
}
|
|
5693
|
+
/** Validate tab endpoint types and head indexes before native span construction. */
|
|
5694
|
+
tabEndpoints(notes) {
|
|
5695
|
+
var _a, _b;
|
|
5696
|
+
this.endpoints(notes.firstNote, notes.lastNote, true);
|
|
5697
|
+
const first = (_a = notes.firstIndexes) !== null && _a !== void 0 ? _a : [0], last = (_b = notes.lastIndexes) !== null && _b !== void 0 ? _b : [0];
|
|
5698
|
+
if (!first.length || first.length !== last.length)
|
|
5699
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Tab span index lists must match.');
|
|
5700
|
+
for (const [note, indices] of [
|
|
5701
|
+
[notes.firstNote, first],
|
|
5702
|
+
[notes.lastNote, last],
|
|
5703
|
+
]) {
|
|
5704
|
+
if (!note)
|
|
5705
|
+
continue;
|
|
5706
|
+
if (!(note instanceof _tabnote__WEBPACK_IMPORTED_MODULE_5__.TabNote))
|
|
5707
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Tab spans need tab notes.');
|
|
5708
|
+
indices.forEach((index) => this.host.checkIndex(note, index));
|
|
5709
|
+
}
|
|
5710
|
+
}
|
|
5711
|
+
/** Tab ties support native hammer-on/pull-off text and explicit partial endpoints. */
|
|
5712
|
+
tabTie(...args) {
|
|
5713
|
+
this.tabEndpoints(args[0]);
|
|
5714
|
+
return this.host.manage(() => this.factory.TabTie(...args));
|
|
5715
|
+
}
|
|
5716
|
+
/** A partial slide needs an explicit direction; there are not two frets to compare. */
|
|
5717
|
+
tabSlide(...args) {
|
|
5718
|
+
this.tabEndpoints(args[0]);
|
|
5719
|
+
if ((args[1] !== undefined && args[1] !== 1 && args[1] !== -1) ||
|
|
5720
|
+
(args[1] === undefined && (!args[0].firstNote || !args[0].lastNote)))
|
|
5721
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Partial tab slides need direction 1 or -1.');
|
|
5722
|
+
return this.host.manage(() => this.factory.TabSlide(...args));
|
|
5723
|
+
}
|
|
5724
|
+
/** Connect owned staves without introducing another layout owner. */
|
|
5725
|
+
connector(params) {
|
|
5726
|
+
this.host.owned(params.topStave);
|
|
5727
|
+
this.host.owned(params.bottomStave);
|
|
5728
|
+
return this.host.manage(() => this.factory.StaveConnector(params));
|
|
5729
|
+
}
|
|
5730
|
+
/** Multi-measure rests are standalone drawables; set their stave explicitly. */
|
|
5731
|
+
multiMeasureRest(params) {
|
|
5732
|
+
var _a;
|
|
5733
|
+
if (!Number.isSafeInteger(params.numberOfMeasures) || ((_a = params.numberOfMeasures) !== null && _a !== void 0 ? _a : 0) < 1)
|
|
5734
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'A multi-measure rest needs a positive measure count.');
|
|
5735
|
+
return this.host.manage(() => this.factory.MultiMeasureRest(params));
|
|
5736
|
+
}
|
|
5737
|
+
/** Typed notes inherit score clef/stem defaults; explicit native fields win. */
|
|
5738
|
+
note(options) {
|
|
5739
|
+
return this.host.manage(() => this.factory.StaveNote(Object.assign(Object.assign(Object.assign({}, this.host.noteDefaults()), (options.stemDirection !== undefined && options.autoStem === undefined ? { autoStem: false } : {})), options)));
|
|
5740
|
+
}
|
|
5741
|
+
/** Construct a native Annotation; its options and setters remain available. */
|
|
5742
|
+
annotation(...args) {
|
|
5743
|
+
return this.host.manage(() => this.factory.Annotation(...args));
|
|
5744
|
+
}
|
|
5745
|
+
/** Construct a native GhostNote; its options and setters remain available. */
|
|
5746
|
+
ghostNote(...args) {
|
|
5747
|
+
return this.host.manage(() => this.factory.GhostNote(...args));
|
|
5748
|
+
}
|
|
5749
|
+
/** Construct a native GraceNote; its options and setters remain available. */
|
|
5750
|
+
graceNote(options) {
|
|
5751
|
+
return this.host.manage(() => this.factory.GraceNote(Object.assign(Object.assign(Object.assign({}, this.host.noteDefaults()), (options.stemDirection !== undefined && options.autoStem === undefined ? { autoStem: false } : {})), options)));
|
|
5752
|
+
}
|
|
5753
|
+
/** Construct a native Accidental; its options and setters remain available. */
|
|
5754
|
+
accidental(...args) {
|
|
5755
|
+
return this.host.manage(() => this.factory.Accidental(...args));
|
|
5756
|
+
}
|
|
5757
|
+
/** Construct a native Articulation; its options and setters remain available. */
|
|
5758
|
+
articulation(options = {}) {
|
|
5759
|
+
var _a;
|
|
5760
|
+
const marks = _articulation__WEBPACK_IMPORTED_MODULE_0__.Articulation.parseEasyScore((_a = options.type) !== null && _a !== void 0 ? _a : 'staccato');
|
|
5761
|
+
if (marks.length !== 1)
|
|
5762
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Create one articulation per helper call.');
|
|
5763
|
+
return this.host.manage(() => this.factory.Articulation(Object.assign(Object.assign(Object.assign({}, marks[0]), options), { type: marks[0].type })));
|
|
5764
|
+
}
|
|
5765
|
+
/** Construct a native Ornament; its options and setters remain available. */
|
|
5766
|
+
ornament(...args) {
|
|
5767
|
+
return this.host.manage(() => this.factory.Ornament(...args));
|
|
5768
|
+
}
|
|
5769
|
+
/** Construct a native Dot; its options and setters remain available. */
|
|
5770
|
+
dot(...args) {
|
|
5771
|
+
return this.host.manage(() => this.factory.Dot(...args));
|
|
5772
|
+
}
|
|
5773
|
+
/** Construct a native Parenthesis; its options and setters remain available. */
|
|
5774
|
+
parenthesis(...args) {
|
|
5775
|
+
return this.host.manage(() => this.factory.Parenthesis(...args));
|
|
5776
|
+
}
|
|
5777
|
+
/** Construct a native Stroke; its options and setters remain available. */
|
|
5778
|
+
stroke(...args) {
|
|
5779
|
+
return this.host.manage(() => this.factory.Stroke(...args));
|
|
5780
|
+
}
|
|
5781
|
+
/** Construct a native Tremolo; its options and setters remain available. */
|
|
5782
|
+
tremolo(...args) {
|
|
5783
|
+
return this.host.manage(() => this.factory.Tremolo(...args));
|
|
5784
|
+
}
|
|
5785
|
+
/** Construct a native Vibrato; its options and setters remain available. */
|
|
5786
|
+
vibrato(...args) {
|
|
5787
|
+
return this.host.manage(() => this.factory.Vibrato(...args));
|
|
5788
|
+
}
|
|
5789
|
+
/** Construct a native ChordSymbol; its options and setters remain available. */
|
|
5790
|
+
chordSymbol(...args) {
|
|
5791
|
+
return this.host.manage(() => this.factory.ChordSymbol(...args));
|
|
5792
|
+
}
|
|
5793
|
+
/** Construct a native TextNote; its options and setters remain available. */
|
|
5794
|
+
textNote(...args) {
|
|
5795
|
+
return this.host.manage(() => this.factory.TextNote(...args));
|
|
5796
|
+
}
|
|
5797
|
+
/** Construct a native Fingering; its options and setters remain available. */
|
|
5798
|
+
fingering(...args) {
|
|
5799
|
+
return this.host.manage(() => this.factory.Fingering(...args));
|
|
5800
|
+
}
|
|
5801
|
+
/** Construct a native StringNumber; its options and setters remain available. */
|
|
5802
|
+
stringNumber(...args) {
|
|
5803
|
+
return this.host.manage(() => this.factory.StringNumber(...args));
|
|
5804
|
+
}
|
|
5805
|
+
/** Grace children are owned by one modifier and are removed from the standalone draw queue. */
|
|
5806
|
+
graceNoteGroup(options) {
|
|
5807
|
+
options.notes.forEach((note) => this.host.owned(note));
|
|
5808
|
+
return this.host.manage(() => this.factory.groupNotes(options.notes, () => this.factory.GraceNoteGroup(Object.assign(Object.assign({}, options), { notes: options.notes.slice() }))));
|
|
5809
|
+
}
|
|
5810
|
+
/** Group inline notation or other subnotes before inserting the parent into a voice. */
|
|
5811
|
+
noteSubGroup(options) {
|
|
5812
|
+
options.notes.forEach((note) => this.host.owned(note));
|
|
5813
|
+
return this.host.manage(() => this.factory.groupNotes(options.notes, () => this.factory.NoteSubGroup({ notes: options.notes.slice() })));
|
|
5814
|
+
}
|
|
5815
|
+
/** Ties validate ownership and chord-head indexes before construction. */
|
|
5816
|
+
tie(options) {
|
|
5817
|
+
var _a, _b;
|
|
5818
|
+
const { from, to } = options;
|
|
5819
|
+
this.endpoints(from, to, true);
|
|
5820
|
+
const first = (_a = options.firstIndexes) !== null && _a !== void 0 ? _a : [0];
|
|
5821
|
+
const last = (_b = options.lastIndexes) !== null && _b !== void 0 ? _b : [0];
|
|
5822
|
+
if (!first.length || first.length !== last.length) {
|
|
5823
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Tie index lists must be nonempty and have the same length.');
|
|
5824
|
+
}
|
|
5825
|
+
for (const [note, indices] of [
|
|
5826
|
+
[from, first],
|
|
5827
|
+
[to, last],
|
|
5828
|
+
]) {
|
|
5829
|
+
if (!note)
|
|
5830
|
+
continue;
|
|
5831
|
+
this.host.owned(note);
|
|
5832
|
+
indices.forEach((index) => this.host.checkIndex(note, index));
|
|
5833
|
+
}
|
|
5834
|
+
return this.host.manage(() => this.factory.StaveTie(options));
|
|
5835
|
+
}
|
|
5836
|
+
/** Validate complete or explicitly partial spans before native constructors run. */
|
|
5837
|
+
endpoints(from, to, partial = false) {
|
|
5838
|
+
if ((!from && !to) || (!partial && (!from || !to)))
|
|
5839
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Missing span endpoint.');
|
|
5840
|
+
for (const note of [from, to]) {
|
|
5841
|
+
if (!note)
|
|
5842
|
+
continue;
|
|
5843
|
+
if (!(note instanceof _note__WEBPACK_IMPORTED_MODULE_1__.Note))
|
|
5844
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Span endpoints must be notes.');
|
|
5845
|
+
this.host.owned(note);
|
|
5846
|
+
}
|
|
5847
|
+
}
|
|
5848
|
+
/** Return a beam handle while preserving EasyScore's automatic/explicit stem policy. */
|
|
5849
|
+
beam(params) {
|
|
5850
|
+
var _a, _b, _c;
|
|
5851
|
+
const { notes, options } = params;
|
|
5852
|
+
if (notes.length < 2 || new Set(notes).size !== notes.length)
|
|
5853
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'A beam needs at least two distinct notes.');
|
|
5854
|
+
notes.forEach((note) => {
|
|
5855
|
+
if (!(note instanceof _stemmablenote__WEBPACK_IMPORTED_MODULE_3__.StemmableNote))
|
|
5856
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Beam endpoints must be stemmable notes.');
|
|
5857
|
+
this.host.owned(note);
|
|
5858
|
+
if (note.hasBeam())
|
|
5859
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Note already belongs to a beam.');
|
|
5860
|
+
if (note.getIntrinsicTicks() >= _tables__WEBPACK_IMPORTED_MODULE_4__.Tables.durationToTicks('4'))
|
|
5861
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Beamed notes must be shorter than a quarter note.');
|
|
5862
|
+
});
|
|
5863
|
+
for (const index of (_a = options === null || options === void 0 ? void 0 : options.secondaryBeamBreaks) !== null && _a !== void 0 ? _a : [])
|
|
5864
|
+
this.noteIndex(notes.length, index);
|
|
5865
|
+
for (const [index, direction] of Object.entries((_b = options === null || options === void 0 ? void 0 : options.partialBeamDirections) !== null && _b !== void 0 ? _b : {})) {
|
|
5866
|
+
this.noteIndex(notes.length, Number(index));
|
|
5867
|
+
if (!['L', 'R', 'B'].includes(direction))
|
|
5868
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Invalid partial beam direction.');
|
|
5869
|
+
}
|
|
5870
|
+
const autoStem = (_c = options === null || options === void 0 ? void 0 : options.autoStem) !== null && _c !== void 0 ? _c : this.host.beamStems(notes);
|
|
5871
|
+
return this.host.manage(() => this.factory.Beam({ notes, options: Object.assign(Object.assign({}, options), { autoStem }) }));
|
|
5872
|
+
}
|
|
5873
|
+
/** Reject non-integer and out-of-range note indices before native mutation. */
|
|
5874
|
+
noteIndex(length, index) {
|
|
5875
|
+
if (!Number.isInteger(index) || index < 0 || index >= length)
|
|
5876
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Invalid beam note index.');
|
|
5877
|
+
}
|
|
5878
|
+
/** Tuplets change rational timing before voice insertion. Nested tuplets retain native behavior. */
|
|
5879
|
+
tuplet(params) {
|
|
5880
|
+
var _a, _b;
|
|
5881
|
+
const { notes, options } = params;
|
|
5882
|
+
if (!notes.length || new Set(notes).size !== notes.length)
|
|
5883
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'A tuplet needs distinct notes.');
|
|
5884
|
+
notes.forEach((note) => {
|
|
5885
|
+
if (!(note instanceof _note__WEBPACK_IMPORTED_MODULE_1__.Note))
|
|
5886
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Tuplets require notes.');
|
|
5887
|
+
this.host.owned(note);
|
|
5888
|
+
let voiced = false;
|
|
5889
|
+
try {
|
|
5890
|
+
note.getVoice();
|
|
5891
|
+
voiced = true;
|
|
5892
|
+
}
|
|
5893
|
+
catch (error) {
|
|
5894
|
+
if (!(error instanceof _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError) || error.code !== 'NoVoice')
|
|
5895
|
+
throw error;
|
|
5896
|
+
}
|
|
5897
|
+
if (voiced)
|
|
5898
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Create tuplets before inserting notes into a voice.');
|
|
5899
|
+
});
|
|
5900
|
+
for (const ratio of [(_a = options === null || options === void 0 ? void 0 : options.numNotes) !== null && _a !== void 0 ? _a : notes.length, (_b = options === null || options === void 0 ? void 0 : options.notesOccupied) !== null && _b !== void 0 ? _b : 2]) {
|
|
5901
|
+
if (!Number.isSafeInteger(ratio) || ratio <= 0)
|
|
5902
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Tuplet ratios must be positive integers.');
|
|
5903
|
+
}
|
|
5904
|
+
return this.host.manage(() => this.factory.Tuplet(params));
|
|
5905
|
+
}
|
|
5906
|
+
/** Native curves support explicit partial spans at stave boundaries. */
|
|
5907
|
+
curve(params) {
|
|
5908
|
+
this.endpoints(params.from, params.to, true);
|
|
5909
|
+
return this.host.manage(() => { var _a; return this.factory.Curve({ from: params.from, to: params.to, options: (_a = params.options) !== null && _a !== void 0 ? _a : {} }); });
|
|
5910
|
+
}
|
|
5911
|
+
/** Hairpins require two endpoints; native render offsets remain editable. */
|
|
5912
|
+
hairpin(params) {
|
|
5913
|
+
this.endpoints(params.from, params.to);
|
|
5914
|
+
if (![1, 2].includes(params.type))
|
|
5915
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Unknown hairpin type.');
|
|
5916
|
+
return this.host.manage(() => this.factory.StaveHairpin(params));
|
|
5917
|
+
}
|
|
5918
|
+
/** Lines require two staff-note endpoints and matched chord-head indexes. */
|
|
5919
|
+
line(params) {
|
|
5920
|
+
this.endpoints(params.from, params.to);
|
|
5921
|
+
if (!(params.from instanceof _stavenote__WEBPACK_IMPORTED_MODULE_2__.StaveNote) || !(params.to instanceof _stavenote__WEBPACK_IMPORTED_MODULE_2__.StaveNote))
|
|
5922
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Lines require staff notes.');
|
|
5923
|
+
if (!params.firstIndexes.length || params.firstIndexes.length !== params.lastIndexes.length)
|
|
5924
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Line index lists must be nonempty and matched.');
|
|
5925
|
+
params.firstIndexes.forEach((index) => this.host.checkIndex(params.from, index));
|
|
5926
|
+
params.lastIndexes.forEach((index) => this.host.checkIndex(params.to, index));
|
|
5927
|
+
return this.host.manage(() => this.factory.StaveLine(params));
|
|
5928
|
+
}
|
|
5929
|
+
/** Text brackets have two complete endpoints; use explicit segments at row breaks. */
|
|
5930
|
+
textBracket(params) {
|
|
5931
|
+
this.endpoints(params.from, params.to);
|
|
5932
|
+
return this.host.manage(() => this.factory.TextBracket(params));
|
|
5933
|
+
}
|
|
5934
|
+
/** Vibrato brackets accept native partial endpoints. */
|
|
5935
|
+
vibratoBracket(params) {
|
|
5936
|
+
this.endpoints(params.from, params.to, true);
|
|
5937
|
+
return this.host.manage(() => this.factory.VibratoBracket(params));
|
|
5938
|
+
}
|
|
5939
|
+
/** Pedal points are explicit ordered staff-note events, including repeated depress/release points. */
|
|
5940
|
+
pedalMarking(params) {
|
|
5941
|
+
var _a, _b;
|
|
5942
|
+
if (!params.notes.length)
|
|
5943
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Pedal markings need notes.');
|
|
5944
|
+
params.notes.forEach((note) => {
|
|
5945
|
+
if (!(note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_2__.StaveNote))
|
|
5946
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Pedal points must be staff notes.');
|
|
5947
|
+
this.host.owned(note);
|
|
5948
|
+
});
|
|
5949
|
+
if (!['text', 'bracket', 'mixed'].includes((_b = (_a = params.options) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : 'mixed'))
|
|
5950
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Unknown pedal style.');
|
|
5951
|
+
return this.host.manage(() => this.factory.PedalMarking(params));
|
|
5952
|
+
}
|
|
5953
|
+
/** Timed dynamics retain all native text-note fields. */
|
|
5954
|
+
textDynamics(params = {}) {
|
|
5955
|
+
var _a;
|
|
5956
|
+
if (!/^[pmfsrz]*$/i.test((_a = params.text) !== null && _a !== void 0 ? _a : 'p'))
|
|
5957
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_6__.RuntimeError('BadArguments', 'Unknown dynamics glyph.');
|
|
5958
|
+
return this.host.manage(() => this.factory.TextDynamics(params));
|
|
5959
|
+
}
|
|
5960
|
+
/** Timed crescendo notes expose their native direction and height setters. */
|
|
5961
|
+
crescendo(...args) {
|
|
5962
|
+
return this.host.manage(() => this.factory.Crescendo(...args));
|
|
5963
|
+
}
|
|
5964
|
+
}
|
|
5965
|
+
|
|
5966
|
+
|
|
5967
|
+
/***/ },
|
|
5968
|
+
|
|
5969
|
+
/***/ "./src/easyscore/policies.ts"
|
|
5970
|
+
/*!***********************************!*\
|
|
5971
|
+
!*** ./src/easyscore/policies.ts ***!
|
|
5972
|
+
\***********************************/
|
|
5973
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5974
|
+
|
|
5975
|
+
__webpack_require__.r(__webpack_exports__);
|
|
5976
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
5977
|
+
/* harmony export */ applyCompositionAccidentals: () => (/* binding */ applyCompositionAccidentals)
|
|
5978
|
+
/* harmony export */ });
|
|
5979
|
+
/* harmony import */ var _accidental__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../accidental */ "./src/accidental.ts");
|
|
5980
|
+
/* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../fraction */ "./src/fraction.ts");
|
|
5981
|
+
/* harmony import */ var _music__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../music */ "./src/music.ts");
|
|
5982
|
+
/* harmony import */ var _stavenote__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../stavenote */ "./src/stavenote.ts");
|
|
5983
|
+
// Opt-in accidental generation preserves written pitches and explicit native decorations.
|
|
5984
|
+
|
|
5985
|
+
|
|
5986
|
+
|
|
5987
|
+
|
|
5988
|
+
/** Each onset is evaluated against one prior state, so voice ordering cannot change accidental output. */
|
|
5989
|
+
function applyCompositionAccidentals(score, voices, key, changes, generated, stave) {
|
|
5990
|
+
var _a, _b;
|
|
5991
|
+
const music = new _music__WEBPACK_IMPORTED_MODULE_2__.Music();
|
|
5992
|
+
let scale = music.createScaleMap(key);
|
|
5993
|
+
const state = new Map();
|
|
5994
|
+
const positions = new Map();
|
|
5995
|
+
for (const voice of voices) {
|
|
5996
|
+
const at = new _fraction__WEBPACK_IMPORTED_MODULE_1__.Fraction(0, 1);
|
|
5997
|
+
for (const note of voice.getTickables()) {
|
|
5998
|
+
if (note.shouldIgnoreTicks())
|
|
5999
|
+
continue;
|
|
6000
|
+
const id = at.clone().simplify().toString();
|
|
6001
|
+
const group = (_a = positions.get(id)) !== null && _a !== void 0 ? _a : { at: at.clone(), notes: [] };
|
|
6002
|
+
if (note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_3__.StaveNote && !note.isRest() && note.getStave() === stave)
|
|
6003
|
+
group.notes.push(note);
|
|
6004
|
+
positions.set(id, group);
|
|
6005
|
+
at.add(note.getTicks());
|
|
6006
|
+
}
|
|
6007
|
+
}
|
|
6008
|
+
let changeIndex = 0;
|
|
6009
|
+
const sorted = [...positions.values()].sort((a, b) => (a.at.equals(b.at) ? 0 : a.at.lessThan(b.at) ? -1 : 1));
|
|
6010
|
+
for (const group of sorted) {
|
|
6011
|
+
while (changeIndex < changes.length && !changes[changeIndex].at.greaterThan(group.at)) {
|
|
6012
|
+
scale = music.createScaleMap(changes[changeIndex++].key);
|
|
6013
|
+
state.clear();
|
|
6014
|
+
}
|
|
6015
|
+
const simultaneous = new Map();
|
|
6016
|
+
for (const note of group.notes)
|
|
6017
|
+
for (const written of note.getKeys()) {
|
|
6018
|
+
const [name, octave] = written.split('/');
|
|
6019
|
+
const parts = music.getNoteParts(name);
|
|
6020
|
+
const id = `${parts.root}/${octave}`;
|
|
6021
|
+
const values = (_b = simultaneous.get(id)) !== null && _b !== void 0 ? _b : new Set();
|
|
6022
|
+
values.add(parts.accidental || 'n');
|
|
6023
|
+
simultaneous.set(id, values);
|
|
6024
|
+
}
|
|
6025
|
+
const updates = new Map();
|
|
6026
|
+
for (const note of group.notes) {
|
|
6027
|
+
note.getKeys().forEach((written, index) => {
|
|
6028
|
+
var _a, _b, _c, _d;
|
|
6029
|
+
const [name, octave] = written.split('/');
|
|
6030
|
+
const parts = music.getNoteParts(name);
|
|
6031
|
+
const accidental = parts.accidental || 'n';
|
|
6032
|
+
const pitch = parts.root + accidental;
|
|
6033
|
+
const id = `${parts.root}/${octave}`;
|
|
6034
|
+
const previous = (_a = state.get(id)) !== null && _a !== void 0 ? _a : scale[parts.root];
|
|
6035
|
+
// Only ordinary parser-generated marks can be suppressed. Native/cautionary/microtonal marks stay.
|
|
6036
|
+
const marks = note
|
|
6037
|
+
.getModifiers()
|
|
6038
|
+
.filter((mark) => mark instanceof _accidental__WEBPACK_IMPORTED_MODULE_0__.Accidental && mark.getIndex() === index);
|
|
6039
|
+
const explicit = marks.filter((mark) => !generated.has(mark) || mark.isCautionary() || !_music__WEBPACK_IMPORTED_MODULE_2__.Music.accidentals.includes(mark.type));
|
|
6040
|
+
for (const mark of marks) {
|
|
6041
|
+
if (!explicit.includes(mark))
|
|
6042
|
+
note.getModifiers().splice(note.getModifiers().indexOf(mark), 1);
|
|
6043
|
+
}
|
|
6044
|
+
if (!explicit.length && (previous !== pitch || ((_c = (_b = simultaneous.get(id)) === null || _b === void 0 ? void 0 : _b.size) !== null && _c !== void 0 ? _c : 0) > 1))
|
|
6045
|
+
score.attach(note, score.make.accidental({ type: accidental }), index);
|
|
6046
|
+
// Microtonal spellings have no native key-string representation. Force a fresh sign next time.
|
|
6047
|
+
const value = explicit.some((mark) => !_music__WEBPACK_IMPORTED_MODULE_2__.Music.accidentals.includes(mark.type)) ? 'microtonal' : pitch;
|
|
6048
|
+
const values = (_d = updates.get(id)) !== null && _d !== void 0 ? _d : new Set();
|
|
6049
|
+
values.add(value);
|
|
6050
|
+
updates.set(id, values);
|
|
6051
|
+
});
|
|
6052
|
+
}
|
|
6053
|
+
// Conflicting simultaneous spellings require an explicit sign on the next occurrence.
|
|
6054
|
+
updates.forEach((values, id) => state.set(id, values.size === 1 ? [...values][0] : 'ambiguous'));
|
|
6055
|
+
}
|
|
6056
|
+
}
|
|
6057
|
+
|
|
6058
|
+
|
|
6059
|
+
/***/ },
|
|
6060
|
+
|
|
6061
|
+
/***/ "./src/easyscore/rhythm.ts"
|
|
6062
|
+
/*!*********************************!*\
|
|
6063
|
+
!*** ./src/easyscore/rhythm.ts ***!
|
|
6064
|
+
\*********************************/
|
|
6065
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6066
|
+
|
|
6067
|
+
__webpack_require__.r(__webpack_exports__);
|
|
6068
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
6069
|
+
/* harmony export */ autoBeam: () => (/* binding */ autoBeam)
|
|
6070
|
+
/* harmony export */ });
|
|
6071
|
+
/* harmony import */ var _beam__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../beam */ "./src/beam.ts");
|
|
6072
|
+
/* harmony import */ var _factory__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../factory */ "./src/factory.ts");
|
|
6073
|
+
/* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../fraction */ "./src/fraction.ts");
|
|
6074
|
+
/* harmony import */ var _stemmablenote__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../stemmablenote */ "./src/stemmablenote.ts");
|
|
6075
|
+
/* harmony import */ var _tables__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../tables */ "./src/tables.ts");
|
|
6076
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util */ "./src/util.ts");
|
|
6077
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
6078
|
+
var t = {};
|
|
6079
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
6080
|
+
t[p] = s[p];
|
|
6081
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6082
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
6083
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
6084
|
+
t[p[i]] = s[p[i]];
|
|
6085
|
+
}
|
|
6086
|
+
return t;
|
|
6087
|
+
};
|
|
6088
|
+
// Automatic beaming reuses native rational grouping with an explicit EasyScore stem policy.
|
|
6089
|
+
|
|
6090
|
+
|
|
6091
|
+
|
|
6092
|
+
|
|
6093
|
+
|
|
6094
|
+
|
|
6095
|
+
/** Validate every setting before native grouping mutates existing notes or tuplets. */
|
|
6096
|
+
function autoBeam(score, notes, options) {
|
|
6097
|
+
var _a, _b;
|
|
6098
|
+
if (new Set(notes).size !== notes.length)
|
|
6099
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArguments', 'Beam notes must be distinct.');
|
|
6100
|
+
notes.forEach((note) => {
|
|
6101
|
+
if (!(note instanceof _stemmablenote__WEBPACK_IMPORTED_MODULE_3__.StemmableNote) || _factory__WEBPACK_IMPORTED_MODULE_1__.Factory.getOwner(note) !== score.factory)
|
|
6102
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArguments', 'Beam notes must belong to this Factory.');
|
|
6103
|
+
if (note.hasBeam())
|
|
6104
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArguments', 'Note already belongs to a beam.');
|
|
6105
|
+
});
|
|
6106
|
+
const time = (_a = score.defaults.time) !== null && _a !== void 0 ? _a : '4/4';
|
|
6107
|
+
const signature = typeof time === 'string' ? time : `${time.numBeats}/${time.beatValue}`;
|
|
6108
|
+
const groups = (_b = options.groups) !== null && _b !== void 0 ? _b : _beam__WEBPACK_IMPORTED_MODULE_0__.Beam.getDefaultBeamGroups(signature);
|
|
6109
|
+
if (!groups.length ||
|
|
6110
|
+
groups.some((group) => !(group instanceof _fraction__WEBPACK_IMPORTED_MODULE_2__.Fraction) || !Number.isFinite(group.value()) || group.value() <= 0)) {
|
|
6111
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArguments', 'Beam groups must be positive finite Fractions.');
|
|
6112
|
+
}
|
|
6113
|
+
if (options.secondaryBreaks !== undefined)
|
|
6114
|
+
_tables__WEBPACK_IMPORTED_MODULE_4__.Tables.durationToTicks(options.secondaryBreaks);
|
|
6115
|
+
if (options.stemDirection !== undefined && ![1, -1].includes(options.stemDirection))
|
|
6116
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArguments', 'Invalid beam stem direction.');
|
|
6117
|
+
const { autoStem } = options, native = __rest(options, ["autoStem"]);
|
|
6118
|
+
const stemPolicy = autoStem === false ? 'preserve' : autoStem === true || options.stemDirection !== undefined ? 'auto' : 'explicit';
|
|
6119
|
+
return score.build(() => _beam__WEBPACK_IMPORTED_MODULE_0__.Beam.generateBeams(notes, Object.assign(Object.assign({}, native), { groups: groups.map((group) => group.clone()), stemPolicy })).map((beam) => score.adopt(beam, 'drawable')));
|
|
6120
|
+
}
|
|
4611
6121
|
|
|
4612
6122
|
|
|
4613
6123
|
/***/ },
|
|
@@ -4627,8 +6137,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4627
6137
|
/* harmony import */ var _metrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./metrics */ "./src/metrics.ts");
|
|
4628
6138
|
/* harmony import */ var _registry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./registry */ "./src/registry.ts");
|
|
4629
6139
|
/* harmony import */ var _textmetricscache__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textmetricscache */ "./src/textmetricscache.ts");
|
|
4630
|
-
/* harmony import */ var
|
|
4631
|
-
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
6140
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
4632
6141
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
4633
6142
|
// Shared element ownership, styling, fonts, and drawing state.
|
|
4634
6143
|
// MIT License
|
|
@@ -4639,7 +6148,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4639
6148
|
|
|
4640
6149
|
|
|
4641
6150
|
|
|
4642
|
-
|
|
4643
6151
|
/**
|
|
4644
6152
|
* Element implements a generic base class for VexFlow, with implementations
|
|
4645
6153
|
* of general functions and properties that can be inherited by all VexFlow elements.
|
|
@@ -4656,7 +6164,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4656
6164
|
*/
|
|
4657
6165
|
class Element {
|
|
4658
6166
|
static get CATEGORY() {
|
|
4659
|
-
return
|
|
6167
|
+
return "Element" /* Category.Element */;
|
|
4660
6168
|
}
|
|
4661
6169
|
static newID() {
|
|
4662
6170
|
return `auto${Element.ID++}`;
|
|
@@ -4737,7 +6245,7 @@ class Element {
|
|
|
4737
6245
|
*/
|
|
4738
6246
|
addChild(child) {
|
|
4739
6247
|
if (child.parent)
|
|
4740
|
-
throw new
|
|
6248
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('Element', 'Parent already defined');
|
|
4741
6249
|
child.parent = this;
|
|
4742
6250
|
this.children.push(child);
|
|
4743
6251
|
return this;
|
|
@@ -4839,7 +6347,7 @@ class Element {
|
|
|
4839
6347
|
}
|
|
4840
6348
|
/** Draw an element. */
|
|
4841
6349
|
draw() {
|
|
4842
|
-
throw new
|
|
6350
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('Element', 'Draw not defined');
|
|
4843
6351
|
}
|
|
4844
6352
|
/** Check if it has a class label (An element can have multiple class labels). */
|
|
4845
6353
|
hasClass(className) {
|
|
@@ -4908,19 +6416,31 @@ class Element {
|
|
|
4908
6416
|
}
|
|
4909
6417
|
/** Return associated SVGElement. */
|
|
4910
6418
|
getSVGElement(suffix = '') {
|
|
4911
|
-
const id = (0,
|
|
6419
|
+
const id = (0,_util__WEBPACK_IMPORTED_MODULE_5__.prefix)(this.attrs.id + suffix);
|
|
4912
6420
|
const element = document.getElementById(id);
|
|
4913
6421
|
if (element)
|
|
4914
6422
|
return element;
|
|
4915
6423
|
}
|
|
6424
|
+
/** @internal Subscribe a local ID index. All validators run before an ID is changed. */
|
|
6425
|
+
onIdChange(validate, changed) {
|
|
6426
|
+
var _a;
|
|
6427
|
+
const listener = { validate, changed };
|
|
6428
|
+
const listeners = ((_a = this.idListeners) !== null && _a !== void 0 ? _a : (this.idListeners = new Set()));
|
|
6429
|
+
listeners.add(listener);
|
|
6430
|
+
return () => listeners.delete(listener);
|
|
6431
|
+
}
|
|
4916
6432
|
/** Set an attribute such as 'id', 'class', or 'type'. */
|
|
4917
6433
|
setAttribute(name, value) {
|
|
4918
|
-
var _a;
|
|
6434
|
+
var _a, _b, _c;
|
|
4919
6435
|
const oldID = this.attrs.id;
|
|
4920
6436
|
const oldValue = this.attrs[name];
|
|
6437
|
+
if (name === 'id')
|
|
6438
|
+
(_a = this.idListeners) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.validate(value));
|
|
4921
6439
|
this.attrs[name] = value;
|
|
4922
6440
|
// Register with old id to support id changes.
|
|
4923
|
-
(
|
|
6441
|
+
(_b = this.registry) === null || _b === void 0 ? void 0 : _b.onUpdate({ id: oldID, name, value, oldValue });
|
|
6442
|
+
if (name === 'id')
|
|
6443
|
+
(_c = this.idListeners) === null || _c === void 0 ? void 0 : _c.forEach((listener) => listener.changed());
|
|
4924
6444
|
return this;
|
|
4925
6445
|
}
|
|
4926
6446
|
/** Get the boundingBox. */
|
|
@@ -4946,7 +6466,7 @@ class Element {
|
|
|
4946
6466
|
}
|
|
4947
6467
|
/** Validate and return the rendering context. */
|
|
4948
6468
|
checkContext() {
|
|
4949
|
-
return (0,
|
|
6469
|
+
return (0,_util__WEBPACK_IMPORTED_MODULE_5__.defined)(this.context, 'NoContext', 'No rendering context attached to instance.');
|
|
4950
6470
|
}
|
|
4951
6471
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
4952
6472
|
// Font Handling
|
|
@@ -5249,44 +6769,69 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5249
6769
|
/* harmony import */ var _articulation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./articulation */ "./src/articulation.ts");
|
|
5250
6770
|
/* harmony import */ var _barnote__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./barnote */ "./src/barnote.ts");
|
|
5251
6771
|
/* harmony import */ var _beam__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./beam */ "./src/beam.ts");
|
|
5252
|
-
/* harmony import */ var
|
|
5253
|
-
/* harmony import */ var
|
|
5254
|
-
/* harmony import */ var
|
|
5255
|
-
/* harmony import */ var
|
|
5256
|
-
/* harmony import */ var
|
|
5257
|
-
/* harmony import */ var
|
|
5258
|
-
/* harmony import */ var
|
|
5259
|
-
/* harmony import */ var
|
|
5260
|
-
/* harmony import */ var
|
|
5261
|
-
/* harmony import */ var
|
|
5262
|
-
/* harmony import */ var
|
|
5263
|
-
/* harmony import */ var
|
|
5264
|
-
/* harmony import */ var
|
|
5265
|
-
/* harmony import */ var
|
|
5266
|
-
/* harmony import */ var
|
|
5267
|
-
/* harmony import */ var
|
|
5268
|
-
/* harmony import */ var
|
|
5269
|
-
/* harmony import */ var
|
|
5270
|
-
/* harmony import */ var
|
|
5271
|
-
/* harmony import */ var
|
|
5272
|
-
/* harmony import */ var
|
|
5273
|
-
/* harmony import */ var
|
|
5274
|
-
/* harmony import */ var
|
|
5275
|
-
/* harmony import */ var
|
|
5276
|
-
/* harmony import */ var
|
|
5277
|
-
/* harmony import */ var
|
|
5278
|
-
/* harmony import */ var
|
|
5279
|
-
/* harmony import */ var
|
|
5280
|
-
/* harmony import */ var
|
|
5281
|
-
/* harmony import */ var
|
|
5282
|
-
/* harmony import */ var
|
|
5283
|
-
/* harmony import */ var
|
|
5284
|
-
/* harmony import */ var
|
|
5285
|
-
/* harmony import */ var
|
|
5286
|
-
/* harmony import */ var
|
|
5287
|
-
/* harmony import */ var
|
|
5288
|
-
/* harmony import */ var
|
|
5289
|
-
/* harmony import */ var
|
|
6772
|
+
/* harmony import */ var _bend__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./bend */ "./src/bend.ts");
|
|
6773
|
+
/* harmony import */ var _chordsymbol__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./chordsymbol */ "./src/chordsymbol.ts");
|
|
6774
|
+
/* harmony import */ var _clef__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./clef */ "./src/clef.ts");
|
|
6775
|
+
/* harmony import */ var _clefnote__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./clefnote */ "./src/clefnote.ts");
|
|
6776
|
+
/* harmony import */ var _crescendo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./crescendo */ "./src/crescendo.ts");
|
|
6777
|
+
/* harmony import */ var _curve__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./curve */ "./src/curve.ts");
|
|
6778
|
+
/* harmony import */ var _dot__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./dot */ "./src/dot.ts");
|
|
6779
|
+
/* harmony import */ var _easyscore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./easyscore */ "./src/easyscore.ts");
|
|
6780
|
+
/* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./element */ "./src/element.ts");
|
|
6781
|
+
/* harmony import */ var _formatter__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./formatter */ "./src/formatter.ts");
|
|
6782
|
+
/* harmony import */ var _frethandfinger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./frethandfinger */ "./src/frethandfinger.ts");
|
|
6783
|
+
/* harmony import */ var _ghostnote__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ghostnote */ "./src/ghostnote.ts");
|
|
6784
|
+
/* harmony import */ var _glyphnote__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./glyphnote */ "./src/glyphnote.ts");
|
|
6785
|
+
/* harmony import */ var _gracenote__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./gracenote */ "./src/gracenote.ts");
|
|
6786
|
+
/* harmony import */ var _gracenotegroup__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./gracenotegroup */ "./src/gracenotegroup.ts");
|
|
6787
|
+
/* harmony import */ var _gracetabnote__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./gracetabnote */ "./src/gracetabnote.ts");
|
|
6788
|
+
/* harmony import */ var _keysignature__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./keysignature */ "./src/keysignature.ts");
|
|
6789
|
+
/* harmony import */ var _keysignote__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./keysignote */ "./src/keysignote.ts");
|
|
6790
|
+
/* harmony import */ var _modifier__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./modifier */ "./src/modifier.ts");
|
|
6791
|
+
/* harmony import */ var _modifiercontext__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./modifiercontext */ "./src/modifiercontext.ts");
|
|
6792
|
+
/* harmony import */ var _multimeasurerest__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./multimeasurerest */ "./src/multimeasurerest.ts");
|
|
6793
|
+
/* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./note */ "./src/note.ts");
|
|
6794
|
+
/* harmony import */ var _notesubgroup__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./notesubgroup */ "./src/notesubgroup.ts");
|
|
6795
|
+
/* harmony import */ var _ornament__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./ornament */ "./src/ornament.ts");
|
|
6796
|
+
/* harmony import */ var _parenthesis__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./parenthesis */ "./src/parenthesis.ts");
|
|
6797
|
+
/* harmony import */ var _pedalmarking__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./pedalmarking */ "./src/pedalmarking.ts");
|
|
6798
|
+
/* harmony import */ var _registry__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./registry */ "./src/registry.ts");
|
|
6799
|
+
/* harmony import */ var _renderer__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./renderer */ "./src/renderer.ts");
|
|
6800
|
+
/* harmony import */ var _repeatnote__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./repeatnote */ "./src/repeatnote.ts");
|
|
6801
|
+
/* harmony import */ var _sheet__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./sheet */ "./src/sheet.ts");
|
|
6802
|
+
/* harmony import */ var _stave__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./stave */ "./src/stave.ts");
|
|
6803
|
+
/* harmony import */ var _stavebarline__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./stavebarline */ "./src/stavebarline.ts");
|
|
6804
|
+
/* harmony import */ var _staveconnector__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./staveconnector */ "./src/staveconnector.ts");
|
|
6805
|
+
/* harmony import */ var _stavehairpin__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./stavehairpin */ "./src/stavehairpin.ts");
|
|
6806
|
+
/* harmony import */ var _staveline__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./staveline */ "./src/staveline.ts");
|
|
6807
|
+
/* harmony import */ var _stavemodifier__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./stavemodifier */ "./src/stavemodifier.ts");
|
|
6808
|
+
/* harmony import */ var _stavenote__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./stavenote */ "./src/stavenote.ts");
|
|
6809
|
+
/* harmony import */ var _staverepetition__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./staverepetition */ "./src/staverepetition.ts");
|
|
6810
|
+
/* harmony import */ var _stavesection__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ./stavesection */ "./src/stavesection.ts");
|
|
6811
|
+
/* harmony import */ var _stavetempo__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ./stavetempo */ "./src/stavetempo.ts");
|
|
6812
|
+
/* harmony import */ var _stavetext__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(/*! ./stavetext */ "./src/stavetext.ts");
|
|
6813
|
+
/* harmony import */ var _stavetie__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(/*! ./stavetie */ "./src/stavetie.ts");
|
|
6814
|
+
/* harmony import */ var _stavevolta__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(/*! ./stavevolta */ "./src/stavevolta.ts");
|
|
6815
|
+
/* harmony import */ var _stringnumber__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(/*! ./stringnumber */ "./src/stringnumber.ts");
|
|
6816
|
+
/* harmony import */ var _strokes__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(/*! ./strokes */ "./src/strokes.ts");
|
|
6817
|
+
/* harmony import */ var _system__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(/*! ./system */ "./src/system.ts");
|
|
6818
|
+
/* harmony import */ var _tabnote__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(/*! ./tabnote */ "./src/tabnote.ts");
|
|
6819
|
+
/* harmony import */ var _tabslide__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(/*! ./tabslide */ "./src/tabslide.ts");
|
|
6820
|
+
/* harmony import */ var _tabstave__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(/*! ./tabstave */ "./src/tabstave.ts");
|
|
6821
|
+
/* harmony import */ var _tabtie__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(/*! ./tabtie */ "./src/tabtie.ts");
|
|
6822
|
+
/* harmony import */ var _textbracket__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(/*! ./textbracket */ "./src/textbracket.ts");
|
|
6823
|
+
/* harmony import */ var _textdynamics__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(/*! ./textdynamics */ "./src/textdynamics.ts");
|
|
6824
|
+
/* harmony import */ var _textnote__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(/*! ./textnote */ "./src/textnote.ts");
|
|
6825
|
+
/* harmony import */ var _tickcontext__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(/*! ./tickcontext */ "./src/tickcontext.ts");
|
|
6826
|
+
/* harmony import */ var _timesignature__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(/*! ./timesignature */ "./src/timesignature.ts");
|
|
6827
|
+
/* harmony import */ var _timesignote__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(/*! ./timesignote */ "./src/timesignote.ts");
|
|
6828
|
+
/* harmony import */ var _tremolo__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(/*! ./tremolo */ "./src/tremolo.ts");
|
|
6829
|
+
/* harmony import */ var _tuplet__WEBPACK_IMPORTED_MODULE_62__ = __webpack_require__(/*! ./tuplet */ "./src/tuplet.ts");
|
|
6830
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
6831
|
+
/* harmony import */ var _vibrato__WEBPACK_IMPORTED_MODULE_64__ = __webpack_require__(/*! ./vibrato */ "./src/vibrato.ts");
|
|
6832
|
+
/* harmony import */ var _vibratobracket__WEBPACK_IMPORTED_MODULE_65__ = __webpack_require__(/*! ./vibratobracket */ "./src/vibratobracket.ts");
|
|
6833
|
+
/* harmony import */ var _voice__WEBPACK_IMPORTED_MODULE_66__ = __webpack_require__(/*! ./voice */ "./src/voice.ts");
|
|
6834
|
+
/* harmony import */ var _web__WEBPACK_IMPORTED_MODULE_67__ = __webpack_require__(/*! ./web */ "./src/web.ts");
|
|
5290
6835
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
5291
6836
|
// Construct, lay out, theme, and draw notation with optional retained scores.
|
|
5292
6837
|
// MIT License
|
|
@@ -5314,6 +6859,31 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5314
6859
|
|
|
5315
6860
|
|
|
5316
6861
|
|
|
6862
|
+
|
|
6863
|
+
|
|
6864
|
+
|
|
6865
|
+
|
|
6866
|
+
|
|
6867
|
+
|
|
6868
|
+
|
|
6869
|
+
|
|
6870
|
+
|
|
6871
|
+
|
|
6872
|
+
|
|
6873
|
+
|
|
6874
|
+
|
|
6875
|
+
|
|
6876
|
+
|
|
6877
|
+
|
|
6878
|
+
|
|
6879
|
+
|
|
6880
|
+
|
|
6881
|
+
|
|
6882
|
+
|
|
6883
|
+
|
|
6884
|
+
|
|
6885
|
+
|
|
6886
|
+
|
|
5317
6887
|
|
|
5318
6888
|
|
|
5319
6889
|
|
|
@@ -5338,7 +6908,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5338
6908
|
// eslint-disable-next-line
|
|
5339
6909
|
function L(...args) {
|
|
5340
6910
|
if (Factory.DEBUG)
|
|
5341
|
-
(0,
|
|
6911
|
+
(0,_util__WEBPACK_IMPORTED_MODULE_63__.log)('VexFlow.Factory', args);
|
|
5342
6912
|
}
|
|
5343
6913
|
/**
|
|
5344
6914
|
* Factory implements a high level API around VexFlow.
|
|
@@ -5356,6 +6926,87 @@ class Factory {
|
|
|
5356
6926
|
static newFromElementId(elementId, width = 500, height = 200) {
|
|
5357
6927
|
return new Factory({ renderer: { elementId, width, height } });
|
|
5358
6928
|
}
|
|
6929
|
+
/** A grouped note draws only through its modifier, never through a main voice or queue. */
|
|
6930
|
+
static getGroup(note) {
|
|
6931
|
+
return Factory.groups.get(note);
|
|
6932
|
+
}
|
|
6933
|
+
/** Identify the Factory that created an element, without changing its draw role. */
|
|
6934
|
+
static getOwner(element) {
|
|
6935
|
+
return Factory.owners.get(element);
|
|
6936
|
+
}
|
|
6937
|
+
/** Record ownership independently of whether the element draws itself or attaches to a note. */
|
|
6938
|
+
own(element) {
|
|
6939
|
+
const owner = Factory.owners.get(element);
|
|
6940
|
+
if (owner === this)
|
|
6941
|
+
return element;
|
|
6942
|
+
if (owner)
|
|
6943
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_63__.RuntimeError('BadArguments', 'Element belongs to another Factory.');
|
|
6944
|
+
Factory.owners.set(element, this);
|
|
6945
|
+
this.constructionScopes.forEach((scope) => scope.push(element));
|
|
6946
|
+
return element;
|
|
6947
|
+
}
|
|
6948
|
+
/**
|
|
6949
|
+
* Adopt a native extension without guessing its drawing role. Attachment and layout remain explicit.
|
|
6950
|
+
* Repeating adoption cannot enqueue an element twice. Ownership survives draw/reset.
|
|
6951
|
+
*/
|
|
6952
|
+
adopt(element, role) {
|
|
6953
|
+
const valid = (role === 'note' && element instanceof _note__WEBPACK_IMPORTED_MODULE_26__.Note) ||
|
|
6954
|
+
(role === 'modifier' && element instanceof _modifier__WEBPACK_IMPORTED_MODULE_23__.Modifier) ||
|
|
6955
|
+
(role === 'staveModifier' && element instanceof _stavemodifier__WEBPACK_IMPORTED_MODULE_40__.StaveModifier) ||
|
|
6956
|
+
(role === 'drawable' &&
|
|
6957
|
+
element instanceof _element__WEBPACK_IMPORTED_MODULE_13__.Element &&
|
|
6958
|
+
!(element instanceof _note__WEBPACK_IMPORTED_MODULE_26__.Note) &&
|
|
6959
|
+
!(element instanceof _modifier__WEBPACK_IMPORTED_MODULE_23__.Modifier) &&
|
|
6960
|
+
!(element instanceof _voice__WEBPACK_IMPORTED_MODULE_66__.Voice) &&
|
|
6961
|
+
!(element instanceof _stave__WEBPACK_IMPORTED_MODULE_35__.Stave) &&
|
|
6962
|
+
!(element instanceof _stavemodifier__WEBPACK_IMPORTED_MODULE_40__.StaveModifier) &&
|
|
6963
|
+
!(element instanceof _system__WEBPACK_IMPORTED_MODULE_50__.System));
|
|
6964
|
+
if (!valid)
|
|
6965
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_63__.RuntimeError('BadArguments', `Invalid adopted element role: ${role}`);
|
|
6966
|
+
if (element instanceof _note__WEBPACK_IMPORTED_MODULE_26__.Note && Factory.groups.has(element)) {
|
|
6967
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_63__.RuntimeError('BadArguments', 'A grouped note cannot be queued independently.');
|
|
6968
|
+
}
|
|
6969
|
+
this.own(element);
|
|
6970
|
+
if ((role === 'note' || role === 'drawable') && !this.renderQ.includes(element))
|
|
6971
|
+
this.renderQ.push(element);
|
|
6972
|
+
return element;
|
|
6973
|
+
}
|
|
6974
|
+
/** Stage synchronous construction. Failed operations preserve existing queues and registry entries. */
|
|
6975
|
+
transaction(build) {
|
|
6976
|
+
const snapshot = {
|
|
6977
|
+
staves: this.staves.slice(),
|
|
6978
|
+
voices: this.voices.slice(),
|
|
6979
|
+
renderQ: this.renderQ.slice(),
|
|
6980
|
+
systems: this.systems.slice(),
|
|
6981
|
+
sheets: this.sheets.slice(),
|
|
6982
|
+
stave: this.stave,
|
|
6983
|
+
retained: this.retained,
|
|
6984
|
+
};
|
|
6985
|
+
const created = [];
|
|
6986
|
+
const grouped = [];
|
|
6987
|
+
this.constructionScopes.push(created);
|
|
6988
|
+
this.groupScopes.push(grouped);
|
|
6989
|
+
const run = () => {
|
|
6990
|
+
try {
|
|
6991
|
+
return build();
|
|
6992
|
+
}
|
|
6993
|
+
catch (error) {
|
|
6994
|
+
Object.assign(this, snapshot);
|
|
6995
|
+
created.forEach((element) => Factory.owners.delete(element));
|
|
6996
|
+
grouped
|
|
6997
|
+
.slice()
|
|
6998
|
+
.reverse()
|
|
6999
|
+
.forEach((restore) => restore());
|
|
7000
|
+
throw error;
|
|
7001
|
+
}
|
|
7002
|
+
finally {
|
|
7003
|
+
this.constructionScopes.pop();
|
|
7004
|
+
this.groupScopes.pop();
|
|
7005
|
+
}
|
|
7006
|
+
};
|
|
7007
|
+
const registry = _registry__WEBPACK_IMPORTED_MODULE_31__.Registry.getDefaultRegistry();
|
|
7008
|
+
return registry ? registry.transaction(run) : run();
|
|
7009
|
+
}
|
|
5359
7010
|
/**
|
|
5360
7011
|
* Example:
|
|
5361
7012
|
*
|
|
@@ -5365,6 +7016,8 @@ class Factory {
|
|
|
5365
7016
|
*/
|
|
5366
7017
|
constructor(options = {}) {
|
|
5367
7018
|
this.retained = false;
|
|
7019
|
+
this.constructionScopes = [];
|
|
7020
|
+
this.groupScopes = [];
|
|
5368
7021
|
/** Foreground defaults survive reset(), like renderer options. */
|
|
5369
7022
|
this.style = {};
|
|
5370
7023
|
L('New factory: ', options);
|
|
@@ -5402,7 +7055,7 @@ class Factory {
|
|
|
5402
7055
|
}
|
|
5403
7056
|
if (elementId === '') {
|
|
5404
7057
|
L(this);
|
|
5405
|
-
throw new
|
|
7058
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_63__.RuntimeError('renderer.elementId not set in FactoryOptions');
|
|
5406
7059
|
}
|
|
5407
7060
|
let backend = this.options.renderer.backend;
|
|
5408
7061
|
if (backend === undefined) {
|
|
@@ -5411,14 +7064,14 @@ class Factory {
|
|
|
5411
7064
|
// but is not an instance of window.HTMLCanvasElement.
|
|
5412
7065
|
// In fact, `window` might be undefined here.
|
|
5413
7066
|
// See: https://www.npmjs.com/package/canvas
|
|
5414
|
-
if ((0,
|
|
5415
|
-
backend =
|
|
7067
|
+
if ((0,_web__WEBPACK_IMPORTED_MODULE_67__.isHTMLCanvas)(elem)) {
|
|
7068
|
+
backend = _renderer__WEBPACK_IMPORTED_MODULE_32__.Renderer.Backends.CANVAS;
|
|
5416
7069
|
}
|
|
5417
7070
|
else {
|
|
5418
|
-
backend =
|
|
7071
|
+
backend = _renderer__WEBPACK_IMPORTED_MODULE_32__.Renderer.Backends.SVG;
|
|
5419
7072
|
}
|
|
5420
7073
|
}
|
|
5421
|
-
this.context =
|
|
7074
|
+
this.context = _renderer__WEBPACK_IMPORTED_MODULE_32__.Renderer.buildContext(elementId, backend, width, height, background);
|
|
5422
7075
|
}
|
|
5423
7076
|
getContext() {
|
|
5424
7077
|
return this.context;
|
|
@@ -5440,7 +7093,7 @@ class Factory {
|
|
|
5440
7093
|
}
|
|
5441
7094
|
/** Create an optional continuous sheet from measure-sized Systems. */
|
|
5442
7095
|
Sheet(options = {}) {
|
|
5443
|
-
const sheet = new
|
|
7096
|
+
const sheet = new _sheet__WEBPACK_IMPORTED_MODULE_34__.Sheet(Object.assign(Object.assign({}, options), { factory: this }));
|
|
5444
7097
|
this.sheets.push(sheet);
|
|
5445
7098
|
return sheet;
|
|
5446
7099
|
}
|
|
@@ -5448,60 +7101,112 @@ class Factory {
|
|
|
5448
7101
|
Stave(params) {
|
|
5449
7102
|
const staveSpace = this.options.stave.space;
|
|
5450
7103
|
const p = Object.assign({ x: 0, y: 0, width: this.options.renderer.width - staveSpace * 1.0, options: { spacingBetweenLinesPx: staveSpace * 1.0 } }, params);
|
|
5451
|
-
const stave = new
|
|
7104
|
+
const stave = new _stave__WEBPACK_IMPORTED_MODULE_35__.Stave(p.x, p.y, p.width, p.options);
|
|
5452
7105
|
this.staves.push(stave);
|
|
5453
7106
|
stave.setContext(this.context);
|
|
5454
7107
|
this.stave = stave;
|
|
5455
|
-
return stave;
|
|
7108
|
+
return this.own(stave);
|
|
5456
7109
|
}
|
|
5457
7110
|
TabStave(params) {
|
|
5458
7111
|
const staveSpace = this.options.stave.space;
|
|
5459
7112
|
const p = Object.assign({ x: 0, y: 0, width: this.options.renderer.width - staveSpace * 1.0, options: { spacingBetweenLinesPx: staveSpace * 1.3 } }, params);
|
|
5460
|
-
const stave = new
|
|
7113
|
+
const stave = new _tabstave__WEBPACK_IMPORTED_MODULE_53__.TabStave(p.x, p.y, p.width, p.options);
|
|
5461
7114
|
this.staves.push(stave);
|
|
5462
7115
|
stave.setContext(this.context);
|
|
5463
7116
|
this.stave = stave;
|
|
5464
|
-
return stave;
|
|
7117
|
+
return this.own(stave);
|
|
7118
|
+
}
|
|
7119
|
+
/** Construct a native Bend with an explicit drawing role. */
|
|
7120
|
+
Bend(...args) {
|
|
7121
|
+
return this.adopt(new _bend__WEBPACK_IMPORTED_MODULE_5__.Bend(...args).setContext(this.context), 'modifier');
|
|
7122
|
+
}
|
|
7123
|
+
/** Construct a native Clef with an explicit drawing role. */
|
|
7124
|
+
Clef(...args) {
|
|
7125
|
+
return this.adopt(new _clef__WEBPACK_IMPORTED_MODULE_7__.Clef(...args).setContext(this.context), 'staveModifier');
|
|
7126
|
+
}
|
|
7127
|
+
/** Construct a native KeySignature with an explicit drawing role. */
|
|
7128
|
+
KeySignature(...args) {
|
|
7129
|
+
return this.adopt(new _keysignature__WEBPACK_IMPORTED_MODULE_21__.KeySignature(...args).setContext(this.context), 'staveModifier');
|
|
7130
|
+
}
|
|
7131
|
+
/** Construct a native TimeSignature with an explicit drawing role. */
|
|
7132
|
+
TimeSignature(...args) {
|
|
7133
|
+
return this.adopt(new _timesignature__WEBPACK_IMPORTED_MODULE_59__.TimeSignature(...args).setContext(this.context), 'staveModifier');
|
|
7134
|
+
}
|
|
7135
|
+
/** Construct a native Barline with an explicit drawing role. */
|
|
7136
|
+
Barline(...args) {
|
|
7137
|
+
return this.adopt(new _stavebarline__WEBPACK_IMPORTED_MODULE_36__.Barline(...args).setContext(this.context), 'staveModifier');
|
|
7138
|
+
}
|
|
7139
|
+
/** Construct a native Repetition with an explicit drawing role. */
|
|
7140
|
+
Repetition(...args) {
|
|
7141
|
+
return this.adopt(new _staverepetition__WEBPACK_IMPORTED_MODULE_42__.Repetition(...args).setContext(this.context), 'staveModifier');
|
|
7142
|
+
}
|
|
7143
|
+
/** Construct a native Volta with an explicit drawing role. */
|
|
7144
|
+
Volta(...args) {
|
|
7145
|
+
return this.adopt(new _stavevolta__WEBPACK_IMPORTED_MODULE_47__.Volta(...args).setContext(this.context), 'staveModifier');
|
|
7146
|
+
}
|
|
7147
|
+
/** Construct a native StaveSection with an explicit drawing role. */
|
|
7148
|
+
StaveSection(...args) {
|
|
7149
|
+
return this.adopt(new _stavesection__WEBPACK_IMPORTED_MODULE_43__.StaveSection(...args).setContext(this.context), 'staveModifier');
|
|
7150
|
+
}
|
|
7151
|
+
/** Construct a native StaveTempo with an explicit drawing role. */
|
|
7152
|
+
StaveTempo(...args) {
|
|
7153
|
+
return this.adopt(new _stavetempo__WEBPACK_IMPORTED_MODULE_44__.StaveTempo(...args).setContext(this.context), 'staveModifier');
|
|
7154
|
+
}
|
|
7155
|
+
/** Construct a native StaveText with an explicit drawing role. */
|
|
7156
|
+
StaveText(...args) {
|
|
7157
|
+
return this.adopt(new _stavetext__WEBPACK_IMPORTED_MODULE_45__.StaveText(...args).setContext(this.context), 'staveModifier');
|
|
7158
|
+
}
|
|
7159
|
+
/** Construct a native TabTie with an explicit drawing role. */
|
|
7160
|
+
TabTie(...args) {
|
|
7161
|
+
return this.adopt(new _tabtie__WEBPACK_IMPORTED_MODULE_54__.TabTie(...args).setContext(this.context), 'drawable');
|
|
7162
|
+
}
|
|
7163
|
+
/** Construct a native TabSlide with an explicit drawing role. */
|
|
7164
|
+
TabSlide(...args) {
|
|
7165
|
+
return this.adopt(new _tabslide__WEBPACK_IMPORTED_MODULE_52__.TabSlide(...args).setContext(this.context), 'drawable');
|
|
7166
|
+
}
|
|
7167
|
+
/** Grace tab children draw through a GraceNoteGroup, never as standalone tickables. */
|
|
7168
|
+
GraceTabNote(options) {
|
|
7169
|
+
return this.own(new _gracetabnote__WEBPACK_IMPORTED_MODULE_20__.GraceTabNote(options).setContext(this.context));
|
|
5465
7170
|
}
|
|
5466
7171
|
StaveNote(noteStruct) {
|
|
5467
|
-
const note = new
|
|
7172
|
+
const note = new _stavenote__WEBPACK_IMPORTED_MODULE_41__.StaveNote(noteStruct);
|
|
5468
7173
|
if (this.stave)
|
|
5469
7174
|
note.setStave(this.stave);
|
|
5470
7175
|
note.setContext(this.context);
|
|
5471
7176
|
this.renderQ.push(note);
|
|
5472
|
-
return note;
|
|
7177
|
+
return this.own(note);
|
|
5473
7178
|
}
|
|
5474
7179
|
GlyphNote(glyph, noteStruct, options) {
|
|
5475
|
-
const note = new
|
|
7180
|
+
const note = new _glyphnote__WEBPACK_IMPORTED_MODULE_17__.GlyphNote(glyph, noteStruct, options);
|
|
5476
7181
|
if (this.stave)
|
|
5477
7182
|
note.setStave(this.stave);
|
|
5478
7183
|
note.setContext(this.context);
|
|
5479
7184
|
this.renderQ.push(note);
|
|
5480
|
-
return note;
|
|
7185
|
+
return this.own(note);
|
|
5481
7186
|
}
|
|
5482
7187
|
RepeatNote(type, noteStruct, options) {
|
|
5483
|
-
const note = new
|
|
7188
|
+
const note = new _repeatnote__WEBPACK_IMPORTED_MODULE_33__.RepeatNote(type, noteStruct, options);
|
|
5484
7189
|
if (this.stave)
|
|
5485
7190
|
note.setStave(this.stave);
|
|
5486
7191
|
note.setContext(this.context);
|
|
5487
7192
|
this.renderQ.push(note);
|
|
5488
|
-
return note;
|
|
7193
|
+
return this.own(note);
|
|
5489
7194
|
}
|
|
5490
7195
|
GhostNote(noteStruct) {
|
|
5491
|
-
const ghostNote = new
|
|
7196
|
+
const ghostNote = new _ghostnote__WEBPACK_IMPORTED_MODULE_16__.GhostNote(noteStruct);
|
|
5492
7197
|
if (this.stave)
|
|
5493
7198
|
ghostNote.setStave(this.stave);
|
|
5494
7199
|
ghostNote.setContext(this.context);
|
|
5495
7200
|
this.renderQ.push(ghostNote);
|
|
5496
|
-
return ghostNote;
|
|
7201
|
+
return this.own(ghostNote);
|
|
5497
7202
|
}
|
|
5498
7203
|
TextNote(noteStruct) {
|
|
5499
|
-
const textNote = new
|
|
7204
|
+
const textNote = new _textnote__WEBPACK_IMPORTED_MODULE_57__.TextNote(noteStruct);
|
|
5500
7205
|
if (this.stave)
|
|
5501
7206
|
textNote.setStave(this.stave);
|
|
5502
7207
|
textNote.setContext(this.context);
|
|
5503
7208
|
this.renderQ.push(textNote);
|
|
5504
|
-
return textNote;
|
|
7209
|
+
return this.own(textNote);
|
|
5505
7210
|
}
|
|
5506
7211
|
BarNote(params = {}) {
|
|
5507
7212
|
const barNote = new _barnote__WEBPACK_IMPORTED_MODULE_3__.BarNote(params.type);
|
|
@@ -5509,61 +7214,56 @@ class Factory {
|
|
|
5509
7214
|
barNote.setStave(this.stave);
|
|
5510
7215
|
barNote.setContext(this.context);
|
|
5511
7216
|
this.renderQ.push(barNote);
|
|
5512
|
-
return barNote;
|
|
7217
|
+
return this.own(barNote);
|
|
5513
7218
|
}
|
|
5514
7219
|
ClefNote(params) {
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
annotation: undefined,
|
|
5518
|
-
} }, params);
|
|
5519
|
-
const clefNote = new _clefnote__WEBPACK_IMPORTED_MODULE_6__.ClefNote(p.type, p.options.size, p.options.annotation);
|
|
7220
|
+
var _a, _b, _c;
|
|
7221
|
+
const clefNote = new _clefnote__WEBPACK_IMPORTED_MODULE_8__.ClefNote((_a = params === null || params === void 0 ? void 0 : params.type) !== null && _a !== void 0 ? _a : 'treble', (_b = params === null || params === void 0 ? void 0 : params.options) === null || _b === void 0 ? void 0 : _b.size, (_c = params === null || params === void 0 ? void 0 : params.options) === null || _c === void 0 ? void 0 : _c.annotation);
|
|
5520
7222
|
if (this.stave)
|
|
5521
7223
|
clefNote.setStave(this.stave);
|
|
5522
7224
|
clefNote.setContext(this.context);
|
|
5523
7225
|
this.renderQ.push(clefNote);
|
|
5524
|
-
return clefNote;
|
|
7226
|
+
return this.own(clefNote);
|
|
5525
7227
|
}
|
|
5526
7228
|
TimeSigNote(params) {
|
|
5527
7229
|
const p = Object.assign({ time: '4/4' }, params);
|
|
5528
|
-
const timeSigNote = new
|
|
7230
|
+
const timeSigNote = new _timesignote__WEBPACK_IMPORTED_MODULE_60__.TimeSigNote(p.time);
|
|
5529
7231
|
if (this.stave)
|
|
5530
7232
|
timeSigNote.setStave(this.stave);
|
|
5531
7233
|
timeSigNote.setContext(this.context);
|
|
5532
7234
|
this.renderQ.push(timeSigNote);
|
|
5533
|
-
return timeSigNote;
|
|
7235
|
+
return this.own(timeSigNote);
|
|
5534
7236
|
}
|
|
5535
7237
|
KeySigNote(params) {
|
|
5536
|
-
const keySigNote = new
|
|
7238
|
+
const keySigNote = new _keysignote__WEBPACK_IMPORTED_MODULE_22__.KeySigNote(params.key, params.cancelKey, params.alterKey, params.clef);
|
|
5537
7239
|
if (this.stave)
|
|
5538
7240
|
keySigNote.setStave(this.stave);
|
|
5539
7241
|
keySigNote.setContext(this.context);
|
|
5540
7242
|
this.renderQ.push(keySigNote);
|
|
5541
|
-
return keySigNote;
|
|
7243
|
+
return this.own(keySigNote);
|
|
5542
7244
|
}
|
|
5543
|
-
TabNote(noteStruct) {
|
|
5544
|
-
const note = new
|
|
7245
|
+
TabNote(noteStruct, drawStem = false) {
|
|
7246
|
+
const note = new _tabnote__WEBPACK_IMPORTED_MODULE_51__.TabNote(noteStruct, drawStem);
|
|
5545
7247
|
if (this.stave)
|
|
5546
7248
|
note.setStave(this.stave);
|
|
5547
7249
|
note.setContext(this.context);
|
|
5548
7250
|
this.renderQ.push(note);
|
|
5549
|
-
return note;
|
|
7251
|
+
return this.own(note);
|
|
5550
7252
|
}
|
|
5551
7253
|
GraceNote(noteStruct) {
|
|
5552
|
-
const note = new
|
|
7254
|
+
const note = new _gracenote__WEBPACK_IMPORTED_MODULE_18__.GraceNote(noteStruct);
|
|
5553
7255
|
if (this.stave)
|
|
5554
7256
|
note.setStave(this.stave);
|
|
5555
7257
|
note.setContext(this.context);
|
|
5556
|
-
return note;
|
|
7258
|
+
return this.own(note);
|
|
5557
7259
|
}
|
|
5558
7260
|
GraceNoteGroup(params) {
|
|
5559
|
-
|
|
5560
|
-
group.setContext(this.context);
|
|
5561
|
-
return group;
|
|
7261
|
+
return this.own(new _gracenotegroup__WEBPACK_IMPORTED_MODULE_19__.GraceNoteGroup(params.notes, params.slur).setContext(this.context));
|
|
5562
7262
|
}
|
|
5563
7263
|
Accidental(params) {
|
|
5564
7264
|
const accid = new _accidental__WEBPACK_IMPORTED_MODULE_0__.Accidental(params.type);
|
|
5565
7265
|
accid.setContext(this.context);
|
|
5566
|
-
return accid;
|
|
7266
|
+
return this.own(accid);
|
|
5567
7267
|
}
|
|
5568
7268
|
Annotation(params) {
|
|
5569
7269
|
const p = Object.assign({ text: 'p', hJustify: _annotation__WEBPACK_IMPORTED_MODULE_1__.AnnotationHorizontalJustify.CENTER, vJustify: _annotation__WEBPACK_IMPORTED_MODULE_1__.AnnotationVerticalJustify.BOTTOM }, params);
|
|
@@ -5572,11 +7272,11 @@ class Factory {
|
|
|
5572
7272
|
annotation.setVerticalJustification(p.vJustify);
|
|
5573
7273
|
annotation.setFont(p.font);
|
|
5574
7274
|
annotation.setContext(this.context);
|
|
5575
|
-
return annotation;
|
|
7275
|
+
return this.own(annotation);
|
|
5576
7276
|
}
|
|
5577
7277
|
ChordSymbol(params) {
|
|
5578
7278
|
const p = Object.assign({ vJustify: 'top', hJustify: 'center' }, params);
|
|
5579
|
-
const chordSymbol = new
|
|
7279
|
+
const chordSymbol = new _chordsymbol__WEBPACK_IMPORTED_MODULE_6__.ChordSymbol();
|
|
5580
7280
|
chordSymbol.setHorizontal(p.hJustify);
|
|
5581
7281
|
chordSymbol.setVertical(p.vJustify);
|
|
5582
7282
|
// There is a default font based on the engraving font. Only set then
|
|
@@ -5591,7 +7291,7 @@ class Factory {
|
|
|
5591
7291
|
chordSymbol.setFontSize(p.fontSize);
|
|
5592
7292
|
}
|
|
5593
7293
|
chordSymbol.setContext(this.context);
|
|
5594
|
-
return chordSymbol;
|
|
7294
|
+
return this.own(chordSymbol);
|
|
5595
7295
|
}
|
|
5596
7296
|
Articulation(params) {
|
|
5597
7297
|
var _a;
|
|
@@ -5601,11 +7301,11 @@ class Factory {
|
|
|
5601
7301
|
if ((params === null || params === void 0 ? void 0 : params.betweenLines) !== undefined)
|
|
5602
7302
|
articulation.setBetweenLines(params.betweenLines);
|
|
5603
7303
|
articulation.setContext(this.context);
|
|
5604
|
-
return articulation;
|
|
7304
|
+
return this.own(articulation);
|
|
5605
7305
|
}
|
|
5606
7306
|
Ornament(type, params) {
|
|
5607
7307
|
const options = Object.assign({ type, accidental: '' }, params);
|
|
5608
|
-
const ornament = new
|
|
7308
|
+
const ornament = new _ornament__WEBPACK_IMPORTED_MODULE_28__.Ornament(type);
|
|
5609
7309
|
if ((params === null || params === void 0 ? void 0 : params.position) !== undefined) {
|
|
5610
7310
|
ornament.setPosition(params.position);
|
|
5611
7311
|
}
|
|
@@ -5619,69 +7319,63 @@ class Factory {
|
|
|
5619
7319
|
ornament.setDelayed(options.delayed);
|
|
5620
7320
|
}
|
|
5621
7321
|
ornament.setContext(this.context);
|
|
5622
|
-
return ornament;
|
|
7322
|
+
return this.own(ornament);
|
|
5623
7323
|
}
|
|
5624
7324
|
TextDynamics(params) {
|
|
5625
|
-
const
|
|
5626
|
-
const text = new _textdynamics__WEBPACK_IMPORTED_MODULE_34__.TextDynamics({
|
|
5627
|
-
text: p.text,
|
|
5628
|
-
line: p.line,
|
|
5629
|
-
duration: p.duration,
|
|
5630
|
-
dots: p.dots,
|
|
5631
|
-
});
|
|
7325
|
+
const text = new _textdynamics__WEBPACK_IMPORTED_MODULE_56__.TextDynamics(Object.assign({ text: 'p', duration: 'q', dots: 0, line: 0 }, params));
|
|
5632
7326
|
if (this.stave)
|
|
5633
7327
|
text.setStave(this.stave);
|
|
5634
7328
|
text.setContext(this.context);
|
|
5635
7329
|
this.renderQ.push(text);
|
|
5636
|
-
return text;
|
|
7330
|
+
return this.own(text);
|
|
5637
7331
|
}
|
|
5638
7332
|
Fingering(params) {
|
|
5639
7333
|
const p = Object.assign({ number: '0', position: 'left' }, params);
|
|
5640
|
-
const fingering = new
|
|
7334
|
+
const fingering = new _frethandfinger__WEBPACK_IMPORTED_MODULE_15__.FretHandFinger(p.number);
|
|
5641
7335
|
fingering.setPosition(p.position);
|
|
5642
7336
|
fingering.setContext(this.context);
|
|
5643
|
-
return fingering;
|
|
7337
|
+
return this.own(fingering);
|
|
5644
7338
|
}
|
|
5645
7339
|
StringNumber(params, drawCircle = true) {
|
|
5646
|
-
const stringNumber = new
|
|
7340
|
+
const stringNumber = new _stringnumber__WEBPACK_IMPORTED_MODULE_48__.StringNumber(params.number);
|
|
5647
7341
|
stringNumber.setPosition(params.position);
|
|
5648
7342
|
stringNumber.setContext(this.context);
|
|
5649
7343
|
stringNumber.setDrawCircle(drawCircle);
|
|
5650
|
-
return stringNumber;
|
|
7344
|
+
return this.own(stringNumber);
|
|
5651
7345
|
}
|
|
5652
7346
|
TickContext() {
|
|
5653
|
-
return new
|
|
7347
|
+
return new _tickcontext__WEBPACK_IMPORTED_MODULE_58__.TickContext();
|
|
5654
7348
|
}
|
|
5655
7349
|
ModifierContext() {
|
|
5656
|
-
return new
|
|
7350
|
+
return new _modifiercontext__WEBPACK_IMPORTED_MODULE_24__.ModifierContext();
|
|
5657
7351
|
}
|
|
5658
7352
|
MultiMeasureRest(params) {
|
|
5659
|
-
const numMeasures = (0,
|
|
5660
|
-
const multiMeasureRest = new
|
|
7353
|
+
const numMeasures = (0,_util__WEBPACK_IMPORTED_MODULE_63__.defined)(params.numberOfMeasures, 'NoNumberOfMeasures');
|
|
7354
|
+
const multiMeasureRest = new _multimeasurerest__WEBPACK_IMPORTED_MODULE_25__.MultiMeasureRest(numMeasures, params);
|
|
5661
7355
|
multiMeasureRest.setContext(this.context);
|
|
5662
7356
|
this.renderQ.push(multiMeasureRest);
|
|
5663
|
-
return multiMeasureRest;
|
|
7357
|
+
return this.own(multiMeasureRest);
|
|
5664
7358
|
}
|
|
5665
7359
|
Voice(params) {
|
|
5666
7360
|
const p = Object.assign({ time: '4/4' }, params);
|
|
5667
|
-
const voice = new
|
|
7361
|
+
const voice = new _voice__WEBPACK_IMPORTED_MODULE_66__.Voice(p.time);
|
|
5668
7362
|
this.voices.push(voice);
|
|
5669
|
-
return voice;
|
|
7363
|
+
return this.own(voice);
|
|
5670
7364
|
}
|
|
5671
7365
|
StaveConnector(params) {
|
|
5672
|
-
const connector = new
|
|
7366
|
+
const connector = new _staveconnector__WEBPACK_IMPORTED_MODULE_37__.StaveConnector(params.topStave, params.bottomStave);
|
|
5673
7367
|
connector.setType(params.type).setContext(this.context);
|
|
5674
7368
|
this.renderQ.push(connector);
|
|
5675
|
-
return connector;
|
|
7369
|
+
return this.own(connector);
|
|
5676
7370
|
}
|
|
5677
7371
|
Formatter(options) {
|
|
5678
|
-
return new
|
|
7372
|
+
return new _formatter__WEBPACK_IMPORTED_MODULE_14__.Formatter(options);
|
|
5679
7373
|
}
|
|
5680
7374
|
Tuplet(params) {
|
|
5681
7375
|
const p = Object.assign({ notes: [], options: {} }, params);
|
|
5682
|
-
const tuplet = new
|
|
7376
|
+
const tuplet = new _tuplet__WEBPACK_IMPORTED_MODULE_62__.Tuplet(p.notes, p.options).setContext(this.context);
|
|
5683
7377
|
this.renderQ.push(tuplet);
|
|
5684
|
-
return tuplet;
|
|
7378
|
+
return this.own(tuplet);
|
|
5685
7379
|
}
|
|
5686
7380
|
Beam(params) {
|
|
5687
7381
|
var _a, _b, _c, _d, _e;
|
|
@@ -5693,16 +7387,16 @@ class Factory {
|
|
|
5693
7387
|
});
|
|
5694
7388
|
}
|
|
5695
7389
|
this.renderQ.push(beam);
|
|
5696
|
-
return beam;
|
|
7390
|
+
return this.own(beam);
|
|
5697
7391
|
}
|
|
5698
7392
|
Curve(params) {
|
|
5699
|
-
const curve = new
|
|
7393
|
+
const curve = new _curve__WEBPACK_IMPORTED_MODULE_10__.Curve(params.from, params.to, params.options).setContext(this.context);
|
|
5700
7394
|
this.renderQ.push(curve);
|
|
5701
|
-
return curve;
|
|
7395
|
+
return this.own(curve);
|
|
5702
7396
|
}
|
|
5703
7397
|
StaveTie(params) {
|
|
5704
7398
|
var _a;
|
|
5705
|
-
const tie = new
|
|
7399
|
+
const tie = new _stavetie__WEBPACK_IMPORTED_MODULE_46__.StaveTie({
|
|
5706
7400
|
firstNote: params.from,
|
|
5707
7401
|
lastNote: params.to,
|
|
5708
7402
|
firstIndexes: params.firstIndexes,
|
|
@@ -5712,11 +7406,11 @@ class Factory {
|
|
|
5712
7406
|
tie.setDirection(params.options.direction);
|
|
5713
7407
|
tie.setContext(this.context);
|
|
5714
7408
|
this.renderQ.push(tie);
|
|
5715
|
-
return tie;
|
|
7409
|
+
return this.own(tie);
|
|
5716
7410
|
}
|
|
5717
7411
|
StaveLine(params) {
|
|
5718
7412
|
var _a, _b;
|
|
5719
|
-
const line = new
|
|
7413
|
+
const line = new _staveline__WEBPACK_IMPORTED_MODULE_39__.StaveLine({
|
|
5720
7414
|
firstNote: params.from,
|
|
5721
7415
|
lastNote: params.to,
|
|
5722
7416
|
firstIndexes: params.firstIndexes,
|
|
@@ -5728,42 +7422,41 @@ class Factory {
|
|
|
5728
7422
|
line.setFont(params.options.font);
|
|
5729
7423
|
line.setContext(this.context);
|
|
5730
7424
|
this.renderQ.push(line);
|
|
5731
|
-
return line;
|
|
7425
|
+
return this.own(line);
|
|
5732
7426
|
}
|
|
5733
7427
|
VibratoBracket(params) {
|
|
5734
|
-
const vibratoBracket = new
|
|
7428
|
+
const vibratoBracket = new _vibratobracket__WEBPACK_IMPORTED_MODULE_65__.VibratoBracket({
|
|
5735
7429
|
start: params.from,
|
|
5736
7430
|
stop: params.to,
|
|
5737
7431
|
});
|
|
5738
|
-
if (params.options.line)
|
|
7432
|
+
if (params.options.line !== undefined)
|
|
5739
7433
|
vibratoBracket.setLine(params.options.line);
|
|
5740
|
-
if (params.options.code)
|
|
7434
|
+
if (params.options.code !== undefined)
|
|
5741
7435
|
vibratoBracket.setVibratoCode(params.options.code);
|
|
5742
7436
|
vibratoBracket.setContext(this.context);
|
|
5743
7437
|
this.renderQ.push(vibratoBracket);
|
|
5744
|
-
return vibratoBracket;
|
|
7438
|
+
return this.own(vibratoBracket);
|
|
5745
7439
|
}
|
|
5746
7440
|
TextBracket(params) {
|
|
5747
|
-
const textBracket = new
|
|
7441
|
+
const textBracket = new _textbracket__WEBPACK_IMPORTED_MODULE_55__.TextBracket({
|
|
5748
7442
|
start: params.from,
|
|
5749
7443
|
stop: params.to,
|
|
5750
7444
|
text: params.text,
|
|
5751
7445
|
superscript: params.options.superscript,
|
|
5752
7446
|
position: params.options.position,
|
|
5753
7447
|
});
|
|
5754
|
-
if (params.options.line)
|
|
7448
|
+
if (params.options.line !== undefined)
|
|
5755
7449
|
textBracket.setLine(params.options.line);
|
|
5756
7450
|
if (params.options.font)
|
|
5757
7451
|
textBracket.setFont(params.options.font);
|
|
5758
7452
|
textBracket.setContext(this.context);
|
|
5759
7453
|
this.renderQ.push(textBracket);
|
|
5760
|
-
return textBracket;
|
|
7454
|
+
return this.own(textBracket);
|
|
5761
7455
|
}
|
|
5762
7456
|
System(params = {}) {
|
|
5763
|
-
params
|
|
5764
|
-
const system = new _system__WEBPACK_IMPORTED_MODULE_30__.System(params).setContext(this.context);
|
|
7457
|
+
const system = new _system__WEBPACK_IMPORTED_MODULE_50__.System(Object.assign(Object.assign({}, params), { factory: this })).setContext(this.context);
|
|
5765
7458
|
this.systems.push(system);
|
|
5766
|
-
return system;
|
|
7459
|
+
return this.own(system);
|
|
5767
7460
|
}
|
|
5768
7461
|
/**
|
|
5769
7462
|
* Creates EasyScore. Normally the first step after constructing a Factory. For example:
|
|
@@ -5777,25 +7470,100 @@ class Factory {
|
|
|
5777
7470
|
* @param options.throwOnError throw error in case of parsing error
|
|
5778
7471
|
*/
|
|
5779
7472
|
EasyScore(options = {}) {
|
|
5780
|
-
options
|
|
5781
|
-
return new _easyscore__WEBPACK_IMPORTED_MODULE_8__.EasyScore(options);
|
|
7473
|
+
return new _easyscore__WEBPACK_IMPORTED_MODULE_12__.EasyScore(Object.assign(Object.assign({}, options), { factory: this }));
|
|
5782
7474
|
}
|
|
5783
7475
|
PedalMarking(params) {
|
|
5784
7476
|
const p = Object.assign({ notes: [], options: {
|
|
5785
7477
|
style: 'mixed',
|
|
5786
7478
|
} }, params);
|
|
5787
|
-
const pedal = new
|
|
5788
|
-
pedal.setType(
|
|
7479
|
+
const pedal = new _pedalmarking__WEBPACK_IMPORTED_MODULE_30__.PedalMarking(p.notes);
|
|
7480
|
+
pedal.setType(_pedalmarking__WEBPACK_IMPORTED_MODULE_30__.PedalMarking.typeString[p.options.style]);
|
|
5789
7481
|
pedal.setContext(this.context);
|
|
5790
7482
|
this.renderQ.push(pedal);
|
|
5791
|
-
return pedal;
|
|
7483
|
+
return this.own(pedal);
|
|
5792
7484
|
}
|
|
5793
7485
|
NoteSubGroup(params) {
|
|
5794
7486
|
const p = Object.assign({ notes: [] }, params);
|
|
5795
|
-
|
|
5796
|
-
|
|
7487
|
+
return this.own(new _notesubgroup__WEBPACK_IMPORTED_MODULE_27__.NoteSubGroup(p.notes).setContext(this.context));
|
|
7488
|
+
}
|
|
7489
|
+
/** Transfer unvoiced notes to one modifier. Validation happens before native voice assignment. */
|
|
7490
|
+
groupNotes(notes, construct) {
|
|
7491
|
+
if (!notes.length || new Set(notes).size !== notes.length) {
|
|
7492
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_63__.RuntimeError('BadArguments', 'A note group needs distinct notes.');
|
|
7493
|
+
}
|
|
7494
|
+
notes.forEach((note) => {
|
|
7495
|
+
const owner = Factory.getOwner(note);
|
|
7496
|
+
if (owner && owner !== this)
|
|
7497
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_63__.RuntimeError('BadArguments', 'Group note belongs to another Factory.');
|
|
7498
|
+
if (Factory.groups.has(note))
|
|
7499
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_63__.RuntimeError('BadArguments', 'Note already belongs to a group.');
|
|
7500
|
+
let voice;
|
|
7501
|
+
try {
|
|
7502
|
+
voice = note.getVoice();
|
|
7503
|
+
}
|
|
7504
|
+
catch (error) {
|
|
7505
|
+
if (!(error instanceof _util__WEBPACK_IMPORTED_MODULE_63__.RuntimeError) || error.code !== 'NoVoice')
|
|
7506
|
+
throw error;
|
|
7507
|
+
}
|
|
7508
|
+
if (voice)
|
|
7509
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_63__.RuntimeError('BadArguments', 'A voiced note cannot be moved into a group.');
|
|
7510
|
+
});
|
|
7511
|
+
const ignored = notes.map((note) => note.shouldIgnoreTicks());
|
|
7512
|
+
const restore = () => notes.forEach((note, index) => {
|
|
7513
|
+
Factory.groups.delete(note);
|
|
7514
|
+
note.clearVoice().setIgnoreTicks(ignored[index]);
|
|
7515
|
+
});
|
|
7516
|
+
let group;
|
|
7517
|
+
try {
|
|
7518
|
+
group = this.own(construct().setContext(this.context));
|
|
7519
|
+
}
|
|
7520
|
+
catch (error) {
|
|
7521
|
+
restore();
|
|
7522
|
+
throw error;
|
|
7523
|
+
}
|
|
7524
|
+
this.groupScopes.forEach((scope) => scope.push(restore));
|
|
7525
|
+
notes.forEach((note) => {
|
|
7526
|
+
this.own(note);
|
|
7527
|
+
Factory.groups.set(note, group);
|
|
7528
|
+
});
|
|
7529
|
+
this.renderQ = this.renderQ.filter((element) => !notes.includes(element));
|
|
5797
7530
|
return group;
|
|
5798
7531
|
}
|
|
7532
|
+
/** Construct a native Dot for attachment; preserve its full constructor options. */
|
|
7533
|
+
Dot(...args) {
|
|
7534
|
+
return this.adopt(new _dot__WEBPACK_IMPORTED_MODULE_11__.Dot(...args).setContext(this.context), 'modifier');
|
|
7535
|
+
}
|
|
7536
|
+
/** Construct a native Parenthesis for attachment; preserve its full constructor options. */
|
|
7537
|
+
Parenthesis(...args) {
|
|
7538
|
+
return this.adopt(new _parenthesis__WEBPACK_IMPORTED_MODULE_29__.Parenthesis(...args).setContext(this.context), 'modifier');
|
|
7539
|
+
}
|
|
7540
|
+
/** Construct a native Stroke for attachment; preserve its full constructor options. */
|
|
7541
|
+
Stroke(...args) {
|
|
7542
|
+
return this.adopt(new _strokes__WEBPACK_IMPORTED_MODULE_49__.Stroke(...args).setContext(this.context), 'modifier');
|
|
7543
|
+
}
|
|
7544
|
+
/** Construct a native Tremolo for attachment; preserve its full constructor options. */
|
|
7545
|
+
Tremolo(...args) {
|
|
7546
|
+
return this.adopt(new _tremolo__WEBPACK_IMPORTED_MODULE_61__.Tremolo(...args).setContext(this.context), 'modifier');
|
|
7547
|
+
}
|
|
7548
|
+
/** Construct a native Vibrato for attachment; preserve its full constructor options. */
|
|
7549
|
+
Vibrato(...args) {
|
|
7550
|
+
return this.adopt(new _vibrato__WEBPACK_IMPORTED_MODULE_64__.Vibrato(...args).setContext(this.context), 'modifier');
|
|
7551
|
+
}
|
|
7552
|
+
/** Timed crescendo note; span hairpins have a separate constructor. */
|
|
7553
|
+
Crescendo(...args) {
|
|
7554
|
+
const note = new _crescendo__WEBPACK_IMPORTED_MODULE_9__.Crescendo(...args).setContext(this.context);
|
|
7555
|
+
if (this.stave)
|
|
7556
|
+
note.setStave(this.stave);
|
|
7557
|
+
return this.adopt(note, 'note');
|
|
7558
|
+
}
|
|
7559
|
+
/** Stave-bound hairpin. The native renderer requires both endpoints. */
|
|
7560
|
+
StaveHairpin(params) {
|
|
7561
|
+
const notes = Object.assign(Object.assign({}, (params.from && { firstNote: params.from })), (params.to && { lastNote: params.to }));
|
|
7562
|
+
const hairpin = new _stavehairpin__WEBPACK_IMPORTED_MODULE_38__.StaveHairpin(notes, params.type).setContext(this.context);
|
|
7563
|
+
if (params.options)
|
|
7564
|
+
hairpin.setRenderOptions(Object.assign(Object.assign({}, hairpin.renderOptions), params.options));
|
|
7565
|
+
return this.adopt(hairpin, 'drawable');
|
|
7566
|
+
}
|
|
5799
7567
|
/** Render the score. */
|
|
5800
7568
|
draw(options = {}) {
|
|
5801
7569
|
var _a;
|
|
@@ -5836,6 +7604,9 @@ class Factory {
|
|
|
5836
7604
|
}
|
|
5837
7605
|
/** To enable logging for this class. Set `VexFlow.Factory.DEBUG` to `true`. */
|
|
5838
7606
|
Factory.DEBUG = false;
|
|
7607
|
+
/** Ownership survives drawing; weak keys do not retain discarded notation. */
|
|
7608
|
+
Factory.owners = new WeakMap();
|
|
7609
|
+
Factory.groups = new WeakMap();
|
|
5839
7610
|
|
|
5840
7611
|
|
|
5841
7612
|
/***/ },
|
|
@@ -6352,15 +8123,18 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
6352
8123
|
/* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fraction */ "./src/fraction.ts");
|
|
6353
8124
|
/* harmony import */ var _metrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./metrics */ "./src/metrics.ts");
|
|
6354
8125
|
/* harmony import */ var _modifiercontext__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modifiercontext */ "./src/modifiercontext.ts");
|
|
6355
|
-
/* harmony import */ var
|
|
6356
|
-
/* harmony import */ var
|
|
6357
|
-
/* harmony import */ var
|
|
6358
|
-
/* harmony import */ var
|
|
6359
|
-
/* harmony import */ var
|
|
6360
|
-
/* harmony import */ var
|
|
6361
|
-
/* harmony import */ var
|
|
8126
|
+
/* harmony import */ var _proportionalformatter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./proportionalformatter */ "./src/proportionalformatter.ts");
|
|
8127
|
+
/* harmony import */ var _stave__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stave */ "./src/stave.ts");
|
|
8128
|
+
/* harmony import */ var _staveconnector__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./staveconnector */ "./src/staveconnector.ts");
|
|
8129
|
+
/* harmony import */ var _tables__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./tables */ "./src/tables.ts");
|
|
8130
|
+
/* harmony import */ var _tickcontext__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./tickcontext */ "./src/tickcontext.ts");
|
|
8131
|
+
/* harmony import */ var _typeguard__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./typeguard */ "./src/typeguard.ts");
|
|
8132
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
8133
|
+
/* harmony import */ var _voice__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./voice */ "./src/voice.ts");
|
|
6362
8134
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
6363
8135
|
// MIT License
|
|
8136
|
+
// Engraving layout and opt-in placement on a strict musical-time grid.
|
|
8137
|
+
|
|
6364
8138
|
|
|
6365
8139
|
|
|
6366
8140
|
|
|
@@ -6375,7 +8149,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
6375
8149
|
// eslint-disable-next-line
|
|
6376
8150
|
function L(...args) {
|
|
6377
8151
|
if (Formatter.DEBUG)
|
|
6378
|
-
(0,
|
|
8152
|
+
(0,_util__WEBPACK_IMPORTED_MODULE_10__.log)('VexFlow.Formatter', args);
|
|
6379
8153
|
}
|
|
6380
8154
|
/**
|
|
6381
8155
|
* Get the rest line number of the next non-rest note(s).
|
|
@@ -6391,7 +8165,7 @@ function getRestLineForNextNoteGroup(notes, currRestLine, currNoteIndex, compare
|
|
|
6391
8165
|
// Start with the next note and keep going until we find a valid non-rest note group.
|
|
6392
8166
|
for (let noteIndex = currNoteIndex + 1; noteIndex < notes.length; noteIndex++) {
|
|
6393
8167
|
const note = notes[noteIndex];
|
|
6394
|
-
if ((0,
|
|
8168
|
+
if ((0,_typeguard__WEBPACK_IMPORTED_MODULE_9__.isNote)(note) && !note.isRest() && !note.shouldIgnoreTicks()) {
|
|
6395
8169
|
nextRestLine = note.getLineForRest();
|
|
6396
8170
|
break;
|
|
6397
8171
|
}
|
|
@@ -6400,7 +8174,7 @@ function getRestLineForNextNoteGroup(notes, currRestLine, currNoteIndex, compare
|
|
|
6400
8174
|
if (compare && currRestLine !== nextRestLine) {
|
|
6401
8175
|
const top = Math.max(currRestLine, nextRestLine);
|
|
6402
8176
|
const bot = Math.min(currRestLine, nextRestLine);
|
|
6403
|
-
nextRestLine = (0,
|
|
8177
|
+
nextRestLine = (0,_util__WEBPACK_IMPORTED_MODULE_10__.midLine)(top, bot);
|
|
6404
8178
|
}
|
|
6405
8179
|
return nextRestLine;
|
|
6406
8180
|
}
|
|
@@ -6428,7 +8202,7 @@ class Formatter {
|
|
|
6428
8202
|
static SimpleFormat(notes, x = 0, { paddingBetween = 10 } = {}) {
|
|
6429
8203
|
notes.reduce((accumulator, note) => {
|
|
6430
8204
|
note.addToModifierContext(new _modifiercontext__WEBPACK_IMPORTED_MODULE_3__.ModifierContext());
|
|
6431
|
-
const tickContext = new
|
|
8205
|
+
const tickContext = new _tickcontext__WEBPACK_IMPORTED_MODULE_8__.TickContext().addTickable(note).preFormat();
|
|
6432
8206
|
const metrics = tickContext.getMetrics();
|
|
6433
8207
|
tickContext.setX(accumulator + metrics.totalLeftPx);
|
|
6434
8208
|
return accumulator + tickContext.getWidth() + metrics.totalRightPx + paddingBetween;
|
|
@@ -6485,7 +8259,7 @@ class Formatter {
|
|
|
6485
8259
|
options.autoBeam = params;
|
|
6486
8260
|
}
|
|
6487
8261
|
// Start by creating a voice and adding all the notes to it.
|
|
6488
|
-
const voice = new
|
|
8262
|
+
const voice = new _voice__WEBPACK_IMPORTED_MODULE_11__.Voice(_tables__WEBPACK_IMPORTED_MODULE_7__.Tables.TIME4_4).setMode(_voice__WEBPACK_IMPORTED_MODULE_11__.Voice.Mode.SOFT).addTickables(notes);
|
|
6489
8263
|
// Then create beams, if requested.
|
|
6490
8264
|
const beams = options.autoBeam ? _beam__WEBPACK_IMPORTED_MODULE_0__.Beam.applyAndGetBeams(voice) : [];
|
|
6491
8265
|
// Instantiate a `Formatter` and format the notes.
|
|
@@ -6523,9 +8297,9 @@ class Formatter {
|
|
|
6523
8297
|
opts.autoBeam = params;
|
|
6524
8298
|
}
|
|
6525
8299
|
// Create a `4/4` voice for `notes`.
|
|
6526
|
-
const notevoice = new
|
|
8300
|
+
const notevoice = new _voice__WEBPACK_IMPORTED_MODULE_11__.Voice(_tables__WEBPACK_IMPORTED_MODULE_7__.Tables.TIME4_4).setMode(_voice__WEBPACK_IMPORTED_MODULE_11__.Voice.Mode.SOFT).addTickables(notes);
|
|
6527
8301
|
// Create a `4/4` voice for `tabnotes`.
|
|
6528
|
-
const tabvoice = new
|
|
8302
|
+
const tabvoice = new _voice__WEBPACK_IMPORTED_MODULE_11__.Voice(_tables__WEBPACK_IMPORTED_MODULE_7__.Tables.TIME4_4).setMode(_voice__WEBPACK_IMPORTED_MODULE_11__.Voice.Mode.SOFT).addTickables(tabnotes);
|
|
6529
8303
|
// Then create beams, if requested.
|
|
6530
8304
|
const beams = opts.autoBeam ? _beam__WEBPACK_IMPORTED_MODULE_0__.Beam.applyAndGetBeams(notevoice) : [];
|
|
6531
8305
|
// Instantiate a `Formatter` and align tab and stave notes.
|
|
@@ -6538,7 +8312,7 @@ class Formatter {
|
|
|
6538
8312
|
tabvoice.draw(ctx, tabstave);
|
|
6539
8313
|
beams.forEach((beam) => beam.setContext(ctx).drawWithStyle());
|
|
6540
8314
|
// Draw a connector between tab and note staves.
|
|
6541
|
-
new
|
|
8315
|
+
new _staveconnector__WEBPACK_IMPORTED_MODULE_6__.StaveConnector(stave, tabstave).setContext(ctx).drawWithStyle();
|
|
6542
8316
|
}
|
|
6543
8317
|
/**
|
|
6544
8318
|
* Automatically set the vertical position of rests based on previous/next note positions.
|
|
@@ -6550,7 +8324,7 @@ class Formatter {
|
|
|
6550
8324
|
*/
|
|
6551
8325
|
static AlignRestsToNotes(tickables, alignAllNotes, alignTuplets = false) {
|
|
6552
8326
|
tickables.forEach((currTickable, index) => {
|
|
6553
|
-
if ((0,
|
|
8327
|
+
if ((0,_typeguard__WEBPACK_IMPORTED_MODULE_9__.isStaveNote)(currTickable) && currTickable.isRest()) {
|
|
6554
8328
|
if (currTickable.getTuplet() && !alignTuplets) {
|
|
6555
8329
|
return;
|
|
6556
8330
|
}
|
|
@@ -6568,7 +8342,7 @@ class Formatter {
|
|
|
6568
8342
|
else if (index > 0 && index < tickables.length) {
|
|
6569
8343
|
// If previous tickable is a rest, use its line number.
|
|
6570
8344
|
const prevTickable = tickables[index - 1];
|
|
6571
|
-
if ((0,
|
|
8345
|
+
if ((0,_typeguard__WEBPACK_IMPORTED_MODULE_9__.isStaveNote)(prevTickable)) {
|
|
6572
8346
|
if (prevTickable.isRest()) {
|
|
6573
8347
|
props.line = prevTickable.getKeyProps()[0].line;
|
|
6574
8348
|
}
|
|
@@ -6585,7 +8359,10 @@ class Formatter {
|
|
|
6585
8359
|
});
|
|
6586
8360
|
}
|
|
6587
8361
|
constructor(options) {
|
|
6588
|
-
this.formatterOptions = Object.assign({ globalSoftmax: false, softmaxFactor:
|
|
8362
|
+
this.formatterOptions = Object.assign({ globalSoftmax: false, softmaxFactor: _tables__WEBPACK_IMPORTED_MODULE_7__.Tables.SOFTMAX_FACTOR, maxIterations: 5 }, options);
|
|
8363
|
+
if ((options === null || options === void 0 ? void 0 : options.spacing) && options.spacing.mode !== 'proportional') {
|
|
8364
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_10__.RuntimeError('BadArgument', 'Unknown formatter spacing mode.');
|
|
8365
|
+
}
|
|
6589
8366
|
this.justifyWidth = 0;
|
|
6590
8367
|
this.totalCost = 0;
|
|
6591
8368
|
this.totalShift = 0;
|
|
@@ -6619,7 +8396,7 @@ class Formatter {
|
|
|
6619
8396
|
*/
|
|
6620
8397
|
alignRests(voices, alignAllNotes) {
|
|
6621
8398
|
if (!voices || !voices.length) {
|
|
6622
|
-
throw new
|
|
8399
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_10__.RuntimeError('BadArgument', 'No voices to format rests');
|
|
6623
8400
|
}
|
|
6624
8401
|
voices.forEach((voice) => Formatter.AlignRestsToNotes(voice.getTickables(), alignAllNotes));
|
|
6625
8402
|
}
|
|
@@ -6644,6 +8421,12 @@ class Formatter {
|
|
|
6644
8421
|
* @returns the estimated width in pixels
|
|
6645
8422
|
*/
|
|
6646
8423
|
preCalculateMinTotalWidth(voices) {
|
|
8424
|
+
if (this.formatterOptions.spacing) {
|
|
8425
|
+
this.createTickContexts(voices);
|
|
8426
|
+
this.minTotalWidth = this.proportional.minimumWidth(this.formatterOptions.spacing);
|
|
8427
|
+
this.hasMinTotalWidth = true;
|
|
8428
|
+
return this.minTotalWidth;
|
|
8429
|
+
}
|
|
6647
8430
|
const unalignedPadding = _metrics__WEBPACK_IMPORTED_MODULE_2__.Metrics.get('Stave.unalignedNotePadding');
|
|
6648
8431
|
// Calculate additional padding based on 3 methods:
|
|
6649
8432
|
// 1) unaligned beats in voices, 2) variance of width, 3) variance of durations
|
|
@@ -6657,7 +8440,7 @@ class Formatter {
|
|
|
6657
8440
|
return this.minTotalWidth;
|
|
6658
8441
|
// Create tick contexts.
|
|
6659
8442
|
if (!voices) {
|
|
6660
|
-
throw new
|
|
8443
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_10__.RuntimeError('BadArgument', "'voices' required to run preCalculateMinTotalWidth");
|
|
6661
8444
|
}
|
|
6662
8445
|
this.createTickContexts(voices);
|
|
6663
8446
|
const { list: contextList, map: contextMap } = this.tickContexts;
|
|
@@ -6685,10 +8468,10 @@ class Formatter {
|
|
|
6685
8468
|
this.hasMinTotalWidth = true;
|
|
6686
8469
|
// normalized (0-1) STDDEV of widths/durations gives us padding hints.
|
|
6687
8470
|
const wavg = wsum > 0 ? wsum / widths.length : 1 / widths.length;
|
|
6688
|
-
const wvar = (0,
|
|
8471
|
+
const wvar = (0,_util__WEBPACK_IMPORTED_MODULE_10__.sumArray)(widths.map((ll) => Math.pow(ll - wavg, 2)));
|
|
6689
8472
|
const wpads = Math.pow(wvar / widths.length, 0.5) / wavg;
|
|
6690
8473
|
const davg = dsum / durations.length;
|
|
6691
|
-
const dvar = (0,
|
|
8474
|
+
const dvar = (0,_util__WEBPACK_IMPORTED_MODULE_10__.sumArray)(durations.map((ll) => Math.pow(ll - davg, 2)));
|
|
6692
8475
|
const dpads = Math.pow(dvar / durations.length, 0.5) / davg;
|
|
6693
8476
|
// Find max of 3 methods pad the width with that
|
|
6694
8477
|
const padmax = Math.max(dpads, wpads) * contextList.length * unalignedPadding;
|
|
@@ -6701,7 +8484,7 @@ class Formatter {
|
|
|
6701
8484
|
*/
|
|
6702
8485
|
getMinTotalWidth() {
|
|
6703
8486
|
if (!this.hasMinTotalWidth) {
|
|
6704
|
-
throw new
|
|
8487
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_10__.RuntimeError('NoMinTotalWidth', "Call 'preCalculateMinTotalWidth' or 'preFormat' before calling 'getMinTotalWidth'");
|
|
6705
8488
|
}
|
|
6706
8489
|
return this.minTotalWidth;
|
|
6707
8490
|
}
|
|
@@ -6709,15 +8492,15 @@ class Formatter {
|
|
|
6709
8492
|
* least common multiple of all the voices' getResolutionMultiplier() results. */
|
|
6710
8493
|
static getResolutionMultiplier(voices) {
|
|
6711
8494
|
if (!voices || !voices.length) {
|
|
6712
|
-
throw new
|
|
8495
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_10__.RuntimeError('BadArgument', 'No voices to format');
|
|
6713
8496
|
}
|
|
6714
8497
|
const totalTicks = voices[0].getTotalTicks();
|
|
6715
8498
|
const resolutionMultiplier = voices.reduce((accumulator, voice) => {
|
|
6716
8499
|
if (!voice.getTotalTicks().equals(totalTicks)) {
|
|
6717
|
-
throw new
|
|
8500
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_10__.RuntimeError('TickMismatch', 'Voices should have same total note duration in ticks.');
|
|
6718
8501
|
}
|
|
6719
|
-
if (voice.getMode() ===
|
|
6720
|
-
throw new
|
|
8502
|
+
if (voice.getMode() === _voice__WEBPACK_IMPORTED_MODULE_11__.Voice.Mode.STRICT && !voice.isComplete()) {
|
|
8503
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_10__.RuntimeError('IncompleteVoice', 'Voice does not have enough notes.');
|
|
6721
8504
|
}
|
|
6722
8505
|
return Math.max(accumulator, _fraction__WEBPACK_IMPORTED_MODULE_1__.Fraction.LCM(accumulator, voice.getResolutionMultiplier()));
|
|
6723
8506
|
}, 1);
|
|
@@ -6752,7 +8535,8 @@ class Formatter {
|
|
|
6752
8535
|
}
|
|
6753
8536
|
// Add this tickable to the TickContext.
|
|
6754
8537
|
tickable.addToModifierContext(staveTickToContextMap[integerTicks]);
|
|
6755
|
-
|
|
8538
|
+
if (!this.formatterOptions.spacing || !tickable.shouldIgnoreTicks())
|
|
8539
|
+
ticksUsed.add(tickable.getTicks());
|
|
6756
8540
|
});
|
|
6757
8541
|
});
|
|
6758
8542
|
this.modifierContexts.push({
|
|
@@ -6767,6 +8551,8 @@ class Formatter {
|
|
|
6767
8551
|
*/
|
|
6768
8552
|
createTickContexts(voices) {
|
|
6769
8553
|
if (voices.length === 0) {
|
|
8554
|
+
if (this.formatterOptions.spacing)
|
|
8555
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_10__.RuntimeError('BadArgument', 'No voices to format');
|
|
6770
8556
|
// We need to short-circuit this since at present, Formatter.getResolutionMultiplier
|
|
6771
8557
|
// throws an error on no voices.
|
|
6772
8558
|
return {
|
|
@@ -6776,6 +8562,11 @@ class Formatter {
|
|
|
6776
8562
|
resolutionMultiplier: 0,
|
|
6777
8563
|
};
|
|
6778
8564
|
}
|
|
8565
|
+
if (this.formatterOptions.spacing) {
|
|
8566
|
+
this.proportional = new _proportionalformatter__WEBPACK_IMPORTED_MODULE_4__.ProportionalFormatter(voices, Formatter.getResolutionMultiplier(voices));
|
|
8567
|
+
this.tickContexts = this.proportional.contexts;
|
|
8568
|
+
return this.tickContexts;
|
|
8569
|
+
}
|
|
6779
8570
|
// Initialize tick maps.
|
|
6780
8571
|
const tickToContextMap = {};
|
|
6781
8572
|
const tickList = [];
|
|
@@ -6791,7 +8582,7 @@ class Formatter {
|
|
|
6791
8582
|
const integerTicks = ticksUsed.numerator;
|
|
6792
8583
|
// If we have no tick context for this tick, create one.
|
|
6793
8584
|
if (!tickToContextMap[integerTicks]) {
|
|
6794
|
-
const newContext = new
|
|
8585
|
+
const newContext = new _tickcontext__WEBPACK_IMPORTED_MODULE_8__.TickContext({ tickID: integerTicks });
|
|
6795
8586
|
tickContexts.push(newContext);
|
|
6796
8587
|
tickToContextMap[integerTicks] = newContext;
|
|
6797
8588
|
// Maintain a list of unique integerTicks.
|
|
@@ -6835,7 +8626,7 @@ class Formatter {
|
|
|
6835
8626
|
// Initialize context maps.
|
|
6836
8627
|
const contexts = this.tickContexts;
|
|
6837
8628
|
if (!contexts) {
|
|
6838
|
-
throw new
|
|
8629
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_10__.RuntimeError('NoTickContexts', 'preFormat requires TickContexts');
|
|
6839
8630
|
}
|
|
6840
8631
|
const { list: contextList, map: contextMap } = contexts;
|
|
6841
8632
|
// Reset loss history for evaluator.
|
|
@@ -6845,6 +8636,13 @@ class Formatter {
|
|
|
6845
8636
|
if (voicesParam && stave) {
|
|
6846
8637
|
voicesParam.forEach((voice) => voice.setStave(stave).preFormat());
|
|
6847
8638
|
}
|
|
8639
|
+
if (this.proportional && this.formatterOptions.spacing) {
|
|
8640
|
+
const spacing = this.formatterOptions.spacing;
|
|
8641
|
+
this.minTotalWidth = this.proportional.minimumWidth(spacing);
|
|
8642
|
+
this.justifyWidth = this.proportional.format(spacing, justifyWidth);
|
|
8643
|
+
this.hasMinTotalWidth = true;
|
|
8644
|
+
return this.evaluate();
|
|
8645
|
+
}
|
|
6848
8646
|
// Now distribute the ticks to each tick context, and assign them their
|
|
6849
8647
|
// own X positions.
|
|
6850
8648
|
let x = 0;
|
|
@@ -6870,7 +8668,7 @@ class Formatter {
|
|
|
6870
8668
|
// Use softmax based on all notes across all staves. (options.globalSoftmax)
|
|
6871
8669
|
const { globalSoftmax, softmaxFactor, maxIterations } = this.formatterOptions;
|
|
6872
8670
|
const exp = (tick) => Math.pow(softmaxFactor, (contextMap[tick].getMaxTicks().value() / totalTicks));
|
|
6873
|
-
const expTicksUsed = (0,
|
|
8671
|
+
const expTicksUsed = (0,_util__WEBPACK_IMPORTED_MODULE_10__.sumArray)(contextList.map(exp));
|
|
6874
8672
|
this.minTotalWidth = x + shift;
|
|
6875
8673
|
this.hasMinTotalWidth = true;
|
|
6876
8674
|
// No justification needed. End formatting.
|
|
@@ -6955,7 +8753,7 @@ class Formatter {
|
|
|
6955
8753
|
if (index > 0) {
|
|
6956
8754
|
const contextX = context.getX();
|
|
6957
8755
|
const ideal = idealDistances[index];
|
|
6958
|
-
const errorPx = (0,
|
|
8756
|
+
const errorPx = (0,_util__WEBPACK_IMPORTED_MODULE_10__.defined)(ideal.fromTickable).getX() + ideal.expectedDistance - (contextX + spaceAccum);
|
|
6959
8757
|
let negativeShiftPx = 0;
|
|
6960
8758
|
if (errorPx > 0) {
|
|
6961
8759
|
spaceAccum += errorPx;
|
|
@@ -7124,6 +8922,9 @@ class Formatter {
|
|
|
7124
8922
|
*/
|
|
7125
8923
|
tune(options) {
|
|
7126
8924
|
var _a;
|
|
8925
|
+
// Tuning must never move strict rhythmic anchors, including when called by System.
|
|
8926
|
+
if (this.proportional)
|
|
8927
|
+
return this.totalCost;
|
|
7127
8928
|
const contexts = this.tickContexts;
|
|
7128
8929
|
if (!contexts) {
|
|
7129
8930
|
return 0;
|
|
@@ -7166,9 +8967,10 @@ class Formatter {
|
|
|
7166
8967
|
this.modifierContexts.forEach((modifierContexts) => {
|
|
7167
8968
|
modifierContexts.array.forEach((mc) => mc.postFormat());
|
|
7168
8969
|
});
|
|
7169
|
-
this.
|
|
7170
|
-
this.tickContexts.
|
|
7171
|
-
|
|
8970
|
+
const contexts = this.proportional
|
|
8971
|
+
? this.tickContexts.array
|
|
8972
|
+
: this.tickContexts.list.map((tick) => this.tickContexts.map[tick]);
|
|
8973
|
+
contexts.forEach((context) => context.postFormat());
|
|
7172
8974
|
return this;
|
|
7173
8975
|
}
|
|
7174
8976
|
/**
|
|
@@ -7208,7 +9010,7 @@ class Formatter {
|
|
|
7208
9010
|
// This method is just like `format` except that the `justifyWidth` is inferred from the `stave`.
|
|
7209
9011
|
formatToStave(voices, stave, optionsParam) {
|
|
7210
9012
|
const options = Object.assign({ context: stave.getContext() }, optionsParam);
|
|
7211
|
-
const justifyWidth = stave.getNoteEndX() - stave.getNoteStartX() -
|
|
9013
|
+
const justifyWidth = stave.getNoteEndX() - stave.getNoteStartX() - _stave__WEBPACK_IMPORTED_MODULE_5__.Stave.defaultPadding;
|
|
7212
9014
|
L('Formatting voices to width: ', justifyWidth);
|
|
7213
9015
|
return this.format(voices, justifyWidth, options);
|
|
7214
9016
|
}
|
|
@@ -14065,6 +15867,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
14065
15867
|
/* harmony export */ CurvePosition: () => (/* reexport safe */ _curve__WEBPACK_IMPORTED_MODULE_12__.CurvePosition),
|
|
14066
15868
|
/* harmony export */ Dot: () => (/* reexport safe */ _dot__WEBPACK_IMPORTED_MODULE_13__.Dot),
|
|
14067
15869
|
/* harmony export */ EasyScore: () => (/* reexport safe */ _easyscore__WEBPACK_IMPORTED_MODULE_14__.EasyScore),
|
|
15870
|
+
/* harmony export */ EasyScoreError: () => (/* reexport safe */ _easyscore__WEBPACK_IMPORTED_MODULE_14__.EasyScoreError),
|
|
14068
15871
|
/* harmony export */ EasyScoreGrammar: () => (/* reexport safe */ _easyscore__WEBPACK_IMPORTED_MODULE_14__.EasyScoreGrammar),
|
|
14069
15872
|
/* harmony export */ Element: () => (/* reexport safe */ _element__WEBPACK_IMPORTED_MODULE_15__.Element),
|
|
14070
15873
|
/* harmony export */ Factory: () => (/* reexport safe */ _factory__WEBPACK_IMPORTED_MODULE_16__.Factory),
|
|
@@ -14142,7 +15945,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
14142
15945
|
/* harmony export */ Tremolo: () => (/* reexport safe */ _tremolo__WEBPACK_IMPORTED_MODULE_78__.Tremolo),
|
|
14143
15946
|
/* harmony export */ Tuning: () => (/* reexport safe */ _tuning__WEBPACK_IMPORTED_MODULE_79__.Tuning),
|
|
14144
15947
|
/* harmony export */ Tuplet: () => (/* reexport safe */ _tuplet__WEBPACK_IMPORTED_MODULE_80__.Tuplet),
|
|
14145
|
-
/* harmony export */ TupletLocation: () => (/* reexport safe */ _tuplet__WEBPACK_IMPORTED_MODULE_80__.TupletLocation),
|
|
14146
15948
|
/* harmony export */ VexFlow: () => (/* reexport safe */ _vexflow__WEBPACK_IMPORTED_MODULE_83__.VexFlow),
|
|
14147
15949
|
/* harmony export */ Vibrato: () => (/* reexport safe */ _vibrato__WEBPACK_IMPORTED_MODULE_84__.Vibrato),
|
|
14148
15950
|
/* harmony export */ VibratoBracket: () => (/* reexport safe */ _vibratobracket__WEBPACK_IMPORTED_MODULE_85__.VibratoBracket),
|
|
@@ -14506,8 +16308,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
14506
16308
|
/* harmony import */ var _stave__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stave */ "./src/stave.ts");
|
|
14507
16309
|
/* harmony import */ var _stavemodifier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stavemodifier */ "./src/stavemodifier.ts");
|
|
14508
16310
|
/* harmony import */ var _tables__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tables */ "./src/tables.ts");
|
|
14509
|
-
/* harmony import */ var
|
|
14510
|
-
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
16311
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
14511
16312
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
14512
16313
|
// @author Cyril Silverman
|
|
14513
16314
|
//
|
|
@@ -14522,10 +16323,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
14522
16323
|
|
|
14523
16324
|
|
|
14524
16325
|
|
|
14525
|
-
|
|
14526
16326
|
class KeySignature extends _stavemodifier__WEBPACK_IMPORTED_MODULE_4__.StaveModifier {
|
|
14527
16327
|
static get CATEGORY() {
|
|
14528
|
-
return
|
|
16328
|
+
return "KeySignature" /* Category.KeySignature */;
|
|
14529
16329
|
}
|
|
14530
16330
|
// Create a new Key Signature based on a `keySpec`
|
|
14531
16331
|
constructor(keySpec, cancelKeySpec, alterKeySpec) {
|
|
@@ -14541,7 +16341,7 @@ class KeySignature extends _stavemodifier__WEBPACK_IMPORTED_MODULE_4__.StaveModi
|
|
|
14541
16341
|
// spacing will be included in the glyph's position
|
|
14542
16342
|
convertToGlyph(acc, nextAcc, stave) {
|
|
14543
16343
|
const code = _tables__WEBPACK_IMPORTED_MODULE_5__.Tables.accidentalCodes(acc.type);
|
|
14544
|
-
const glyph = new _element__WEBPACK_IMPORTED_MODULE_1__.Element(
|
|
16344
|
+
const glyph = new _element__WEBPACK_IMPORTED_MODULE_1__.Element("KeySignature" /* Category.KeySignature */);
|
|
14545
16345
|
glyph.setText(code);
|
|
14546
16346
|
// Determine spacing between current accidental and the next accidental
|
|
14547
16347
|
let extraWidth = 1;
|
|
@@ -14695,6 +16495,14 @@ class KeySignature extends _stavemodifier__WEBPACK_IMPORTED_MODULE_4__.StaveModi
|
|
|
14695
16495
|
this.format();
|
|
14696
16496
|
return this.width;
|
|
14697
16497
|
}
|
|
16498
|
+
/** Override staff clef for an inline signature following an inline clef change. */
|
|
16499
|
+
setClef(clef) {
|
|
16500
|
+
if (clef !== undefined)
|
|
16501
|
+
_tables__WEBPACK_IMPORTED_MODULE_5__.Tables.clefProperties(clef);
|
|
16502
|
+
this.clefOverride = clef;
|
|
16503
|
+
this.formatted = false;
|
|
16504
|
+
return this;
|
|
16505
|
+
}
|
|
14698
16506
|
// Set the key signature to a specific key, ie: 'C' or 'Gm'
|
|
14699
16507
|
setKeySig(keySpec, cancelKeySpec, alterKeySpec) {
|
|
14700
16508
|
this.formatted = false;
|
|
@@ -14725,6 +16533,7 @@ class KeySignature extends _stavemodifier__WEBPACK_IMPORTED_MODULE_4__.StaveModi
|
|
|
14725
16533
|
* If no stave is set, a dummy stave is created.
|
|
14726
16534
|
*/
|
|
14727
16535
|
format() {
|
|
16536
|
+
var _a;
|
|
14728
16537
|
let stave = this.getStave();
|
|
14729
16538
|
if (!stave) {
|
|
14730
16539
|
stave = new _stave__WEBPACK_IMPORTED_MODULE_3__.Stave(0, 0, 100);
|
|
@@ -14732,7 +16541,7 @@ class KeySignature extends _stavemodifier__WEBPACK_IMPORTED_MODULE_4__.StaveModi
|
|
|
14732
16541
|
}
|
|
14733
16542
|
this.width = 0;
|
|
14734
16543
|
this.children = [];
|
|
14735
|
-
this.accList = _tables__WEBPACK_IMPORTED_MODULE_5__.Tables.keySignature((0,
|
|
16544
|
+
this.accList = _tables__WEBPACK_IMPORTED_MODULE_5__.Tables.keySignature((0,_util__WEBPACK_IMPORTED_MODULE_6__.defined)(this.keySpec));
|
|
14736
16545
|
const accList = this.accList;
|
|
14737
16546
|
const firstAccidentalType = accList.length > 0 ? accList[0].type : undefined;
|
|
14738
16547
|
let cancelAccList;
|
|
@@ -14743,7 +16552,7 @@ class KeySignature extends _stavemodifier__WEBPACK_IMPORTED_MODULE_4__.StaveModi
|
|
|
14743
16552
|
this.convertToAlterAccList(this.alterKeySpec);
|
|
14744
16553
|
}
|
|
14745
16554
|
if (this.accList.length > 0) {
|
|
14746
|
-
const clef = (this.position === _stavemodifier__WEBPACK_IMPORTED_MODULE_4__.StaveModifierPosition.END ? stave.getEndClef() : stave.getClef()) || stave.getClef();
|
|
16555
|
+
const clef = (_a = this.clefOverride) !== null && _a !== void 0 ? _a : ((this.position === _stavemodifier__WEBPACK_IMPORTED_MODULE_4__.StaveModifierPosition.END ? stave.getEndClef() : stave.getClef()) || stave.getClef());
|
|
14747
16556
|
if (cancelAccList) {
|
|
14748
16557
|
this.convertAccLines(clef, cancelAccList.type, cancelAccList.accList);
|
|
14749
16558
|
}
|
|
@@ -14788,19 +16597,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
14788
16597
|
/* harmony export */ });
|
|
14789
16598
|
/* harmony import */ var _keysignature__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keysignature */ "./src/keysignature.ts");
|
|
14790
16599
|
/* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./note */ "./src/note.ts");
|
|
14791
|
-
/* harmony import */ var _typeguard__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./typeguard */ "./src/typeguard.ts");
|
|
14792
16600
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
14793
16601
|
// @author: Mark Meeus 2019
|
|
14794
16602
|
|
|
14795
16603
|
|
|
14796
|
-
|
|
14797
16604
|
class KeySigNote extends _note__WEBPACK_IMPORTED_MODULE_1__.Note {
|
|
14798
16605
|
static get CATEGORY() {
|
|
14799
|
-
return
|
|
16606
|
+
return "KeySigNote" /* Category.KeySigNote */;
|
|
14800
16607
|
}
|
|
14801
|
-
constructor(keySpec, cancelKeySpec, alterKeySpec) {
|
|
16608
|
+
constructor(keySpec, cancelKeySpec, alterKeySpec, clef) {
|
|
14802
16609
|
super({ duration: 'b' });
|
|
14803
|
-
this.keySignature = new _keysignature__WEBPACK_IMPORTED_MODULE_0__.KeySignature(keySpec, cancelKeySpec, alterKeySpec);
|
|
16610
|
+
this.keySignature = new _keysignature__WEBPACK_IMPORTED_MODULE_0__.KeySignature(keySpec, cancelKeySpec, alterKeySpec).setClef(clef);
|
|
14804
16611
|
// Note properties
|
|
14805
16612
|
this.ignoreTicks = true;
|
|
14806
16613
|
}
|
|
@@ -16096,8 +17903,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
16096
17903
|
/* harmony import */ var _rendercontext__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./rendercontext */ "./src/rendercontext.ts");
|
|
16097
17904
|
/* harmony import */ var _tables__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tables */ "./src/tables.ts");
|
|
16098
17905
|
/* harmony import */ var _tickable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./tickable */ "./src/tickable.ts");
|
|
16099
|
-
/* harmony import */ var
|
|
16100
|
-
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
17906
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
16101
17907
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
16102
17908
|
// MIT License
|
|
16103
17909
|
// Base note layout and bounded duration parsing for score input.
|
|
@@ -16107,7 +17913,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
16107
17913
|
|
|
16108
17914
|
|
|
16109
17915
|
|
|
16110
|
-
|
|
16111
17916
|
/**
|
|
16112
17917
|
* Note implements an abstract interface for notes and chords that
|
|
16113
17918
|
* are rendered on a stave. Notes have some common properties: All of them
|
|
@@ -16121,7 +17926,7 @@ class Note extends _tickable__WEBPACK_IMPORTED_MODULE_4__.Tickable {
|
|
|
16121
17926
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
16122
17927
|
// STATIC MEMBERS
|
|
16123
17928
|
static get CATEGORY() {
|
|
16124
|
-
return
|
|
17929
|
+
return "Note" /* Category.Note */;
|
|
16125
17930
|
}
|
|
16126
17931
|
// Return a glyph given duration and type. The type can be a custom glyph code from customNoteHeads.
|
|
16127
17932
|
// The default type is a regular note ('n').
|
|
@@ -16256,12 +18061,12 @@ class Note extends _tickable__WEBPACK_IMPORTED_MODULE_4__.Tickable {
|
|
|
16256
18061
|
constructor(noteStruct) {
|
|
16257
18062
|
super();
|
|
16258
18063
|
if (!noteStruct) {
|
|
16259
|
-
throw new
|
|
18064
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArguments', 'Note must have valid initialization data to identify duration and type.');
|
|
16260
18065
|
}
|
|
16261
18066
|
/** Parses `noteStruct` and get note properties. */
|
|
16262
18067
|
const parsedNoteStruct = Note.parseNoteStruct(noteStruct);
|
|
16263
18068
|
if (!parsedNoteStruct) {
|
|
16264
|
-
throw new
|
|
18069
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArguments', `Invalid note initialization object: ${JSON.stringify(noteStruct)}`);
|
|
16265
18070
|
}
|
|
16266
18071
|
// Set note properties from parameters.
|
|
16267
18072
|
this.keys = noteStruct.keys || [];
|
|
@@ -16339,9 +18144,15 @@ class Note extends _tickable__WEBPACK_IMPORTED_MODULE_4__.Tickable {
|
|
|
16339
18144
|
getStave() {
|
|
16340
18145
|
return this.stave;
|
|
16341
18146
|
}
|
|
18147
|
+
/** Release a staged stave assignment when managed composition fails. */
|
|
18148
|
+
clearStave() {
|
|
18149
|
+
this.stave = undefined;
|
|
18150
|
+
this.preFormatted = false;
|
|
18151
|
+
return this;
|
|
18152
|
+
}
|
|
16342
18153
|
/** Check and get the target stave. */
|
|
16343
18154
|
checkStave() {
|
|
16344
|
-
return (0,
|
|
18155
|
+
return (0,_util__WEBPACK_IMPORTED_MODULE_5__.defined)(this.stave, 'NoStave', 'No stave attached to instance.');
|
|
16345
18156
|
}
|
|
16346
18157
|
/** Set the target stave. */
|
|
16347
18158
|
setStave(stave) {
|
|
@@ -16403,7 +18214,7 @@ class Note extends _tickable__WEBPACK_IMPORTED_MODULE_4__.Tickable {
|
|
|
16403
18214
|
*/
|
|
16404
18215
|
getYs() {
|
|
16405
18216
|
if (this.ys.length === 0) {
|
|
16406
|
-
throw new
|
|
18217
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('NoYValues', 'No Y-values calculated for this note.');
|
|
16407
18218
|
}
|
|
16408
18219
|
return this.ys;
|
|
16409
18220
|
}
|
|
@@ -16417,7 +18228,7 @@ class Note extends _tickable__WEBPACK_IMPORTED_MODULE_4__.Tickable {
|
|
|
16417
18228
|
/** Return the voice that this note belongs in. */
|
|
16418
18229
|
getVoice() {
|
|
16419
18230
|
if (!this.voice)
|
|
16420
|
-
throw new
|
|
18231
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('NoVoice', 'Note has no voice.');
|
|
16421
18232
|
return this.voice;
|
|
16422
18233
|
}
|
|
16423
18234
|
/** Attach this note to `voice`. */
|
|
@@ -16442,7 +18253,7 @@ class Note extends _tickable__WEBPACK_IMPORTED_MODULE_4__.Tickable {
|
|
|
16442
18253
|
}
|
|
16443
18254
|
/** Accessor to isDotted. */
|
|
16444
18255
|
isDotted() {
|
|
16445
|
-
return this.getModifiersByType(
|
|
18256
|
+
return this.getModifiersByType("Dot" /* Category.Dot */).length > 0;
|
|
16446
18257
|
}
|
|
16447
18258
|
/** Accessor to hasStem. */
|
|
16448
18259
|
hasStem() {
|
|
@@ -16458,7 +18269,7 @@ class Note extends _tickable__WEBPACK_IMPORTED_MODULE_4__.Tickable {
|
|
|
16458
18269
|
}
|
|
16459
18270
|
/** Check and get the beam. */
|
|
16460
18271
|
checkBeam() {
|
|
16461
|
-
return (0,
|
|
18272
|
+
return (0,_util__WEBPACK_IMPORTED_MODULE_5__.defined)(this.beam, 'NoBeam', 'No beam attached to instance');
|
|
16462
18273
|
}
|
|
16463
18274
|
/** Check it has a beam. */
|
|
16464
18275
|
hasBeam() {
|
|
@@ -16486,7 +18297,7 @@ class Note extends _tickable__WEBPACK_IMPORTED_MODULE_4__.Tickable {
|
|
|
16486
18297
|
// Some versions of VexFlow had the two parameters reversed.
|
|
16487
18298
|
// Check here and throw an error if the argument types are not correct.
|
|
16488
18299
|
if (typeof modifier !== 'object' || typeof index !== 'number') {
|
|
16489
|
-
throw new
|
|
18300
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('WrongParams', 'Incorrect call signature. Use ' + signature + ' instead.');
|
|
16490
18301
|
}
|
|
16491
18302
|
modifier.setNote(this);
|
|
16492
18303
|
modifier.setIndex(index);
|
|
@@ -16501,7 +18312,7 @@ class Note extends _tickable__WEBPACK_IMPORTED_MODULE_4__.Tickable {
|
|
|
16501
18312
|
// eslint-disable-next-line
|
|
16502
18313
|
getModifierStartXY(position, index, options) {
|
|
16503
18314
|
if (!this.preFormatted) {
|
|
16504
|
-
throw new
|
|
18315
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('UnformattedNote', "Can't call GetModifierStartXY on an unformatted note");
|
|
16505
18316
|
}
|
|
16506
18317
|
return {
|
|
16507
18318
|
x: this.getAbsoluteX(),
|
|
@@ -16528,7 +18339,7 @@ class Note extends _tickable__WEBPACK_IMPORTED_MODULE_4__.Tickable {
|
|
|
16528
18339
|
/** Get the metrics for this note. */
|
|
16529
18340
|
getMetrics() {
|
|
16530
18341
|
if (!this.preFormatted) {
|
|
16531
|
-
throw new
|
|
18342
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('UnformattedNote', "Can't call getMetrics on an unformatted note.");
|
|
16532
18343
|
}
|
|
16533
18344
|
const modLeftPx = this.modifierContext ? this.modifierContext.getState().leftShift : 0;
|
|
16534
18345
|
const modRightPx = this.modifierContext ? this.modifierContext.getState().rightShift : 0;
|
|
@@ -16572,11 +18383,11 @@ class Note extends _tickable__WEBPACK_IMPORTED_MODULE_4__.Tickable {
|
|
|
16572
18383
|
}
|
|
16573
18384
|
/** Get the direction of the stem. */
|
|
16574
18385
|
getStemDirection() {
|
|
16575
|
-
throw new
|
|
18386
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('NoStem', 'No stem attached to this note.');
|
|
16576
18387
|
}
|
|
16577
18388
|
/** Get the top and bottom `y` values of the stem. */
|
|
16578
18389
|
getStemExtents() {
|
|
16579
|
-
throw new
|
|
18390
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('NoStem', 'No stem attached to this note.');
|
|
16580
18391
|
}
|
|
16581
18392
|
/** Get the `x` coordinate to the right of the note. */
|
|
16582
18393
|
getTieRightX() {
|
|
@@ -17118,16 +18929,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
17118
18929
|
/* harmony export */ Parenthesis: () => (/* binding */ Parenthesis)
|
|
17119
18930
|
/* harmony export */ });
|
|
17120
18931
|
/* harmony import */ var _modifier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modifier */ "./src/modifier.ts");
|
|
17121
|
-
/* harmony import */ var _typeguard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./typeguard */ "./src/typeguard.ts");
|
|
17122
18932
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
17123
18933
|
// @author Rodrigo Vilar
|
|
17124
18934
|
// MIT License
|
|
17125
18935
|
|
|
17126
|
-
|
|
17127
18936
|
/** Parenthesis implements parenthesis modifiers for notes. */
|
|
17128
18937
|
class Parenthesis extends _modifier__WEBPACK_IMPORTED_MODULE_0__.Modifier {
|
|
17129
18938
|
static get CATEGORY() {
|
|
17130
|
-
return
|
|
18939
|
+
return "Parenthesis" /* Category.Parenthesis */;
|
|
17131
18940
|
}
|
|
17132
18941
|
/** Add parentheses to the notes. */
|
|
17133
18942
|
static buildAndAttach(notes) {
|
|
@@ -17182,7 +18991,8 @@ class Parenthesis extends _modifier__WEBPACK_IMPORTED_MODULE_0__.Modifier {
|
|
|
17182
18991
|
/** Set the associated note. */
|
|
17183
18992
|
setNote(note) {
|
|
17184
18993
|
this.note = note;
|
|
17185
|
-
|
|
18994
|
+
// Copy structured font data so attachment also works without a browser document.
|
|
18995
|
+
this.setFont(note.fontInfo);
|
|
17186
18996
|
return this;
|
|
17187
18997
|
}
|
|
17188
18998
|
/** Render the parenthesis. */
|
|
@@ -17244,6 +19054,7 @@ class Parser {
|
|
|
17244
19054
|
// For an example of a simple grammar, take a look at tests/parser_tests.ts or
|
|
17245
19055
|
// the EasyScore grammar in easyscore.ts.
|
|
17246
19056
|
constructor(grammar) {
|
|
19057
|
+
this.furthestErrorPos = NO_ERROR_POS;
|
|
17247
19058
|
this.grammar = grammar;
|
|
17248
19059
|
this.line = '';
|
|
17249
19060
|
this.pos = 0;
|
|
@@ -17256,8 +19067,10 @@ class Parser {
|
|
|
17256
19067
|
this.line = line;
|
|
17257
19068
|
this.pos = 0;
|
|
17258
19069
|
this.errorPos = NO_ERROR_POS;
|
|
19070
|
+
this.furthestErrorPos = NO_ERROR_POS;
|
|
17259
19071
|
const result = this.expect(this.grammar.begin());
|
|
17260
19072
|
result.errorPos = this.errorPos;
|
|
19073
|
+
result.furthestErrorPos = result.success ? NO_ERROR_POS : this.furthestErrorPos;
|
|
17261
19074
|
return result;
|
|
17262
19075
|
}
|
|
17263
19076
|
matchFail(returnPos) {
|
|
@@ -17283,6 +19096,7 @@ class Parser {
|
|
|
17283
19096
|
};
|
|
17284
19097
|
}
|
|
17285
19098
|
else {
|
|
19099
|
+
this.furthestErrorPos = Math.max(this.furthestErrorPos, this.pos);
|
|
17286
19100
|
return { success: false, pos: this.pos };
|
|
17287
19101
|
}
|
|
17288
19102
|
}
|
|
@@ -17371,6 +19185,7 @@ class Parser {
|
|
|
17371
19185
|
if (!ruleFunc) {
|
|
17372
19186
|
throw new _util__WEBPACK_IMPORTED_MODULE_0__.RuntimeError('Invalid rule function');
|
|
17373
19187
|
}
|
|
19188
|
+
const start = this.pos;
|
|
17374
19189
|
let result;
|
|
17375
19190
|
// Get rule from Grammar class.
|
|
17376
19191
|
// expect(...) handles both lexing & parsing:
|
|
@@ -17415,7 +19230,7 @@ class Parser {
|
|
|
17415
19230
|
result.results.forEach((r) => matches.push(flattenMatches(r)));
|
|
17416
19231
|
}
|
|
17417
19232
|
if (rule.run && result.success) {
|
|
17418
|
-
rule.run({ matches });
|
|
19233
|
+
rule.run({ matches, start, end: this.pos });
|
|
17419
19234
|
}
|
|
17420
19235
|
return result;
|
|
17421
19236
|
}
|
|
@@ -17705,6 +19520,223 @@ PedalMarking.typeString = {
|
|
|
17705
19520
|
};
|
|
17706
19521
|
|
|
17707
19522
|
|
|
19523
|
+
/***/ },
|
|
19524
|
+
|
|
19525
|
+
/***/ "./src/proportionalformatter.ts"
|
|
19526
|
+
/*!**************************************!*\
|
|
19527
|
+
!*** ./src/proportionalformatter.ts ***!
|
|
19528
|
+
\**************************************/
|
|
19529
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
19530
|
+
|
|
19531
|
+
__webpack_require__.r(__webpack_exports__);
|
|
19532
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
19533
|
+
/* harmony export */ ProportionalFormatter: () => (/* binding */ ProportionalFormatter)
|
|
19534
|
+
/* harmony export */ });
|
|
19535
|
+
/* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fraction */ "./src/fraction.ts");
|
|
19536
|
+
/* harmony import */ var _tickcontext__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tickcontext */ "./src/tickcontext.ts");
|
|
19537
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
19538
|
+
|
|
19539
|
+
|
|
19540
|
+
|
|
19541
|
+
/** Pixel allowance between measured boxes, including the two outer boundaries. */
|
|
19542
|
+
const PADDING = 2;
|
|
19543
|
+
/** Ignore floating-point noise when comparing computed pixel widths. */
|
|
19544
|
+
const EPSILON = 1e-7;
|
|
19545
|
+
/** Round required dimensions up so copying an error's suggestion is sufficient. */
|
|
19546
|
+
function required(value) {
|
|
19547
|
+
return (Math.ceil(value * 100) / 100).toFixed(2);
|
|
19548
|
+
}
|
|
19549
|
+
/** Build a common rational timeline without advancing time for clefs or barlines. */
|
|
19550
|
+
class ProportionalFormatter {
|
|
19551
|
+
constructor(voices, resolutionMultiplier) {
|
|
19552
|
+
var _a;
|
|
19553
|
+
var _b;
|
|
19554
|
+
this.origin = 0;
|
|
19555
|
+
this.tail = PADDING;
|
|
19556
|
+
this.minimumScale = 0;
|
|
19557
|
+
this.centeredWidth = 0;
|
|
19558
|
+
const resolution = voices[0].getActualResolution() / voices[0].getResolutionMultiplier();
|
|
19559
|
+
this.quarterTicks = resolution / 4;
|
|
19560
|
+
let durationTicks = voices[0].getTotalTicks().value();
|
|
19561
|
+
// Inspect every duration, not only the final voice total. Tuplet denominators can cancel.
|
|
19562
|
+
for (const voice of voices) {
|
|
19563
|
+
if (voice.getActualResolution() / voice.getResolutionMultiplier() !== resolution) {
|
|
19564
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_2__.RuntimeError('BadArgument', 'Proportional voices must use the same tick resolution.');
|
|
19565
|
+
}
|
|
19566
|
+
durationTicks = Math.max(durationTicks, voice.getTicksUsed().value());
|
|
19567
|
+
for (const note of voice.getTickables()) {
|
|
19568
|
+
if (note.shouldIgnoreTicks())
|
|
19569
|
+
continue;
|
|
19570
|
+
const ticks = note.getTicks();
|
|
19571
|
+
if (ticks.value() <= 0)
|
|
19572
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_2__.RuntimeError('BadArgument', 'Rhythmic durations must be positive.');
|
|
19573
|
+
resolutionMultiplier = _fraction__WEBPACK_IMPORTED_MODULE_0__.Fraction.LCM(resolutionMultiplier, ticks.denominator);
|
|
19574
|
+
}
|
|
19575
|
+
}
|
|
19576
|
+
if (!Number.isSafeInteger(resolutionMultiplier) || resolutionMultiplier <= 0) {
|
|
19577
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_2__.RuntimeError('BadArgument', 'Proportional timeline exceeds the supported rational tick range.');
|
|
19578
|
+
}
|
|
19579
|
+
this.duration = durationTicks / this.quarterTicks;
|
|
19580
|
+
const byTick = new Map();
|
|
19581
|
+
for (const [voiceIndex, voice] of voices.entries()) {
|
|
19582
|
+
const elapsed = new _fraction__WEBPACK_IMPORTED_MODULE_0__.Fraction(0, resolutionMultiplier);
|
|
19583
|
+
for (const note of voice.getTickables()) {
|
|
19584
|
+
const tick = elapsed.numerator;
|
|
19585
|
+
if (!Number.isSafeInteger(tick)) {
|
|
19586
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_2__.RuntimeError('BadArgument', 'Proportional timeline exceeds the supported rational tick range.');
|
|
19587
|
+
}
|
|
19588
|
+
let anchor = byTick.get(tick);
|
|
19589
|
+
if (!anchor) {
|
|
19590
|
+
anchor = { tick, context: new _tickcontext__WEBPACK_IMPORTED_MODULE_1__.TickContext({ tickID: tick }), prefixes: [], extents: new Map() };
|
|
19591
|
+
byTick.set(tick, anchor);
|
|
19592
|
+
}
|
|
19593
|
+
if (note.shouldIgnoreTicks()) {
|
|
19594
|
+
// Each voice retains its inline sequence. Different voices may share the same time.
|
|
19595
|
+
const prefix = ((_a = (_b = anchor.prefixes)[voiceIndex]) !== null && _a !== void 0 ? _a : (_b[voiceIndex] = { contexts: [] }));
|
|
19596
|
+
prefix.contexts.push(new _tickcontext__WEBPACK_IMPORTED_MODULE_1__.TickContext({ tickID: tick }).addTickable(note, voiceIndex));
|
|
19597
|
+
}
|
|
19598
|
+
else {
|
|
19599
|
+
anchor.context.addTickable(note, voiceIndex);
|
|
19600
|
+
elapsed.add(note.getTicks());
|
|
19601
|
+
}
|
|
19602
|
+
}
|
|
19603
|
+
}
|
|
19604
|
+
this.anchors = [...byTick.values()].sort((a, b) => a.tick - b.tick);
|
|
19605
|
+
const map = {};
|
|
19606
|
+
const array = [];
|
|
19607
|
+
for (const anchor of this.anchors) {
|
|
19608
|
+
map[anchor.tick] = anchor.context;
|
|
19609
|
+
anchor.prefixes.forEach((prefix) => array.push(...prefix.contexts));
|
|
19610
|
+
array.push(anchor.context);
|
|
19611
|
+
}
|
|
19612
|
+
array.forEach((context) => (context.tContexts = array));
|
|
19613
|
+
this.contexts = { map, array, list: this.anchors.map((anchor) => anchor.tick), resolutionMultiplier };
|
|
19614
|
+
}
|
|
19615
|
+
/** Convert an exact timeline key once, at the point where pixels are needed. */
|
|
19616
|
+
quarters(anchor) {
|
|
19617
|
+
return anchor.tick / this.contexts.resolutionMultiplier / this.quarterTicks;
|
|
19618
|
+
}
|
|
19619
|
+
/** Measure each stave independently so unrelated onsets on other staves do not compete. */
|
|
19620
|
+
measure() {
|
|
19621
|
+
var _a, _b, _c, _d;
|
|
19622
|
+
this.origin = PADDING;
|
|
19623
|
+
this.tail = PADDING;
|
|
19624
|
+
this.minimumScale = 0;
|
|
19625
|
+
this.centeredWidth = 0;
|
|
19626
|
+
for (const anchor of this.anchors) {
|
|
19627
|
+
anchor.extents.clear();
|
|
19628
|
+
anchor.context.preFormat();
|
|
19629
|
+
for (const note of anchor.context.getTickables()) {
|
|
19630
|
+
const metrics = note.getMetrics();
|
|
19631
|
+
const left = metrics.modLeftPx + metrics.leftDisplacedHeadPx;
|
|
19632
|
+
const right = metrics.notePx + metrics.modRightPx + metrics.rightDisplacedHeadPx;
|
|
19633
|
+
if (note.isCenterAligned()) {
|
|
19634
|
+
this.centeredWidth = Math.max(this.centeredWidth, 2 * Math.max(left, right));
|
|
19635
|
+
continue;
|
|
19636
|
+
}
|
|
19637
|
+
const extent = (_a = anchor.extents.get(note.getStave())) !== null && _a !== void 0 ? _a : { left: 0, right: 0 };
|
|
19638
|
+
extent.left = Math.max(extent.left, left);
|
|
19639
|
+
extent.right = Math.max(extent.right, right);
|
|
19640
|
+
anchor.extents.set(note.getStave(), extent);
|
|
19641
|
+
}
|
|
19642
|
+
// Prefix widths are measured before placement. Keep the largest sequence on each stave.
|
|
19643
|
+
const prefixWidths = new Map();
|
|
19644
|
+
anchor.prefixes.forEach((prefix) => {
|
|
19645
|
+
var _a;
|
|
19646
|
+
let width = 0;
|
|
19647
|
+
for (const context of prefix.contexts)
|
|
19648
|
+
width += context.preFormat().getWidth();
|
|
19649
|
+
const stave = prefix.contexts[0].getTickables()[0].getStave();
|
|
19650
|
+
prefixWidths.set(stave, Math.max((_a = prefixWidths.get(stave)) !== null && _a !== void 0 ? _a : 0, width));
|
|
19651
|
+
});
|
|
19652
|
+
for (const [stave, width] of prefixWidths) {
|
|
19653
|
+
const extent = (_b = anchor.extents.get(stave)) !== null && _b !== void 0 ? _b : { left: 0, right: 0 };
|
|
19654
|
+
extent.left += width;
|
|
19655
|
+
anchor.extents.set(stave, extent);
|
|
19656
|
+
}
|
|
19657
|
+
for (const extent of anchor.extents.values()) {
|
|
19658
|
+
if (this.quarters(anchor) === 0)
|
|
19659
|
+
this.origin = Math.max(this.origin, extent.left + PADDING);
|
|
19660
|
+
if (this.quarters(anchor) === this.duration)
|
|
19661
|
+
this.tail = Math.max(this.tail, extent.right + PADDING);
|
|
19662
|
+
}
|
|
19663
|
+
}
|
|
19664
|
+
// All pairs also cover a wide earlier object extending past an intervening narrow one.
|
|
19665
|
+
const previous = new Map();
|
|
19666
|
+
for (const anchor of this.anchors) {
|
|
19667
|
+
const time = this.quarters(anchor);
|
|
19668
|
+
for (const [stave, extent] of anchor.extents) {
|
|
19669
|
+
for (const before of (_c = previous.get(stave)) !== null && _c !== void 0 ? _c : []) {
|
|
19670
|
+
this.minimumScale = Math.max(this.minimumScale, (before.extent.right + extent.left + PADDING) / (time - before.time));
|
|
19671
|
+
}
|
|
19672
|
+
if (time > 0)
|
|
19673
|
+
this.minimumScale = Math.max(this.minimumScale, (extent.left + PADDING - this.origin) / time);
|
|
19674
|
+
if (time < this.duration) {
|
|
19675
|
+
this.minimumScale = Math.max(this.minimumScale, (extent.right + PADDING - this.tail) / (this.duration - time));
|
|
19676
|
+
}
|
|
19677
|
+
const list = (_d = previous.get(stave)) !== null && _d !== void 0 ? _d : [];
|
|
19678
|
+
list.push({ time, extent });
|
|
19679
|
+
previous.set(stave, list);
|
|
19680
|
+
}
|
|
19681
|
+
}
|
|
19682
|
+
this.minimumScale = Math.max(this.minimumScale, this.centeredWidth / this.duration);
|
|
19683
|
+
}
|
|
19684
|
+
/** Compute one scale and validate it before changing any anchor positions. */
|
|
19685
|
+
dimensions(spacing, width) {
|
|
19686
|
+
if (!Number.isFinite(width) || width < 0)
|
|
19687
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_2__.RuntimeError('BadArgument', 'Width must be finite and nonnegative.');
|
|
19688
|
+
const requested = spacing.pixelsPerQuarter;
|
|
19689
|
+
if (requested !== undefined && (!Number.isFinite(requested) || requested <= 0)) {
|
|
19690
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_2__.RuntimeError('BadArgument', 'pixelsPerQuarter must be positive and finite.');
|
|
19691
|
+
}
|
|
19692
|
+
this.measure();
|
|
19693
|
+
const minimumWidth = this.origin + this.duration * this.minimumScale + this.tail;
|
|
19694
|
+
const scale = requested !== null && requested !== void 0 ? requested : (width > 0 ? (width - this.origin - this.tail) / this.duration : this.minimumScale);
|
|
19695
|
+
const neededWidth = this.origin + this.duration * scale + this.tail;
|
|
19696
|
+
if (!Number.isFinite(neededWidth) || !Number.isFinite(this.minimumScale)) {
|
|
19697
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_2__.RuntimeError('BadArgument', 'Proportional dimensions exceed the supported pixel range.');
|
|
19698
|
+
}
|
|
19699
|
+
if (scale + EPSILON < this.minimumScale || (width > 0 && width + EPSILON < neededWidth)) {
|
|
19700
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_2__.RuntimeError('InsufficientProportionalSpace', `Proportional spacing requires at least ${required(this.minimumScale)} px/quarter and ` +
|
|
19701
|
+
`${required(Math.max(minimumWidth, neededWidth))} px width; received ${scale.toFixed(2)} px/quarter` +
|
|
19702
|
+
(width > 0 ? ` and ${width.toFixed(2)} px width.` : '.'));
|
|
19703
|
+
}
|
|
19704
|
+
return { scale, width: neededWidth };
|
|
19705
|
+
}
|
|
19706
|
+
/** Minimum total width for autoWidth, honoring a supplied exact scale. */
|
|
19707
|
+
minimumWidth(spacing) {
|
|
19708
|
+
return this.dimensions(spacing, 0).width;
|
|
19709
|
+
}
|
|
19710
|
+
/** Place anchors and prefixes, retaining the established centering exception for measure rests. */
|
|
19711
|
+
format(spacing, width) {
|
|
19712
|
+
const dimensions = this.dimensions(spacing, width);
|
|
19713
|
+
for (const anchor of this.anchors) {
|
|
19714
|
+
const x = this.origin + this.quarters(anchor) * dimensions.scale;
|
|
19715
|
+
anchor.context.setX(x);
|
|
19716
|
+
anchor.context.getCenterAlignedTickables().forEach((note) => {
|
|
19717
|
+
note.setCenterXShift(this.origin + (this.duration * dimensions.scale) / 2 - x);
|
|
19718
|
+
});
|
|
19719
|
+
anchor.prefixes.forEach((prefix) => {
|
|
19720
|
+
// Right-align each sequence just before the rhythmic note's left modifiers.
|
|
19721
|
+
const stave = prefix.contexts[0].getTickables()[0].getStave();
|
|
19722
|
+
const notes = anchor.context.getTickables().filter((note) => note.getStave() === stave);
|
|
19723
|
+
let right = x -
|
|
19724
|
+
Math.max(0, ...notes.map((note) => {
|
|
19725
|
+
const metrics = note.getMetrics();
|
|
19726
|
+
return metrics.modLeftPx + metrics.leftDisplacedHeadPx;
|
|
19727
|
+
}));
|
|
19728
|
+
for (const context of [...prefix.contexts].reverse()) {
|
|
19729
|
+
const metrics = context.getMetrics();
|
|
19730
|
+
context.setX(right - PADDING / 2 - metrics.notePx - metrics.totalRightPx);
|
|
19731
|
+
right -= context.getWidth();
|
|
19732
|
+
}
|
|
19733
|
+
});
|
|
19734
|
+
}
|
|
19735
|
+
return dimensions.width;
|
|
19736
|
+
}
|
|
19737
|
+
}
|
|
19738
|
+
|
|
19739
|
+
|
|
17708
19740
|
/***/ },
|
|
17709
19741
|
|
|
17710
19742
|
/***/ "./src/registry.ts"
|
|
@@ -17764,7 +19796,35 @@ class Registry {
|
|
|
17764
19796
|
static disableDefaultRegistry() {
|
|
17765
19797
|
Registry.defaultRegistry = undefined;
|
|
17766
19798
|
}
|
|
19799
|
+
/** Restore indexes and detach new elements if construction fails. External mutations are not undone. */
|
|
19800
|
+
transaction(build) {
|
|
19801
|
+
const before = new Index();
|
|
19802
|
+
for (const name of Object.keys(this.index)) {
|
|
19803
|
+
for (const [value, elements] of Object.entries(this.index[name])) {
|
|
19804
|
+
before[name][value] = Object.assign(Object.create(null), elements);
|
|
19805
|
+
}
|
|
19806
|
+
}
|
|
19807
|
+
const existing = new Set(Object.values(before.id).flatMap((elements) => Object.values(elements)));
|
|
19808
|
+
const created = new Set();
|
|
19809
|
+
this.transactions.push(created);
|
|
19810
|
+
try {
|
|
19811
|
+
return build();
|
|
19812
|
+
}
|
|
19813
|
+
catch (error) {
|
|
19814
|
+
created.forEach((element) => {
|
|
19815
|
+
if (!existing.has(element))
|
|
19816
|
+
element.onRegister(undefined);
|
|
19817
|
+
});
|
|
19818
|
+
this.index = before;
|
|
19819
|
+
throw error;
|
|
19820
|
+
}
|
|
19821
|
+
finally {
|
|
19822
|
+
this.transactions.pop();
|
|
19823
|
+
}
|
|
19824
|
+
}
|
|
17767
19825
|
constructor() {
|
|
19826
|
+
/** Registrations made during nested synchronous construction scopes. */
|
|
19827
|
+
this.transactions = [];
|
|
17768
19828
|
this.index = new Index();
|
|
17769
19829
|
}
|
|
17770
19830
|
clear() {
|
|
@@ -17808,6 +19868,7 @@ class Registry {
|
|
|
17808
19868
|
if (!id) {
|
|
17809
19869
|
throw new _util__WEBPACK_IMPORTED_MODULE_0__.RuntimeError("Can't add element without `id` attribute to registry");
|
|
17810
19870
|
}
|
|
19871
|
+
this.transactions.forEach((transaction) => transaction.add(elem));
|
|
17811
19872
|
// Manually add id to index, then update other indexes.
|
|
17812
19873
|
elem.setAttribute('id', id);
|
|
17813
19874
|
this.setIndexValue('id', id, id, elem);
|
|
@@ -18107,7 +20168,16 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
18107
20168
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
18108
20169
|
/* harmony export */ Sheet: () => (/* binding */ Sheet)
|
|
18109
20170
|
/* harmony export */ });
|
|
18110
|
-
/* harmony import */ var
|
|
20171
|
+
/* harmony import */ var _clefnote__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./clefnote */ "./src/clefnote.ts");
|
|
20172
|
+
/* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./note */ "./src/note.ts");
|
|
20173
|
+
/* harmony import */ var _stavenote__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stavenote */ "./src/stavenote.ts");
|
|
20174
|
+
/* harmony import */ var _stemmablenote__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stemmablenote */ "./src/stemmablenote.ts");
|
|
20175
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
20176
|
+
// Optional continuous-sheet layout for existing Systems. No music data model or pagination.
|
|
20177
|
+
|
|
20178
|
+
|
|
20179
|
+
|
|
20180
|
+
|
|
18111
20181
|
|
|
18112
20182
|
/** Arrange measure-sized Systems left to right, wrapping at a requested width. */
|
|
18113
20183
|
class Sheet {
|
|
@@ -18118,7 +20188,7 @@ class Sheet {
|
|
|
18118
20188
|
this.setWidth(this.options.width);
|
|
18119
20189
|
for (const key of ['x', 'y', 'rowGap', 'measureGap', 'measurePadding']) {
|
|
18120
20190
|
if (!Number.isFinite(this.options[key]) || this.options[key] < 0) {
|
|
18121
|
-
throw new
|
|
20191
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_4__.RuntimeError('BadArgument', `Sheet ${key} must be a nonnegative finite number.`);
|
|
18122
20192
|
}
|
|
18123
20193
|
}
|
|
18124
20194
|
}
|
|
@@ -18131,7 +20201,7 @@ class Sheet {
|
|
|
18131
20201
|
/** Update the available row width. Call format() or Factory.draw() to reflow. */
|
|
18132
20202
|
setWidth(width) {
|
|
18133
20203
|
if (!Number.isFinite(width) || width <= 0) {
|
|
18134
|
-
throw new
|
|
20204
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_4__.RuntimeError('BadArgument', 'Sheet width must be a positive finite number.');
|
|
18135
20205
|
}
|
|
18136
20206
|
this.options.width = width;
|
|
18137
20207
|
return this;
|
|
@@ -18195,9 +20265,25 @@ class Sheet {
|
|
|
18195
20265
|
// Spanning marks and arbitrary annotations still need caller-supplied rowGap.
|
|
18196
20266
|
for (const voice of system.getVoices()) {
|
|
18197
20267
|
for (const note of voice.getTickables()) {
|
|
18198
|
-
|
|
18199
|
-
|
|
18200
|
-
|
|
20268
|
+
// Modifier and generic text bounds may still contain coordinates from the last draw.
|
|
20269
|
+
// Measure pitched heads/stems and inline clefs from current layout only. Other notes use
|
|
20270
|
+
// their stave-relative Y positions; arbitrary labels and spans still need explicit rowGap.
|
|
20271
|
+
if (note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_2__.StaveNote || note instanceof _clefnote__WEBPACK_IMPORTED_MODULE_0__.ClefNote) {
|
|
20272
|
+
const box = note instanceof _stavenote__WEBPACK_IMPORTED_MODULE_2__.StaveNote ? note.getBoundingBox(false) : note.getBoundingBox();
|
|
20273
|
+
top = Math.min(top, box.getY());
|
|
20274
|
+
bottom = Math.max(bottom, box.getY() + box.getH());
|
|
20275
|
+
}
|
|
20276
|
+
else if (note instanceof _note__WEBPACK_IMPORTED_MODULE_1__.Note) {
|
|
20277
|
+
const padding = note.checkStave().getSpacingBetweenLines();
|
|
20278
|
+
const ys = note.getYs();
|
|
20279
|
+
top = Math.min(top, ...ys.map((y) => y - padding));
|
|
20280
|
+
bottom = Math.max(bottom, ...ys.map((y) => y + padding));
|
|
20281
|
+
if (note instanceof _stemmablenote__WEBPACK_IMPORTED_MODULE_3__.StemmableNote && note.hasStem()) {
|
|
20282
|
+
const { topY, baseY } = note.getStemExtents();
|
|
20283
|
+
top = Math.min(top, topY, baseY);
|
|
20284
|
+
bottom = Math.max(bottom, topY, baseY);
|
|
20285
|
+
}
|
|
20286
|
+
}
|
|
18201
20287
|
}
|
|
18202
20288
|
}
|
|
18203
20289
|
return { top, bottom };
|
|
@@ -18303,7 +20389,7 @@ const SORT_ORDER_END_MODIFIERS = {
|
|
|
18303
20389
|
};
|
|
18304
20390
|
class Stave extends _element__WEBPACK_IMPORTED_MODULE_2__.Element {
|
|
18305
20391
|
static get CATEGORY() {
|
|
18306
|
-
return
|
|
20392
|
+
return "Stave" /* Category.Stave */;
|
|
18307
20393
|
}
|
|
18308
20394
|
// This is the sum of the padding that normally goes on left + right of a stave during
|
|
18309
20395
|
// drawing. Used to size staves correctly with content width.
|
|
@@ -18315,6 +20401,7 @@ class Stave extends _element__WEBPACK_IMPORTED_MODULE_2__.Element {
|
|
|
18315
20401
|
return _metrics__WEBPACK_IMPORTED_MODULE_4__.Metrics.get('Stave.endPaddingMax');
|
|
18316
20402
|
}
|
|
18317
20403
|
constructor(x, y, width, options) {
|
|
20404
|
+
var _a;
|
|
18318
20405
|
super();
|
|
18319
20406
|
this.x = x;
|
|
18320
20407
|
this.y = y;
|
|
@@ -18324,9 +20411,9 @@ class Stave extends _element__WEBPACK_IMPORTED_MODULE_2__.Element {
|
|
|
18324
20411
|
this.endX = x + width;
|
|
18325
20412
|
this.modifiers = []; // stave modifiers (clef, key, time, barlines, coda, segno, etc.)
|
|
18326
20413
|
this.measure = 0;
|
|
18327
|
-
this.clef = 'treble';
|
|
20414
|
+
this.clef = (_a = options === null || options === void 0 ? void 0 : options.clef) !== null && _a !== void 0 ? _a : 'treble';
|
|
18328
20415
|
this.endClef = undefined;
|
|
18329
|
-
this.options = Object.assign({ verticalBarWidth: 10, numLines: 5, leftBar: true, rightBar: true, spacingBetweenLinesPx: _tables__WEBPACK_IMPORTED_MODULE_12__.Tables.STAVE_LINE_DISTANCE, spaceAboveStaffLn: 4, spaceBelowStaffLn: 4, topTextPosition: 1, bottomTextPosition: 4, lineConfig: [] }, options);
|
|
20416
|
+
this.options = Object.assign({ clef: 'treble', verticalBarWidth: 10, numLines: 5, leftBar: true, rightBar: true, spacingBetweenLinesPx: _tables__WEBPACK_IMPORTED_MODULE_12__.Tables.STAVE_LINE_DISTANCE, spaceAboveStaffLn: 4, spaceBelowStaffLn: 4, topTextPosition: 1, bottomTextPosition: 4, lineConfig: [] }, options);
|
|
18330
20417
|
this.bounds = { x: this.x, y: this.y, w: this.width, h: 0 };
|
|
18331
20418
|
this.defaultLedgerLineStyle = { lineWidth: 2 };
|
|
18332
20419
|
this.resetLines();
|
|
@@ -18535,6 +20622,12 @@ class Stave extends _element__WEBPACK_IMPORTED_MODULE_2__.Element {
|
|
|
18535
20622
|
if (position !== undefined) {
|
|
18536
20623
|
modifier.setPosition(position);
|
|
18537
20624
|
}
|
|
20625
|
+
if (modifier instanceof _clef__WEBPACK_IMPORTED_MODULE_1__.Clef) {
|
|
20626
|
+
if (modifier.getPosition() === _stavemodifier__WEBPACK_IMPORTED_MODULE_6__.StaveModifierPosition.BEGIN)
|
|
20627
|
+
this.clef = modifier.getType();
|
|
20628
|
+
else if (modifier.getPosition() === _stavemodifier__WEBPACK_IMPORTED_MODULE_6__.StaveModifierPosition.END)
|
|
20629
|
+
this.endClef = modifier.getType();
|
|
20630
|
+
}
|
|
18538
20631
|
modifier.setStave(this);
|
|
18539
20632
|
this.formatted = false;
|
|
18540
20633
|
this.modifiers.push(modifier);
|
|
@@ -18944,11 +21037,11 @@ class Stave extends _element__WEBPACK_IMPORTED_MODULE_2__.Element {
|
|
|
18944
21037
|
stave.format();
|
|
18945
21038
|
});
|
|
18946
21039
|
// Align Clefs
|
|
18947
|
-
adjustCategoryStartX(
|
|
21040
|
+
adjustCategoryStartX("Clef" /* Category.Clef */);
|
|
18948
21041
|
// Align key signatures
|
|
18949
|
-
adjustCategoryStartX(
|
|
21042
|
+
adjustCategoryStartX("KeySignature" /* Category.KeySignature */);
|
|
18950
21043
|
// Align time signatures
|
|
18951
|
-
adjustCategoryStartX(
|
|
21044
|
+
adjustCategoryStartX("TimeSignature" /* Category.TimeSignature */);
|
|
18952
21045
|
let maxX = 0;
|
|
18953
21046
|
// align note start
|
|
18954
21047
|
staves.forEach((stave) => {
|
|
@@ -18961,7 +21054,7 @@ class Stave extends _element__WEBPACK_IMPORTED_MODULE_2__.Element {
|
|
|
18961
21054
|
maxX = 0;
|
|
18962
21055
|
// align REPEAT_BEGIN
|
|
18963
21056
|
staves.forEach((stave) => {
|
|
18964
|
-
const modifiers = stave.getModifiers(_stavemodifier__WEBPACK_IMPORTED_MODULE_6__.StaveModifierPosition.BEGIN,
|
|
21057
|
+
const modifiers = stave.getModifiers(_stavemodifier__WEBPACK_IMPORTED_MODULE_6__.StaveModifierPosition.BEGIN, "Barline" /* Category.Barline */);
|
|
18965
21058
|
modifiers.forEach((modifier) => {
|
|
18966
21059
|
if (modifier.getType() === _stavebarline__WEBPACK_IMPORTED_MODULE_5__.BarlineType.REPEAT_BEGIN)
|
|
18967
21060
|
if (modifier.getX() > maxX)
|
|
@@ -18969,7 +21062,7 @@ class Stave extends _element__WEBPACK_IMPORTED_MODULE_2__.Element {
|
|
|
18969
21062
|
});
|
|
18970
21063
|
});
|
|
18971
21064
|
staves.forEach((stave) => {
|
|
18972
|
-
const modifiers = stave.getModifiers(_stavemodifier__WEBPACK_IMPORTED_MODULE_6__.StaveModifierPosition.BEGIN,
|
|
21065
|
+
const modifiers = stave.getModifiers(_stavemodifier__WEBPACK_IMPORTED_MODULE_6__.StaveModifierPosition.BEGIN, "Barline" /* Category.Barline */);
|
|
18973
21066
|
modifiers.forEach((modifier) => {
|
|
18974
21067
|
if (modifier.getType() === _stavebarline__WEBPACK_IMPORTED_MODULE_5__.BarlineType.REPEAT_BEGIN)
|
|
18975
21068
|
modifier.setX(maxX);
|
|
@@ -20037,8 +22130,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
20037
22130
|
/* harmony import */ var _stem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stem */ "./src/stem.ts");
|
|
20038
22131
|
/* harmony import */ var _stemmablenote__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stemmablenote */ "./src/stemmablenote.ts");
|
|
20039
22132
|
/* harmony import */ var _tables__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./tables */ "./src/tables.ts");
|
|
20040
|
-
/* harmony import */ var
|
|
20041
|
-
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
22133
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
20042
22134
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
20043
22135
|
// Staff note geometry, owned noteheads, stems, and modifiers.
|
|
20044
22136
|
//
|
|
@@ -20059,12 +22151,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
20059
22151
|
|
|
20060
22152
|
|
|
20061
22153
|
|
|
20062
|
-
|
|
20063
22154
|
// To enable logging for this class. Set `VexFlow.StaveNote.DEBUG` to `true`.
|
|
20064
22155
|
// eslint-disable-next-line
|
|
20065
22156
|
function L(...args) {
|
|
20066
22157
|
if (StaveNote.DEBUG)
|
|
20067
|
-
(0,
|
|
22158
|
+
(0,_util__WEBPACK_IMPORTED_MODULE_9__.log)('VexFlow.StaveNote', args);
|
|
20068
22159
|
}
|
|
20069
22160
|
const isInnerNoteIndex = (note, index) => index === (note.getStemDirection() === _stem__WEBPACK_IMPORTED_MODULE_6__.Stem.UP ? note.keyProps.length - 1 : 0);
|
|
20070
22161
|
// Helper methods for rest positioning in ModifierContext.
|
|
@@ -20081,7 +22172,7 @@ function shiftRestVertical(rest, note, dir) {
|
|
|
20081
22172
|
}
|
|
20082
22173
|
// Called from formatNotes :: center a rest between two notes
|
|
20083
22174
|
function centerRest(rest, noteU, noteL) {
|
|
20084
|
-
const delta = rest.line - (0,
|
|
22175
|
+
const delta = rest.line - (0,_util__WEBPACK_IMPORTED_MODULE_9__.midLine)(noteU.minLine, noteL.maxLine);
|
|
20085
22176
|
rest.note.setKeyLine(0, rest.note.getKeyLine(0) - delta);
|
|
20086
22177
|
rest.line -= delta;
|
|
20087
22178
|
rest.maxLine -= delta;
|
|
@@ -20089,7 +22180,7 @@ function centerRest(rest, noteU, noteL) {
|
|
|
20089
22180
|
}
|
|
20090
22181
|
class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNote {
|
|
20091
22182
|
static get CATEGORY() {
|
|
20092
|
-
return
|
|
22183
|
+
return "StaveNote" /* Category.StaveNote */;
|
|
20093
22184
|
}
|
|
20094
22185
|
static get LEDGER_LINE_OFFSET() {
|
|
20095
22186
|
return 3;
|
|
@@ -20212,9 +22303,9 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20212
22303
|
// If we have different noteheads, shift
|
|
20213
22304
|
noteUHead !== noteLHead ||
|
|
20214
22305
|
// If we have different dot values, shift
|
|
20215
|
-
noteU.note.getModifiers().filter((item) => item.getCategory() ===
|
|
22306
|
+
noteU.note.getModifiers().filter((item) => item.getCategory() === "Dot" /* Category.Dot */ && item.getIndex() === 0)
|
|
20216
22307
|
.length !==
|
|
20217
|
-
noteL.note.getModifiers().filter((item) => item.getCategory() ===
|
|
22308
|
+
noteL.note.getModifiers().filter((item) => item.getCategory() === "Dot" /* Category.Dot */ && item.getIndex() === 0)
|
|
20218
22309
|
.length ||
|
|
20219
22310
|
// If the notes are quite close but not on the same line, shift
|
|
20220
22311
|
(lineDiff < 1 && lineDiff > 0) ||
|
|
@@ -20241,7 +22332,7 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20241
22332
|
//same line, swap stem direction for one note
|
|
20242
22333
|
if (noteL.stemDirection === 1) {
|
|
20243
22334
|
noteL.stemDirection = -1;
|
|
20244
|
-
noteL.note.setStemDirection(-1);
|
|
22335
|
+
noteL.note.setStemDirection(-1, noteL.note.isAutoStem());
|
|
20245
22336
|
}
|
|
20246
22337
|
}
|
|
20247
22338
|
}
|
|
@@ -20260,11 +22351,11 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20260
22351
|
}
|
|
20261
22352
|
else if (noteU.note.hasStem()) {
|
|
20262
22353
|
noteU.stemDirection = -noteU.note.getStemDirection();
|
|
20263
|
-
noteU.note.setStemDirection(noteU.stemDirection);
|
|
22354
|
+
noteU.note.setStemDirection(noteU.stemDirection, noteU.note.isAutoStem());
|
|
20264
22355
|
}
|
|
20265
22356
|
else if (noteL.note.hasStem()) {
|
|
20266
22357
|
noteL.stemDirection = -noteL.note.getStemDirection();
|
|
20267
|
-
noteL.note.setStemDirection(noteL.stemDirection);
|
|
22358
|
+
noteL.note.setStemDirection(noteL.stemDirection, noteL.note.isAutoStem());
|
|
20268
22359
|
}
|
|
20269
22360
|
}
|
|
20270
22361
|
}
|
|
@@ -20273,7 +22364,7 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20273
22364
|
return true;
|
|
20274
22365
|
}
|
|
20275
22366
|
if (!noteM)
|
|
20276
|
-
throw new
|
|
22367
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_9__.RuntimeError('InvalidState', 'noteM not defined.');
|
|
20277
22368
|
// For three voices, test if rests can be repositioned
|
|
20278
22369
|
//
|
|
20279
22370
|
// Special case 1 :: middle voice rest between two notes
|
|
@@ -20291,11 +22382,11 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20291
22382
|
noteM.note.setXShift(xShift);
|
|
20292
22383
|
if (noteL.note.hasBeam() === false) {
|
|
20293
22384
|
noteL.stemDirection = -1;
|
|
20294
|
-
noteL.note.setStemDirection(-1);
|
|
22385
|
+
noteL.note.setStemDirection(-1, noteL.note.isAutoStem());
|
|
20295
22386
|
}
|
|
20296
22387
|
if (noteU.minLine <= noteL.maxLine && noteU.note.hasBeam() === false) {
|
|
20297
22388
|
noteU.stemDirection = 1;
|
|
20298
|
-
noteU.note.setStemDirection(1);
|
|
22389
|
+
noteU.note.setStemDirection(1, noteU.note.isAutoStem());
|
|
20299
22390
|
}
|
|
20300
22391
|
}
|
|
20301
22392
|
// format complete
|
|
@@ -20337,11 +22428,11 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20337
22428
|
noteM.note.setXShift(xShift);
|
|
20338
22429
|
if (noteL.note.hasBeam() === false) {
|
|
20339
22430
|
noteL.stemDirection = -1;
|
|
20340
|
-
noteL.note.setStemDirection(-1);
|
|
22431
|
+
noteL.note.setStemDirection(-1, noteL.note.isAutoStem());
|
|
20341
22432
|
}
|
|
20342
22433
|
if (noteU.minLine <= noteL.maxLine && noteU.note.hasBeam() === false) {
|
|
20343
22434
|
noteU.stemDirection = 1;
|
|
20344
|
-
noteU.note.setStemDirection(1);
|
|
22435
|
+
noteU.note.setStemDirection(1, noteU.note.isAutoStem());
|
|
20345
22436
|
}
|
|
20346
22437
|
}
|
|
20347
22438
|
state.rightShift += xShift;
|
|
@@ -20367,7 +22458,7 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20367
22458
|
this.octaveShift = (_b = noteStruct.octaveShift) !== null && _b !== void 0 ? _b : 0;
|
|
20368
22459
|
// Pull note rendering properties.
|
|
20369
22460
|
this.glyphProps = _note__WEBPACK_IMPORTED_MODULE_4__.Note.getGlyphProps(this.duration, this.noteType);
|
|
20370
|
-
(0,
|
|
22461
|
+
(0,_util__WEBPACK_IMPORTED_MODULE_9__.defined)(this.glyphProps, 'BadArguments', `No glyph found for duration '${this.duration}' and type '${this.noteType}'`);
|
|
20371
22462
|
// if true, displace note to right
|
|
20372
22463
|
this.displaced = false;
|
|
20373
22464
|
this.dotShiftY = 0;
|
|
@@ -20482,7 +22573,7 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20482
22573
|
}
|
|
20483
22574
|
// Automatically sets the stem direction based on the keys in the note
|
|
20484
22575
|
autoStem() {
|
|
20485
|
-
this.setStemDirection(this.calculateOptimalStemDirection());
|
|
22576
|
+
this.setStemDirection(this.calculateOptimalStemDirection(), true);
|
|
20486
22577
|
}
|
|
20487
22578
|
calculateOptimalStemDirection() {
|
|
20488
22579
|
// Figure out optimal stem direction based on given notes
|
|
@@ -20503,7 +22594,7 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20503
22594
|
const options = { octaveShift: (_a = this.octaveShift) !== null && _a !== void 0 ? _a : 0, duration: this.duration };
|
|
20504
22595
|
const props = _tables__WEBPACK_IMPORTED_MODULE_8__.Tables.keyProperties(key, this.clef, this.noteType, options);
|
|
20505
22596
|
if (!props) {
|
|
20506
|
-
throw new
|
|
22597
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_9__.RuntimeError('BadArguments', `Invalid key for note properties: ${key}`);
|
|
20507
22598
|
}
|
|
20508
22599
|
// Override line placement for default rests
|
|
20509
22600
|
if (props.key === 'R') {
|
|
@@ -20542,7 +22633,7 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20542
22633
|
this.sortedKeyProps.sort((a, b) => a.keyProps.line - b.keyProps.line);
|
|
20543
22634
|
}
|
|
20544
22635
|
// Measure noteheads and flags from layout coordinates, including before draw().
|
|
20545
|
-
getBoundingBox() {
|
|
22636
|
+
getBoundingBox(includeModifiers = true) {
|
|
20546
22637
|
const boundingBox = new _boundingbox__WEBPACK_IMPORTED_MODULE_0__.BoundingBox(this.getAbsoluteX(), this.ys[0], 0, 0);
|
|
20547
22638
|
this._noteHeads.forEach((notehead) => {
|
|
20548
22639
|
const displacement = notehead.isDisplaced()
|
|
@@ -20567,16 +22658,16 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20567
22658
|
bbFlag.setY(y + this.flag.getYShift() - this.flag.getTextMetrics().actualBoundingBoxAscent);
|
|
20568
22659
|
boundingBox.mergeWith(bbFlag);
|
|
20569
22660
|
}
|
|
20570
|
-
|
|
20571
|
-
|
|
20572
|
-
|
|
22661
|
+
if (includeModifiers)
|
|
22662
|
+
for (const modifier of this.modifiers)
|
|
22663
|
+
boundingBox.mergeWith(modifier.getBoundingBox());
|
|
20573
22664
|
return boundingBox;
|
|
20574
22665
|
}
|
|
20575
22666
|
// Gets the line number of the bottom note in the chord.
|
|
20576
22667
|
// If `isTopNote` is `true` then get the top note's line number instead
|
|
20577
22668
|
getLineNumber(isTopNote) {
|
|
20578
22669
|
if (!this.keyProps.length) {
|
|
20579
|
-
throw new
|
|
22670
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_9__.RuntimeError('NoKeyProps', "Can't get bottom note line, because note is not initialized properly.");
|
|
20580
22671
|
}
|
|
20581
22672
|
let resultLine = this.keyProps[0].line;
|
|
20582
22673
|
// No precondition assumed for sortedness of keyProps array
|
|
@@ -20676,7 +22767,7 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20676
22767
|
const lastLine = this.keyProps[this.keyProps.length - 1].line;
|
|
20677
22768
|
const top = Math.max(restLine, lastLine);
|
|
20678
22769
|
const bot = Math.min(restLine, lastLine);
|
|
20679
|
-
restLine = (0,
|
|
22770
|
+
restLine = (0,_util__WEBPACK_IMPORTED_MODULE_9__.midLine)(top, bot);
|
|
20680
22771
|
}
|
|
20681
22772
|
return restLine;
|
|
20682
22773
|
}
|
|
@@ -20684,10 +22775,10 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20684
22775
|
// and key `index`
|
|
20685
22776
|
getModifierStartXY(position, index, options = {}) {
|
|
20686
22777
|
if (!this.preFormatted) {
|
|
20687
|
-
throw new
|
|
22778
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_9__.RuntimeError('UnformattedNote', "Can't call GetModifierStartXY on an unformatted note");
|
|
20688
22779
|
}
|
|
20689
22780
|
if (this.ys.length === 0) {
|
|
20690
|
-
throw new
|
|
22781
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_9__.RuntimeError('NoYValues', 'No Y-Values calculated for this note.');
|
|
20691
22782
|
}
|
|
20692
22783
|
const { ABOVE, BELOW, LEFT, RIGHT } = _modifier__WEBPACK_IMPORTED_MODULE_3__.Modifier.Position;
|
|
20693
22784
|
let x = 0;
|
|
@@ -20932,7 +23023,7 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
20932
23023
|
if (this.isRest())
|
|
20933
23024
|
return;
|
|
20934
23025
|
if (!ctx) {
|
|
20935
|
-
throw new
|
|
23026
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_9__.RuntimeError('NoCanvasContext', "Can't draw without a canvas context.");
|
|
20936
23027
|
}
|
|
20937
23028
|
const { highestLine, lowestLine, highestDisplacedLine, highestNonDisplacedLine, lowestDisplacedLine, lowestNonDisplacedLine, displacedX, nonDisplacedX, } = this.getNoteHeadBounds();
|
|
20938
23029
|
// Early out if there are no ledger lines to draw.
|
|
@@ -21003,7 +23094,7 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
21003
23094
|
drawFlag() {
|
|
21004
23095
|
const ctx = this.checkContext();
|
|
21005
23096
|
if (!ctx) {
|
|
21006
|
-
throw new
|
|
23097
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_9__.RuntimeError('NoCanvasContext', "Can't draw without a canvas context.");
|
|
21007
23098
|
}
|
|
21008
23099
|
if (this.shouldDrawFlag()) {
|
|
21009
23100
|
const { x: flagX, y: flagY } = this.getFlagPosition();
|
|
@@ -21079,7 +23170,7 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_7__.StemmableNot
|
|
|
21079
23170
|
if (this.renderOptions.draw === false)
|
|
21080
23171
|
return;
|
|
21081
23172
|
if (this.ys.length === 0) {
|
|
21082
|
-
throw new
|
|
23173
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_9__.RuntimeError('NoYValues', "Can't draw note without Y values.");
|
|
21083
23174
|
}
|
|
21084
23175
|
const ctx = this.checkContext();
|
|
21085
23176
|
const xBegin = this.getNoteHeadBeginX();
|
|
@@ -22064,14 +24155,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
22064
24155
|
/* harmony import */ var _note__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./note */ "./src/note.ts");
|
|
22065
24156
|
/* harmony import */ var _stem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stem */ "./src/stem.ts");
|
|
22066
24157
|
/* harmony import */ var _tables__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./tables */ "./src/tables.ts");
|
|
22067
|
-
/* harmony import */ var
|
|
22068
|
-
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
24158
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
22069
24159
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
22070
24160
|
//
|
|
22071
24161
|
// ## Description
|
|
22072
24162
|
// `StemmableNote` is an abstract interface for notes with optional stems.
|
|
22073
|
-
// Examples of stemmable notes are `StaveNote` and `TabNote
|
|
22074
|
-
|
|
24163
|
+
// Examples of stemmable notes are `StaveNote` and `TabNote`.
|
|
24164
|
+
// Retains whether stem direction is automatic or explicitly chosen.
|
|
22075
24165
|
|
|
22076
24166
|
|
|
22077
24167
|
|
|
@@ -22080,10 +24170,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
22080
24170
|
|
|
22081
24171
|
class StemmableNote extends _note__WEBPACK_IMPORTED_MODULE_2__.Note {
|
|
22082
24172
|
static get CATEGORY() {
|
|
22083
|
-
return
|
|
24173
|
+
return "StemmableNote" /* Category.StemmableNote */;
|
|
22084
24174
|
}
|
|
22085
24175
|
constructor(noteStruct) {
|
|
22086
24176
|
super(noteStruct);
|
|
24177
|
+
/** Automatic stems may be resolved again when notes are grouped into a beam. */
|
|
24178
|
+
this.autoStemEnabled = false;
|
|
22087
24179
|
this.flag = new _flag__WEBPACK_IMPORTED_MODULE_0__.Flag();
|
|
22088
24180
|
}
|
|
22089
24181
|
// Get and set the note's `Stem`
|
|
@@ -22092,7 +24184,7 @@ class StemmableNote extends _note__WEBPACK_IMPORTED_MODULE_2__.Note {
|
|
|
22092
24184
|
}
|
|
22093
24185
|
checkStem() {
|
|
22094
24186
|
if (!this.stem) {
|
|
22095
|
-
throw new
|
|
24187
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('NoStem', 'No stem attached to instance');
|
|
22096
24188
|
}
|
|
22097
24189
|
return this.stem;
|
|
22098
24190
|
}
|
|
@@ -22181,16 +24273,22 @@ class StemmableNote extends _note__WEBPACK_IMPORTED_MODULE_2__.Note {
|
|
|
22181
24273
|
// Get/set the direction of the stem
|
|
22182
24274
|
getStemDirection() {
|
|
22183
24275
|
if (!this.stemDirection)
|
|
22184
|
-
throw new
|
|
24276
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('NoStem', 'No stem attached to this note.');
|
|
22185
24277
|
return this.stemDirection;
|
|
22186
24278
|
}
|
|
22187
|
-
|
|
24279
|
+
/** True when layout, rather than the caller, chooses the stem direction. */
|
|
24280
|
+
isAutoStem() {
|
|
24281
|
+
return this.autoStemEnabled;
|
|
24282
|
+
}
|
|
24283
|
+
/** Set direction; automatic layout passes true to retain the automatic policy. */
|
|
24284
|
+
setStemDirection(direction, autoStem = false) {
|
|
22188
24285
|
if (!direction)
|
|
22189
24286
|
direction = _stem__WEBPACK_IMPORTED_MODULE_3__.Stem.UP;
|
|
22190
24287
|
if (direction !== _stem__WEBPACK_IMPORTED_MODULE_3__.Stem.UP && direction !== _stem__WEBPACK_IMPORTED_MODULE_3__.Stem.DOWN) {
|
|
22191
|
-
throw new
|
|
24288
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('BadArgument', `Invalid stem direction: ${direction}`);
|
|
22192
24289
|
}
|
|
22193
24290
|
this.stemDirection = direction;
|
|
24291
|
+
this.autoStemEnabled = autoStem;
|
|
22194
24292
|
// Reset and reformat everything. Flag has to be built before calling getStemExtension.
|
|
22195
24293
|
this.reset();
|
|
22196
24294
|
if (this.hasFlag()) {
|
|
@@ -22241,7 +24339,7 @@ class StemmableNote extends _note__WEBPACK_IMPORTED_MODULE_2__.Note {
|
|
|
22241
24339
|
// Get the top and bottom `y` values of the stem.
|
|
22242
24340
|
getStemExtents() {
|
|
22243
24341
|
if (!this.stem)
|
|
22244
|
-
throw new
|
|
24342
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('NoStem', 'No stem attached to this note.');
|
|
22245
24343
|
return this.stem.getExtents();
|
|
22246
24344
|
}
|
|
22247
24345
|
/** Gets the `y` value for the top modifiers at a specific `textLine`. */
|
|
@@ -22250,7 +24348,7 @@ class StemmableNote extends _note__WEBPACK_IMPORTED_MODULE_2__.Note {
|
|
|
22250
24348
|
if (this.hasStem()) {
|
|
22251
24349
|
const extents = this.getStemExtents();
|
|
22252
24350
|
if (!extents)
|
|
22253
|
-
throw new
|
|
24351
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('InvalidState', 'Stem does not have extents.');
|
|
22254
24352
|
return Math.min(stave.getYForTopText(textLine), extents.topY - this.renderOptions.annotationSpacing * (textLine + 1));
|
|
22255
24353
|
}
|
|
22256
24354
|
else {
|
|
@@ -22263,7 +24361,7 @@ class StemmableNote extends _note__WEBPACK_IMPORTED_MODULE_2__.Note {
|
|
|
22263
24361
|
if (this.hasStem()) {
|
|
22264
24362
|
const extents = this.getStemExtents();
|
|
22265
24363
|
if (!extents)
|
|
22266
|
-
throw new
|
|
24364
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_5__.RuntimeError('InvalidState', 'Stem does not have extents.');
|
|
22267
24365
|
return Math.max(stave.getYForTopText(textLine), extents.baseY + this.renderOptions.annotationSpacing * textLine);
|
|
22268
24366
|
}
|
|
22269
24367
|
else {
|
|
@@ -25590,8 +27688,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
25590
27688
|
/* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./element */ "./src/element.ts");
|
|
25591
27689
|
/* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fraction */ "./src/fraction.ts");
|
|
25592
27690
|
/* harmony import */ var _tables__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tables */ "./src/tables.ts");
|
|
25593
|
-
/* harmony import */ var
|
|
25594
|
-
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
27691
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
25595
27692
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
25596
27693
|
// MIT License
|
|
25597
27694
|
// Timed score elements; duration changes invalidate their voice's cached totals.
|
|
@@ -25599,14 +27696,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
25599
27696
|
|
|
25600
27697
|
|
|
25601
27698
|
|
|
25602
|
-
|
|
25603
27699
|
/**
|
|
25604
27700
|
* Tickable represents a element that sit on a score and
|
|
25605
27701
|
* has a duration, i.e., Tickables occupy space in the musical rendering dimension.
|
|
25606
27702
|
*/
|
|
25607
27703
|
class Tickable extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
25608
27704
|
static get CATEGORY() {
|
|
25609
|
-
return
|
|
27705
|
+
return "Tickable" /* Category.Tickable */;
|
|
25610
27706
|
}
|
|
25611
27707
|
constructor() {
|
|
25612
27708
|
super();
|
|
@@ -25667,7 +27763,7 @@ class Tickable extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
25667
27763
|
/** Get width of note. Used by the formatter for positioning. */
|
|
25668
27764
|
getWidth() {
|
|
25669
27765
|
if (!this._preFormatted) {
|
|
25670
|
-
throw new
|
|
27766
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_3__.RuntimeError('UnformattedNote', "Can't call GetWidth on an unformatted note.");
|
|
25671
27767
|
}
|
|
25672
27768
|
return this.width + (this.modifierContext ? this.modifierContext.getWidth() : 0);
|
|
25673
27769
|
}
|
|
@@ -25706,12 +27802,18 @@ class Tickable extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
25706
27802
|
* This allows formatters and preFormatter to associate them with the right modifierContexts.
|
|
25707
27803
|
*/
|
|
25708
27804
|
getVoice() {
|
|
25709
|
-
return (0,
|
|
27805
|
+
return (0,_util__WEBPACK_IMPORTED_MODULE_3__.defined)(this.voice, 'NoVoice', 'Tickable has no voice.');
|
|
25710
27806
|
}
|
|
25711
27807
|
/** Set the associated voice. */
|
|
25712
27808
|
setVoice(voice) {
|
|
25713
27809
|
this.voice = voice;
|
|
25714
27810
|
}
|
|
27811
|
+
/** Release a temporary voice assignment during managed construction rollback. */
|
|
27812
|
+
clearVoice() {
|
|
27813
|
+
this.voice = undefined;
|
|
27814
|
+
this.preFormatted = false;
|
|
27815
|
+
return this;
|
|
27816
|
+
}
|
|
25715
27817
|
/** Get the Tuplet if any.
|
|
25716
27818
|
* If there are multiple Tuplets, the most recently added one is returned. */
|
|
25717
27819
|
getTuplet() {
|
|
@@ -25727,7 +27829,7 @@ class Tickable extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
25727
27829
|
removeTuplet(tuplet) {
|
|
25728
27830
|
const i = this.tupletStack.indexOf(tuplet);
|
|
25729
27831
|
if (i === -1) {
|
|
25730
|
-
throw new
|
|
27832
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_3__.RuntimeError('BadArguments', 'Tuplet is not found in this tickable');
|
|
25731
27833
|
}
|
|
25732
27834
|
this.tupletStack.splice(i, 1);
|
|
25733
27835
|
const noteCount = tuplet.getNoteCount();
|
|
@@ -25838,7 +27940,7 @@ class Tickable extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
25838
27940
|
this._preFormatted = false;
|
|
25839
27941
|
}
|
|
25840
27942
|
checkTickContext(message = 'Tickable has no tick context.') {
|
|
25841
|
-
return (0,
|
|
27943
|
+
return (0,_util__WEBPACK_IMPORTED_MODULE_3__.defined)(this.tickContext, 'NoTickContext', message);
|
|
25842
27944
|
}
|
|
25843
27945
|
/** Preformat the Tickable. */
|
|
25844
27946
|
preFormat() {
|
|
@@ -25918,7 +28020,7 @@ class Tickable extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
|
|
|
25918
28020
|
}
|
|
25919
28021
|
/** Check and get `ModifierContext`. */
|
|
25920
28022
|
checkModifierContext() {
|
|
25921
|
-
return (0,
|
|
28023
|
+
return (0,_util__WEBPACK_IMPORTED_MODULE_3__.defined)(this.modifierContext, 'NoModifierContext', 'No modifier context attached to this tickable.');
|
|
25922
28024
|
}
|
|
25923
28025
|
}
|
|
25924
28026
|
|
|
@@ -26634,8 +28736,7 @@ class Tuning {
|
|
|
26634
28736
|
|
|
26635
28737
|
__webpack_require__.r(__webpack_exports__);
|
|
26636
28738
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
26637
|
-
/* harmony export */ Tuplet: () => (/* binding */ Tuplet)
|
|
26638
|
-
/* harmony export */ TupletLocation: () => (/* binding */ TupletLocation)
|
|
28739
|
+
/* harmony export */ Tuplet: () => (/* binding */ Tuplet)
|
|
26639
28740
|
/* harmony export */ });
|
|
26640
28741
|
/* harmony import */ var _boundingbox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingbox */ "./src/boundingbox.ts");
|
|
26641
28742
|
/* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./element */ "./src/element.ts");
|
|
@@ -26644,8 +28745,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26644
28745
|
/* harmony import */ var _metrics__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./metrics */ "./src/metrics.ts");
|
|
26645
28746
|
/* harmony import */ var _stem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stem */ "./src/stem.ts");
|
|
26646
28747
|
/* harmony import */ var _tables__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./tables */ "./src/tables.ts");
|
|
26647
|
-
/* harmony import */ var
|
|
26648
|
-
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
28748
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./util */ "./src/util.ts");
|
|
26649
28749
|
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
26650
28750
|
// Tuplet brackets and labels with stable coordinates across redraws.
|
|
26651
28751
|
/**
|
|
@@ -26703,29 +28803,24 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26703
28803
|
|
|
26704
28804
|
|
|
26705
28805
|
|
|
26706
|
-
|
|
26707
|
-
var TupletLocation;
|
|
26708
|
-
(function (TupletLocation) {
|
|
26709
|
-
TupletLocation[TupletLocation["BOTTOM"] = -1] = "BOTTOM";
|
|
26710
|
-
TupletLocation[TupletLocation["TOP"] = 1] = "TOP";
|
|
26711
|
-
})(TupletLocation || (TupletLocation = {}));
|
|
26712
28806
|
class Tuplet extends _element__WEBPACK_IMPORTED_MODULE_1__.Element {
|
|
26713
28807
|
static get CATEGORY() {
|
|
26714
|
-
return
|
|
28808
|
+
return "Tuplet" /* Category.Tuplet */;
|
|
26715
28809
|
}
|
|
26716
28810
|
static get LOCATION_TOP() {
|
|
26717
|
-
return TupletLocation.TOP
|
|
28811
|
+
return 1 /* TupletLocation.TOP */;
|
|
26718
28812
|
}
|
|
26719
28813
|
static get LOCATION_BOTTOM() {
|
|
26720
|
-
return TupletLocation.BOTTOM
|
|
28814
|
+
return -1 /* TupletLocation.BOTTOM */;
|
|
26721
28815
|
}
|
|
26722
28816
|
static get NESTING_OFFSET() {
|
|
26723
28817
|
return 15;
|
|
26724
28818
|
}
|
|
26725
28819
|
constructor(notes, options = {}) {
|
|
28820
|
+
var _a, _b;
|
|
26726
28821
|
super();
|
|
26727
28822
|
if (!notes || !notes.length) {
|
|
26728
|
-
throw new
|
|
28823
|
+
throw new _util__WEBPACK_IMPORTED_MODULE_7__.RuntimeError('BadArguments', 'No notes provided for tuplet.');
|
|
26729
28824
|
}
|
|
26730
28825
|
this.notes = notes;
|
|
26731
28826
|
const numNotes = options.numNotes !== undefined ? options.numNotes : notes.length;
|
|
@@ -26733,8 +28828,8 @@ class Tuplet extends _element__WEBPACK_IMPORTED_MODULE_1__.Element {
|
|
|
26733
28828
|
const bracketed = options.bracketed !== undefined ? options.bracketed : notes.some((note) => !note.hasBeam());
|
|
26734
28829
|
const ratioed = options.ratioed !== undefined ? options.ratioed : Math.abs(notesOccupied - numNotes) > 1;
|
|
26735
28830
|
const location = options.location || Tuplet.LOCATION_TOP;
|
|
26736
|
-
const yOffset = options.yOffset
|
|
26737
|
-
const textYOffset = options.textYOffset
|
|
28831
|
+
const yOffset = (_a = options.yOffset) !== null && _a !== void 0 ? _a : _metrics__WEBPACK_IMPORTED_MODULE_4__.Metrics.get('Tuplet.yOffset');
|
|
28832
|
+
const textYOffset = (_b = options.textYOffset) !== null && _b !== void 0 ? _b : _metrics__WEBPACK_IMPORTED_MODULE_4__.Metrics.get('Tuplet.textYOffset');
|
|
26738
28833
|
const suffix = options.suffix || '';
|
|
26739
28834
|
this.options = {
|
|
26740
28835
|
bracketed,
|
|
@@ -26937,7 +29032,7 @@ class Tuplet extends _element__WEBPACK_IMPORTED_MODULE_1__.Element {
|
|
|
26937
29032
|
// determine y value for tuplet
|
|
26938
29033
|
yPos = this.getYPosition();
|
|
26939
29034
|
// set y and height for bounding box calculations
|
|
26940
|
-
this.setY(location === TupletLocation.TOP ? yPos : yPos - bracketLegLength + bracketThickness);
|
|
29035
|
+
this.setY(location === 1 /* TupletLocation.TOP */ ? yPos : yPos - bracketLegLength + bracketThickness);
|
|
26941
29036
|
this.height = bracketLegLength;
|
|
26942
29037
|
// calculate width taken by all text elements
|
|
26943
29038
|
const ratioWidth = this.textElement.getWidth();
|
|
@@ -27701,6 +29796,7 @@ VexFlow.Crescendo = _crescendo__WEBPACK_IMPORTED_MODULE_11__.Crescendo;
|
|
|
27701
29796
|
VexFlow.Curve = _curve__WEBPACK_IMPORTED_MODULE_12__.Curve;
|
|
27702
29797
|
VexFlow.Dot = _dot__WEBPACK_IMPORTED_MODULE_13__.Dot;
|
|
27703
29798
|
VexFlow.EasyScore = _easyscore__WEBPACK_IMPORTED_MODULE_14__.EasyScore;
|
|
29799
|
+
VexFlow.EasyScoreError = _easyscore__WEBPACK_IMPORTED_MODULE_14__.EasyScoreError;
|
|
27704
29800
|
VexFlow.Element = _element__WEBPACK_IMPORTED_MODULE_15__.Element;
|
|
27705
29801
|
VexFlow.Factory = _factory__WEBPACK_IMPORTED_MODULE_16__.Factory;
|
|
27706
29802
|
VexFlow.Font = _font__WEBPACK_IMPORTED_MODULE_17__.Font;
|
|
@@ -28743,6 +30839,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
28743
30839
|
/* harmony export */ CurvePosition: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.CurvePosition),
|
|
28744
30840
|
/* harmony export */ Dot: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.Dot),
|
|
28745
30841
|
/* harmony export */ EasyScore: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.EasyScore),
|
|
30842
|
+
/* harmony export */ EasyScoreError: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.EasyScoreError),
|
|
28746
30843
|
/* harmony export */ EasyScoreGrammar: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.EasyScoreGrammar),
|
|
28747
30844
|
/* harmony export */ Element: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.Element),
|
|
28748
30845
|
/* harmony export */ Factory: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.Factory),
|
|
@@ -28820,7 +30917,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
28820
30917
|
/* harmony export */ Tremolo: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.Tremolo),
|
|
28821
30918
|
/* harmony export */ Tuning: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.Tuning),
|
|
28822
30919
|
/* harmony export */ Tuplet: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.Tuplet),
|
|
28823
|
-
/* harmony export */ TupletLocation: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.TupletLocation),
|
|
28824
30920
|
/* harmony export */ VexFlow: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.VexFlow),
|
|
28825
30921
|
/* harmony export */ Vibrato: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.Vibrato),
|
|
28826
30922
|
/* harmony export */ VibratoBracket: () => (/* reexport safe */ _src_index__WEBPACK_IMPORTED_MODULE_8__.VibratoBracket),
|