@mcqj/vexflow 0.0.1-alpha.4 → 0.0.1-alpha.6
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 +1 -1
- package/build/cjs/vexflow-bravura.js.map +1 -1
- package/build/cjs/vexflow-core.js +1 -1
- package/build/cjs/vexflow-core.js.map +1 -1
- package/build/cjs/vexflow-debug-with-tests.js +83 -12
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +28 -12
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow.js +1 -1
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/src/formatter.js +14 -7
- package/build/esm/src/tickcontext.js +7 -2
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/voice.js +8 -0
- package/build/esm/tests/formatter_tests.js +37 -0
- package/build/types/src/tickcontext.d.ts +2 -1
- package/build/types/src/voice.d.ts +5 -0
- package/package.json +3 -2
- package/build/playwright-artifacts/.last-run.json +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! VexFlow 0.0.1-alpha.
|
|
1
|
+
/*! VexFlow 0.0.1-alpha.6 2026-09-14T15:22:16.685Z a4bb5ff157f4570b2d6149b7199b0baa4c7e3775
|
|
2
2
|
Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/vexflow/blob/main/AUTHORS.md). */
|
|
3
3
|
(function(global, factory) {
|
|
4
4
|
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define([], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.VexFlow = factory());
|
|
@@ -10138,6 +10138,7 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
10138
10138
|
this.resolutionMultiplier = 1;
|
|
10139
10139
|
this.mode = 1;
|
|
10140
10140
|
this.preFormatted = false;
|
|
10141
|
+
this.dependent = false;
|
|
10141
10142
|
this.ticksUsed = new Fraction(0, 1);
|
|
10142
10143
|
this.largestTickWidth = 0;
|
|
10143
10144
|
this.tickables = [];
|
|
@@ -10191,6 +10192,15 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
10191
10192
|
this.mode = mode;
|
|
10192
10193
|
return this;
|
|
10193
10194
|
}
|
|
10195
|
+
/** Mark this voice as dependent on the layout established by other voices. */
|
|
10196
|
+
setDependent(dependent) {
|
|
10197
|
+
this.dependent = dependent;
|
|
10198
|
+
return this;
|
|
10199
|
+
}
|
|
10200
|
+
/** Return whether this voice follows another voice's layout. */
|
|
10201
|
+
isDependent() {
|
|
10202
|
+
return this.dependent;
|
|
10203
|
+
}
|
|
10194
10204
|
/** Get the resolution multiplier for the voice. */
|
|
10195
10205
|
getResolutionMultiplier() {
|
|
10196
10206
|
return this.resolutionMultiplier;
|
|
@@ -13839,6 +13849,7 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
13839
13849
|
this.xBase = 0;
|
|
13840
13850
|
this.xOffset = 0;
|
|
13841
13851
|
this.tickables = [];
|
|
13852
|
+
this.dependentTickables = /* @__PURE__ */ new Set();
|
|
13842
13853
|
this.tickablesByVoice = {};
|
|
13843
13854
|
this.notePx = 0;
|
|
13844
13855
|
this.glyphPx = 0;
|
|
@@ -13939,9 +13950,9 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
13939
13950
|
this.currentTick = tick;
|
|
13940
13951
|
this.preFormatted = false;
|
|
13941
13952
|
}
|
|
13942
|
-
addTickable(tickable, voiceIndex) {
|
|
13953
|
+
addTickable(tickable, voiceIndex, dependent = false) {
|
|
13943
13954
|
if (!tickable) throw new RuntimeError("BadArgument", "Invalid tickable added.");
|
|
13944
|
-
if (!tickable.shouldIgnoreTicks()) {
|
|
13955
|
+
if (!dependent && !tickable.shouldIgnoreTicks()) {
|
|
13945
13956
|
const ticks = tickable.getTicks();
|
|
13946
13957
|
if (ticks.greaterThan(this.maxTicks)) {
|
|
13947
13958
|
this.maxTicks = ticks.clone();
|
|
@@ -13957,6 +13968,7 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
13957
13968
|
}
|
|
13958
13969
|
tickable.setTickContext(this);
|
|
13959
13970
|
this.tickables.push(tickable);
|
|
13971
|
+
if (dependent) this.dependentTickables.add(tickable);
|
|
13960
13972
|
this.tickablesByVoice[voiceIndex ?? 0] = tickable;
|
|
13961
13973
|
this.preFormatted = false;
|
|
13962
13974
|
return this;
|
|
@@ -13966,6 +13978,7 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
13966
13978
|
for (let i = 0; i < this.tickables.length; ++i) {
|
|
13967
13979
|
const tickable = this.tickables[i];
|
|
13968
13980
|
tickable.preFormat();
|
|
13981
|
+
if (this.dependentTickables.has(tickable)) continue;
|
|
13969
13982
|
const metrics = tickable.getMetrics();
|
|
13970
13983
|
this.leftDisplacedHeadPx = Math.max(this.leftDisplacedHeadPx, metrics.leftDisplacedHeadPx);
|
|
13971
13984
|
this.rightDisplacedHeadPx = Math.max(this.rightDisplacedHeadPx, metrics.rightDisplacedHeadPx);
|
|
@@ -14028,6 +14041,9 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
14028
14041
|
function L$8(...args) {
|
|
14029
14042
|
if (Formatter.DEBUG) log("VexFlow.Formatter", args);
|
|
14030
14043
|
}
|
|
14044
|
+
function isBarNote(tickable) {
|
|
14045
|
+
return isCategory(tickable, Category.BarNote);
|
|
14046
|
+
}
|
|
14031
14047
|
/**
|
|
14032
14048
|
* Get the rest line number of the next non-rest note(s).
|
|
14033
14049
|
* @param notes array of Notes
|
|
@@ -14335,7 +14351,7 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
14335
14351
|
staveTickToContextMap[integerTicks] = newContext;
|
|
14336
14352
|
}
|
|
14337
14353
|
tickable.addToModifierContext(staveTickToContextMap[integerTicks]);
|
|
14338
|
-
ticksUsed.add(tickable.getTicks());
|
|
14354
|
+
if (!isBarNote(tickable)) ticksUsed.add(tickable.getTicks());
|
|
14339
14355
|
});
|
|
14340
14356
|
});
|
|
14341
14357
|
this.modifierContexts.push({
|
|
@@ -14369,8 +14385,8 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
14369
14385
|
tickToContextMap[integerTicks] = newContext;
|
|
14370
14386
|
tickList.push(integerTicks);
|
|
14371
14387
|
}
|
|
14372
|
-
tickToContextMap[integerTicks].addTickable(tickable, voiceIndex);
|
|
14373
|
-
ticksUsed.add(tickable.getTicks());
|
|
14388
|
+
tickToContextMap[integerTicks].addTickable(tickable, voiceIndex, voice.isDependent());
|
|
14389
|
+
if (!isBarNote(tickable)) ticksUsed.add(tickable.getTicks());
|
|
14374
14390
|
});
|
|
14375
14391
|
});
|
|
14376
14392
|
const contexts = {
|
|
@@ -14440,7 +14456,7 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
14440
14456
|
const backVoices = contextMap[contextList[j]].getTickablesByVoice();
|
|
14441
14457
|
const matchingVoices = [];
|
|
14442
14458
|
Object.keys(voices).forEach((v) => {
|
|
14443
|
-
if (backVoices[v]) matchingVoices.push(v);
|
|
14459
|
+
if (backVoices[v] && !voices[v].getVoice().isDependent()) matchingVoices.push(v);
|
|
14444
14460
|
});
|
|
14445
14461
|
if (matchingVoices.length > 0) {
|
|
14446
14462
|
let maxTicks = 0;
|
|
@@ -14481,9 +14497,9 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
14481
14497
|
let spaceAccum = 0;
|
|
14482
14498
|
contextList.forEach((tick, index) => {
|
|
14483
14499
|
const context = contextMap[tick];
|
|
14484
|
-
|
|
14500
|
+
const ideal = idealDistances[index];
|
|
14501
|
+
if (index > 0 && ideal.fromTickable) {
|
|
14485
14502
|
const contextX = context.getX();
|
|
14486
|
-
const ideal = idealDistances[index];
|
|
14487
14503
|
const errorPx = defined(ideal.fromTickable).getX() + ideal.expectedDistance - (contextX + spaceAccum);
|
|
14488
14504
|
let negativeShiftPx = 0;
|
|
14489
14505
|
if (errorPx > 0) spaceAccum += errorPx;
|
|
@@ -18701,9 +18717,9 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
18701
18717
|
};
|
|
18702
18718
|
//#endregion
|
|
18703
18719
|
//#region src/version.ts
|
|
18704
|
-
var VERSION = "0.0.1-alpha.
|
|
18705
|
-
var ID = "
|
|
18706
|
-
var DATE = "2026-09-
|
|
18720
|
+
var VERSION = "0.0.1-alpha.6";
|
|
18721
|
+
var ID = "a4bb5ff157f4570b2d6149b7199b0baa4c7e3775";
|
|
18722
|
+
var DATE = "2026-09-14T15:22:16.685Z";
|
|
18707
18723
|
//#endregion
|
|
18708
18724
|
//#region src/vexflow.ts
|
|
18709
18725
|
var VexFlow = class {
|
|
@@ -27480,6 +27496,8 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
27480
27496
|
run("Tight", tightNotes1);
|
|
27481
27497
|
run("Tight 2", tightNotes2);
|
|
27482
27498
|
run("Annotations", annotations);
|
|
27499
|
+
VexFlowTests.test("Ignored bar notes preserve lyric tick alignment", ignoredBarNotesPreserveLyricTickAlignment);
|
|
27500
|
+
VexFlowTests.test("Dependent voices do not affect music layout", dependentVoicesDoNotAffectMusicLayout);
|
|
27483
27501
|
run("Proportional Formatting - No Tuning", proportional, {
|
|
27484
27502
|
debug: true,
|
|
27485
27503
|
iterations: 0
|
|
@@ -27501,6 +27519,59 @@ Copyright (c) 2023-present VexFlow contributors (see https://github.com/vexflow/
|
|
|
27501
27519
|
el.setText(glyph);
|
|
27502
27520
|
return el.getWidth();
|
|
27503
27521
|
}
|
|
27522
|
+
function ignoredBarNotesPreserveLyricTickAlignment(assert) {
|
|
27523
|
+
const musicNotes = Array.from({ length: 12 }, () => new StaveNote({
|
|
27524
|
+
keys: ["c/4"],
|
|
27525
|
+
duration: "8"
|
|
27526
|
+
}));
|
|
27527
|
+
const when = new TextNote({
|
|
27528
|
+
text: "When",
|
|
27529
|
+
duration: "8"
|
|
27530
|
+
});
|
|
27531
|
+
const lyricNotes = [
|
|
27532
|
+
...Array.from({ length: 6 }, () => new GhostNote({ duration: "8" })),
|
|
27533
|
+
new BarNote(),
|
|
27534
|
+
when,
|
|
27535
|
+
...Array.from({ length: 5 }, () => new TextNote({
|
|
27536
|
+
text: "",
|
|
27537
|
+
duration: "8"
|
|
27538
|
+
}))
|
|
27539
|
+
];
|
|
27540
|
+
const musicVoice = new Voice({
|
|
27541
|
+
numBeats: 6,
|
|
27542
|
+
beatValue: 4
|
|
27543
|
+
}).addTickables(musicNotes);
|
|
27544
|
+
const lyricVoice = new Voice({
|
|
27545
|
+
numBeats: 6,
|
|
27546
|
+
beatValue: 4
|
|
27547
|
+
}).addTickables(lyricNotes);
|
|
27548
|
+
new Formatter().joinVoices([musicVoice, lyricVoice]).format([musicVoice, lyricVoice], 500);
|
|
27549
|
+
assert.strictEqual(when.getTickContext(), musicNotes[6].getTickContext());
|
|
27550
|
+
}
|
|
27551
|
+
function dependentVoicesDoNotAffectMusicLayout(assert) {
|
|
27552
|
+
const makeMusicNotes = () => Array.from({ length: 4 }, () => new StaveNote({
|
|
27553
|
+
keys: ["c/4"],
|
|
27554
|
+
duration: "4"
|
|
27555
|
+
}));
|
|
27556
|
+
const baselineNotes = makeMusicNotes();
|
|
27557
|
+
const baselineVoice = new Voice("4/4").addTickables(baselineNotes);
|
|
27558
|
+
new Formatter().joinVoices([baselineVoice]).format([baselineVoice], 500);
|
|
27559
|
+
const musicNotes = makeMusicNotes();
|
|
27560
|
+
const musicVoice = new Voice("4/4").addTickables(musicNotes);
|
|
27561
|
+
const lyric = new TextNote({
|
|
27562
|
+
text: "A much wider lyric",
|
|
27563
|
+
duration: "4"
|
|
27564
|
+
});
|
|
27565
|
+
const lyricVoice = new Voice("4/4").setDependent(true).addTickables([
|
|
27566
|
+
new GhostNote({ duration: "4" }),
|
|
27567
|
+
lyric,
|
|
27568
|
+
new GhostNote({ duration: "2" })
|
|
27569
|
+
]);
|
|
27570
|
+
new Formatter().joinVoices([musicVoice, lyricVoice]).format([musicVoice, lyricVoice], 500);
|
|
27571
|
+
assert.strictEqual(lyric.getTickContext(), musicNotes[1].getTickContext());
|
|
27572
|
+
assert.strictEqual(lyric.getX(), musicNotes[1].getX());
|
|
27573
|
+
musicNotes.forEach((note, index) => assert.strictEqual(note.getX(), baselineNotes[index].getX()));
|
|
27574
|
+
}
|
|
27504
27575
|
function getResolutionMultiplier(assert) {
|
|
27505
27576
|
const [voice1, voice2] = getTestVoices();
|
|
27506
27577
|
assert.equal(voice1.getResolutionMultiplier(), voice2.getResolutionMultiplier(), "Voices with same smallest duration have the same resolution multiplier");
|