@barmark/score 0.3.0 → 0.4.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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,45 @@ package uses [semantic versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.4.0] - 2026-11-10
10
+
11
+ ### Added
12
+
13
+ - **The grid takes `columns`** (`@barmark/render`'s `columns: "shared" |
14
+ "row"`): `<barmark-score>` observes the `columns` attribute and redraws
15
+ its grid, and `renderScoreHtml` passes the option through. With
16
+ `columns="row"` each row of the grid sizes its own bars; the score view
17
+ is unchanged.
18
+ - **A `scoreerror` event says why the score couldn't be drawn.** Whenever
19
+ `<barmark-score>` shows "The score couldn't be drawn", it fires
20
+ `scoreerror` (`bubbles`, `composed`) with `detail: { reason }`, the
21
+ reason its console warning gives: Verovio failing to load or engrave, a
22
+ refused `verovio-url` or `verovio-integrity`, a `src` that could not be
23
+ loaded, or an engraving that is not clean SVG. Once per failure; a
24
+ retry the chart or a new URL enables fires again if it fails.
25
+
26
+ ### Changed
27
+
28
+ - **Requires `barmark` 0.23.0, `@barmark/render` 0.19.0** (the tempo
29
+ beat, the `rehearsal-letters` rule) **and `@barmark/musicxml` 0.9.0**
30
+ (an ending across lines), whose minor releases a caret range would not
31
+ reach.
32
+ - **The grid follows `@barmark/render`'s new `rehearsal-letters` rule**:
33
+ no letters beside a chart's own rehearsal marks (`@A`), so the grid's
34
+ headings no longer show two marks, matching the score, which draws only
35
+ the chart's own.
36
+
37
+ ### Fixed
38
+
39
+ - **The grid's tempo shows the beat it counts**, from `@barmark/render`:
40
+ "♩. = 40" in 6/8, 9/8 and 12/8, where it showed "♩ = 40".
41
+
42
+ ### Technical
43
+
44
+ - **The README says when Vite needs `worker: { format: "es" }`**: on Vite 8
45
+ too, with `verovio-url`, or the worker inlines Verovio's fallback copy
46
+ and a reader downloads Verovio twice.
47
+
9
48
  ## [0.3.0] - 2026-11-10
10
49
 
11
50
  ### Added
@@ -187,7 +226,8 @@ First release.
187
226
  needs no config; Vite 7 needs `optimizeDeps.exclude` and
188
227
  `worker.format: "es"`.
189
228
 
190
- [Unreleased]: https://github.com/kevinpeckham/barmark/compare/score-v0.3.0...HEAD
229
+ [Unreleased]: https://github.com/kevinpeckham/barmark/compare/score-v0.4.0...HEAD
230
+ [0.4.0]: https://github.com/kevinpeckham/barmark/compare/score-v0.3.0...score-v0.4.0
191
231
  [0.3.0]: https://github.com/kevinpeckham/barmark/compare/score-v0.2.0...score-v0.3.0
192
232
  [0.2.0]: https://github.com/kevinpeckham/barmark/compare/score-v0.1.1...score-v0.2.0
193
233
  [0.1.1]: https://github.com/kevinpeckham/barmark/compare/score-v0.1.0...score-v0.1.1
package/README.md CHANGED
@@ -46,7 +46,7 @@ technology the score is one image named for the chart's title, or "Score".
46
46
 
47
47
  | Attribute (property) | |
48
48
  |---|---|
49
- | `src`, `theme`, `bar-numbers`, `rehearsal-letters`, `numerals`, `wrap`, `show-part` | the grid's own, as in [`@barmark/render`](../render/README.md#options-and-attributes) |
49
+ | `src`, `theme`, `bar-numbers`, `rehearsal-letters`, `numerals`, `wrap`, `show-part`, `columns` | the grid's own, as in [`@barmark/render`](../render/README.md#options-and-attributes) |
50
50
  | `view` (`view`) | `"grid"` (default) or `"score"`; the view being shown. Set before the chart arrives, `"score"` waits for it |
51
51
  | `verovio-url` | where to load Verovio from (below) |
52
52
  | `verovio-integrity` | the SRI digest (`sha384-…`) the `verovio-url` copy must have; on a mismatch the package's own copy loads (below) |
@@ -54,7 +54,9 @@ technology the score is one image named for the chart's title, or "Score".
54
54
 
55
55
  The `text` property is the chart's text (`null` goes back to `src` or the
56
56
  script child). The element fires a `viewchange` event, with
57
- `detail.view`, whenever the view changes, from the switch or from script.
57
+ `detail.view`, whenever the view changes, from the switch or from script,
58
+ and a `scoreerror` event, with `detail.reason`, when the score can't be
59
+ drawn (below).
58
60
 
59
61
  ```js
60
62
  const score = document.querySelector("barmark-score");
@@ -69,16 +71,21 @@ The engine runs in a module Worker, created as
69
71
  That is the pattern Vite and webpack follow, so a bundler finds the worker
70
72
  and Verovio for you.
71
73
 
72
- Vite 8 (and Vite+) needs no config, in `vite dev` or a build. Vite 7 needs
73
- two lines: its dev pre-bundler moves the element away from the worker and
74
- the font it finds by URL, and it builds workers as `iife`, which cannot
75
- load Verovio on demand.
74
+ Vite 8 (and Vite+) draws a score with no config, in `vite dev` or a
75
+ build. But Vite builds workers as `iife` by default, which cannot split, so
76
+ the worker's fallback copy of Verovio is inlined into it: with
77
+ `verovio-url`, a reader then downloads Verovio twice, inside the worker and
78
+ from your URL. Set `worker: { format: "es" }` and Verovio becomes a chunk
79
+ of its own, fetched only if your URL fails. Vite 7 needs that line in any
80
+ case (an `iife` worker cannot load Verovio on demand) and one more: its dev
81
+ pre-bundler moves the element away from the worker and the font it finds
82
+ by URL.
76
83
 
77
84
  ```js
78
- // vite.config.js, for Vite 7 (harmless on Vite 8)
85
+ // vite.config.js
79
86
  export default {
80
- optimizeDeps: { exclude: ["@barmark/score"] },
81
- worker: { format: "es" },
87
+ worker: { format: "es" }, // Vite 8 with verovio-url; Vite 7 always
88
+ optimizeDeps: { exclude: ["@barmark/score"] }, // Vite 7 only (harmless on Vite 8)
82
89
  };
83
90
  ```
84
91
 
@@ -174,10 +181,27 @@ one load every element on the page uses, and asking twice does nothing.
174
181
  If Verovio fails to load, or rejects the MusicXML, or the chart will not
175
182
  export or is too large to draw (see "Engraving directly"), or Verovio
176
183
  takes over 60 seconds to load or 20 seconds to engrave, the grid stays and
177
- a note by the switch says "The score couldn't be drawn". The reason goes
178
- to the console. A score an element no longer wants (its chart or width
179
- changed) is dropped, and cut off after three seconds if the worker is
180
- already engraving it.
184
+ a note by the switch says "The score couldn't be drawn". The same happens
185
+ when `verovio-url` or `verovio-integrity` is refused, when the chart's
186
+ `src` could not be loaded, or when the engraving is not clean SVG. The
187
+ Score radio is disabled until the chart (`text`, `src` or the script
188
+ child), `verovio-url` or `verovio-integrity` changes.
189
+
190
+ The reason goes to the console as a warning, and the element fires a
191
+ `scoreerror` event (`bubbles`, `composed`) whose `detail.reason` is the
192
+ same string, so a page can show or log it:
193
+
194
+ ```js
195
+ score.addEventListener("scoreerror", (e) => report(e.detail.reason));
196
+ ```
197
+
198
+ It fires once per failure, as the note appears, after the grid is shown
199
+ again (and after the `viewchange` back to the grid, when the score was
200
+ being shown). Pressing the disabled Score radio fires nothing; once a
201
+ change enables it, a score that fails again fires again. A score an
202
+ element no longer wants (its chart or width changed) is dropped, not
203
+ failed, and fires nothing: it is cut off after three seconds if the worker
204
+ is already engraving it.
181
205
 
182
206
  ## On the server
183
207
 
@@ -236,7 +260,8 @@ stays MIT. Verovio © Laurent Pugin and others; its licence text is
236
260
  A site that bundles the worker ships Verovio inside its bundle. Keeping
237
261
  Verovio a separate file (through `verovio-url`, or the bundler's own
238
262
  chunk) and keeping its notice is the easy way to meet the LGPL. If it is
239
- bundled into one file with the worker instead (Vite 8 does this), credit it
240
- with its copyright and licence, host or link the LGPL and GPL texts, and
241
- link your site's source so a visitor can rebuild it with another Verovio;
242
- barmark.dev does all three in its footer. This is not legal advice.
263
+ bundled into one file with the worker instead (Vite's default `iife`
264
+ worker format does this), credit it with its copyright and licence, host
265
+ or link the LGPL and GPL texts, and link your site's source so a visitor
266
+ can rebuild it with another Verovio; barmark.dev does all three in its
267
+ footer. This is not legal advice.
package/dist/element.js CHANGED
@@ -84,6 +84,7 @@ function takeEarlyText(el) {
84
84
  /** The grid's attributes, as `<barmark-chart>` observes them, then the score's own. */
85
85
  const OBSERVED = [
86
86
  ...["src", "theme", "bar-numbers", "rehearsal-letters", "numerals", "wrap", "show-part"],
87
+ "columns",
87
88
  ...["view", "verovio-url", "verovio-integrity", "preload"],
88
89
  ];
89
90
  /** With no `requestIdleCallback`, how long after connecting `preload="idle"` starts the load. */
@@ -495,7 +496,10 @@ function defineElement() {
495
496
  pane.toggleAttribute("hidden", false);
496
497
  grid?.toggleAttribute("hidden", true);
497
498
  }
498
- /** The score could not be drawn: the grid again, a note by the switch, Score disabled. */
499
+ /**
500
+ * The score could not be drawn: the grid again, a note by the switch, Score
501
+ * disabled, and a `scoreerror` event saying why, once per failure.
502
+ */
499
503
  #fail(reason) {
500
504
  console.warn(`<barmark-score>: the score couldn't be drawn: ${reason}`);
501
505
  this.#failed = true;
@@ -519,6 +523,7 @@ function defineElement() {
519
523
  this.#showGrid();
520
524
  if (this.view === "score")
521
525
  this.view = "grid";
526
+ this.dispatchEvent(new CustomEvent("scoreerror", { detail: { reason }, bubbles: true, composed: true }));
522
527
  }
523
528
  #clearFailure() {
524
529
  if (!this.#failed)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barmark/score",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Show a barmark chord chart as a full engraved score: MusicXML from @barmark/musicxml, engraved by Verovio (LGPL-3.0, a dependency loaded unchanged).",
5
5
  "type": "module",
6
6
  "exports": {
@@ -49,9 +49,9 @@
49
49
  "url": "https://github.com/kevinpeckham/barmark/issues"
50
50
  },
51
51
  "dependencies": {
52
- "@barmark/musicxml": "^0.8.0",
53
- "@barmark/render": "^0.18.0",
54
- "barmark": "^0.22.0",
52
+ "@barmark/musicxml": "^0.9.0",
53
+ "@barmark/render": "^0.19.0",
54
+ "barmark": "^0.23.0",
55
55
  "verovio": "6.4.1"
56
56
  },
57
57
  "scripts": {