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;