vexflow 5.0.0-alpha.3 → 5.0.0-beta.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 +6 -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 +2066 -1877
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +1052 -993
- 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 +22 -28
- package/build/esm/src/annotation.js +0 -2
- package/build/esm/src/barnote.js +3 -3
- package/build/esm/src/beam.js +26 -46
- package/build/esm/src/bend.js +11 -3
- package/build/esm/src/chordsymbol.js +0 -4
- package/build/esm/src/clef.js +0 -2
- package/build/esm/src/clefnote.js +6 -1
- package/build/esm/src/curve.js +8 -5
- package/build/esm/src/element.js +94 -118
- package/build/esm/src/factory.js +4 -4
- package/build/esm/src/flag.js +20 -0
- package/build/esm/src/fonts/gonville.js +1 -1
- package/build/esm/src/formatter.js +13 -21
- package/build/esm/src/fraction.js +15 -22
- package/build/esm/src/glyphnote.js +3 -4
- package/build/esm/src/gracenote.js +0 -2
- package/build/esm/src/gracenotegroup.js +17 -8
- package/build/esm/src/index.js +1 -0
- package/build/esm/src/keysignature.js +38 -31
- package/build/esm/src/keysignote.js +1 -1
- package/build/esm/src/metrics.js +58 -7
- package/build/esm/src/modifier.js +10 -23
- package/build/esm/src/multimeasurerest.js +16 -25
- package/build/esm/src/note.js +7 -0
- package/build/esm/src/notehead.js +6 -1
- package/build/esm/src/ornament.js +0 -2
- package/build/esm/src/pedalmarking.js +33 -41
- package/build/esm/src/registry.js +5 -19
- package/build/esm/src/stave.js +11 -19
- package/build/esm/src/stavebarline.js +2 -3
- package/build/esm/src/stavehairpin.js +1 -1
- package/build/esm/src/staveline.js +0 -4
- package/build/esm/src/stavemodifier.js +0 -2
- package/build/esm/src/stavenote.js +42 -68
- package/build/esm/src/staverepetition.js +3 -2
- package/build/esm/src/stavesection.js +13 -15
- package/build/esm/src/stavetempo.js +7 -13
- package/build/esm/src/stavetext.js +2 -2
- package/build/esm/src/stavetie.js +82 -40
- package/build/esm/src/stavevolta.js +3 -2
- package/build/esm/src/stem.js +0 -4
- package/build/esm/src/stemmablenote.js +5 -6
- package/build/esm/src/stringnumber.js +0 -2
- package/build/esm/src/svgcontext.js +5 -13
- package/build/esm/src/tabnote.js +2 -8
- package/build/esm/src/textbracket.js +0 -3
- package/build/esm/src/textnote.js +0 -2
- package/build/esm/src/tickable.js +13 -26
- package/build/esm/src/tickcontext.js +20 -2
- package/build/esm/src/timesignature.js +2 -4
- package/build/esm/src/timesignote.js +2 -0
- package/build/esm/src/tuplet.js +37 -30
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vexflow.js +6 -2
- package/build/esm/src/vibrato.js +6 -1
- package/build/esm/tests/accidental_tests.js +30 -17
- package/build/esm/tests/annotation_tests.js +12 -12
- package/build/esm/tests/articulation_tests.js +13 -13
- package/build/esm/tests/auto_beam_formatting_tests.js +33 -33
- package/build/esm/tests/beam_tests.js +1 -1
- package/build/esm/tests/bend_tests.js +7 -7
- package/build/esm/tests/chordsymbol_tests.js +8 -8
- package/build/esm/tests/clef_tests.js +5 -1
- package/build/esm/tests/curve_tests.js +34 -0
- package/build/esm/tests/{bach_tests.js → demo_petzold_tests.js} +7 -7
- package/build/esm/tests/dot_tests.js +4 -4
- package/build/esm/tests/formatter_tests.js +25 -25
- package/build/esm/tests/glyphnote_tests.js +6 -0
- package/build/esm/tests/gracenote_tests.js +2 -1
- package/build/esm/tests/gracetabnote_tests.js +1 -1
- package/build/esm/tests/index.js +1 -1
- package/build/esm/tests/key_clef_tests.js +6 -6
- package/build/esm/tests/keysignature_tests.js +20 -17
- package/build/esm/tests/notehead_tests.js +10 -7
- package/build/esm/tests/offscreencanvas_tests.js +1 -1
- package/build/esm/tests/ornament_tests.js +8 -8
- package/build/esm/tests/pedalmarking_tests.js +27 -0
- package/build/esm/tests/percussion_tests.js +6 -3
- package/build/esm/tests/renderer_tests.js +1 -1
- package/build/esm/tests/rests_tests.js +26 -26
- package/build/esm/tests/rhythm_tests.js +15 -15
- package/build/esm/tests/stave_tests.js +44 -43
- package/build/esm/tests/staveconnector_tests.js +73 -73
- package/build/esm/tests/stavehairpin_tests.js +1 -1
- package/build/esm/tests/stavemodifier_tests.js +3 -3
- package/build/esm/tests/stavenote_tests.js +29 -29
- package/build/esm/tests/stavetie_tests.js +29 -0
- package/build/esm/tests/stringnumber_tests.js +1 -1
- package/build/esm/tests/strokes_tests.js +1 -1
- package/build/esm/tests/style_tests.js +1 -1
- package/build/esm/tests/tabnote_tests.js +7 -7
- package/build/esm/tests/tabslide_tests.js +6 -6
- package/build/esm/tests/tabstave_tests.js +2 -1
- package/build/esm/tests/tabtie_tests.js +8 -8
- package/build/esm/tests/textnote_tests.js +1 -1
- package/build/esm/tests/threevoice_tests.js +2 -2
- package/build/esm/tests/timesignature_tests.js +23 -13
- package/build/esm/tests/vexflow_test_helpers.js +25 -39
- package/build/esm/tests/vibrato_tests.js +3 -3
- package/build/esm/tests/voice_tests.js +1 -1
- package/build/types/src/accidental.d.ts +19 -1
- package/build/types/src/annotation.d.ts +1 -1
- package/build/types/src/beam.d.ts +12 -1
- package/build/types/src/bend.d.ts +6 -0
- package/build/types/src/clefnote.d.ts +2 -0
- package/build/types/src/curve.d.ts +5 -4
- package/build/types/src/element.d.ts +23 -14
- package/build/types/src/factory.d.ts +2 -2
- package/build/types/src/flag.d.ts +12 -0
- package/build/types/src/fonts/gonville.d.ts +1 -1
- package/build/types/src/formatter.d.ts +5 -3
- package/build/types/src/fraction.d.ts +12 -7
- package/build/types/src/frethandfinger.d.ts +1 -1
- package/build/types/src/index.d.ts +1 -0
- package/build/types/src/keysignature.d.ts +7 -7
- package/build/types/src/metrics.d.ts +5 -0
- package/build/types/src/modifier.d.ts +3 -2
- package/build/types/src/multimeasurerest.d.ts +4 -1
- package/build/types/src/note.d.ts +2 -0
- package/build/types/src/pedalmarking.d.ts +2 -2
- package/build/types/src/registry.d.ts +1 -1
- package/build/types/src/stave.d.ts +1 -3
- package/build/types/src/stavebarline.d.ts +1 -1
- package/build/types/src/staveline.d.ts +1 -1
- package/build/types/src/stavemodifier.d.ts +0 -1
- package/build/types/src/stavenote.d.ts +2 -1
- package/build/types/src/staverepetition.d.ts +1 -1
- package/build/types/src/stavesection.d.ts +3 -4
- package/build/types/src/stavetempo.d.ts +4 -5
- package/build/types/src/stavetext.d.ts +1 -2
- package/build/types/src/stavetie.d.ts +39 -2
- package/build/types/src/stavevolta.d.ts +1 -2
- package/build/types/src/stemmablenote.d.ts +2 -3
- package/build/types/src/svgcontext.d.ts +1 -1
- package/build/types/src/tickable.d.ts +2 -1
- package/build/types/src/tickcontext.d.ts +30 -0
- package/build/types/src/tuplet.d.ts +2 -12
- package/build/types/src/typeguard.d.ts +1 -0
- package/package.json +33 -29
- package/tests/flow.html +2 -2
package/build/esm/src/stem.js
CHANGED
|
@@ -120,8 +120,6 @@ export class Stem extends Element {
|
|
|
120
120
|
const stemHeight = this.getHeight();
|
|
121
121
|
L('Rendering stem - ', 'Top Y: ', this.yTop, 'Bottom Y: ', this.yBottom);
|
|
122
122
|
const stemletYOffset = this.isStemlet ? stemHeight - this.stemletHeight * this.stemDirection : 0;
|
|
123
|
-
ctx.save();
|
|
124
|
-
this.applyStyle();
|
|
125
123
|
ctx.openGroup('stem', this.getAttribute('id'));
|
|
126
124
|
ctx.beginPath();
|
|
127
125
|
ctx.setLineWidth(Stem.WIDTH);
|
|
@@ -129,8 +127,6 @@ export class Stem extends Element {
|
|
|
129
127
|
ctx.lineTo(stemX, stemY - stemHeight - this.renderHeightAdjustment * stemDirection);
|
|
130
128
|
ctx.stroke();
|
|
131
129
|
ctx.closeGroup();
|
|
132
|
-
this.restoreStyle();
|
|
133
|
-
ctx.restore();
|
|
134
130
|
}
|
|
135
131
|
}
|
|
136
132
|
Stem.DEBUG = false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Flag } from './flag.js';
|
|
2
2
|
import { Glyphs } from './glyphs.js';
|
|
3
3
|
import { Note } from './note.js';
|
|
4
4
|
import { Stem } from './stem.js';
|
|
@@ -10,8 +10,7 @@ export class StemmableNote extends Note {
|
|
|
10
10
|
}
|
|
11
11
|
constructor(noteStruct) {
|
|
12
12
|
super(noteStruct);
|
|
13
|
-
this.flag = new
|
|
14
|
-
this.flagStyle = {};
|
|
13
|
+
this.flag = new Flag();
|
|
15
14
|
}
|
|
16
15
|
getStem() {
|
|
17
16
|
return this.stem;
|
|
@@ -24,7 +23,7 @@ export class StemmableNote extends Note {
|
|
|
24
23
|
}
|
|
25
24
|
setStem(stem) {
|
|
26
25
|
this.stem = stem;
|
|
27
|
-
this.
|
|
26
|
+
this.addChild(stem);
|
|
28
27
|
return this;
|
|
29
28
|
}
|
|
30
29
|
buildStem() {
|
|
@@ -38,7 +37,7 @@ export class StemmableNote extends Note {
|
|
|
38
37
|
if (this.hasFlag()) {
|
|
39
38
|
const flagCode = this.getStemDirection() === Stem.DOWN
|
|
40
39
|
? String.fromCodePoint(((_b = (_a = glyphProps.codeFlagUp) === null || _a === void 0 ? void 0 : _a.codePointAt(0)) !== null && _b !== void 0 ? _b : -1) + 1)
|
|
41
|
-
: (_c = glyphProps.codeFlagUp) !== null && _c !== void 0 ? _c : Glyphs.null;
|
|
40
|
+
: ((_c = glyphProps.codeFlagUp) !== null && _c !== void 0 ? _c : Glyphs.null);
|
|
42
41
|
this.flag.setText(flagCode);
|
|
43
42
|
this.flag.fontInfo = this.fontInfo;
|
|
44
43
|
}
|
|
@@ -180,6 +179,6 @@ export class StemmableNote extends Note {
|
|
|
180
179
|
this.checkContext();
|
|
181
180
|
this.setRendered();
|
|
182
181
|
this.setStem(new Stem(stemOptions));
|
|
183
|
-
(_a = this.stem) === null || _a === void 0 ? void 0 : _a.setContext(this.getContext()).
|
|
182
|
+
(_a = this.stem) === null || _a === void 0 ? void 0 : _a.setContext(this.getContext()).drawWithStyle();
|
|
184
183
|
}
|
|
185
184
|
}
|
|
@@ -186,7 +186,6 @@ export class StringNumber extends Modifier {
|
|
|
186
186
|
default:
|
|
187
187
|
throw new RuntimeError('InvalidPosition', `The position ${this.position} is invalid`);
|
|
188
188
|
}
|
|
189
|
-
ctx.save();
|
|
190
189
|
if (this.drawCircle) {
|
|
191
190
|
ctx.beginPath();
|
|
192
191
|
ctx.arc(dotX, dotY, this.radius, 0, Math.PI * 2, false);
|
|
@@ -225,6 +224,5 @@ export class StringNumber extends Modifier {
|
|
|
225
224
|
break;
|
|
226
225
|
}
|
|
227
226
|
}
|
|
228
|
-
ctx.restore();
|
|
229
227
|
}
|
|
230
228
|
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var _SVGContext_instances, _SVGContext_getShadowStyle;
|
|
7
1
|
import { Element } from './element.js';
|
|
8
2
|
import { Font, FontStyle, FontWeight } from './font.js';
|
|
9
3
|
import { Metrics } from './metrics.js';
|
|
@@ -37,7 +31,6 @@ const TWO_PI = 2 * Math.PI;
|
|
|
37
31
|
export class SVGContext extends RenderContext {
|
|
38
32
|
constructor(element) {
|
|
39
33
|
super();
|
|
40
|
-
_SVGContext_instances.add(this);
|
|
41
34
|
this.width = 0;
|
|
42
35
|
this.height = 0;
|
|
43
36
|
this.precision = 1;
|
|
@@ -184,7 +177,6 @@ export class SVGContext extends RenderContext {
|
|
|
184
177
|
while (this.svg.lastChild) {
|
|
185
178
|
this.svg.removeChild(this.svg.lastChild);
|
|
186
179
|
}
|
|
187
|
-
this.scale(this.state.scaleX, this.state.scaleY);
|
|
188
180
|
}
|
|
189
181
|
rect(x, y, width, height, attributes) {
|
|
190
182
|
if (height < 0) {
|
|
@@ -308,6 +300,9 @@ export class SVGContext extends RenderContext {
|
|
|
308
300
|
this.path += 'Z';
|
|
309
301
|
return this;
|
|
310
302
|
}
|
|
303
|
+
getShadowStyle() {
|
|
304
|
+
return `filter: drop-shadow(0 0 ${this.attributes.shadowBlur / 1.5}px ${this.attributes.shadowColor})`;
|
|
305
|
+
}
|
|
311
306
|
fill(attributes) {
|
|
312
307
|
const path = this.create('path');
|
|
313
308
|
if (typeof attributes === 'undefined') {
|
|
@@ -315,7 +310,7 @@ export class SVGContext extends RenderContext {
|
|
|
315
310
|
}
|
|
316
311
|
attributes.d = this.path;
|
|
317
312
|
if (this.attributes.shadowBlur > 0) {
|
|
318
|
-
attributes.style =
|
|
313
|
+
attributes.style = this.getShadowStyle();
|
|
319
314
|
}
|
|
320
315
|
this.applyAttributes(path, attributes);
|
|
321
316
|
this.add(path);
|
|
@@ -325,7 +320,7 @@ export class SVGContext extends RenderContext {
|
|
|
325
320
|
const path = this.create('path');
|
|
326
321
|
const attributes = Object.assign(Object.assign({}, this.attributes), { fill: 'none', d: this.path });
|
|
327
322
|
if (this.attributes.shadowBlur > 0) {
|
|
328
|
-
attributes.style =
|
|
323
|
+
attributes.style = this.getShadowStyle();
|
|
329
324
|
}
|
|
330
325
|
this.applyAttributes(path, attributes);
|
|
331
326
|
this.add(path);
|
|
@@ -396,7 +391,4 @@ export class SVGContext extends RenderContext {
|
|
|
396
391
|
return this.fontCSSString;
|
|
397
392
|
}
|
|
398
393
|
}
|
|
399
|
-
_SVGContext_instances = new WeakSet(), _SVGContext_getShadowStyle = function _SVGContext_getShadowStyle() {
|
|
400
|
-
return `filter: drop-shadow(0 0 ${this.attributes.shadowBlur / 1.5}px ${this.attributes.shadowColor})`;
|
|
401
|
-
};
|
|
402
394
|
SVGContext.measureTextElement = new Element();
|
package/build/esm/src/tabnote.js
CHANGED
|
@@ -207,9 +207,7 @@ export class TabNote extends StemmableNote {
|
|
|
207
207
|
this.getStemY() - this.checkStem().getHeight() - this.getStemExtension()
|
|
208
208
|
:
|
|
209
209
|
this.getStemY() - this.checkStem().getHeight() + this.getStemExtension();
|
|
210
|
-
this.
|
|
211
|
-
this.flag.renderText(context, flagX, flagY);
|
|
212
|
-
this.restoreStyle(context, this.flagStyle);
|
|
210
|
+
this.flag.setContext(context).setX(flagX).setY(flagY).drawWithStyle();
|
|
213
211
|
}
|
|
214
212
|
}
|
|
215
213
|
drawModifiers() {
|
|
@@ -232,7 +230,6 @@ export class TabNote extends StemmableNote {
|
|
|
232
230
|
const stringsUsed = this.positions.map((position) => Number(position.str));
|
|
233
231
|
const unusedStrings = getUnusedStringGroups(numLines, stringsUsed);
|
|
234
232
|
const stemLines = getPartialStemLines(stemY, unusedStrings, this.checkStave(), this.getStemDirection());
|
|
235
|
-
ctx.save();
|
|
236
233
|
ctx.setLineWidth(Stem.WIDTH);
|
|
237
234
|
stemLines.forEach((bounds) => {
|
|
238
235
|
if (bounds.length === 0)
|
|
@@ -243,7 +240,6 @@ export class TabNote extends StemmableNote {
|
|
|
243
240
|
ctx.stroke();
|
|
244
241
|
ctx.closePath();
|
|
245
242
|
});
|
|
246
|
-
ctx.restore();
|
|
247
243
|
}
|
|
248
244
|
}
|
|
249
245
|
drawPositions() {
|
|
@@ -265,18 +261,16 @@ export class TabNote extends StemmableNote {
|
|
|
265
261
|
}
|
|
266
262
|
this.setRendered();
|
|
267
263
|
const renderStem = this.beam === undefined && this.renderOptions.drawStem;
|
|
268
|
-
this.applyStyle();
|
|
269
264
|
ctx.openGroup('tabnote', this.getAttribute('id'));
|
|
270
265
|
this.drawPositions();
|
|
271
266
|
this.drawStemThrough();
|
|
272
267
|
if (this.stem && renderStem) {
|
|
273
268
|
const stemX = this.getStemX();
|
|
274
269
|
this.stem.setNoteHeadXBounds(stemX, stemX);
|
|
275
|
-
this.stem.setContext(ctx).
|
|
270
|
+
this.stem.setContext(ctx).drawWithStyle();
|
|
276
271
|
}
|
|
277
272
|
this.drawFlag();
|
|
278
273
|
this.drawModifiers();
|
|
279
274
|
ctx.closeGroup();
|
|
280
|
-
this.restoreStyle();
|
|
281
275
|
}
|
|
282
276
|
}
|
|
@@ -86,8 +86,6 @@ export class TextBracket extends Element {
|
|
|
86
86
|
const stop = { x: this.stop.getAbsoluteX(), y };
|
|
87
87
|
L('Rendering TextBracket: start:', start, 'stop:', stop, 'y:', y);
|
|
88
88
|
const bracketHeight = this.renderOptions.bracketHeight * this.position;
|
|
89
|
-
ctx.save();
|
|
90
|
-
this.applyStyle(ctx);
|
|
91
89
|
this.textElement.renderText(ctx, start.x, start.y);
|
|
92
90
|
const mainWidth = this.textElement.getWidth();
|
|
93
91
|
const mainHeight = this.textElement.getHeight();
|
|
@@ -125,7 +123,6 @@ export class TextBracket extends Element {
|
|
|
125
123
|
ctx.stroke();
|
|
126
124
|
ctx.closePath();
|
|
127
125
|
}
|
|
128
|
-
ctx.restore();
|
|
129
126
|
}
|
|
130
127
|
}
|
|
131
128
|
TextBracket.DEBUG = false;
|
|
@@ -103,7 +103,6 @@ export class TextNote extends Note {
|
|
|
103
103
|
x -= width;
|
|
104
104
|
}
|
|
105
105
|
const y = stave.getYForLine(this.line + -3);
|
|
106
|
-
this.applyStyle(ctx);
|
|
107
106
|
this.renderText(ctx, x, y);
|
|
108
107
|
const height = this.getHeight();
|
|
109
108
|
if (this.superscript) {
|
|
@@ -112,7 +111,6 @@ export class TextNote extends Note {
|
|
|
112
111
|
if (this.subscript) {
|
|
113
112
|
this.subscript.renderText(ctx, x + this.width + 2, y + height / 2.2 - 1);
|
|
114
113
|
}
|
|
115
|
-
this.restoreStyle(ctx);
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
116
|
TextNote.Justification = TextJustification;
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
-
};
|
|
12
|
-
var _Tickable_preFormatted, _Tickable_postFormatted;
|
|
13
1
|
import { Element } from './element.js';
|
|
14
2
|
import { Fraction } from './fraction.js';
|
|
15
3
|
import { Tables } from './tables.js';
|
|
@@ -20,8 +8,8 @@ export class Tickable extends Element {
|
|
|
20
8
|
}
|
|
21
9
|
constructor() {
|
|
22
10
|
super();
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
this._preFormatted = false;
|
|
12
|
+
this._postFormatted = false;
|
|
25
13
|
this.ticks = new Fraction(0, 1);
|
|
26
14
|
this.intrinsicTicks = 0;
|
|
27
15
|
this.tickMultiplier = new Fraction(1, 1);
|
|
@@ -55,7 +43,7 @@ export class Tickable extends Element {
|
|
|
55
43
|
return this;
|
|
56
44
|
}
|
|
57
45
|
getWidth() {
|
|
58
|
-
if (!
|
|
46
|
+
if (!this._preFormatted) {
|
|
59
47
|
throw new RuntimeError('UnformattedNote', "Can't call GetWidth on an unformatted note.");
|
|
60
48
|
}
|
|
61
49
|
return this.width + (this.modifierContext ? this.modifierContext.getWidth() : 0);
|
|
@@ -133,12 +121,12 @@ export class Tickable extends Element {
|
|
|
133
121
|
this.modifierContext.addMember(this.modifiers[i]);
|
|
134
122
|
}
|
|
135
123
|
this.modifierContext.addMember(this);
|
|
136
|
-
|
|
124
|
+
this._preFormatted = false;
|
|
137
125
|
return this;
|
|
138
126
|
}
|
|
139
127
|
addModifier(modifier, index = 0) {
|
|
140
128
|
this.modifiers.push(modifier);
|
|
141
|
-
|
|
129
|
+
this._preFormatted = false;
|
|
142
130
|
return this;
|
|
143
131
|
}
|
|
144
132
|
getModifiers() {
|
|
@@ -146,13 +134,13 @@ export class Tickable extends Element {
|
|
|
146
134
|
}
|
|
147
135
|
setTickContext(tc) {
|
|
148
136
|
this.tickContext = tc;
|
|
149
|
-
|
|
137
|
+
this._preFormatted = false;
|
|
150
138
|
}
|
|
151
139
|
checkTickContext(message = 'Tickable has no tick context.') {
|
|
152
140
|
return defined(this.tickContext, 'NoTickContext', message);
|
|
153
141
|
}
|
|
154
142
|
preFormat() {
|
|
155
|
-
if (
|
|
143
|
+
if (this._preFormatted)
|
|
156
144
|
return;
|
|
157
145
|
this.width = 0;
|
|
158
146
|
if (this.modifierContext) {
|
|
@@ -161,22 +149,22 @@ export class Tickable extends Element {
|
|
|
161
149
|
}
|
|
162
150
|
}
|
|
163
151
|
set preFormatted(value) {
|
|
164
|
-
|
|
152
|
+
this._preFormatted = value;
|
|
165
153
|
}
|
|
166
154
|
get preFormatted() {
|
|
167
|
-
return
|
|
155
|
+
return this._preFormatted;
|
|
168
156
|
}
|
|
169
157
|
postFormat() {
|
|
170
|
-
if (
|
|
158
|
+
if (this._postFormatted)
|
|
171
159
|
return this;
|
|
172
|
-
|
|
160
|
+
this._postFormatted = true;
|
|
173
161
|
return this;
|
|
174
162
|
}
|
|
175
163
|
set postFormatted(value) {
|
|
176
|
-
|
|
164
|
+
this._postFormatted = value;
|
|
177
165
|
}
|
|
178
166
|
get postFormatted() {
|
|
179
|
-
return
|
|
167
|
+
return this._postFormatted;
|
|
180
168
|
}
|
|
181
169
|
getIntrinsicTicks() {
|
|
182
170
|
return this.intrinsicTicks;
|
|
@@ -212,4 +200,3 @@ export class Tickable extends Element {
|
|
|
212
200
|
return defined(this.modifierContext, 'NoModifierContext', 'No modifier context attached to this tickable.');
|
|
213
201
|
}
|
|
214
202
|
}
|
|
215
|
-
_Tickable_preFormatted = new WeakMap(), _Tickable_postFormatted = new WeakMap();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fraction } from './fraction.js';
|
|
2
|
-
import { RuntimeError } from './util.js';
|
|
2
|
+
import { RuntimeError, sumArray } from './util.js';
|
|
3
3
|
export class TickContext {
|
|
4
4
|
static getNextContext(tContext) {
|
|
5
5
|
const contexts = tContext.tContexts;
|
|
@@ -8,9 +8,10 @@ export class TickContext {
|
|
|
8
8
|
return contexts[index + 1];
|
|
9
9
|
}
|
|
10
10
|
constructor(options) {
|
|
11
|
+
var _a;
|
|
11
12
|
this.preFormatted = false;
|
|
12
13
|
this.postFormatted = false;
|
|
13
|
-
this.tickID = options
|
|
14
|
+
this.tickID = (_a = options === null || options === void 0 ? void 0 : options.tickID) !== null && _a !== void 0 ? _a : 0;
|
|
14
15
|
this.currentTick = new Fraction(0, 1);
|
|
15
16
|
this.maxTicks = new Fraction(0, 1);
|
|
16
17
|
this.maxTickable = undefined;
|
|
@@ -168,4 +169,21 @@ export class TickContext {
|
|
|
168
169
|
getFormatterMetrics() {
|
|
169
170
|
return this.formatterMetrics;
|
|
170
171
|
}
|
|
172
|
+
move(shift, prev, next) {
|
|
173
|
+
this.setX(this.getX() + shift);
|
|
174
|
+
this.getFormatterMetrics().freedom.left += shift;
|
|
175
|
+
this.getFormatterMetrics().freedom.right -= shift;
|
|
176
|
+
if (prev)
|
|
177
|
+
prev.getFormatterMetrics().freedom.right += shift;
|
|
178
|
+
if (next)
|
|
179
|
+
next.getFormatterMetrics().freedom.left -= shift;
|
|
180
|
+
}
|
|
181
|
+
getDeviationCost() {
|
|
182
|
+
return sumArray(this.tickables.map((t) => t.getFormatterMetrics().space.deviation));
|
|
183
|
+
}
|
|
184
|
+
getAverageDeviationCost() {
|
|
185
|
+
if (!this.tickables.length)
|
|
186
|
+
return 0;
|
|
187
|
+
return this.getDeviationCost() / this.tickables.length;
|
|
188
|
+
}
|
|
171
189
|
}
|
|
@@ -123,12 +123,12 @@ export class TimeSignature extends StaveModifier {
|
|
|
123
123
|
const stave = this.checkStave();
|
|
124
124
|
const ctx = stave.checkContext();
|
|
125
125
|
this.setRendered();
|
|
126
|
+
ctx.openGroup('timesignature', this.getAttribute('id'));
|
|
126
127
|
this.drawAt(ctx, stave, this.x);
|
|
128
|
+
ctx.closeGroup();
|
|
127
129
|
}
|
|
128
130
|
drawAt(ctx, stave, x) {
|
|
129
131
|
this.setRendered();
|
|
130
|
-
this.applyStyle(ctx);
|
|
131
|
-
ctx.openGroup('timesignature', this.getAttribute('id'));
|
|
132
132
|
if (this.isNumeric) {
|
|
133
133
|
let startX = x + this.topStartX;
|
|
134
134
|
let y = 0;
|
|
@@ -144,7 +144,5 @@ export class TimeSignature extends StaveModifier {
|
|
|
144
144
|
else {
|
|
145
145
|
this.renderText(ctx, x - this.x, stave.getYForLine(this.line));
|
|
146
146
|
}
|
|
147
|
-
ctx.closeGroup();
|
|
148
|
-
this.restoreStyle(ctx);
|
|
149
147
|
}
|
|
150
148
|
}
|
|
@@ -21,6 +21,8 @@ export class TimeSigNote extends Note {
|
|
|
21
21
|
const stave = this.checkStave();
|
|
22
22
|
const ctx = this.checkContext();
|
|
23
23
|
this.setRendered();
|
|
24
|
+
ctx.openGroup('timesignote', this.getAttribute('id'));
|
|
24
25
|
this.timeSig.drawAt(ctx, stave, this.getAbsoluteX());
|
|
26
|
+
ctx.closeGroup();
|
|
25
27
|
}
|
|
26
28
|
}
|
package/build/esm/src/tuplet.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Element } from './element.js';
|
|
2
2
|
import { Formatter } from './formatter.js';
|
|
3
3
|
import { Glyphs } from './glyphs.js';
|
|
4
|
+
import { Metrics } from './metrics.js';
|
|
4
5
|
import { Stem } from './stem.js';
|
|
5
6
|
import { Tables } from './tables.js';
|
|
6
7
|
import { RuntimeError } from './util.js';
|
|
@@ -22,20 +23,25 @@ export class Tuplet extends Element {
|
|
|
22
23
|
if (!notes || !notes.length) {
|
|
23
24
|
throw new RuntimeError('BadArguments', 'No notes provided for tuplet.');
|
|
24
25
|
}
|
|
25
|
-
this.options = options;
|
|
26
26
|
this.notes = notes;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
const numNotes = options.numNotes !== undefined ? options.numNotes : notes.length;
|
|
28
|
+
const notesOccupied = options.notesOccupied || 2;
|
|
29
|
+
const bracketed = options.bracketed !== undefined ? options.bracketed : notes.some((note) => !note.hasBeam());
|
|
30
|
+
const ratioed = options.ratioed !== undefined ? options.ratioed : Math.abs(notesOccupied - numNotes) > 1;
|
|
31
|
+
const location = options.location || Tuplet.LOCATION_TOP;
|
|
32
|
+
const yOffset = options.yOffset || Metrics.get('Tuplet.yOffset');
|
|
33
|
+
const textYOffset = options.textYOffset || Metrics.get('Tuplet.textYOffset');
|
|
34
|
+
this.options = {
|
|
35
|
+
bracketed,
|
|
36
|
+
location,
|
|
37
|
+
notesOccupied,
|
|
38
|
+
numNotes,
|
|
39
|
+
ratioed,
|
|
40
|
+
yOffset,
|
|
41
|
+
textYOffset,
|
|
42
|
+
};
|
|
37
43
|
this.textElement = new Element('Tuplet');
|
|
38
|
-
this.setTupletLocation(
|
|
44
|
+
this.setTupletLocation(location || Tuplet.LOCATION_TOP);
|
|
39
45
|
Formatter.AlignRestsToNotes(notes, true, true);
|
|
40
46
|
this.resolveGlyphs();
|
|
41
47
|
this.attach();
|
|
@@ -53,11 +59,11 @@ export class Tuplet extends Element {
|
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
setBracketed(bracketed) {
|
|
56
|
-
this.bracketed =
|
|
62
|
+
this.options.bracketed = bracketed;
|
|
57
63
|
return this;
|
|
58
64
|
}
|
|
59
65
|
setRatioed(ratioed) {
|
|
60
|
-
this.ratioed =
|
|
66
|
+
this.options.ratioed = ratioed;
|
|
61
67
|
return this;
|
|
62
68
|
}
|
|
63
69
|
setTupletLocation(location) {
|
|
@@ -65,34 +71,34 @@ export class Tuplet extends Element {
|
|
|
65
71
|
console.warn(`Invalid tuplet location [${location}]. Using Tuplet.LOCATION_TOP.`);
|
|
66
72
|
location = Tuplet.LOCATION_TOP;
|
|
67
73
|
}
|
|
68
|
-
this.location = location;
|
|
74
|
+
this.options.location = location;
|
|
69
75
|
return this;
|
|
70
76
|
}
|
|
71
77
|
getNotes() {
|
|
72
78
|
return this.notes;
|
|
73
79
|
}
|
|
74
80
|
getNoteCount() {
|
|
75
|
-
return this.numNotes;
|
|
81
|
+
return this.options.numNotes;
|
|
76
82
|
}
|
|
77
83
|
getNotesOccupied() {
|
|
78
|
-
return this.notesOccupied;
|
|
84
|
+
return this.options.notesOccupied;
|
|
79
85
|
}
|
|
80
86
|
setNotesOccupied(notes) {
|
|
81
87
|
this.detach();
|
|
82
|
-
this.notesOccupied = notes;
|
|
88
|
+
this.options.notesOccupied = notes;
|
|
83
89
|
this.resolveGlyphs();
|
|
84
90
|
this.attach();
|
|
85
91
|
}
|
|
86
92
|
resolveGlyphs() {
|
|
87
93
|
let numerator = '';
|
|
88
94
|
let denominator = '';
|
|
89
|
-
let n = this.numNotes;
|
|
95
|
+
let n = this.options.numNotes;
|
|
90
96
|
while (n >= 1) {
|
|
91
97
|
numerator = String.fromCharCode(0xe880 + (n % 10)) + numerator;
|
|
92
98
|
n = Math.floor(n / 10);
|
|
93
99
|
}
|
|
94
|
-
if (this.ratioed) {
|
|
95
|
-
n = this.notesOccupied;
|
|
100
|
+
if (this.options.ratioed) {
|
|
101
|
+
n = this.options.notesOccupied;
|
|
96
102
|
while (n >= 1) {
|
|
97
103
|
denominator = String.fromCharCode(0xe880 + (n % 10)) + denominator;
|
|
98
104
|
n = Math.floor(n / 10);
|
|
@@ -102,12 +108,12 @@ export class Tuplet extends Element {
|
|
|
102
108
|
this.textElement.setText(numerator + denominator);
|
|
103
109
|
}
|
|
104
110
|
getNestedTupletCount() {
|
|
105
|
-
const location = this.
|
|
111
|
+
const { location } = this.options;
|
|
106
112
|
const firstNote = this.notes[0];
|
|
107
113
|
let maxTupletCount = countTuplets(firstNote, location);
|
|
108
114
|
let minTupletCount = countTuplets(firstNote, location);
|
|
109
115
|
function countTuplets(note, location) {
|
|
110
|
-
return note.getTupletStack().filter((tuplet) => tuplet.location === location).length;
|
|
116
|
+
return note.getTupletStack().filter((tuplet) => tuplet.options.location === location).length;
|
|
111
117
|
}
|
|
112
118
|
this.notes.forEach((note) => {
|
|
113
119
|
const tupletCount = countTuplets(note, location);
|
|
@@ -118,11 +124,11 @@ export class Tuplet extends Element {
|
|
|
118
124
|
}
|
|
119
125
|
getYPosition() {
|
|
120
126
|
var _a;
|
|
121
|
-
const nestedTupletYOffset = this.getNestedTupletCount() * Tuplet.NESTING_OFFSET * -this.location;
|
|
127
|
+
const nestedTupletYOffset = this.getNestedTupletCount() * Tuplet.NESTING_OFFSET * -this.options.location;
|
|
122
128
|
const yOffset = (_a = this.options.yOffset) !== null && _a !== void 0 ? _a : 0;
|
|
123
129
|
const firstNote = this.notes[0];
|
|
124
130
|
let yPosition;
|
|
125
|
-
if (this.location === Tuplet.LOCATION_TOP) {
|
|
131
|
+
if (this.options.location === Tuplet.LOCATION_TOP) {
|
|
126
132
|
yPosition = firstNote.checkStave().getYForLine(0) - 1.5 * Tables.STAVE_LINE_DISTANCE;
|
|
127
133
|
for (let i = 0; i < this.notes.length; ++i) {
|
|
128
134
|
const note = this.notes[i];
|
|
@@ -166,13 +172,14 @@ export class Tuplet extends Element {
|
|
|
166
172
|
return yPosition + nestedTupletYOffset + yOffset;
|
|
167
173
|
}
|
|
168
174
|
draw() {
|
|
175
|
+
const { location, bracketed, textYOffset } = this.options;
|
|
169
176
|
const ctx = this.checkContext();
|
|
170
177
|
let xPos = 0;
|
|
171
178
|
let yPos = 0;
|
|
172
179
|
this.setRendered();
|
|
173
180
|
const firstNote = this.notes[0];
|
|
174
181
|
const lastNote = this.notes[this.notes.length - 1];
|
|
175
|
-
if (!
|
|
182
|
+
if (!bracketed) {
|
|
176
183
|
xPos = firstNote.getStemX();
|
|
177
184
|
this.width = lastNote.getStemX() - xPos;
|
|
178
185
|
}
|
|
@@ -183,15 +190,15 @@ export class Tuplet extends Element {
|
|
|
183
190
|
yPos = this.getYPosition();
|
|
184
191
|
const notationCenterX = xPos + this.width / 2;
|
|
185
192
|
const notationStartX = notationCenterX - this.textElement.getWidth() / 2;
|
|
186
|
-
if (
|
|
193
|
+
if (bracketed) {
|
|
187
194
|
const lineWidth = this.width / 2 - this.textElement.getWidth() / 2 - 5;
|
|
188
195
|
if (lineWidth > 0) {
|
|
189
196
|
ctx.fillRect(xPos, yPos, lineWidth, 1);
|
|
190
197
|
ctx.fillRect(xPos + this.width / 2 + this.textElement.getWidth() / 2 + 5, yPos, lineWidth, 1);
|
|
191
|
-
ctx.fillRect(xPos, yPos + (
|
|
192
|
-
ctx.fillRect(xPos + this.width, yPos + (
|
|
198
|
+
ctx.fillRect(xPos, yPos + (location === Tuplet.LOCATION_BOTTOM ? 1 : 0), 1, location * 10);
|
|
199
|
+
ctx.fillRect(xPos + this.width, yPos + (location === Tuplet.LOCATION_BOTTOM ? 1 : 0), 1, location * 10);
|
|
193
200
|
}
|
|
194
201
|
}
|
|
195
|
-
this.textElement.renderText(ctx, notationStartX, yPos + this.textElement.getHeight() / 2);
|
|
202
|
+
this.textElement.renderText(ctx, notationStartX, yPos + this.textElement.getHeight() / 2 + (location === Tuplet.LOCATION_TOP ? -1 : 1) * textYOffset);
|
|
196
203
|
}
|
|
197
204
|
}
|
package/build/esm/src/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const VERSION = '5.0.0-
|
|
2
|
-
export const ID = '
|
|
3
|
-
export const DATE = '2024-
|
|
1
|
+
export const VERSION = '5.0.0-beta.0';
|
|
2
|
+
export const ID = '2daeb4def8b685227f2a3c924177b40ddcc5bda3';
|
|
3
|
+
export const DATE = '2024-09-12T19:16:57.446Z';
|
package/build/esm/src/vexflow.js
CHANGED
|
@@ -104,6 +104,7 @@ export class VexFlow {
|
|
|
104
104
|
}
|
|
105
105
|
static setFonts(...fontNames) {
|
|
106
106
|
MetricsDefaults.fontFamily = fontNames.join(',');
|
|
107
|
+
Metrics.clear();
|
|
107
108
|
}
|
|
108
109
|
static getFonts() {
|
|
109
110
|
return Metrics.get('fontFamily').split(',');
|
|
@@ -157,10 +158,13 @@ export class VexFlow {
|
|
|
157
158
|
Tables.STAVE_LINE_DISTANCE = value;
|
|
158
159
|
}
|
|
159
160
|
static get STAVE_LINE_THICKNESS() {
|
|
160
|
-
return
|
|
161
|
+
return MetricsDefaults.Stave.lineWidth;
|
|
161
162
|
}
|
|
162
163
|
static set STAVE_LINE_THICKNESS(value) {
|
|
163
|
-
|
|
164
|
+
MetricsDefaults.Stave.lineWidth = value;
|
|
165
|
+
MetricsDefaults.TabStave.lineWidth = value;
|
|
166
|
+
Metrics.clear('Stave');
|
|
167
|
+
Metrics.clear('TabStave');
|
|
164
168
|
}
|
|
165
169
|
static get STEM_HEIGHT() {
|
|
166
170
|
return Tables.STEM_HEIGHT;
|
package/build/esm/src/vibrato.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Bend } from './bend.js';
|
|
2
2
|
import { Modifier } from './modifier.js';
|
|
3
3
|
import { Tables } from './tables.js';
|
|
4
|
+
import { RuntimeError } from './util.js';
|
|
4
5
|
export class Vibrato extends Modifier {
|
|
5
6
|
static get CATEGORY() {
|
|
6
7
|
return "Vibrato";
|
|
@@ -41,7 +42,11 @@ export class Vibrato extends Modifier {
|
|
|
41
42
|
setVibratoWidth(width) {
|
|
42
43
|
this.renderOptions.width = width;
|
|
43
44
|
this.text = String.fromCodePoint(this.renderOptions.code);
|
|
44
|
-
const
|
|
45
|
+
const myWidth = this.getWidth();
|
|
46
|
+
if (!myWidth) {
|
|
47
|
+
throw new RuntimeError('Cannot set vibrato width if width is 0');
|
|
48
|
+
}
|
|
49
|
+
const items = Math.round(this.renderOptions.width / myWidth);
|
|
45
50
|
for (let i = 1; i < items; i++) {
|
|
46
51
|
this.text += String.fromCodePoint(this.renderOptions.code);
|
|
47
52
|
}
|