barmark 0.14.0 → 0.15.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 +36 -1
- package/README.md +1 -0
- package/dist/chart/credits.d.ts +9 -0
- package/dist/chart/credits.js +62 -0
- package/dist/chart/directives.d.ts +2 -0
- package/dist/chart/directives.js +2 -0
- package/dist/chart/document.d.ts +2 -1
- package/dist/chart/document.js +9 -2
- package/dist/chart/index.d.ts +1 -0
- package/dist/chart/index.js +1 -0
- package/dist/chart/parse.d.ts +7 -1
- package/dist/chart/parse.js +37 -8
- package/dist/chart/print.js +6 -1
- package/dist/chart/repeats.js +1 -1
- package/dist/chart/systems.js +20 -5
- package/dist/chart/types.d.ts +13 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,39 @@ Releases follow the process in [RELEASING.md](RELEASING.md).
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.15.0] - 2026-11-04
|
|
13
|
+
|
|
14
|
+
A grammar change: credit lines (7.5). Charts that read before read the
|
|
15
|
+
same, unless a text line starts with a credit's name and a colon.
|
|
16
|
+
Implements the
|
|
17
|
+
[grammar v0.1 draft](https://github.com/kevinpeckham/barmark/blob/main/docs/grammar-v0.1-draft.md).
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **Credit lines** (grammar 7.5): `composer:`, `lyricist:`, `arranger:`
|
|
22
|
+
and `copyright:`, each a line of its own, allowed anywhere in a chart
|
|
23
|
+
and repeatable. `ChartParse.credits` lists each role's entries in
|
|
24
|
+
written order; a `Line` of kind `"credit"` keeps the line, and the
|
|
25
|
+
printer writes it where it was written. An empty credit is an error;
|
|
26
|
+
`author:`, `music:`, `words:`, `arr:`, `rights:` and the other near
|
|
27
|
+
misses warn with the right name. `CREDIT_ROLES` is exported.
|
|
28
|
+
- A text line starting with one of the four names and a colon is now a
|
|
29
|
+
credit, not text.
|
|
30
|
+
|
|
31
|
+
## [0.14.1] - 2026-11-03
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- In a system, the line that differs from the one most lines agree with
|
|
36
|
+
is the error, wherever it sits; before, an odd first line made every
|
|
37
|
+
other line of its system the error (grammar 7.4).
|
|
38
|
+
- Parts that play one bar in different meters (a `%` copying a one-bar
|
|
39
|
+
meter) are reported on every line that plays it, naming the meters.
|
|
40
|
+
- `printPart` leaves out a `part:` line set aside for sharing a label,
|
|
41
|
+
which would otherwise declare a part again in the extract.
|
|
42
|
+
- If parts ever fell out of step, the first place they part is now an
|
|
43
|
+
error instead of a silent fallback.
|
|
44
|
+
|
|
12
45
|
## [0.14.0] - 2026-11-03
|
|
13
46
|
|
|
14
47
|
### Added
|
|
@@ -350,7 +383,9 @@ The first working release: the reference parser and printer for the
|
|
|
350
383
|
|
|
351
384
|
- **A placeholder package that holds the `barmark` name** while the spec and parser are written.
|
|
352
385
|
|
|
353
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.
|
|
386
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.15.0...HEAD
|
|
387
|
+
[0.15.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.14.1...barmark-v0.15.0
|
|
388
|
+
[0.14.1]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.14.0...barmark-v0.14.1
|
|
354
389
|
[0.14.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.13.0...barmark-v0.14.0
|
|
355
390
|
[0.13.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.12.0...barmark-v0.13.0
|
|
356
391
|
[0.12.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.11.0...barmark-v0.12.0
|
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
const chart = parseChart(text);
|
|
52
52
|
chart.title; // "Example Song"
|
|
53
53
|
chart.parts; // [{ label: "Gtr", name: "Electric Guitar 1" }] from part: Gtr = Electric Guitar 1, in score order
|
|
54
|
+
chart.credits; // { composer: ["Kevin Peckham"], lyricist: [], arranger: [], copyright: [] } from composer: Kevin Peckham
|
|
54
55
|
chart.bars; // every bar in play order: its number as written, slots, section, key, meter, tempo, feel (and swingPercent)
|
|
55
56
|
chart.sections; // each section as played, with its first and last bar
|
|
56
57
|
chart.diagnostics; // errors and warnings, each with a line number
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChartDiagnostic, CreditRole, Credits, Line } from "./types.js";
|
|
2
|
+
/** The credit roles, in the order MusicXML writes them (grammar 7.5). */
|
|
3
|
+
export declare const CREDIT_ROLES: readonly CreditRole[];
|
|
4
|
+
/** A credit line, or null when the line isn't one (grammar 7.5). */
|
|
5
|
+
export declare function readCredit(text: string, line: number, diagnostics: ChartDiagnostic[]): Line | null;
|
|
6
|
+
/** A text line that reads like a credit under another name: `author: X`. */
|
|
7
|
+
export declare function nearCredit(text: string, line: number): ChartDiagnostic | null;
|
|
8
|
+
/** Every credit line's text, by role, in written order. */
|
|
9
|
+
export declare function creditsOf(lines: Line[]): Credits;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DIRECTIVE_AFTER } from "./directives.js";
|
|
2
|
+
/** The credit roles, in the order MusicXML writes them (grammar 7.5). */
|
|
3
|
+
export const CREDIT_ROLES = [
|
|
4
|
+
"composer",
|
|
5
|
+
"lyricist",
|
|
6
|
+
"arranger",
|
|
7
|
+
"copyright",
|
|
8
|
+
];
|
|
9
|
+
const NEAR_CREDITS = {
|
|
10
|
+
author: "composer",
|
|
11
|
+
writer: "composer",
|
|
12
|
+
music: "composer",
|
|
13
|
+
words: "lyricist",
|
|
14
|
+
lyrics: "lyricist",
|
|
15
|
+
arr: "arranger",
|
|
16
|
+
arranged: "arranger",
|
|
17
|
+
rights: "copyright",
|
|
18
|
+
"©": "copyright",
|
|
19
|
+
};
|
|
20
|
+
/** A credit line, or null when the line isn't one (grammar 7.5). */
|
|
21
|
+
export function readCredit(text, line, diagnostics) {
|
|
22
|
+
const m = /^(composer|lyricist|arranger|copyright)\s*:(.*)$/i.exec(text);
|
|
23
|
+
if (!m)
|
|
24
|
+
return null;
|
|
25
|
+
const role = (m[1] ?? "").toLowerCase();
|
|
26
|
+
const value = (m[2] ?? "").trim().replace(/\s+/g, " ");
|
|
27
|
+
if (!value) {
|
|
28
|
+
diagnostics.push({ line, severity: "error", message: `${role}: needs a value`, token: text });
|
|
29
|
+
return { kind: "text", line, text };
|
|
30
|
+
}
|
|
31
|
+
const after = DIRECTIVE_AFTER.exec(value);
|
|
32
|
+
if (after)
|
|
33
|
+
diagnostics.push({
|
|
34
|
+
line,
|
|
35
|
+
severity: "warning",
|
|
36
|
+
message: `a credit runs to the end of the line; put ${after[1]?.toLowerCase()}: on its own line`,
|
|
37
|
+
token: text,
|
|
38
|
+
});
|
|
39
|
+
return { kind: "credit", line, role, text: value };
|
|
40
|
+
}
|
|
41
|
+
/** A text line that reads like a credit under another name: `author: X`. */
|
|
42
|
+
export function nearCredit(text, line) {
|
|
43
|
+
const m = /^([^\s:]+)\s*:\s*(.*)$/.exec(text);
|
|
44
|
+
const role = m?.[1] ? NEAR_CREDITS[m[1].toLowerCase()] : undefined;
|
|
45
|
+
if (!m || !role)
|
|
46
|
+
return null;
|
|
47
|
+
return {
|
|
48
|
+
line,
|
|
49
|
+
severity: "warning",
|
|
50
|
+
message: `not a credit; did you mean ${role}:?`,
|
|
51
|
+
token: text,
|
|
52
|
+
...(m[2] && { suggestion: `${role}: ${m[2]}` }),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Every credit line's text, by role, in written order. */
|
|
56
|
+
export function creditsOf(lines) {
|
|
57
|
+
const credits = { composer: [], lyricist: [], arranger: [], copyright: [] };
|
|
58
|
+
for (const l of lines)
|
|
59
|
+
if (l.kind === "credit")
|
|
60
|
+
credits[l.role].push(l.text);
|
|
61
|
+
return credits;
|
|
62
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ChartDiagnostic, Directives, Meter } from "./types.js";
|
|
2
2
|
export declare const DIRECTIVE_NAMES: readonly ["key", "time", "tempo", "feel"];
|
|
3
|
+
/** A directive written after a comma, in a line that runs to its end (`part:`, credits). */
|
|
4
|
+
export declare const DIRECTIVE_AFTER: RegExp;
|
|
3
5
|
/** `n/d` with n from 1 to 32 and d in 2, 4, 8, 16. */
|
|
4
6
|
export declare function parseMeter(text: string): Meter | null;
|
|
5
7
|
/** Beats per bar: compound meters (6/8, 9/8, 12/8) count dotted quarters. */
|
package/dist/chart/directives.js
CHANGED
package/dist/chart/document.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ChartDiagnostic, Line, Part } from "./types.js";
|
|
1
|
+
import type { ChartDiagnostic, Credits, Line, Part } from "./types.js";
|
|
2
2
|
/** Classify every line of a chart: title, sections, directives, bar lines and text. */
|
|
3
3
|
export declare function readDocument(text: string): {
|
|
4
4
|
title: string | null;
|
|
5
5
|
part: Part | null;
|
|
6
6
|
parts: Part[];
|
|
7
|
+
credits: Credits;
|
|
7
8
|
lines: Line[];
|
|
8
9
|
diagnostics: ChartDiagnostic[];
|
|
9
10
|
};
|
package/dist/chart/document.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseChord } from "../chords/parse.js";
|
|
2
2
|
import { misplacedRepeat, parseBarLine, readRepeat, repeatTail } from "./barLine.js";
|
|
3
|
-
import {
|
|
3
|
+
import { creditsOf, nearCredit, readCredit } from "./credits.js";
|
|
4
|
+
import { DIRECTIVE_AFTER, parseDirectiveLine } from "./directives.js";
|
|
4
5
|
import { groupSystems } from "./systems.js";
|
|
5
6
|
const NEAR_DIRECTIVES = {
|
|
6
7
|
meter: "time",
|
|
@@ -10,7 +11,6 @@ const NEAR_DIRECTIVES = {
|
|
|
10
11
|
instrument: "part",
|
|
11
12
|
parts: "part",
|
|
12
13
|
};
|
|
13
|
-
const DIRECTIVE_AFTER = /,\s*(key|time|tempo|feel)\s*:/i;
|
|
14
14
|
/** A `part:` line's label and name, or why it has none (grammar 7.3). */
|
|
15
15
|
function readPart(text) {
|
|
16
16
|
const m = /^part\s*:(.*)$/i.exec(text);
|
|
@@ -149,6 +149,9 @@ function oldFormat(text, line) {
|
|
|
149
149
|
const label = /^\[([^\]]+)\]$/.exec(text) ?? /^([A-Za-z][\w ]*):$/.exec(text);
|
|
150
150
|
if (label?.[1])
|
|
151
151
|
return warn("a section label; barmark headings start with ##", `## ${label[1].trim()}`);
|
|
152
|
+
const credit = nearCredit(text, line);
|
|
153
|
+
if (credit)
|
|
154
|
+
return credit;
|
|
152
155
|
const near = /^(\w+)\s*:\s*(.*)$/.exec(text);
|
|
153
156
|
const name = near?.[1] ? NEAR_DIRECTIVES[near[1].toLowerCase()] : undefined;
|
|
154
157
|
if (near && name)
|
|
@@ -215,6 +218,9 @@ export function readDocument(text) {
|
|
|
215
218
|
return { kind: "part", line, ...read };
|
|
216
219
|
};
|
|
217
220
|
const otherLine = (t, line) => {
|
|
221
|
+
const credit = readCredit(t, line, diagnostics);
|
|
222
|
+
if (credit)
|
|
223
|
+
return credit;
|
|
218
224
|
const read = readPart(t);
|
|
219
225
|
if (read)
|
|
220
226
|
return partLine(read, t, line);
|
|
@@ -293,6 +299,7 @@ export function readDocument(text) {
|
|
|
293
299
|
title,
|
|
294
300
|
part: parts.length === 1 ? (parts[0] ?? null) : null,
|
|
295
301
|
parts,
|
|
302
|
+
credits: creditsOf(lines),
|
|
296
303
|
lines: grouped.lines,
|
|
297
304
|
diagnostics,
|
|
298
305
|
};
|
package/dist/chart/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { parseBarLine } from "./barLine.js";
|
|
2
|
+
export { CREDIT_ROLES } from "./credits.js";
|
|
2
3
|
export { degreeOf } from "./degree.js";
|
|
3
4
|
export { printDirection } from "./direction.js";
|
|
4
5
|
export { beatsOf, DIRECTIVE_NAMES, parseDirectiveLine, parseMeter } from "./directives.js";
|
package/dist/chart/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { parseBarLine } from "./barLine.js";
|
|
2
|
+
export { CREDIT_ROLES } from "./credits.js";
|
|
2
3
|
export { degreeOf } from "./degree.js";
|
|
3
4
|
export { printDirection } from "./direction.js";
|
|
4
5
|
export { beatsOf, DIRECTIVE_NAMES, parseDirectiveLine, parseMeter } from "./directives.js";
|
package/dist/chart/parse.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type { ChartParse } from "./types.js";
|
|
1
|
+
import type { ChartDiagnostic, ChartEvent, ChartParse } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Each part's events, played in lockstep: the shapes match because every
|
|
4
|
+
* line of a system shares its structure. Where they don't, the lead's
|
|
5
|
+
* shape is kept and the first place they part is an error.
|
|
6
|
+
*/
|
|
7
|
+
export declare function zipEvents(each: ChartEvent[][], report: (d: ChartDiagnostic) => void): ChartEvent[];
|
|
2
8
|
/** Read a whole barmark chart: the document as written and the bars in play order. Never throws. */
|
|
3
9
|
export declare function parseChart(text: string): ChartParse;
|
|
4
10
|
/**
|
package/dist/chart/parse.js
CHANGED
|
@@ -19,23 +19,50 @@ function mergeReports(each) {
|
|
|
19
19
|
return [...most.values()].flat();
|
|
20
20
|
}
|
|
21
21
|
const partBar = (b) => b.tacet ? null : { line: b.line, slots: b.slots, ...(b.words && { words: b.words }) };
|
|
22
|
+
const meterText = (b) => `${b.meter.n}/${b.meter.d}`;
|
|
22
23
|
/** One bar of every part: shared fields from the first, the meter from the first that plays. */
|
|
23
24
|
function zipBar(bars, report) {
|
|
24
25
|
const [first, ...rest] = bars;
|
|
25
26
|
const playing = bars.filter((b) => !b.tacet);
|
|
26
27
|
const meter = playing[0]?.meter ?? first.meter;
|
|
27
|
-
|
|
28
|
+
const meters = [...new Set(playing.map(meterText))];
|
|
29
|
+
// A `%` copies its bar's one-bar meter, so parts can disagree: say so on every line that plays the bar.
|
|
30
|
+
if (meters.length > 1)
|
|
31
|
+
for (const line of new Set(playing.map((b) => b.line)))
|
|
32
|
+
report({
|
|
33
|
+
line,
|
|
34
|
+
severity: "error",
|
|
35
|
+
message: `the parts disagree on this bar's meter (${meters.join(", ")})`,
|
|
36
|
+
token: "|",
|
|
37
|
+
});
|
|
38
|
+
return { ...first, meter, parts: [first, ...rest].map(partBar) };
|
|
39
|
+
}
|
|
40
|
+
const lineOf = (e) => (e.kind === "bar" ? e.bar.line : e.line);
|
|
41
|
+
/** The first event at which some part's timeline differs in shape from the lead's, or -1. */
|
|
42
|
+
function stepAt(each) {
|
|
43
|
+
const [lead = []] = each;
|
|
44
|
+
const longest = Math.max(...each.map((events) => events.length));
|
|
45
|
+
for (let i = 0; i < longest; i++)
|
|
46
|
+
if (each.some((events) => events[i]?.kind !== lead[i]?.kind))
|
|
47
|
+
return i;
|
|
48
|
+
return -1;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Each part's events, played in lockstep: the shapes match because every
|
|
52
|
+
* line of a system shares its structure. Where they don't, the lead's
|
|
53
|
+
* shape is kept and the first place they part is an error.
|
|
54
|
+
*/
|
|
55
|
+
export function zipEvents(each, report) {
|
|
56
|
+
const [lead = []] = each;
|
|
57
|
+
const apart = stepAt(each);
|
|
58
|
+
const at = lead[apart] ?? lead[lead.length - 1];
|
|
59
|
+
if (apart >= 0 && at)
|
|
28
60
|
report({
|
|
29
|
-
line:
|
|
61
|
+
line: lineOf(at),
|
|
30
62
|
severity: "error",
|
|
31
|
-
message: "the parts
|
|
63
|
+
message: "the parts fall out of step here; check that every line of this system writes the same marks",
|
|
32
64
|
token: "|",
|
|
33
65
|
});
|
|
34
|
-
return { ...first, meter, parts: [first, ...rest].map(partBar) };
|
|
35
|
-
}
|
|
36
|
-
/** Each part's events, played in lockstep: the shapes match because every line of a system shares its structure. */
|
|
37
|
-
function zipEvents(each, report) {
|
|
38
|
-
const [lead = []] = each;
|
|
39
66
|
return lead.map((e, i) => {
|
|
40
67
|
const peers = each.map((events) => events[i] ?? e);
|
|
41
68
|
if (e.kind === "bar")
|
|
@@ -66,6 +93,7 @@ export function parseChart(text) {
|
|
|
66
93
|
title: doc.title,
|
|
67
94
|
part: doc.part,
|
|
68
95
|
parts: doc.parts,
|
|
96
|
+
credits: doc.credits,
|
|
69
97
|
lines: doc.lines,
|
|
70
98
|
events: played.events,
|
|
71
99
|
bars: flattenBars(played.events),
|
|
@@ -94,6 +122,7 @@ export function extractPart(text, label) {
|
|
|
94
122
|
title: doc.title,
|
|
95
123
|
part,
|
|
96
124
|
parts: [part],
|
|
125
|
+
credits: doc.credits,
|
|
97
126
|
lines,
|
|
98
127
|
events: played.events,
|
|
99
128
|
bars: flattenBars(played.events),
|
package/dist/chart/print.js
CHANGED
|
@@ -148,6 +148,8 @@ export function printLine(l, beats = []) {
|
|
|
148
148
|
return printDirectives(l.set);
|
|
149
149
|
case "part":
|
|
150
150
|
return `part: ${l.label ? `${l.label} = ` : ""}${l.name}`;
|
|
151
|
+
case "credit":
|
|
152
|
+
return `${l.role}: ${l.text}`;
|
|
151
153
|
case "bars":
|
|
152
154
|
return joinPieces(barPieces(l, beats));
|
|
153
155
|
default:
|
|
@@ -282,7 +284,10 @@ export function printPart(text, label) {
|
|
|
282
284
|
return null;
|
|
283
285
|
const kept = new Set(parsed.lines.map((l) => l.line));
|
|
284
286
|
const skip = new Set(readDocument(text)
|
|
285
|
-
.lines.filter((l) =>
|
|
287
|
+
.lines.filter((l) =>
|
|
288
|
+
// A `part:` demoted to text (a shared label) would declare a part again in the extract.
|
|
289
|
+
(l.kind === "text" && /^part\s*:/i.test(l.text)) ||
|
|
290
|
+
((l.kind === "part" || l.kind === "bars" || l.kind === "invalid") && !kept.has(l.line)))
|
|
286
291
|
.map((l) => l.line));
|
|
287
292
|
return printLines(text, parsed, (l) => l, skip);
|
|
288
293
|
}
|
package/dist/chart/repeats.js
CHANGED
|
@@ -106,7 +106,7 @@ export function pairRepeats(lines, error) {
|
|
|
106
106
|
for (const l of lines) {
|
|
107
107
|
if (l.kind === "bars" && l.ending)
|
|
108
108
|
takeEnding(st, l, error);
|
|
109
|
-
else if (st.endings && l.kind === "text")
|
|
109
|
+
else if (st.endings && (l.kind === "text" || l.kind === "credit"))
|
|
110
110
|
st.endings.between.push({ line: l, repeat: null });
|
|
111
111
|
else {
|
|
112
112
|
finish();
|
package/dist/chart/systems.js
CHANGED
|
@@ -51,6 +51,23 @@ function numberSystems(lines) {
|
|
|
51
51
|
return { ...l, system };
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Each system's reference line: the first whose structure most of the
|
|
56
|
+
* system's lines share, so one odd line is the error wherever it sits.
|
|
57
|
+
*/
|
|
58
|
+
function referenceLines(lines) {
|
|
59
|
+
const bySystem = new Map();
|
|
60
|
+
for (const l of lines)
|
|
61
|
+
if (l.kind === "bars" && l.system !== undefined)
|
|
62
|
+
bySystem.set(l.system, [...(bySystem.get(l.system) ?? []), l]);
|
|
63
|
+
const refs = new Map();
|
|
64
|
+
for (const [system, members] of bySystem) {
|
|
65
|
+
const votes = (l) => members.filter((m) => structureOf(m) === structureOf(l)).length;
|
|
66
|
+
const best = members.reduce((a, b) => (votes(b) > votes(a) ? b : a));
|
|
67
|
+
refs.set(system, best);
|
|
68
|
+
}
|
|
69
|
+
return refs;
|
|
70
|
+
}
|
|
54
71
|
/**
|
|
55
72
|
* Group a multi-part chart's labelled bar lines into systems and check that
|
|
56
73
|
* each system's lines share their bars and structure. A line that differs is
|
|
@@ -59,15 +76,13 @@ function numberSystems(lines) {
|
|
|
59
76
|
export function groupSystems(lines) {
|
|
60
77
|
const diagnostics = [];
|
|
61
78
|
const numbered = numberSystems(lines);
|
|
62
|
-
const
|
|
79
|
+
const refs = referenceLines(numbered);
|
|
63
80
|
const out = numbered.map((l) => {
|
|
64
81
|
if (l.kind !== "bars" || l.system === undefined)
|
|
65
82
|
return l;
|
|
66
|
-
const ref =
|
|
67
|
-
if (!ref)
|
|
68
|
-
first.set(l.system, l);
|
|
83
|
+
const ref = refs.get(l.system);
|
|
84
|
+
if (!ref || ref === l)
|
|
69
85
|
return l;
|
|
70
|
-
}
|
|
71
86
|
const problem = differs(l, ref);
|
|
72
87
|
if (!problem)
|
|
73
88
|
return l;
|
package/dist/chart/types.d.ts
CHANGED
|
@@ -134,6 +134,10 @@ export type Cell = {
|
|
|
134
134
|
label: string;
|
|
135
135
|
};
|
|
136
136
|
export type Repeat = number | "open" | null;
|
|
137
|
+
/** Who a credit line names (grammar 7.5). */
|
|
138
|
+
export type CreditRole = "composer" | "lyricist" | "arranger" | "copyright";
|
|
139
|
+
/** A chart's credits, each role's entries in written order (grammar 7.5). */
|
|
140
|
+
export type Credits = Record<CreditRole, string[]>;
|
|
137
141
|
export type Line = {
|
|
138
142
|
kind: "title";
|
|
139
143
|
line: number;
|
|
@@ -171,6 +175,13 @@ export type Line = {
|
|
|
171
175
|
line: number;
|
|
172
176
|
text: string;
|
|
173
177
|
}
|
|
178
|
+
/** `composer: …` and the other credit lines (grammar 7.5). */
|
|
179
|
+
| {
|
|
180
|
+
kind: "credit";
|
|
181
|
+
line: number;
|
|
182
|
+
role: CreditRole;
|
|
183
|
+
text: string;
|
|
184
|
+
}
|
|
174
185
|
/**
|
|
175
186
|
* A bar line dropped for an error, kept as written so its section still
|
|
176
187
|
* counts as written out; `written` is how many bars its pipes write.
|
|
@@ -265,6 +276,8 @@ export type ChartParse = {
|
|
|
265
276
|
part: Part | null;
|
|
266
277
|
/** Every part the chart declares, in score order (grammar 7.4); empty when none. */
|
|
267
278
|
parts: Part[];
|
|
279
|
+
/** The credit lines (grammar 7.5); each list empty when none is written. */
|
|
280
|
+
credits: Credits;
|
|
268
281
|
lines: Line[];
|
|
269
282
|
events: ChartEvent[];
|
|
270
283
|
/** `events` flattened, with an open repeat's pass included once. */
|