barmark 0.24.0 → 0.25.1
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 +50 -1
- package/dist/chart/direction.js +9 -2
- package/dist/chart/expand.js +36 -14
- package/dist/chords/parse.js +2 -2
- package/dist/chords/vocabulary.d.ts +7 -3
- package/dist/chords/vocabulary.js +11 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,53 @@ Releases follow the process in [RELEASING.md](RELEASING.md).
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.25.1] - 2026-11-29
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **A heading that plays no bars no longer costs a scan of the chart.**
|
|
17
|
+
Each such heading's error (it names the line where a section of that
|
|
18
|
+
name is written later, if one is) searched every section of the chart,
|
|
19
|
+
so the parse took time quadratic in their number: 8,000 empty headings
|
|
20
|
+
took over 2 s, and 8,000 more sections after them some 10 to 13 s. The
|
|
21
|
+
parse now finds that line in constant time: 8,000 empty headings take
|
|
22
|
+
about 15 ms, and about 0.4 s with the 8,000 sections after them.
|
|
23
|
+
- **The sections after an `al Coda`'s Coda no longer cost a scan each.**
|
|
24
|
+
Whether a bar follows the Coda asked every later heading whether it is a
|
|
25
|
+
replay, each from the top of the chart: 32,000 sections after the Coda
|
|
26
|
+
took about 1.5 s, and now take about 0.4 s, growing linearly.
|
|
27
|
+
- **Lines that play nothing are no longer walked on every pass.** Text
|
|
28
|
+
lines, lyric rows, credits and breaks were walked each time their
|
|
29
|
+
section was replayed and each time a repeat around them played a pass,
|
|
30
|
+
so N replays of N such lines, or `|: … :| x N` around them, took time
|
|
31
|
+
quadratic in N (8,000 replays of 8,000 lines: about 1 s; 1 MB of either
|
|
32
|
+
shape: over 30 s). They are now left out of what plays, at the top of a
|
|
33
|
+
section and inside its repeats: 8,000 replays take about 40 ms, and
|
|
34
|
+
1 MB under a second. Directive lines are still applied every time, so
|
|
35
|
+
repeating a run of them is still quadratic (seconds at 100 kB, a minute
|
|
36
|
+
or more at 1 MB): that is open.
|
|
37
|
+
|
|
38
|
+
No chart reads differently: the same bars, events and sections, and the
|
|
39
|
+
same diagnostics at the same lines in the same order.
|
|
40
|
+
|
|
41
|
+
## [0.25.0] - 2026-11-19
|
|
42
|
+
|
|
43
|
+
Grammar changes: more spellings of the major seventh (Kevin, 2026-11-18).
|
|
44
|
+
No chord that read before changes meaning.
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
|
|
48
|
+
- **More spellings of the major seventh** (Kevin, 2026-11-18, with
|
|
49
|
+
Claude's rulings the same day; grammar decisions log): `Maj` and `ma`
|
|
50
|
+
before 9 and 13 as before 7 (`CMaj9` and `Cma9` are `Cmaj9`, `Cma13` is
|
|
51
|
+
`Cmaj13`); the delta after `m`, `-` or `min` (`CmΔ`, `C-Δ7` and `CminΔ`
|
|
52
|
+
are `Cmmaj7`, `CmΔ9` is `Cmmaj9`); and the increment sign `∆` (a Mac's
|
|
53
|
+
Option-J) and the triangles `△` and `▵` as the delta (`C∆7` is `Cmaj7`,
|
|
54
|
+
`Cm△9` is `Cmmaj9`), each with whatever may follow its canonical
|
|
55
|
+
spelling (`CMaj9(#11)`, `CmΔ/Eb`). They print canonically. `Δ11`,
|
|
56
|
+
`Maj11`, `mΔ13`, `CmMaj7` and `Cmma7` stay errors, and no chord that
|
|
57
|
+
read before changes.
|
|
58
|
+
|
|
12
59
|
## [0.24.0] - 2026-11-14
|
|
13
60
|
|
|
14
61
|
Grammar changes: the flat sixth, `add` before any tone, and `Δ9`/`Δ13`
|
|
@@ -911,7 +958,9 @@ The first working release: the reference parser and printer for the
|
|
|
911
958
|
|
|
912
959
|
- **A placeholder package that holds the `barmark` name** while the spec and parser are written.
|
|
913
960
|
|
|
914
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.
|
|
961
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.25.1...HEAD
|
|
962
|
+
[0.25.1]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.25.0...barmark-v0.25.1
|
|
963
|
+
[0.25.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.24.0...barmark-v0.25.0
|
|
915
964
|
[0.24.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.23.1...barmark-v0.24.0
|
|
916
965
|
[0.23.1]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.23.0...barmark-v0.23.1
|
|
917
966
|
[0.23.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.22.0...barmark-v0.23.0
|
package/dist/chart/direction.js
CHANGED
|
@@ -64,8 +64,15 @@ function missingMarks(jump, plan, first) {
|
|
|
64
64
|
const writes = (l) => l.kind === "bars" || l.kind === "invalid";
|
|
65
65
|
/** Whether the section heading at `i` is a replay: no bar line before the next heading. */
|
|
66
66
|
function isReplay(lines, i) {
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
// It looks ahead from the heading, not from the top: barAfter asks every heading after a Coda.
|
|
68
|
+
for (let k = i + 1; k < lines.length; k++) {
|
|
69
|
+
const l = lines[k];
|
|
70
|
+
if (l.kind === "section")
|
|
71
|
+
return true;
|
|
72
|
+
if (writes(l))
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
69
76
|
}
|
|
70
77
|
/** Whether a bar follows `m`: on its line, on a later one, or in a later replay (grammar 5.2). */
|
|
71
78
|
function barAfter(lines, m) {
|
package/dist/chart/expand.js
CHANGED
|
@@ -79,13 +79,26 @@ function pushesIn(slots, meter) {
|
|
|
79
79
|
}
|
|
80
80
|
const normalize = (name) => name.toLowerCase().replace(/\s+/g, " ").trim();
|
|
81
81
|
const isWritten = (s) => s.lines.some((l) => l.kind === "bars" || l.kind === "invalid");
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
/**
|
|
83
|
+
* For each section, the first written section after it with its name, when
|
|
84
|
+
* there is one: one pass from the end, so an empty heading's message costs
|
|
85
|
+
* constant time, not a scan of the chart.
|
|
86
|
+
*/
|
|
87
|
+
function writtenLater(sections) {
|
|
88
|
+
const next = new Map();
|
|
89
|
+
const later = new Map();
|
|
90
|
+
for (let i = sections.length - 1; i >= 0; i--) {
|
|
91
|
+
const s = sections[i];
|
|
92
|
+
if (!s.heading)
|
|
93
|
+
continue;
|
|
94
|
+
later.set(s, next.get(s.key));
|
|
95
|
+
if (isWritten(s))
|
|
96
|
+
next.set(s.key, s.heading);
|
|
97
|
+
}
|
|
98
|
+
return later;
|
|
99
|
+
}
|
|
100
|
+
/** Grammar §6: an empty section that matches nothing, and how to fix it; `later` is where it is written, if it is. */
|
|
101
|
+
function unmatchedReplay(heading, later) {
|
|
89
102
|
const fix = later
|
|
90
103
|
? `replays use only earlier sections (it is written at line ${later.line})`
|
|
91
104
|
: "write its bars under it, or remove the heading";
|
|
@@ -141,10 +154,10 @@ sing) {
|
|
|
141
154
|
reported.add(key);
|
|
142
155
|
diagnostics.push({ line, severity: "error", message, token });
|
|
143
156
|
};
|
|
144
|
-
const sections = [{ heading: null, lines: [] }];
|
|
157
|
+
const sections = [{ heading: null, key: "", lines: [] }];
|
|
145
158
|
for (const l of readable) {
|
|
146
159
|
if (l.kind === "section")
|
|
147
|
-
sections.push({ heading: l, lines: [] });
|
|
160
|
+
sections.push({ heading: l, key: normalize(l.name), lines: [] });
|
|
148
161
|
else if (l.kind !== "title")
|
|
149
162
|
sections.at(-1)?.lines.push(l);
|
|
150
163
|
}
|
|
@@ -228,8 +241,16 @@ sing) {
|
|
|
228
241
|
const unused = pending.mark;
|
|
229
242
|
if (unused)
|
|
230
243
|
error(unused.line, "a rehearsal mark marks the bar after it; none follows", `@${unused.label}`);
|
|
231
|
-
// Pair |: and :| within each section, with any endings.
|
|
232
|
-
|
|
244
|
+
// Pair |: and :| within each section, with any endings. A line that is neither bars nor a
|
|
245
|
+
// directive plays nothing, so it is left out, at the top and inside a repeat (an ending holds
|
|
246
|
+
// only bar lines): each pass and each replay walks only what it plays.
|
|
247
|
+
const plays = (e) => e.line.kind === "bars" || e.line.kind === "directive";
|
|
248
|
+
const playing = (items) => items.flatMap((it) => {
|
|
249
|
+
if (it.kind === "line")
|
|
250
|
+
return plays(it) ? [it] : [];
|
|
251
|
+
return [{ ...it, entries: it.entries.filter(plays) }];
|
|
252
|
+
});
|
|
253
|
+
const itemsOf = new Map(sections.map((s) => [s, playing(pairRepeats(s.lines, error))]));
|
|
233
254
|
const plan = planJump(readable, error);
|
|
234
255
|
const start = () => ({
|
|
235
256
|
key: null,
|
|
@@ -515,6 +536,7 @@ sing) {
|
|
|
515
536
|
const events = [];
|
|
516
537
|
const occurrences = [];
|
|
517
538
|
const definitions = new Map();
|
|
539
|
+
const later = writtenLater(sections);
|
|
518
540
|
/** Headings already played, so a written section played again by the jump is a replay. */
|
|
519
541
|
const heard = new Set();
|
|
520
542
|
const playSections = () => {
|
|
@@ -526,7 +548,7 @@ sing) {
|
|
|
526
548
|
};
|
|
527
549
|
/** A written section's bars into `out`. */
|
|
528
550
|
const playWritten = (s, h, out) => {
|
|
529
|
-
definitions.set(
|
|
551
|
+
definitions.set(s.key, s);
|
|
530
552
|
if (h.elided)
|
|
531
553
|
error(h.line, "-> is only for a replay; leave the bar out instead", "->");
|
|
532
554
|
times(h.repeat, h.line, out, (into) => playItems(itemsOf.get(s) ?? [], into));
|
|
@@ -543,9 +565,9 @@ sing) {
|
|
|
543
565
|
// A nameless heading is already an error; it has nothing to replay.
|
|
544
566
|
if (!h.name)
|
|
545
567
|
return null;
|
|
546
|
-
const source = definitions.get(
|
|
568
|
+
const source = definitions.get(s.key);
|
|
547
569
|
if (!source?.heading) {
|
|
548
|
-
error(h.line, unmatchedReplay(h,
|
|
570
|
+
error(h.line, unmatchedReplay(h, later.get(s)), h.name);
|
|
549
571
|
return null;
|
|
550
572
|
}
|
|
551
573
|
where.replay = h.line;
|
package/dist/chords/parse.js
CHANGED
|
@@ -141,8 +141,8 @@ function aliased(rest) {
|
|
|
141
141
|
rest = rest.replace(pattern, replacement);
|
|
142
142
|
return rest;
|
|
143
143
|
}
|
|
144
|
-
/** The text a symbol is read from: ♯ and ♭ as # and b (Appendix A.5). */
|
|
145
|
-
const ascii = (symbol) => symbol.replace(/♯/g, "#").replace(/♭/g, "b");
|
|
144
|
+
/** The text a symbol is read from: ♯ and ♭ as # and b, ∆ △ ▵ as Δ (Appendix A.5). */
|
|
145
|
+
const ascii = (symbol) => symbol.replace(/♯/g, "#").replace(/♭/g, "b").replace(/[∆△▵]/g, "Δ");
|
|
146
146
|
/** Appendix A.5 and A.6: rejections, then aliases into canonical vocabulary. */
|
|
147
147
|
function normalizeSymbol(text) {
|
|
148
148
|
const rejected = rejection(text, noteSemitone);
|
|
@@ -49,9 +49,13 @@ export declare function chordIntervals(parts: ChordParts, symbol: string): {
|
|
|
49
49
|
alteredOpen: boolean;
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
|
-
* Appendix A.5, applied in this order after ♯/♭ become #/b
|
|
53
|
-
*
|
|
54
|
-
* own accidental.
|
|
52
|
+
* Appendix A.5, applied in this order after ♯/♭ become #/b and the
|
|
53
|
+
* increment sign and the triangles become Δ. Each pattern reads the text
|
|
54
|
+
* after the root, so a rule can never touch the root's own accidental.
|
|
55
|
+
* `ma` is read only at the start, before `min` and `-` become `m`, so it
|
|
56
|
+
* is never an alias after `m`, `-` or `min` (`Cmma7` stays an error); the
|
|
57
|
+
* delta is read after, so it follows any of the three. `Maj` after them
|
|
58
|
+
* (`CmMaj7`) is not an alias: Kevin, 2026-11-09.
|
|
55
59
|
*/
|
|
56
60
|
export declare const ALIASES: [RegExp, string][];
|
|
57
61
|
/** Appendix A.6: a rejection with its suggestion, or null when the symbol is not one. */
|
|
@@ -134,23 +134,27 @@ export function chordIntervals(parts, symbol) {
|
|
|
134
134
|
return { intervals, warnings, alteredOpen: parts.extension === "7alt" };
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
* Appendix A.5, applied in this order after ♯/♭ become #/b
|
|
138
|
-
*
|
|
139
|
-
* own accidental.
|
|
137
|
+
* Appendix A.5, applied in this order after ♯/♭ become #/b and the
|
|
138
|
+
* increment sign and the triangles become Δ. Each pattern reads the text
|
|
139
|
+
* after the root, so a rule can never touch the root's own accidental.
|
|
140
|
+
* `ma` is read only at the start, before `min` and `-` become `m`, so it
|
|
141
|
+
* is never an alias after `m`, `-` or `min` (`Cmma7` stays an error); the
|
|
142
|
+
* delta is read after, so it follows any of the three. `Maj` after them
|
|
143
|
+
* (`CmMaj7`) is not an alias: Kevin, 2026-11-09.
|
|
140
144
|
*/
|
|
141
145
|
export const ALIASES = [
|
|
142
|
-
[/^Δ9/, "maj9"],
|
|
143
|
-
[/^Δ13/, "maj13"],
|
|
144
|
-
[/^Δ7?/, "maj7"],
|
|
145
146
|
[/^ø7?/, "m7(b5)"],
|
|
146
147
|
[/^°7/, "dim7"],
|
|
147
148
|
[/^°/, "dim"],
|
|
148
149
|
[/^\+7/, "aug7"],
|
|
149
150
|
[/^\+/, "aug"],
|
|
150
151
|
[/^(minmaj7|m\(maj7\))/, "mmaj7"],
|
|
151
|
-
[/^(
|
|
152
|
+
[/^(Maj|ma)(?=7|9|13)/, "maj"],
|
|
152
153
|
[/^min/, "m"],
|
|
153
154
|
[/^-/, "m"],
|
|
155
|
+
[/^(m?)Δ9/, "$1maj9"],
|
|
156
|
+
[/^(m?)Δ13/, "$1maj13"],
|
|
157
|
+
[/^(m?)Δ7?/, "$1maj7"],
|
|
154
158
|
[/^maj(?=$|\/)/, ""],
|
|
155
159
|
[/sus(?![24])/, "sus4"],
|
|
156
160
|
];
|