vexflow 4.0.1 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +2 -2
  2. package/build/cjs/vexflow-bravura.js +2 -2
  3. package/build/cjs/vexflow-bravura.js.map +1 -1
  4. package/build/cjs/vexflow-core.js +2 -2
  5. package/build/cjs/vexflow-core.js.map +1 -1
  6. package/build/cjs/vexflow-debug-with-tests.js +91 -19
  7. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  8. package/build/cjs/vexflow-debug.js +37 -16
  9. package/build/cjs/vexflow-debug.js.map +1 -1
  10. package/build/cjs/vexflow-gonville.js +2 -2
  11. package/build/cjs/vexflow-gonville.js.map +1 -1
  12. package/build/cjs/vexflow-petaluma.js +2 -2
  13. package/build/cjs/vexflow-petaluma.js.map +1 -1
  14. package/build/cjs/vexflow.js +2 -2
  15. package/build/cjs/vexflow.js.map +1 -1
  16. package/build/esm/src/beam.js +2 -0
  17. package/build/esm/src/stave.js +2 -2
  18. package/build/esm/src/staveconnector.js +6 -3
  19. package/build/esm/src/stavenote.js +9 -1
  20. package/build/esm/src/stavesection.js +9 -6
  21. package/build/esm/src/version.js +3 -3
  22. package/build/esm/tests/formatter_tests.js +53 -2
  23. package/build/esm/tests/stave_tests.js +1 -1
  24. package/build/types/src/factory.d.ts +2 -2
  25. package/build/types/src/stave.d.ts +1 -1
  26. package/build/types/src/staveconnector.d.ts +13 -15
  27. package/build/types/src/stavesection.d.ts +2 -1
  28. package/build/types/src/system.d.ts +2 -2
  29. package/package.json +3 -1
  30. package/releases/vexflow-debug.js +30441 -0
  31. package/releases/vexflow-min.js +6 -0
  32. package/src/beam.ts +2 -0
  33. package/src/factory.ts +2 -2
  34. package/src/stave.ts +2 -2
  35. package/src/staveconnector.ts +43 -9
  36. package/src/stavenote.ts +7 -1
  37. package/src/stavesection.ts +10 -6
  38. package/src/system.ts +2 -2
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * VexFlow 4.0.1 2022-03-24T20:35:28.447Z 409af72ce03dd6da1919ee6c7de72c62aac0644e
2
+ * VexFlow 4.0.2 2022-04-28T00:14:05.094Z a968cfa5453a34ff0f8bb8bc882d08ef44f62cea
3
3
  * Copyright (c) 2010 Mohit Muthanna Cheppudira <mohit@muthanna.com>
4
4
  * https://www.vexflow.com https://github.com/0xfe/vexflow
5
5
  */
@@ -29,9 +29,9 @@ __webpack_require__.r(__webpack_exports__);
29
29
  /* harmony export */ "ID": () => (/* binding */ ID),
30
30
  /* harmony export */ "DATE": () => (/* binding */ DATE)
31
31
  /* harmony export */ });
32
- const VERSION = '4.0.1';
33
- const ID = '409af72ce03dd6da1919ee6c7de72c62aac0644e';
34
- const DATE = '2022-03-24T20:35:28.447Z';
32
+ const VERSION = '4.0.2';
33
+ const ID = 'a968cfa5453a34ff0f8bb8bc882d08ef44f62cea';
34
+ const DATE = '2022-04-28T00:14:05.094Z';
35
35
 
36
36
 
37
37
  /***/ }),
@@ -2040,6 +2040,8 @@ class Beam extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
2040
2040
  this.notes.forEach((note) => {
2041
2041
  const stem = note.getStem();
2042
2042
  if (stem) {
2043
+ const stem_x = note.getStemX();
2044
+ stem.setNoteHeadXBounds(stem_x, stem_x);
2043
2045
  ctx.openGroup('stem', note.getAttribute('id') + '-stem');
2044
2046
  stem.setContext(ctx).draw();
2045
2047
  ctx.closeGroup();
@@ -21883,8 +21885,8 @@ class Stave extends _element__WEBPACK_IMPORTED_MODULE_2__.Element {
21883
21885
  return this;
21884
21886
  }
21885
21887
  // Section functions
21886
- setSection(section, y, xOffset = 0, fontSize) {
21887
- const staveSection = new _stavesection__WEBPACK_IMPORTED_MODULE_8__.StaveSection(section, this.x + xOffset, y);
21888
+ setSection(section, y, xOffset = 0, fontSize, drawRect = true) {
21889
+ const staveSection = new _stavesection__WEBPACK_IMPORTED_MODULE_8__.StaveSection(section, this.x + xOffset, y, drawRect);
21888
21890
  if (fontSize)
21889
21891
  staveSection.setFontSize(fontSize);
21890
21892
  this.modifiers.push(staveSection);
@@ -22616,12 +22618,20 @@ class StaveConnector extends _element__WEBPACK_IMPORTED_MODULE_0__.Element {
22616
22618
  * @param type see {@link StaveConnector.type} & {@link StaveConnector.typeString}
22617
22619
  */
22618
22620
  setType(type) {
22619
- type = typeof type === 'string' ? StaveConnector.typeString[type] : type;
22620
- if (type >= StaveConnector.type.SINGLE_RIGHT && type <= StaveConnector.type.NONE) {
22621
- this.type = type;
22621
+ const newType = typeof type === 'string' ? StaveConnector.typeString[type] : type;
22622
+ // Be certain that the type is a valid type:
22623
+ if (Object.values(StaveConnector.type).includes(newType)) {
22624
+ this.type = newType;
22622
22625
  }
22623
22626
  return this;
22624
22627
  }
22628
+ /**
22629
+ * Get type.
22630
+ * @returns number {@link StaveConnector.type}
22631
+ */
22632
+ getType() {
22633
+ return this.type;
22634
+ }
22625
22635
  /** Set optional associated Text. */
22626
22636
  setText(text, options = {}) {
22627
22637
  this.texts.push({
@@ -23624,7 +23634,7 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_4__.StemmableNot
23624
23634
  }
23625
23635
  } //Very close whole notes
23626
23636
  }
23627
- else {
23637
+ else if (lineDiff < 1) {
23628
23638
  xShift = voiceXShift + 2;
23629
23639
  if (noteU.stemDirection === noteL.stemDirection) {
23630
23640
  // upper voice is middle voice, so shift it right
@@ -23635,6 +23645,14 @@ class StaveNote extends _stemmablenote__WEBPACK_IMPORTED_MODULE_4__.StemmableNot
23635
23645
  noteL.note.setXShift(xShift);
23636
23646
  }
23637
23647
  }
23648
+ else if (noteU.note.hasStem()) {
23649
+ noteU.stemDirection = -noteU.note.getStemDirection();
23650
+ noteU.note.setStemDirection(noteU.stemDirection);
23651
+ }
23652
+ else if (noteL.note.hasStem()) {
23653
+ noteL.stemDirection = -noteL.note.getStemDirection();
23654
+ noteL.note.setStemDirection(noteL.stemDirection);
23655
+ }
23638
23656
  }
23639
23657
  }
23640
23658
  // format complete
@@ -24646,13 +24664,14 @@ __webpack_require__.r(__webpack_exports__);
24646
24664
 
24647
24665
 
24648
24666
  class StaveSection extends _stavemodifier__WEBPACK_IMPORTED_MODULE_1__.StaveModifier {
24649
- constructor(section, x, shift_y) {
24667
+ constructor(section, x, shift_y, drawRect = true) {
24650
24668
  super();
24651
24669
  this.setWidth(16);
24652
24670
  this.section = section;
24653
24671
  this.x = x;
24654
24672
  this.shift_x = 0;
24655
24673
  this.shift_y = shift_y;
24674
+ this.drawRect = drawRect;
24656
24675
  this.resetFont();
24657
24676
  }
24658
24677
  static get CATEGORY() {
@@ -24685,12 +24704,14 @@ class StaveSection extends _stavemodifier__WEBPACK_IMPORTED_MODULE_1__.StaveModi
24685
24704
  const width = textWidth + 2 * paddingX; // add left & right padding
24686
24705
  const height = textHeight + 2 * paddingY; // add top & bottom padding
24687
24706
  // Seems to be a good default y
24688
- const y = stave.getYForTopText(2) + this.shift_y;
24707
+ const y = stave.getYForTopText(1.5) + this.shift_y;
24689
24708
  const x = this.x + shift_x;
24690
- ctx.beginPath();
24691
- ctx.setLineWidth(rectWidth);
24692
- ctx.rect(x, y + textMeasurements.y - paddingY, width, height);
24693
- ctx.stroke();
24709
+ if (this.drawRect) {
24710
+ ctx.beginPath();
24711
+ ctx.setLineWidth(rectWidth);
24712
+ ctx.rect(x, y + textMeasurements.y - paddingY, width, height);
24713
+ ctx.stroke();
24714
+ }
24694
24715
  ctx.fillText(this.section, x + paddingX, y);
24695
24716
  ctx.restore();
24696
24717
  return this;
@@ -37556,6 +37577,7 @@ const FormatterTests = {
37556
37577
  QUnit.module('Formatter');
37557
37578
  test('TickContext Building', buildTickContexts);
37558
37579
  const run = _vexflow_test_helpers__WEBPACK_IMPORTED_MODULE_0__.VexFlowTests.runTests;
37580
+ run('Penultimate Note Padding', penultimateNote);
37559
37581
  run('Whitespace and justify', rightJustify);
37560
37582
  run('Notehead padding', noteHeadPadding);
37561
37583
  run('Justification and alignment with accidentals', accidentalJustification);
@@ -37623,7 +37645,7 @@ function buildTickContexts() {
37623
37645
  ok(tickables1[1].getX() < tickables2[1].getX(), 'Second note of voice 2 is to the right of the second note of voice 1');
37624
37646
  }
37625
37647
  function rightJustify(options) {
37626
- const f = _vexflow_test_helpers__WEBPACK_IMPORTED_MODULE_0__.VexFlowTests.makeFactory(options, 1200, 300);
37648
+ const f = _vexflow_test_helpers__WEBPACK_IMPORTED_MODULE_0__.VexFlowTests.makeFactory(options, 1200, 150);
37627
37649
  const getTickables = (time, n, duration, duration2) => {
37628
37650
  const tickar = [];
37629
37651
  let i = 0;
@@ -37635,7 +37657,7 @@ function rightJustify(options) {
37635
37657
  };
37636
37658
  const renderTest = (time, n, duration, duration2, x, width) => {
37637
37659
  const formatter = f.Formatter();
37638
- const stave = f.Stave({ x, y: 40, width });
37660
+ const stave = f.Stave({ x, y: 20, width });
37639
37661
  // stave.addClef('treble').addTimeSignature('4/4');
37640
37662
  const voice = getTickables(time, n, duration, duration2);
37641
37663
  formatter.joinVoices([voice]).formatToStave([voice], stave);
@@ -37648,6 +37670,54 @@ function rightJustify(options) {
37648
37670
  renderTest({ num_beats: 3, beat_value: 4, resolution: 4 * 4096 }, 6, '8', '8', 910, 300);
37649
37671
  ok(true);
37650
37672
  }
37673
+ function penultimateNote(options) {
37674
+ const f = _vexflow_test_helpers__WEBPACK_IMPORTED_MODULE_0__.VexFlowTests.makeFactory(options, 500, 550);
37675
+ const score = f.EasyScore();
37676
+ const staffWidth = 310;
37677
+ let system = undefined;
37678
+ let voices = [];
37679
+ let notes = [];
37680
+ let note = undefined;
37681
+ let stave = undefined;
37682
+ let y = 10;
37683
+ const draw = (softmax) => {
37684
+ system = f.System({
37685
+ width: staffWidth,
37686
+ y,
37687
+ formatOptions: { align_rests: true },
37688
+ details: { softmaxFactor: softmax },
37689
+ });
37690
+ notes = [];
37691
+ voices = [];
37692
+ note = score.notes('C4/8/r', { clef: 'bass' })[0];
37693
+ notes.push(note);
37694
+ note = score.notes('A3/8', { stem: 'up', clef: 'bass' })[0];
37695
+ notes.push(note);
37696
+ note = score.notes('C4/4', { stem: 'up', clef: 'bass' })[0];
37697
+ notes.push(note);
37698
+ voices.push(score.voice(notes).setMode(2));
37699
+ notes = [];
37700
+ note = score.notes('( F3 A3 )/4', { stem: 'down', clef: 'bass' })[0];
37701
+ notes.push(note);
37702
+ note = score.notes('B4/4/r', {})[0];
37703
+ notes.push(note);
37704
+ voices.push(score.voice(notes).setMode(2));
37705
+ notes = [];
37706
+ stave = system.addStave({ voices: voices });
37707
+ stave.addClef('bass');
37708
+ stave.addTimeSignature('2/4');
37709
+ voices = [];
37710
+ f.draw();
37711
+ f.getContext().fillText(`softmax: ${softmax.toString()}`, staffWidth + 20, y + 50);
37712
+ y += 100;
37713
+ };
37714
+ draw(100);
37715
+ draw(10);
37716
+ draw(5);
37717
+ draw(2);
37718
+ draw(1.5);
37719
+ ok(true);
37720
+ }
37651
37721
  function noteHeadPadding(options) {
37652
37722
  const registry = new _src_registry__WEBPACK_IMPORTED_MODULE_13__.Registry();
37653
37723
  _src_registry__WEBPACK_IMPORTED_MODULE_13__.Registry.enableDefaultRegistry(registry);
@@ -38024,6 +38094,7 @@ function proportional(options) {
38024
38094
  }
38025
38095
  function softMax(options) {
38026
38096
  const f = _vexflow_test_helpers__WEBPACK_IMPORTED_MODULE_0__.VexFlowTests.makeFactory(options, 550, 500);
38097
+ const textX = 450 / 0.8;
38027
38098
  f.getContext().scale(0.8, 0.8);
38028
38099
  function draw(y, factor) {
38029
38100
  const score = f.EasyScore();
@@ -38045,6 +38116,7 @@ function softMax(options) {
38045
38116
  .addClef('treble')
38046
38117
  .addTimeSignature('5/4');
38047
38118
  f.draw();
38119
+ f.getContext().fillText(`softmax: ${factor.toString()}`, textX, y + 50);
38048
38120
  ok(true);
38049
38121
  }
38050
38122
  draw(50, 1);
@@ -42816,7 +42888,7 @@ function drawMultipleMeasures(options, contextBuilder) {
42816
42888
  const staveBar1 = new _src_stave__WEBPACK_IMPORTED_MODULE_7__.Stave(10, 50, 200);
42817
42889
  staveBar1.setBegBarType(_src_stavebarline__WEBPACK_IMPORTED_MODULE_8__.BarlineType.REPEAT_BEGIN);
42818
42890
  staveBar1.setEndBarType(_src_stavebarline__WEBPACK_IMPORTED_MODULE_8__.BarlineType.DOUBLE);
42819
- staveBar1.setSection('A', 0, 0, (_a = options.params) === null || _a === void 0 ? void 0 : _a.fontSize);
42891
+ staveBar1.setSection('A', 0, 0, (_a = options.params) === null || _a === void 0 ? void 0 : _a.fontSize, false);
42820
42892
  staveBar1.addClef('treble').setContext(ctx).draw();
42821
42893
  const notesBar1 = [
42822
42894
  new _src_stavenote__WEBPACK_IMPORTED_MODULE_9__.StaveNote({ keys: ['c/4'], duration: 'q' }),