vexflow 5.0.0-alpha.2 → 5.0.0-alpha.4
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/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 +528 -492
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +460 -452
- 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/beam.js +24 -42
- package/build/esm/src/clefnote.js +6 -1
- package/build/esm/src/element.js +83 -101
- package/build/esm/src/fonts/gonville.js +1 -1
- package/build/esm/src/formatter.js +9 -17
- package/build/esm/src/fraction.js +15 -22
- package/build/esm/src/glyphnote.js +3 -2
- package/build/esm/src/metrics.js +3 -0
- package/build/esm/src/modifier.js +6 -21
- package/build/esm/src/multimeasurerest.js +16 -25
- package/build/esm/src/note.js +7 -0
- package/build/esm/src/registry.js +5 -19
- package/build/esm/src/stave.js +4 -6
- package/build/esm/src/stavenote.js +26 -40
- package/build/esm/src/stavetempo.js +4 -11
- package/build/esm/src/stavetie.js +82 -36
- package/build/esm/src/svgcontext.js +5 -12
- package/build/esm/src/tickable.js +13 -26
- package/build/esm/src/tickcontext.js +20 -2
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vibrato.js +6 -1
- package/build/esm/tests/clef_tests.js +5 -1
- package/build/esm/tests/glyphnote_tests.js +6 -0
- package/build/esm/tests/stavetie_tests.js +29 -0
- package/build/esm/tests/tabstave_tests.js +1 -0
- package/build/esm/tests/vexflow_test_helpers.js +25 -39
- 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/clefnote.d.ts +2 -0
- package/build/types/src/element.d.ts +13 -3
- 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/modifier.d.ts +2 -1
- package/build/types/src/multimeasurerest.d.ts +4 -1
- package/build/types/src/note.d.ts +2 -0
- package/build/types/src/registry.d.ts +1 -1
- package/build/types/src/stavenote.d.ts +2 -1
- package/build/types/src/stavetempo.d.ts +3 -3
- package/build/types/src/stavetie.d.ts +39 -2
- 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/package.json +2 -4
- package/tests/flow.html +2 -2
- package/entry/vexflow-bravura.ts +0 -25
- package/entry/vexflow-core.ts +0 -16
- package/entry/vexflow-debug-with-tests.ts +0 -64
- package/entry/vexflow-debug.ts +0 -54
- package/entry/vexflow.ts +0 -47
- package/src/accidental.ts +0 -570
- package/src/annotation.ts +0 -294
- package/src/articulation.ts +0 -383
- package/src/barnote.ts +0 -95
- package/src/beam.ts +0 -999
- package/src/bend.ts +0 -268
- package/src/boundingbox.ts +0 -108
- package/src/canvascontext.ts +0 -348
- package/src/chordsymbol.ts +0 -473
- package/src/clef.ts +0 -164
- package/src/clefnote.ts +0 -50
- package/src/crescendo.ts +0 -132
- package/src/curve.ts +0 -195
- package/src/dot.ts +0 -171
- package/src/easyscore.ts +0 -538
- package/src/element.ts +0 -692
- package/src/factory.ts +0 -694
- package/src/font.ts +0 -343
- package/src/fonts/academico.ts +0 -2
- package/src/fonts/academicobold.ts +0 -2
- package/src/fonts/bravura.ts +0 -2
- package/src/fonts/gonville.ts +0 -2
- package/src/fonts/petaluma.ts +0 -2
- package/src/fonts/petalumascript.ts +0 -2
- package/src/formatter.ts +0 -1107
- package/src/fraction.ts +0 -245
- package/src/frethandfinger.ts +0 -180
- package/src/ghostnote.ts +0 -75
- package/src/glyphnote.ts +0 -68
- package/src/glyphs.ts +0 -5880
- package/src/gracenote.ts +0 -146
- package/src/gracenotegroup.ts +0 -194
- package/src/gracetabnote.ts +0 -30
- package/src/index.ts +0 -90
- package/src/keymanager.ts +0 -153
- package/src/keysignature.ts +0 -272
- package/src/keysignote.ts +0 -46
- package/src/metrics.ts +0 -222
- package/src/modifier.ts +0 -216
- package/src/modifiercontext.ts +0 -177
- package/src/multimeasurerest.ts +0 -229
- package/src/music.ts +0 -443
- package/src/note.ts +0 -690
- package/src/notehead.ts +0 -158
- package/src/notesubgroup.ts +0 -88
- package/src/ornament.ts +0 -301
- package/src/parenthesis.ts +0 -89
- package/src/parser.ts +0 -263
- package/src/pedalmarking.ts +0 -273
- package/src/registry.ts +0 -146
- package/src/rendercontext.ts +0 -98
- package/src/renderer.ts +0 -166
- package/src/repeatnote.ts +0 -25
- package/src/stave.ts +0 -885
- package/src/stavebarline.ts +0 -231
- package/src/staveconnector.ts +0 -281
- package/src/stavehairpin.ts +0 -209
- package/src/staveline.ts +0 -343
- package/src/stavemodifier.ts +0 -93
- package/src/stavenote.ts +0 -1230
- package/src/staverepetition.ts +0 -148
- package/src/stavesection.ts +0 -54
- package/src/stavetempo.ts +0 -162
- package/src/stavetext.ts +0 -69
- package/src/stavetie.ts +0 -235
- package/src/stavevolta.ts +0 -66
- package/src/stem.ts +0 -225
- package/src/stemmablenote.ts +0 -248
- package/src/stringnumber.ts +0 -286
- package/src/strokes.ts +0 -214
- package/src/svgcontext.ts +0 -639
- package/src/system.ts +0 -327
- package/src/tables.ts +0 -796
- package/src/tabnote.ts +0 -449
- package/src/tabslide.ts +0 -115
- package/src/tabstave.ts +0 -31
- package/src/tabtie.ts +0 -44
- package/src/textbracket.ts +0 -231
- package/src/textdynamics.ts +0 -101
- package/src/textnote.ts +0 -175
- package/src/tickable.ts +0 -374
- package/src/tickcontext.ts +0 -280
- package/src/timesignature.ts +0 -229
- package/src/timesignote.ts +0 -45
- package/src/tremolo.ts +0 -51
- package/src/tuning.ts +0 -90
- package/src/tuplet.ts +0 -349
- package/src/typeguard.ts +0 -136
- package/src/util.ts +0 -169
- package/src/version.ts +0 -4
- package/src/vexflow.ts +0 -378
- package/src/vibrato.ts +0 -99
- package/src/vibratobracket.ts +0 -81
- package/src/voice.ts +0 -302
- package/src/web.ts +0 -35
|
@@ -11,6 +11,9 @@ export class StaveTie extends Element {
|
|
|
11
11
|
this.renderOptions = {
|
|
12
12
|
cp1: 8,
|
|
13
13
|
cp2: 12,
|
|
14
|
+
shortTieCutoff: 10,
|
|
15
|
+
cp1Short: 2,
|
|
16
|
+
cp2Short: 8,
|
|
14
17
|
textShiftX: 0,
|
|
15
18
|
firstXShift: 0,
|
|
16
19
|
lastXShift: 0,
|
|
@@ -18,6 +21,20 @@ export class StaveTie extends Element {
|
|
|
18
21
|
tieSpacing: 0,
|
|
19
22
|
};
|
|
20
23
|
}
|
|
24
|
+
getDirection() {
|
|
25
|
+
if (this.direction !== undefined && this.direction !== null) {
|
|
26
|
+
return this.direction;
|
|
27
|
+
}
|
|
28
|
+
else if (this.notes.lastNote) {
|
|
29
|
+
return this.notes.lastNote.getStemDirection();
|
|
30
|
+
}
|
|
31
|
+
else if (this.notes.firstNote) {
|
|
32
|
+
return this.notes.firstNote.getStemDirection();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
21
38
|
setDirection(direction) {
|
|
22
39
|
this.direction = direction;
|
|
23
40
|
return this;
|
|
@@ -48,9 +65,9 @@ export class StaveTie extends Element {
|
|
|
48
65
|
const ctx = this.checkContext();
|
|
49
66
|
let cp1 = this.renderOptions.cp1;
|
|
50
67
|
let cp2 = this.renderOptions.cp2;
|
|
51
|
-
if (Math.abs(params.lastX - params.firstX) <
|
|
52
|
-
cp1 =
|
|
53
|
-
cp2 =
|
|
68
|
+
if (Math.abs(params.lastX - params.firstX) < this.renderOptions.shortTieCutoff) {
|
|
69
|
+
cp1 = this.renderOptions.cp1Short;
|
|
70
|
+
cp2 = this.renderOptions.cp2Short;
|
|
54
71
|
}
|
|
55
72
|
const firstXShift = this.renderOptions.firstXShift;
|
|
56
73
|
const lastXShift = this.renderOptions.lastXShift;
|
|
@@ -94,47 +111,76 @@ export class StaveTie extends Element {
|
|
|
94
111
|
getNotes() {
|
|
95
112
|
return this.notes;
|
|
96
113
|
}
|
|
97
|
-
|
|
98
|
-
this.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
else if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
getFirstX() {
|
|
115
|
+
if (this.notes.firstNote) {
|
|
116
|
+
return this.notes.firstNote.getTieRightX() + this.renderOptions.tieSpacing;
|
|
117
|
+
}
|
|
118
|
+
else if (this.notes.lastNote) {
|
|
119
|
+
return this.notes.lastNote.checkStave().getTieStartX();
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
return 0;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
getLastX() {
|
|
126
|
+
if (this.notes.lastNote) {
|
|
127
|
+
return this.notes.lastNote.getTieLeftX() + this.renderOptions.tieSpacing;
|
|
128
|
+
}
|
|
129
|
+
else if (this.notes.firstNote) {
|
|
130
|
+
return this.notes.firstNote.checkStave().getTieEndX();
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return 0;
|
|
117
134
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
135
|
+
}
|
|
136
|
+
getFirstYs() {
|
|
137
|
+
if (this.notes.firstNote) {
|
|
138
|
+
return this.notes.firstNote.getYs();
|
|
139
|
+
}
|
|
140
|
+
else if (this.notes.lastNote) {
|
|
141
|
+
return this.notes.lastNote.getYs();
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
return [0];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
getLastYs() {
|
|
148
|
+
if (this.notes.lastNote) {
|
|
149
|
+
return this.notes.lastNote.getYs();
|
|
150
|
+
}
|
|
151
|
+
else if (this.notes.firstNote) {
|
|
152
|
+
return this.notes.firstNote.getYs();
|
|
122
153
|
}
|
|
123
|
-
else
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
154
|
+
else {
|
|
155
|
+
return [0];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
synchronizeIndexes() {
|
|
159
|
+
if (this.notes.firstNote && this.notes.lastNote) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
else if (!this.notes.firstNote && !this.notes.lastNote) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
else if (this.notes.firstNote) {
|
|
127
166
|
this.notes.lastIndexes = this.notes.firstIndexes;
|
|
128
167
|
}
|
|
129
|
-
|
|
130
|
-
|
|
168
|
+
else {
|
|
169
|
+
this.notes.firstIndexes = this.notes.lastIndexes;
|
|
131
170
|
}
|
|
171
|
+
}
|
|
172
|
+
draw() {
|
|
173
|
+
this.checkContext();
|
|
174
|
+
this.setRendered();
|
|
175
|
+
this.synchronizeIndexes();
|
|
176
|
+
const firstX = this.getFirstX();
|
|
177
|
+
const lastX = this.getLastX();
|
|
132
178
|
this.renderTie({
|
|
133
179
|
firstX,
|
|
134
180
|
lastX,
|
|
135
|
-
firstYs,
|
|
136
|
-
lastYs,
|
|
137
|
-
direction:
|
|
181
|
+
firstYs: this.getFirstYs(),
|
|
182
|
+
lastYs: this.getLastYs(),
|
|
183
|
+
direction: this.getDirection(),
|
|
138
184
|
});
|
|
139
185
|
this.renderTieText(firstX, lastX);
|
|
140
186
|
return true;
|
|
@@ -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;
|
|
@@ -308,6 +301,9 @@ export class SVGContext extends RenderContext {
|
|
|
308
301
|
this.path += 'Z';
|
|
309
302
|
return this;
|
|
310
303
|
}
|
|
304
|
+
getShadowStyle() {
|
|
305
|
+
return `filter: drop-shadow(0 0 ${this.attributes.shadowBlur / 1.5}px ${this.attributes.shadowColor})`;
|
|
306
|
+
}
|
|
311
307
|
fill(attributes) {
|
|
312
308
|
const path = this.create('path');
|
|
313
309
|
if (typeof attributes === 'undefined') {
|
|
@@ -315,7 +311,7 @@ export class SVGContext extends RenderContext {
|
|
|
315
311
|
}
|
|
316
312
|
attributes.d = this.path;
|
|
317
313
|
if (this.attributes.shadowBlur > 0) {
|
|
318
|
-
attributes.style =
|
|
314
|
+
attributes.style = this.getShadowStyle();
|
|
319
315
|
}
|
|
320
316
|
this.applyAttributes(path, attributes);
|
|
321
317
|
this.add(path);
|
|
@@ -325,7 +321,7 @@ export class SVGContext extends RenderContext {
|
|
|
325
321
|
const path = this.create('path');
|
|
326
322
|
const attributes = Object.assign(Object.assign({}, this.attributes), { fill: 'none', d: this.path });
|
|
327
323
|
if (this.attributes.shadowBlur > 0) {
|
|
328
|
-
attributes.style =
|
|
324
|
+
attributes.style = this.getShadowStyle();
|
|
329
325
|
}
|
|
330
326
|
this.applyAttributes(path, attributes);
|
|
331
327
|
this.add(path);
|
|
@@ -396,7 +392,4 @@ export class SVGContext extends RenderContext {
|
|
|
396
392
|
return this.fontCSSString;
|
|
397
393
|
}
|
|
398
394
|
}
|
|
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
395
|
SVGContext.measureTextElement = new Element();
|
|
@@ -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
|
}
|
package/build/esm/src/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const VERSION = '5.0.0-alpha.
|
|
2
|
-
export const ID = '
|
|
3
|
-
export const DATE = '2024-
|
|
1
|
+
export const VERSION = '5.0.0-alpha.4';
|
|
2
|
+
export const ID = 'b71510759a0805f5a61170a47ec293256833eb35';
|
|
3
|
+
export const DATE = '2024-06-24T05:25:46.334Z';
|
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
|
}
|
|
@@ -4,11 +4,12 @@ const ClefTests = {
|
|
|
4
4
|
QUnit.module('Clef');
|
|
5
5
|
const run = VexFlowTests.runTests;
|
|
6
6
|
run('Bounding Box', draw, { drawBoundingBox: true });
|
|
7
|
+
run('Bounding Box Clef Change', drawClefChange, { drawBoundingBox: true });
|
|
7
8
|
run('Clef Test', draw, { drawBoundingBox: false });
|
|
8
9
|
run('Clef End Test', drawEnd);
|
|
9
10
|
run('Small Clef Test', drawSmall);
|
|
10
11
|
run('Small Clef End Test', drawSmallEnd);
|
|
11
|
-
run('Clef Change Test', drawClefChange);
|
|
12
|
+
run('Clef Change Test', drawClefChange, { drawBoundingBox: false });
|
|
12
13
|
},
|
|
13
14
|
};
|
|
14
15
|
function draw(options) {
|
|
@@ -131,6 +132,9 @@ function drawClefChange(options) {
|
|
|
131
132
|
const voice = f.Voice({ time: '12/4' }).addTickables(notes);
|
|
132
133
|
f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
133
134
|
f.draw();
|
|
135
|
+
if (options.params.drawBoundingBox === true) {
|
|
136
|
+
notes.forEach((element) => VexFlowTests.drawBoundingBox(f.getContext(), element));
|
|
137
|
+
}
|
|
134
138
|
options.assert.ok(true, 'all pass');
|
|
135
139
|
}
|
|
136
140
|
VexFlowTests.register(ClefTests);
|
|
@@ -8,6 +8,7 @@ const GlyphNoteTests = {
|
|
|
8
8
|
QUnit.module('GlyphNote');
|
|
9
9
|
const run = VexFlowTests.runTests;
|
|
10
10
|
run('GlyphNote with ChordSymbols', chordChanges, { debug: false, noPadding: false });
|
|
11
|
+
run('Bounding Box', chordChanges, { debug: false, noPadding: false, drawBoundingBox: true });
|
|
11
12
|
run('GlyphNote Positioning', basic, { debug: false, noPadding: false });
|
|
12
13
|
run('GlyphNote No Stave Padding', basic, { debug: true, noPadding: true });
|
|
13
14
|
run('GlyphNote RepeatNote', repeatNote, { debug: false, noPadding: true });
|
|
@@ -47,6 +48,11 @@ function chordChanges(options) {
|
|
|
47
48
|
system.addStave({ voices: [voice], debugNoteMetrics: options.params.debug });
|
|
48
49
|
system.addConnector().setType(StaveConnector.type.BRACKET);
|
|
49
50
|
f.draw();
|
|
51
|
+
if (options.params.drawBoundingBox === true) {
|
|
52
|
+
notes.forEach((note) => {
|
|
53
|
+
VexFlowTests.drawBoundingBox(f.getContext(), note);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
50
56
|
Registry.disableDefaultRegistry();
|
|
51
57
|
options.assert.ok(true);
|
|
52
58
|
}
|
|
@@ -13,6 +13,7 @@ const StaveTieTests = {
|
|
|
13
13
|
run('No Start Note', noStartNote2);
|
|
14
14
|
run('Set Direction Down', setDirectionDown);
|
|
15
15
|
run('Set Direction Up', setDirectionUp);
|
|
16
|
+
run('Tie Algorithms', tieAlgorithms);
|
|
16
17
|
},
|
|
17
18
|
};
|
|
18
19
|
function createTest(notesData, setupTies) {
|
|
@@ -104,5 +105,33 @@ const setDirectionUp = createTest(['(cb4 e#4 a4)/2, (d4 e4 f4)', { stem: 'down'
|
|
|
104
105
|
options: { direction: Stem.UP },
|
|
105
106
|
});
|
|
106
107
|
});
|
|
108
|
+
function tieAlgorithms(options) {
|
|
109
|
+
const factory = VexFlowTests.makeFactory(options, 300);
|
|
110
|
+
const stave = factory.Stave();
|
|
111
|
+
const score = factory.EasyScore();
|
|
112
|
+
const [n0, n1] = score.notes('(c4 e4 g4)/2, (c4 e4 g4)', { stem: 'up' });
|
|
113
|
+
const voice = score.voice([n0, n1]);
|
|
114
|
+
const tie1 = factory.StaveTie({
|
|
115
|
+
from: n0,
|
|
116
|
+
to: n1,
|
|
117
|
+
firstIndexes: [0],
|
|
118
|
+
lastIndexes: [0],
|
|
119
|
+
});
|
|
120
|
+
const tie2 = factory.StaveTie({
|
|
121
|
+
from: n0,
|
|
122
|
+
to: n1,
|
|
123
|
+
firstIndexes: [1, 2],
|
|
124
|
+
lastIndexes: [1, 2],
|
|
125
|
+
options: { direction: Stem.DOWN },
|
|
126
|
+
});
|
|
127
|
+
factory.Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
128
|
+
factory.draw();
|
|
129
|
+
options.assert.equal(tie1.getDirection(), Stem.UP);
|
|
130
|
+
options.assert.equal(tie2.getDirection(), Stem.DOWN);
|
|
131
|
+
options.assert.ok(tie1.getFirstX() < tie1.getLastX());
|
|
132
|
+
n1.setStemDirection(Stem.DOWN);
|
|
133
|
+
options.assert.equal(tie1.getDirection(), Stem.DOWN);
|
|
134
|
+
options.assert.equal(tie2.getDirection(), Stem.DOWN);
|
|
135
|
+
}
|
|
107
136
|
VexFlowTests.register(StaveTieTests);
|
|
108
137
|
export { StaveTieTests };
|
|
@@ -10,6 +10,7 @@ const TabStaveTests = {
|
|
|
10
10
|
function draw(options, contextBuilder) {
|
|
11
11
|
const ctx = contextBuilder(options.elementId, 400, 160);
|
|
12
12
|
const stave = new TabStave(10, 10, 300);
|
|
13
|
+
stave.setMeasure(1);
|
|
13
14
|
stave.setNumLines(6);
|
|
14
15
|
stave.setContext(ctx);
|
|
15
16
|
stave.draw();
|
|
@@ -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 _a, _VexFlowTests_NEXT_TEST_ID;
|
|
13
1
|
import { Factory, Renderer, VexFlow } from '../src/index.js';
|
|
14
2
|
import { Metrics } from '../src/metrics.js';
|
|
15
3
|
import { globalObject } from '../src/util.js';
|
|
@@ -109,7 +97,7 @@ const NODE_TEST_CONFIG = {
|
|
|
109
97
|
};
|
|
110
98
|
export class VexFlowTests {
|
|
111
99
|
static register(test) {
|
|
112
|
-
|
|
100
|
+
VexFlowTests.tests.push(test);
|
|
113
101
|
}
|
|
114
102
|
static parseJobOptions(runOptions) {
|
|
115
103
|
let { jobs, job } = runOptions || { jobs: 1, job: 0 };
|
|
@@ -133,8 +121,8 @@ export class VexFlowTests {
|
|
|
133
121
|
};
|
|
134
122
|
}
|
|
135
123
|
static run(runOptions) {
|
|
136
|
-
const { jobs, job } =
|
|
137
|
-
|
|
124
|
+
const { jobs, job } = VexFlowTests.parseJobOptions(runOptions);
|
|
125
|
+
VexFlowTests.tests.forEach((test, idx) => {
|
|
138
126
|
if (jobs === 1 || idx % jobs === job) {
|
|
139
127
|
test.Start();
|
|
140
128
|
}
|
|
@@ -144,17 +132,16 @@ export class VexFlowTests {
|
|
|
144
132
|
NODE_TEST_CONFIG.fontStacks = fontStacks;
|
|
145
133
|
}
|
|
146
134
|
static generateTestID(prefix) {
|
|
147
|
-
|
|
148
|
-
return prefix + '_' + (__classPrivateFieldSet(_b = _a, _a, (_d = __classPrivateFieldGet(_b, _a, "f", _VexFlowTests_NEXT_TEST_ID), _c = _d++, _d), "f", _VexFlowTests_NEXT_TEST_ID), _c);
|
|
135
|
+
return prefix + '_' + VexFlowTests.NEXT_TEST_ID++;
|
|
149
136
|
}
|
|
150
137
|
static runTests(name, testFunc, params) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
138
|
+
VexFlowTests.runCanvasTest(name, testFunc, params);
|
|
139
|
+
VexFlowTests.runSVGTest(name, testFunc, params);
|
|
140
|
+
VexFlowTests.runNodeTest(name, testFunc, params);
|
|
154
141
|
}
|
|
155
142
|
static runTextTests(name, testFunc, params) {
|
|
156
|
-
|
|
157
|
-
|
|
143
|
+
VexFlowTests.runCanvasText(name, testFunc, params);
|
|
144
|
+
VexFlowTests.runSVGText(name, testFunc, params);
|
|
158
145
|
}
|
|
159
146
|
static createTest(elementId, testTitle, tagName, titleId = '') {
|
|
160
147
|
const anchorTestTitle = `<a href="#${titleId}">${testTitle}</a>`;
|
|
@@ -169,38 +156,38 @@ export class VexFlowTests {
|
|
|
169
156
|
return new Factory({ renderer: { elementId, backend, width, height } });
|
|
170
157
|
}
|
|
171
158
|
static runCanvasTest(name, testFunc, params) {
|
|
172
|
-
if (
|
|
159
|
+
if (VexFlowTests.RUN_CANVAS_TESTS) {
|
|
173
160
|
const helper = null;
|
|
174
|
-
|
|
161
|
+
VexFlowTests.runWithParams(Object.assign(Object.assign({}, CANVAS_TEST_CONFIG), { name, testFunc, params, helper }));
|
|
175
162
|
}
|
|
176
163
|
}
|
|
177
164
|
static runCanvasText(name, testFunc, params) {
|
|
178
|
-
if (
|
|
165
|
+
if (VexFlowTests.RUN_CANVAS_TESTS) {
|
|
179
166
|
const helper = null;
|
|
180
|
-
|
|
167
|
+
VexFlowTests.runWithParams(Object.assign(Object.assign({}, CANVAS_TEXT_CONFIG), { name, testFunc, params, helper }));
|
|
181
168
|
}
|
|
182
169
|
}
|
|
183
170
|
static runSVGTest(name, testFunc, params) {
|
|
184
|
-
if (
|
|
171
|
+
if (VexFlowTests.RUN_SVG_TESTS) {
|
|
185
172
|
const helper = null;
|
|
186
|
-
|
|
173
|
+
VexFlowTests.runWithParams(Object.assign(Object.assign({}, SVG_TEST_CONFIG), { name, testFunc, params, helper }));
|
|
187
174
|
}
|
|
188
175
|
}
|
|
189
176
|
static runSVGText(name, testFunc, params) {
|
|
190
|
-
if (
|
|
177
|
+
if (VexFlowTests.RUN_SVG_TESTS) {
|
|
191
178
|
const helper = null;
|
|
192
|
-
|
|
179
|
+
VexFlowTests.runWithParams(Object.assign(Object.assign({}, SVG_TEXT_CONFIG), { name, testFunc, params, helper }));
|
|
193
180
|
}
|
|
194
181
|
}
|
|
195
182
|
static runNodeTest(name, testFunc, params) {
|
|
196
|
-
if (
|
|
197
|
-
const helper =
|
|
198
|
-
|
|
183
|
+
if (VexFlowTests.RUN_NODE_TESTS) {
|
|
184
|
+
const helper = VexFlowTests.runNodeTestHelper;
|
|
185
|
+
VexFlowTests.runWithParams(Object.assign(Object.assign({}, NODE_TEST_CONFIG), { name, testFunc, params, helper }));
|
|
199
186
|
}
|
|
200
187
|
}
|
|
201
188
|
static runNodeTestHelper(fontName, element) {
|
|
202
189
|
if (Renderer.lastContext !== undefined) {
|
|
203
|
-
const fileName =
|
|
190
|
+
const fileName = VexFlowTests.NODE_IMAGEDIR +
|
|
204
191
|
'/' +
|
|
205
192
|
sanitize(QUnit.moduleName) +
|
|
206
193
|
'.' +
|
|
@@ -210,7 +197,7 @@ export class VexFlowTests {
|
|
|
210
197
|
'.jsdom.png';
|
|
211
198
|
const imageData = element.toDataURL().split(';base64,').pop();
|
|
212
199
|
const imageBuffer = Buffer.from(imageData, 'base64');
|
|
213
|
-
|
|
200
|
+
VexFlowTests.shims.fs.writeFileSync(fileName, imageBuffer, { encoding: 'base64' });
|
|
214
201
|
}
|
|
215
202
|
}
|
|
216
203
|
static runWithParams({ fontStacks, testFunc, name, params, backend, tagName, testType, helper }) {
|
|
@@ -222,12 +209,12 @@ export class VexFlowTests {
|
|
|
222
209
|
QUnit.test(name, (assert) => {
|
|
223
210
|
useTempFontStack(fontStackName);
|
|
224
211
|
const sanitizedFontStackName = sanitize(fontStackName);
|
|
225
|
-
const elementId =
|
|
212
|
+
const elementId = VexFlowTests.generateTestID(`${testTypeLowerCase}_` + sanitizedFontStackName);
|
|
226
213
|
const moduleName = assert.test.module.name;
|
|
227
214
|
const title = moduleName + ' › ' + name + ` › ${testType} + ${fontStackName}`;
|
|
228
215
|
const prefix = testTypeLowerCase + '_';
|
|
229
216
|
const titleId = `${prefix}${sanitize(moduleName)}.${sanitize(name)}.${sanitizedFontStackName}`;
|
|
230
|
-
const element =
|
|
217
|
+
const element = VexFlowTests.createTest(elementId, title, tagName, titleId);
|
|
231
218
|
const options = { elementId, params, assert, backend };
|
|
232
219
|
const isSVG = backend === Renderer.Backends.SVG;
|
|
233
220
|
const contextBuilder = isSVG ? Renderer.getSVGContext : Renderer.getCanvasContext;
|
|
@@ -268,7 +255,6 @@ export class VexFlowTests {
|
|
|
268
255
|
ctx.stroke();
|
|
269
256
|
}
|
|
270
257
|
}
|
|
271
|
-
_a = VexFlowTests;
|
|
272
258
|
VexFlowTests.tests = [];
|
|
273
259
|
VexFlowTests.RUN_CANVAS_TESTS = true;
|
|
274
260
|
VexFlowTests.RUN_SVG_TESTS = true;
|
|
@@ -287,7 +273,7 @@ VexFlowTests.FONT_STACKS = {
|
|
|
287
273
|
Petaluma: ['Petaluma', 'Petaluma Script'],
|
|
288
274
|
Sebastian: ['Sebastian', 'Nepomuk'],
|
|
289
275
|
};
|
|
290
|
-
|
|
276
|
+
VexFlowTests.NEXT_TEST_ID = 0;
|
|
291
277
|
export const concat = (a, b) => a.concat(b);
|
|
292
278
|
export const MAJOR_KEYS = [
|
|
293
279
|
'C',
|