vexflow 5.0.0-beta.0 → 5.0.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.
@@ -165,6 +165,7 @@ export class Articulation extends Modifier {
165
165
  }
166
166
  articulation.setTextLine(state.topTextLine);
167
167
  state.topTextLine += increment;
168
+ articulation.setOrigin(0.5, 1);
168
169
  }
169
170
  else if (articulation.getPosition() === BELOW) {
170
171
  let noteLine = Math.max(lines - note.getLineNumber(), 0);
@@ -178,6 +179,7 @@ export class Articulation extends Modifier {
178
179
  }
179
180
  articulation.setTextLine(state.textLine);
180
181
  state.textLine += increment;
182
+ articulation.setOrigin(0.5, 0);
181
183
  }
182
184
  });
183
185
  const width = articulations
@@ -251,12 +253,10 @@ export class Articulation extends Modifier {
251
253
  const initialOffset = getInitialOffset(note, position);
252
254
  let y = {
253
255
  [ABOVE]: () => {
254
- this.setOrigin(0.5, 1);
255
256
  const y = getTopY(note, textLine) - (textLine + initialOffset) * staffSpace;
256
257
  return shouldSitOutsideStaff ? Math.min(stave.getYForTopText(Articulation.INITIAL_OFFSET), y) : y;
257
258
  },
258
259
  [BELOW]: () => {
259
- this.setOrigin(0.5, 0);
260
260
  const y = getBottomY(note, textLine) + (textLine + initialOffset) * staffSpace;
261
261
  return shouldSitOutsideStaff ? Math.max(stave.getYForBottomText(Articulation.INITIAL_OFFSET), y) : y;
262
262
  },
@@ -28,6 +28,7 @@ export * from './gracetabnote.js';
28
28
  export * from './keymanager.js';
29
29
  export * from './keysignature.js';
30
30
  export * from './keysignote.js';
31
+ export * from './metrics.js';
31
32
  export * from './modifier.js';
32
33
  export * from './modifiercontext.js';
33
34
  export * from './multimeasurerest.js';
@@ -1,6 +1,7 @@
1
1
  import { BoundingBox } from './boundingbox.js';
2
2
  import { Element } from './element.js';
3
3
  import { Glyphs } from './glyphs.js';
4
+ import { Stave } from './stave.js';
4
5
  import { StaveModifier, StaveModifierPosition } from './stavemodifier.js';
5
6
  import { Tables } from './tables.js';
6
7
  import { defined } from './util.js';
@@ -65,6 +66,10 @@ export class KeySignature extends StaveModifier {
65
66
  stave.addModifier(this);
66
67
  return this;
67
68
  }
69
+ setStave(stave) {
70
+ this.formatted = false;
71
+ return super.setStave(stave);
72
+ }
68
73
  getBoundingBox() {
69
74
  if (!this.formatted)
70
75
  this.format();
@@ -167,7 +172,11 @@ export class KeySignature extends StaveModifier {
167
172
  }
168
173
  }
169
174
  format() {
170
- const stave = this.checkStave();
175
+ let stave = this.getStave();
176
+ if (!stave) {
177
+ stave = new Stave(0, 0, 100);
178
+ this.setStave(stave);
179
+ }
171
180
  this.width = 0;
172
181
  this.children = [];
173
182
  this.accList = Tables.keySignature(defined(this.keySpec));
@@ -50,7 +50,7 @@ export class Stave extends Element {
50
50
  this.endClef = undefined;
51
51
  this.options = Object.assign({ verticalBarWidth: 10, numLines: 5, leftBar: true, rightBar: true, spacingBetweenLinesPx: Tables.STAVE_LINE_DISTANCE, spaceAboveStaffLn: 4, spaceBelowStaffLn: 4, topTextPosition: 1, bottomTextPosition: 4, lineConfig: [] }, options);
52
52
  this.bounds = { x: this.x, y: this.y, w: this.width, h: 0 };
53
- this.defaultLedgerLineStyle = { strokeStyle: '#444', lineWidth: 1.4 };
53
+ this.defaultLedgerLineStyle = { strokeStyle: '#444', lineWidth: 2 };
54
54
  this.resetLines();
55
55
  this.addModifier(new Barline(this.options.leftBar ? BarlineType.SINGLE : BarlineType.NONE));
56
56
  this.addEndModifier(new Barline(this.options.rightBar ? BarlineType.SINGLE : BarlineType.NONE));
@@ -103,12 +103,11 @@ export class Stave extends Element {
103
103
  return this;
104
104
  }
105
105
  getTopLineTopY() {
106
- var _a;
107
- return this.getYForLine(0) - ((_a = this.getStyle().lineWidth) !== null && _a !== void 0 ? _a : 1) / 2;
106
+ return this.getYForLine(0);
108
107
  }
109
108
  getBottomLineBottomY() {
110
109
  var _a;
111
- return this.getYForLine(this.getNumLines() - 1) + ((_a = this.getStyle().lineWidth) !== null && _a !== void 0 ? _a : 1) / 2;
110
+ return this.getYForLine(this.getNumLines() - 1) + ((_a = this.getStyle().lineWidth) !== null && _a !== void 0 ? _a : 1);
112
111
  }
113
112
  setX(x) {
114
113
  const shift = x - this.x;
@@ -449,6 +448,7 @@ export class Stave extends Element {
449
448
  this.formatted = true;
450
449
  }
451
450
  draw() {
451
+ var _a;
452
452
  const ctx = this.checkContext();
453
453
  this.setRendered();
454
454
  ctx.openGroup('stave', this.getAttribute('id'));
@@ -458,12 +458,14 @@ export class Stave extends Element {
458
458
  const width = this.width;
459
459
  const x = this.x;
460
460
  let y;
461
+ const lineWidth = (_a = this.getStyle().lineWidth) !== null && _a !== void 0 ? _a : 1;
462
+ const lineWidthCorrection = lineWidth % 2 === 0 ? 0 : 0.5;
461
463
  for (let line = 0; line < numLines; line++) {
462
464
  y = this.getYForLine(line);
463
465
  if (this.options.lineConfig[line].visible) {
464
466
  ctx.beginPath();
465
- ctx.moveTo(x, y);
466
- ctx.lineTo(x + width, y);
467
+ ctx.moveTo(x, y + lineWidthCorrection);
468
+ ctx.lineTo(x + width, y + lineWidthCorrection);
467
469
  ctx.stroke();
468
470
  }
469
471
  }
@@ -176,7 +176,6 @@ export class Tuplet extends Element {
176
176
  const ctx = this.checkContext();
177
177
  let xPos = 0;
178
178
  let yPos = 0;
179
- this.setRendered();
180
179
  const firstNote = this.notes[0];
181
180
  const lastNote = this.notes[this.notes.length - 1];
182
181
  if (!bracketed) {
@@ -190,6 +189,7 @@ export class Tuplet extends Element {
190
189
  yPos = this.getYPosition();
191
190
  const notationCenterX = xPos + this.width / 2;
192
191
  const notationStartX = notationCenterX - this.textElement.getWidth() / 2;
192
+ ctx.openGroup('tuplet', this.getAttribute('id'));
193
193
  if (bracketed) {
194
194
  const lineWidth = this.width / 2 - this.textElement.getWidth() / 2 - 5;
195
195
  if (lineWidth > 0) {
@@ -200,5 +200,9 @@ export class Tuplet extends Element {
200
200
  }
201
201
  }
202
202
  this.textElement.renderText(ctx, notationStartX, yPos + this.textElement.getHeight() / 2 + (location === Tuplet.LOCATION_TOP ? -1 : 1) * textYOffset);
203
+ const bb = this.getBoundingBox();
204
+ ctx.pointerRect(bb.getX(), bb.getY(), bb.getW(), bb.getH());
205
+ ctx.closeGroup();
206
+ this.setRendered();
203
207
  }
204
208
  }
@@ -1,3 +1,3 @@
1
- export const VERSION = '5.0.0-beta.0';
2
- export const ID = '2daeb4def8b685227f2a3c924177b40ddcc5bda3';
3
- export const DATE = '2024-09-12T19:16:57.446Z';
1
+ export const VERSION = '5.0.0';
2
+ export const ID = '0ca6f889545c33cce851b420c24945f6eb685aeb';
3
+ export const DATE = '2025-03-05T17:05:43.991Z';
@@ -28,6 +28,7 @@ export * from './gracetabnote';
28
28
  export * from './keymanager';
29
29
  export * from './keysignature';
30
30
  export * from './keysignote';
31
+ export * from './metrics';
31
32
  export * from './modifier';
32
33
  export * from './modifiercontext';
33
34
  export * from './multimeasurerest';
@@ -29,6 +29,7 @@ export declare class KeySignature extends StaveModifier {
29
29
  }[];
30
30
  } | undefined;
31
31
  addToStave(stave: Stave): this;
32
+ setStave(stave: Stave): this;
32
33
  getBoundingBox(): BoundingBox;
33
34
  protected calculateDimensions(): void;
34
35
  protected convertAccLines(clef: string, type?: string, accList?: {
@@ -40,6 +41,10 @@ export declare class KeySignature extends StaveModifier {
40
41
  setKeySig(keySpec: string, cancelKeySpec?: string, alterKeySpec?: string[]): this;
41
42
  alterKey(alterKeySpec: string[]): this;
42
43
  protected convertToAlterAccList(alterKeySpec: string[]): void;
44
+ /**
45
+ * Format and position the modifier.
46
+ * If no stave is set, a dummy stave is created.
47
+ */
43
48
  format(): void;
44
49
  draw(): void;
45
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vexflow",
3
- "version": "5.0.0-beta.0",
3
+ "version": "5.0.0",
4
4
  "description": "A JavaScript library for rendering music notation and guitar tablature.",
5
5
  "exports": {
6
6
  ".": {
@@ -47,13 +47,13 @@
47
47
  "url": "https://github.com/vexflow/vexflow/issues"
48
48
  },
49
49
  "devDependencies": {
50
- "@eslint/compat": "^1.1.1",
51
- "@eslint/eslintrc": "^3.1.0",
52
- "@eslint/js": "^9.10.0",
53
- "@types/node": "^22.5.4",
54
- "@types/qunit": "^2.19.10",
55
- "@typescript-eslint/eslint-plugin": "^8.4.0",
56
- "@typescript-eslint/parser": "^8.4.0",
50
+ "@eslint/compat": "^1.2.6",
51
+ "@eslint/eslintrc": "^3.2.0",
52
+ "@eslint/js": "^9.19.0",
53
+ "@types/node": "^22.13.1",
54
+ "@types/qunit": "^2.19.12",
55
+ "@typescript-eslint/eslint-plugin": "^8.23.0",
56
+ "@typescript-eslint/parser": "^8.23.0",
57
57
  "@vexflow-fonts/academico": "^1.0.1",
58
58
  "@vexflow-fonts/bravura": "^1.0.2",
59
59
  "@vexflow-fonts/bravuratext": "^1.0.0",
@@ -81,16 +81,16 @@
81
81
  "@vexflow-fonts/robotoslab": "^1.0.0",
82
82
  "@vexflow-fonts/sebastian": "^1.0.1",
83
83
  "@vexflow-fonts/sebastiantext": "^1.0.0",
84
- "canvas": "^2.11.2",
84
+ "canvas": "^3.1.0",
85
85
  "circular-dependency-plugin": "^5.2.2",
86
- "concurrently": "^8.2.2",
87
- "eslint": "^8.57.0",
88
- "eslint-config-prettier": "^9.1.0",
89
- "eslint-plugin-import": "^2.30.0",
90
- "eslint-plugin-prettier": "^5.2.1",
86
+ "concurrently": "^9.1.2",
87
+ "eslint": "^9.19.0",
88
+ "eslint-config-prettier": "^10.0.1",
89
+ "eslint-plugin-import": "^2.31.0",
90
+ "eslint-plugin-prettier": "^5.2.3",
91
91
  "eslint-plugin-simple-import-sort": "^12.1.1",
92
92
  "fork-ts-checker-webpack-plugin": "^9.0.2",
93
- "globals": "^15.9.0",
93
+ "globals": "^15.14.0",
94
94
  "grunt": "^1.6.1",
95
95
  "grunt-cli": "^1.5.0",
96
96
  "grunt-contrib-clean": "^2.0.1",
@@ -98,22 +98,22 @@
98
98
  "grunt-contrib-qunit": "^10.1.1",
99
99
  "grunt-eslint": "^25.0.0",
100
100
  "grunt-webpack": "^7.0.0",
101
- "jsdom": "^25.0.0",
102
- "jspdf": "^2.5.1",
101
+ "jsdom": "^26.0.0",
102
+ "jspdf": "^2.5.2",
103
103
  "opener": "^1.5.2",
104
104
  "opentype.js": "^1.3.4",
105
- "prettier": "^3.3.3",
106
- "puppeteer": "^23.3.0",
107
- "qunit": "^2.22.0",
105
+ "prettier": "^3.4.2",
106
+ "puppeteer": "^24.2.0",
107
+ "qunit": "^2.24.1",
108
108
  "recursive-copy": "^2.0.14",
109
- "release-it": "^17.6.0",
109
+ "release-it": "^18.1.2",
110
110
  "string-replace-loader": "^3.1.0",
111
111
  "svg2pdf.js": "^2.2.4",
112
- "terser-webpack-plugin": "^5.3.10",
113
- "ts-loader": "^9.5.1",
114
- "tsc-watch": "^6.2.0",
115
- "typescript": "^5.5.4",
116
- "webpack": "^5.94.0"
112
+ "terser-webpack-plugin": "^5.3.11",
113
+ "ts-loader": "^9.5.2",
114
+ "tsc-watch": "^6.2.1",
115
+ "typescript": "^5.7.3",
116
+ "webpack": "^5.97.1"
117
117
  },
118
118
  "scripts": {
119
119
  "start": "grunt",