@barmark/render 0.22.0 → 0.22.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.
- package/CHANGELOG.md +35 -1
- package/dist/model.js +9 -67
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,38 @@ package uses [semantic versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.22.2] - 2026-11-30
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **Works with any `barmark` 0.x from 0.26.0.** The dependency was a
|
|
14
|
+
caret range, which in 0.x stops at the next minor, so every `barmark`
|
|
15
|
+
minor needed a release of this package before the two could be
|
|
16
|
+
installed together as one copy. It is now `>=0.26.0 <1.0.0`. Nothing
|
|
17
|
+
else changes.
|
|
18
|
+
|
|
19
|
+
## [0.22.1] - 2026-11-29
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- **Requires `barmark` 0.26.0**, for the parse's `firstWritten` (each bar
|
|
24
|
+
line's first written bar number), which the grid now reads where it
|
|
25
|
+
recounted the written lines itself; a caret range would not reach that
|
|
26
|
+
minor release.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- **Bar numbers after a system come from the parser in two more cases**,
|
|
31
|
+
where a later row whose first bar no pass plays was numbered off and
|
|
32
|
+
could draw and speak another bar's chord in its cells:
|
|
33
|
+
- a system whose every line is excluded or dropped, with lines writing
|
|
34
|
+
different numbers of bars: it was counted by the system's first line,
|
|
35
|
+
not the parser's;
|
|
36
|
+
- a part's own view where that part's lines in a system are left out
|
|
37
|
+
or excluded and another part's line is the reference: with
|
|
38
|
+
`part: "Pno"`, `Gtr | C | D |` over `Pno.RH | G |`, then
|
|
39
|
+
`| E | Coda | F |`, drew that row as `6: F | F`; it is `5: E | 6: F`.
|
|
40
|
+
|
|
9
41
|
## [0.22.0] - 2026-11-28
|
|
10
42
|
|
|
11
43
|
### Added
|
|
@@ -642,7 +674,9 @@ that needs no script or as the `<barmark-chart>` web component. Requires
|
|
|
642
674
|
zoom without sideways scrolling, the element renders and re-renders, and
|
|
643
675
|
a screen reader hears "bar 9: D". Run them with `bun run test:browser`.
|
|
644
676
|
|
|
645
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.22.
|
|
677
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.22.2...HEAD
|
|
678
|
+
[0.22.2]: https://github.com/kevinpeckham/barmark/compare/render-v0.22.1...render-v0.22.2
|
|
679
|
+
[0.22.1]: https://github.com/kevinpeckham/barmark/compare/render-v0.22.0...render-v0.22.1
|
|
646
680
|
[0.22.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.21.1...render-v0.22.0
|
|
647
681
|
[0.21.1]: https://github.com/kevinpeckham/barmark/compare/render-v0.21.0...render-v0.21.1
|
|
648
682
|
[0.21.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.20.2...render-v0.21.0
|
package/dist/model.js
CHANGED
|
@@ -51,78 +51,20 @@ function indexByLine(bars) {
|
|
|
51
51
|
}
|
|
52
52
|
return out;
|
|
53
53
|
}
|
|
54
|
-
/** How many bars a bar line writes: its bars and `%`, not its fermatas, directions or rehearsal marks. */
|
|
55
|
-
const barCells = (l) => l.cells.filter((c) => c.kind === "slots" || c.kind === "simile").length;
|
|
56
54
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* line writes (`referenceOf`: its first bar line not `dropped`); a part
|
|
61
|
-
* whose own line is dropped plays a stand-in of the reference. With no
|
|
62
|
-
* reference, this counts `unread` of the system's first line: an invalid
|
|
63
|
-
* line's `written`, else none (a system of one dropped line writes none).
|
|
64
|
-
* The parser counts its first stream's own line there, which can differ
|
|
65
|
-
* (FINDINGS, "Known difference left alone"). A line
|
|
66
|
-
* outside a system counts its own: a bar line's bars, an invalid line's
|
|
67
|
-
* `written` (as `expand` adds it).
|
|
55
|
+
* Each bar line's first written number, the parse's `firstWritten`, for a line
|
|
56
|
+
* some pass plays: a row none plays shows no number. A drawn cell's number
|
|
57
|
+
* runs on from its line's first.
|
|
68
58
|
*/
|
|
69
|
-
function
|
|
70
|
-
const ref = group.find((l) => l.kind === "bars" && !l.dropped);
|
|
71
|
-
if (ref)
|
|
72
|
-
return barCells(ref);
|
|
73
|
-
const first = group[0];
|
|
74
|
-
if (first?.kind === "invalid")
|
|
75
|
-
return first.written;
|
|
76
|
-
return first && systemOf(first) === null ? barCells(first) : 0;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Each bar line's first written number. The parser numbers each written bar
|
|
80
|
-
* once, in written order (`PlayedBar.written`), so a line's bars run on
|
|
81
|
-
* from its first, a system's lines sharing them; but it gives a number only
|
|
82
|
-
* to a bar a pass plays. A line's played bars bound where it starts, and
|
|
83
|
-
* the count of bars written before it settles that when a pass leaves out
|
|
84
|
-
* its first bars (a jump lands after them). A line no pass plays has none.
|
|
85
|
-
*/
|
|
86
|
-
function writtenStarts(lines, bars, pickup) {
|
|
59
|
+
function playedStarts(lines, bars) {
|
|
87
60
|
const starts = new Map();
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (start !== null)
|
|
93
|
-
for (const g of group)
|
|
94
|
-
starts.set(g.line, start);
|
|
95
|
-
next = (start ?? next) + n;
|
|
61
|
+
for (const l of lines.filter((l) => bars.has(l.line))) {
|
|
62
|
+
const first = l.kind === "bars" || l.kind === "invalid" ? l.firstWritten : undefined;
|
|
63
|
+
if (first !== undefined)
|
|
64
|
+
starts.set(l.line, first);
|
|
96
65
|
}
|
|
97
66
|
return starts;
|
|
98
67
|
}
|
|
99
|
-
/** The lines that write bars, in written order: a line alone, or a system's lines together. */
|
|
100
|
-
function barGroups(lines) {
|
|
101
|
-
const groups = [];
|
|
102
|
-
for (const [i, l] of lines.entries()) {
|
|
103
|
-
if (l.kind !== "bars" && l.kind !== "invalid")
|
|
104
|
-
continue;
|
|
105
|
-
const system = systemOf(l);
|
|
106
|
-
if (system === null)
|
|
107
|
-
groups.push([l]);
|
|
108
|
-
else if (systemOf(lines[i - 1]) !== system)
|
|
109
|
-
groups.push(systemLines(lines, i));
|
|
110
|
-
}
|
|
111
|
-
return groups;
|
|
112
|
-
}
|
|
113
|
-
/** Where a line of `n` bars starts: `next` if its played bars allow it, else its first played bar; null when none plays. */
|
|
114
|
-
function startWithin(group, bars, n, next) {
|
|
115
|
-
let low = Number.POSITIVE_INFINITY;
|
|
116
|
-
let high = Number.NEGATIVE_INFINITY;
|
|
117
|
-
for (const g of group)
|
|
118
|
-
for (const b of bars.get(g.line) ?? []) {
|
|
119
|
-
low = Math.min(low, b.written);
|
|
120
|
-
high = Math.max(high, b.written);
|
|
121
|
-
}
|
|
122
|
-
if (low > high)
|
|
123
|
-
return null;
|
|
124
|
-
return next <= low && next >= high - n + 1 ? next : low;
|
|
125
|
-
}
|
|
126
68
|
/** Each part's bars on its own lines, and each line's; a tutti bar once (barmark's grammar 7.4, 7.6). */
|
|
127
69
|
function barsByLine(parse) {
|
|
128
70
|
if (parse.parts.length < 2 && !parse.parts.some((p) => p.lines))
|
|
@@ -166,7 +108,7 @@ export function layoutChart(text, options = {}) {
|
|
|
166
108
|
...errorsByLine(parse),
|
|
167
109
|
written: new Map(groups.flatMap((g) => (g.heading ? [[g.heading.line, g]] : []))),
|
|
168
110
|
bars,
|
|
169
|
-
starts:
|
|
111
|
+
starts: playedStarts(parse.lines, bars),
|
|
170
112
|
beats: tempoBeats(parse.lines),
|
|
171
113
|
melody: options.melody !== false,
|
|
172
114
|
changed: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barmark/render",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.2",
|
|
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,8 +47,8 @@
|
|
|
47
47
|
"url": "https://github.com/kevinpeckham/barmark/issues"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@barmark/fretboard": "^0.1.
|
|
51
|
-
"barmark": "
|
|
50
|
+
"@barmark/fretboard": "^0.1.4",
|
|
51
|
+
"barmark": ">=0.26.0 <1.0.0"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|