@barmark/render 0.17.1 → 0.18.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 +23 -1
- package/README.md +3 -1
- package/dist/html.js +4 -3
- package/dist/speech.d.ts +3 -1
- package/dist/speech.js +9 -3
- package/dist/verses.js +26 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,27 @@ package uses [semantic versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.18.0] - 2026-11-09
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **Requires `barmark` 0.22.0** (a pickup is bar 0, `ChartParse.pickup`),
|
|
14
|
+
whose minor release a caret range would not reach.
|
|
15
|
+
- **A pickup is bar 0** (barmark's grammar 2.4). The gutter draws no
|
|
16
|
+
number on a row that starts with the pickup, and the screen-reader
|
|
17
|
+
text says "pickup" where it said "bar 1"; the bars after it are
|
|
18
|
+
numbered from 1. `RowModel.barNumber` is `0` on such a row. Charts
|
|
19
|
+
without a pickup render exactly as before.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- **A bar played many times, or one with many notes and syllables, lays
|
|
24
|
+
out in linear time.** Deciding whether a chart with no parts sings read
|
|
25
|
+
every syllable of every played bar (now once per written bar, with a
|
|
26
|
+
`barmark` whose plays share their syllables), and placing a singing
|
|
27
|
+
bar's syllables under its slots scanned every slot for each syllable
|
|
28
|
+
(now a binary search).
|
|
29
|
+
|
|
9
30
|
## [0.17.1] - 2026-11-08
|
|
10
31
|
|
|
11
32
|
### Changed
|
|
@@ -439,7 +460,8 @@ that needs no script or as the `<barmark-chart>` web component. Requires
|
|
|
439
460
|
zoom without sideways scrolling, the element renders and re-renders, and
|
|
440
461
|
a screen reader hears "bar 9: D". Run them with `bun run test:browser`.
|
|
441
462
|
|
|
442
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.
|
|
463
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.18.0...HEAD
|
|
464
|
+
[0.18.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.17.1...render-v0.18.0
|
|
443
465
|
[0.17.1]: https://github.com/kevinpeckham/barmark/compare/render-v0.17.0...render-v0.17.1
|
|
444
466
|
[0.17.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.16.2...render-v0.17.0
|
|
445
467
|
[0.16.2]: https://github.com/kevinpeckham/barmark/compare/render-v0.16.1...render-v0.16.2
|
package/README.md
CHANGED
|
@@ -186,7 +186,9 @@ shows as Cm⁷(♭5)). `%` is drawn as the bar it copies; a replayed section
|
|
|
186
186
|
is drawn in full, and its own lyrics replace the written section's. Bar
|
|
187
187
|
numbers count the bars as written, each once, as a band counts them: a
|
|
188
188
|
repeat, an ending, a jump or a replay doesn't move them, so a replayed
|
|
189
|
-
section shows the numbers it was written with. A
|
|
189
|
+
section shows the numbers it was written with. A pickup is bar 0: its
|
|
190
|
+
row shows no number in the gutter (`barNumber` is `0` in the model) and
|
|
191
|
+
is spoken as "pickup", and the bars after it are 1, 2, and so on. A line with an error shows as written, underlined,
|
|
190
192
|
with its message. `layoutChart(text)` returns all of this as data, if
|
|
191
193
|
you want to draw it yourself, and `typesetChord(parts)` with `glyphs`
|
|
192
194
|
gives a chord's pieces as the page sets them (root and quality, the
|
package/dist/html.js
CHANGED
|
@@ -9,7 +9,7 @@ import { creditsText } from "./credits.js";
|
|
|
9
9
|
import { escapeHtml } from "./escape.js";
|
|
10
10
|
import { fontFaceCss } from "./font.js";
|
|
11
11
|
import { isTacet as isTacetCell, layoutChart } from "./model.js";
|
|
12
|
-
import { speakBar, speakVerses } from "./speech.js";
|
|
12
|
+
import { barLabel, speakBar, speakVerses } from "./speech.js";
|
|
13
13
|
import { FIT_STEPS, MIN_BAR, stylesheet } from "./styles.js";
|
|
14
14
|
import { beatLinesHtml, pitchHtml, sungBar, sungSlotHtml, verseNumbersHtml, verseWidth, } from "./verses-html.js";
|
|
15
15
|
export function renderChart(text, options = {}) {
|
|
@@ -205,7 +205,8 @@ function systemHtml(item, columns, settings) {
|
|
|
205
205
|
function gutterHtml(row, settings, part) {
|
|
206
206
|
if (!settings.gutter)
|
|
207
207
|
return "";
|
|
208
|
-
const
|
|
208
|
+
const shown = settings.barNumbers && (!part || part.first) && row.barNumber !== 0;
|
|
209
|
+
const number = shown ? (row.barNumber ?? "") : "";
|
|
209
210
|
const label = part
|
|
210
211
|
? `<span class="bm-part-label" part="part-label">${escapeHtml(part.label)}</span>`
|
|
211
212
|
: "";
|
|
@@ -314,7 +315,7 @@ function barBody(cell, view) {
|
|
|
314
315
|
/** A bar where the part rests; the first of a row says so, in its body. */
|
|
315
316
|
function tacetHtml(cell, n, marks, first) {
|
|
316
317
|
const cut = cell.kind === "slots" && cell.cut;
|
|
317
|
-
const spoken = `<span class="bm-sr"
|
|
318
|
+
const spoken = `<span class="bm-sr">${barLabel(n)}: tacet${cut ? ", cut on this pass" : ""}</span>`;
|
|
318
319
|
return `<div class="bm-bar bm-tacet-bar" part="bar"${marks}${cut ? " data-cut" : ""}>${spoken}<span class="bm-bar-body" aria-hidden="true">${first ? "tacet" : ""}</span></div>`;
|
|
319
320
|
}
|
|
320
321
|
/** A bar's slots, each under any words before it, and the words after the last slot. */
|
package/dist/speech.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ import type { CellModel } from "./types.js";
|
|
|
7
7
|
/** A chord's name; with a key, its degree first: "five, A seven". */
|
|
8
8
|
export declare function speakChord(record: ChordRecord, key?: Key): string;
|
|
9
9
|
export declare function speakSlot(slot: Slot, key?: Key): string;
|
|
10
|
-
/**
|
|
10
|
+
/** What a bar is called aloud: "pickup" for bar 0, "bar" with no number, else "bar 9". */
|
|
11
|
+
export declare function barLabel(barNumber: number | null): string;
|
|
12
|
+
/** "bar 9: G, hold, D, hold"; a pickup (bar 0) says "pickup"; a fermata is held until cued. With `numerals`, each chord's degree comes first. */
|
|
11
13
|
export declare function speakBar(barNumber: number | null, cell: CellModel, numerals?: boolean): string;
|
|
12
14
|
/**
|
|
13
15
|
* The words on a bar, each verse's: `sung “maz-ing”` (or `words “…”` in a
|
package/dist/speech.js
CHANGED
|
@@ -150,7 +150,13 @@ function speakDirection(d) {
|
|
|
150
150
|
return d.kind;
|
|
151
151
|
return `${d.to === "start" ? "da capo" : "dal segno"}${d.al ? ` al ${d.al}` : ""}`;
|
|
152
152
|
}
|
|
153
|
-
/**
|
|
153
|
+
/** What a bar is called aloud: "pickup" for bar 0, "bar" with no number, else "bar 9". */
|
|
154
|
+
export function barLabel(barNumber) {
|
|
155
|
+
if (barNumber === 0)
|
|
156
|
+
return "pickup";
|
|
157
|
+
return barNumber === null ? "bar" : `bar ${barNumber}`;
|
|
158
|
+
}
|
|
159
|
+
/** "bar 9: G, hold, D, hold"; a pickup (bar 0) says "pickup"; a fermata is held until cued. With `numerals`, each chord's degree comes first. */
|
|
154
160
|
export function speakBar(barNumber, cell, numerals = false) {
|
|
155
161
|
if (cell.kind === "fermata")
|
|
156
162
|
return "fermata: hold until cued";
|
|
@@ -158,7 +164,7 @@ export function speakBar(barNumber, cell, numerals = false) {
|
|
|
158
164
|
return speakDirection(cell.direction);
|
|
159
165
|
if (cell.kind === "rehearsal")
|
|
160
166
|
return `rehearsal ${cell.label}`;
|
|
161
|
-
const bar =
|
|
167
|
+
const bar = barLabel(barNumber);
|
|
162
168
|
if (cell.simile)
|
|
163
169
|
return `${bar}: each part repeats its bar before`;
|
|
164
170
|
const meter = cell.meter ? `, in ${cell.meter.n}/${cell.meter.d}` : "";
|
|
@@ -166,7 +172,7 @@ export function speakBar(barNumber, cell, numerals = false) {
|
|
|
166
172
|
const words = (at) => (cell.words ?? []).filter((w) => w.at === at).map((w) => `“${w.text}”`);
|
|
167
173
|
const slots = cell.slots.map((s, i) => [...words(i), speakSlot(s, numerals ? cell.key : undefined)].join(" "));
|
|
168
174
|
const spoken = [...slots, ...words(cell.slots.length)].join(", ");
|
|
169
|
-
return
|
|
175
|
+
return `${bar}${meter}: ${spoken}${cut}`;
|
|
170
176
|
}
|
|
171
177
|
/** A verse's syllables as words: "maz-ing"; elided syllables apart, a held one silent. */
|
|
172
178
|
function speakSyllables(syllables) {
|
package/dist/verses.js
CHANGED
|
@@ -31,8 +31,18 @@ export function singerOf(l, parse) {
|
|
|
31
31
|
const name = l.lineName ?? p.lines?.[0] ?? "";
|
|
32
32
|
return same(name, p.sings) ? (p.label ?? "") : null;
|
|
33
33
|
}
|
|
34
|
+
/** Whether a verse's syllables sit on notes, read once for each written bar however often it plays. */
|
|
35
|
+
const noted = new WeakMap();
|
|
36
|
+
function onNote(syllables) {
|
|
37
|
+
let known = noted.get(syllables);
|
|
38
|
+
if (known === undefined) {
|
|
39
|
+
known = syllables.some((s) => s.note);
|
|
40
|
+
noted.set(syllables, known);
|
|
41
|
+
}
|
|
42
|
+
return known;
|
|
43
|
+
}
|
|
34
44
|
/** Whether a chart with no parts sings: its verse 1 sits on notes. */
|
|
35
|
-
const onNotes = (b) => (b.lyrics ?? []).some((v) => v.syllables
|
|
45
|
+
const onNotes = (b) => (b.lyrics ?? []).some((v) => onNote(v.syllables));
|
|
36
46
|
/** `onNotes` over the chart, worked out once a parse: asked for each line, it would read every bar each time. */
|
|
37
47
|
const sang = new WeakMap();
|
|
38
48
|
function singsOnNotes(parse) {
|
|
@@ -91,6 +101,20 @@ function slotStarts(slots) {
|
|
|
91
101
|
});
|
|
92
102
|
return starts;
|
|
93
103
|
}
|
|
104
|
+
/** The last of the ascending `starts` at or before `at` (within a rounding error), or -1: a binary search, so a bar of many notes and syllables isn't their product. */
|
|
105
|
+
function lastStartBy(starts, at) {
|
|
106
|
+
let lo = 0;
|
|
107
|
+
let hi = starts.length;
|
|
108
|
+
while (lo < hi) {
|
|
109
|
+
const mid = (lo + hi) >> 1;
|
|
110
|
+
const start = starts[mid] ?? 0;
|
|
111
|
+
if (start < at || near(start, at))
|
|
112
|
+
lo = mid + 1;
|
|
113
|
+
else
|
|
114
|
+
hi = mid;
|
|
115
|
+
}
|
|
116
|
+
return lo - 1;
|
|
117
|
+
}
|
|
94
118
|
/** A verse's syllables in a bar under its slots: each on the slot sounding at its onset. */
|
|
95
119
|
function underSlots(cell, landing, key, verse) {
|
|
96
120
|
if (cell.kind !== "slots" || !landing)
|
|
@@ -103,8 +127,7 @@ function underSlots(cell, landing, key, verse) {
|
|
|
103
127
|
const out = starts.map(() => []);
|
|
104
128
|
const length = barLength(landing.bar.meter);
|
|
105
129
|
for (const s of sung) {
|
|
106
|
-
|
|
107
|
-
out[Math.max(0, i)]?.push(s.syllable);
|
|
130
|
+
out[Math.max(0, lastStartBy(starts, s.at / length))]?.push(s.syllable);
|
|
108
131
|
}
|
|
109
132
|
return out;
|
|
110
133
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barmark/render",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Render barmark chord charts as a clean, accessible bar grid: HTML with Declarative Shadow DOM, or the <barmark-chart> web component.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"url": "https://github.com/kevinpeckham/barmark/issues"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"barmark": "^0.
|
|
50
|
+
"barmark": "^0.22.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|