chordsheetjs 14.6.1 → 15.0.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/README.md +12 -3
- package/lib/bundle.js +25728 -66671
- package/lib/bundle.min.js +148 -7118
- package/lib/index.js +1 -7770
- package/lib/index.js.map +1 -1
- package/lib/main.d.ts +2 -131
- package/lib/main.d.ts.map +1 -1
- package/lib/module.js +2 -7769
- package/lib/module.js.map +1 -1
- package/lib/pdf/chord.d.ts +219 -0
- package/lib/pdf/chord_definition/chord_definition.d.ts +66 -0
- package/lib/pdf/chord_definition/chord_definition_set.d.ts +12 -0
- package/lib/pdf/chord_diagram/chord_diagram.d.ts +131 -0
- package/lib/pdf/chord_diagram/js_pdf_renderer.d.ts +40 -0
- package/lib/pdf/chord_diagram/renderer.d.ts +43 -0
- package/lib/pdf/chord_parsing_error.d.ts +2 -0
- package/lib/pdf/chord_sheet/ast_component.d.ts +11 -0
- package/lib/pdf/chord_sheet/ast_type.d.ts +9 -0
- package/lib/pdf/chord_sheet/chord_lyrics_pair.d.ts +60 -0
- package/lib/pdf/chord_sheet/chord_pro/composite.d.ts +11 -0
- package/lib/pdf/chord_sheet/chord_pro/evaluatable.d.ts +7 -0
- package/lib/pdf/chord_sheet/chord_pro/evaluation_error.d.ts +7 -0
- package/lib/pdf/chord_sheet/chord_pro/literal.d.ts +9 -0
- package/lib/pdf/chord_sheet/chord_pro/ternary.d.ts +29 -0
- package/lib/pdf/chord_sheet/comment.d.ts +21 -0
- package/lib/pdf/chord_sheet/font.d.ts +47 -0
- package/lib/pdf/chord_sheet/font_size.d.ts +33 -0
- package/lib/pdf/chord_sheet/font_stack.d.ts +13 -0
- package/lib/pdf/chord_sheet/item.d.ts +7 -0
- package/lib/pdf/chord_sheet/line.d.ts +130 -0
- package/lib/pdf/chord_sheet/line_expander.d.ts +12 -0
- package/lib/pdf/chord_sheet/metadata.d.ts +71 -0
- package/lib/pdf/chord_sheet/metadata_accessors.d.ts +18 -0
- package/lib/pdf/chord_sheet/paragraph.d.ts +48 -0
- package/lib/pdf/chord_sheet/soft_line_break.d.ts +15 -0
- package/lib/pdf/chord_sheet/song.d.ts +253 -0
- package/lib/pdf/chord_sheet/song_mapper.d.ts +15 -0
- package/lib/pdf/chord_sheet/standard_metadata_providers.d.ts +5 -0
- package/lib/pdf/chord_sheet/tag.d.ts +104 -0
- package/lib/pdf/chord_sheet/tag_interpreter.d.ts +14 -0
- package/lib/pdf/chord_sheet/tags.d.ts +259 -0
- package/lib/pdf/chord_sheet/trace_info.d.ts +6 -0
- package/lib/pdf/chord_sheet_serializer.d.ts +49 -0
- package/lib/pdf/constants.d.ts +117 -0
- package/lib/pdf/formatter/chord_pro_formatter.d.ts +39 -0
- package/lib/pdf/formatter/chord_renderer.d.ts +30 -0
- package/lib/pdf/formatter/chords_over_words_formatter.d.ts +33 -0
- package/lib/pdf/formatter/configuration/base_configuration.d.ts +58 -0
- package/lib/pdf/formatter/configuration/default_config_manager.d.ts +31 -0
- package/lib/pdf/formatter/configuration/html_configuration.d.ts +37 -0
- package/lib/pdf/formatter/configuration/index.d.ts +13 -0
- package/lib/pdf/formatter/configuration/measured_html_configuration.d.ts +38 -0
- package/lib/pdf/formatter/configuration/measurement_based_configuration.d.ts +204 -0
- package/lib/pdf/formatter/configuration/pdf_configuration.d.ts +16 -0
- package/lib/pdf/formatter/formatter.d.ts +38 -0
- package/lib/pdf/formatter/formatting_context.d.ts +7 -0
- package/lib/pdf/formatter/html_div_formatter.d.ts +9 -0
- package/lib/pdf/formatter/html_formatter.d.ts +60 -0
- package/lib/pdf/formatter/html_table_formatter.d.ts +10 -0
- package/lib/pdf/formatter/measured_html_formatter.d.ts +43 -0
- package/lib/pdf/formatter/measurement_based_formatter.d.ts +19 -0
- package/lib/pdf/formatter/pdf_formatter/doc_wrapper.d.ts +53 -0
- package/lib/pdf/formatter/pdf_formatter/fonts/NimbusSansLFonts.base64.d.ts +4 -0
- package/lib/pdf/formatter/pdf_formatter/types.d.ts +34 -0
- package/lib/pdf/formatter/pdf_formatter.d.ts +40 -0
- package/lib/pdf/formatter/templates/html_div_formatter.d.ts +3 -0
- package/lib/pdf/formatter/templates/html_table_formatter.d.ts +3 -0
- package/lib/pdf/formatter/text_formatter.d.ts +35 -0
- package/lib/pdf/helpers.d.ts +42 -0
- package/lib/pdf/index.d.ts +126 -0
- package/lib/pdf/index.js +24369 -0
- package/lib/pdf/key.d.ts +124 -0
- package/lib/pdf/key_config.d.ts +3 -0
- package/lib/pdf/layout/engine/condition.d.ts +25 -0
- package/lib/pdf/layout/engine/dimensions.d.ts +33 -0
- package/lib/pdf/layout/engine/index.d.ts +7 -0
- package/lib/pdf/layout/engine/item_processor.d.ts +70 -0
- package/lib/pdf/layout/engine/layout_engine.d.ts +67 -0
- package/lib/pdf/layout/engine/layout_factory.d.ts +22 -0
- package/lib/pdf/layout/engine/layout_helpers.d.ts +35 -0
- package/lib/pdf/layout/engine/line_breaker.d.ts +54 -0
- package/lib/pdf/layout/engine/paragraph_splitter/index.d.ts +5 -0
- package/lib/pdf/layout/engine/paragraph_splitter/paragraph_splitter.d.ts +5 -0
- package/lib/pdf/layout/engine/paragraph_splitter/strategies/five_or_more_lines_paragraph_split_strategy.d.ts +14 -0
- package/lib/pdf/layout/engine/paragraph_splitter/strategies/four_lines_paragraph_split_strategy.d.ts +8 -0
- package/lib/pdf/layout/engine/paragraph_splitter/strategies/three_or_less_lines_paragraph_split_strategy.d.ts +4 -0
- package/lib/pdf/layout/engine/title_separator_tag.d.ts +8 -0
- package/lib/pdf/layout/engine/types.d.ts +98 -0
- package/lib/pdf/layout/measurement/canvas_measurer.d.ts +18 -0
- package/lib/pdf/layout/measurement/dom_measurer.d.ts +21 -0
- package/lib/pdf/layout/measurement/index.d.ts +4 -0
- package/lib/pdf/layout/measurement/js_pdf_measurer.d.ts +12 -0
- package/lib/pdf/layout/measurement/measurer.d.ts +52 -0
- package/lib/pdf/module.js +24336 -0
- package/lib/pdf/normalize_mappings/enharmonic-normalize.d.ts +2 -0
- package/lib/pdf/normalize_mappings/suffix-normalize-mapping.d.ts +2 -0
- package/lib/pdf/pango/pango_helpers.d.ts +6 -0
- package/lib/pdf/parser/chord/peg_parser.d.ts +55 -0
- package/lib/pdf/parser/chord_definition/peg_parser.d.ts +55 -0
- package/lib/pdf/parser/chord_pro/helpers.d.ts +15 -0
- package/lib/pdf/parser/chord_pro/peg_parser.d.ts +55 -0
- package/lib/pdf/parser/chord_pro_parser.d.ts +32 -0
- package/lib/pdf/parser/chord_sheet_parser.d.ts +57 -0
- package/lib/pdf/parser/chords_over_words/helpers.d.ts +33 -0
- package/lib/pdf/parser/chords_over_words/peg_parser.d.ts +55 -0
- package/lib/pdf/parser/chords_over_words_parser.d.ts +67 -0
- package/lib/pdf/parser/null_tracer.d.ts +4 -0
- package/lib/pdf/parser/parser_helpers.d.ts +3 -0
- package/lib/pdf/parser/parser_warning.d.ts +33 -0
- package/lib/pdf/parser/ultimate_guitar_parser.d.ts +46 -0
- package/lib/pdf/pdf.d.ts +2 -0
- package/lib/pdf/rendering/html/html_doc_wrapper.d.ts +82 -0
- package/lib/pdf/rendering/html/html_element_styler.d.ts +58 -0
- package/lib/pdf/rendering/html/positioned_html_renderer.d.ts +85 -0
- package/lib/pdf/rendering/pdf/js_pdf_renderer.d.ts +46 -0
- package/lib/pdf/rendering/pdf/pdf_chord_diagram_renderer.d.ts +118 -0
- package/lib/pdf/rendering/renderer.d.ts +273 -0
- package/lib/pdf/rendering/shared/layout_section_renderer.d.ts +93 -0
- package/lib/pdf/scales.d.ts +3 -0
- package/lib/pdf/serialized_types.d.ts +76 -0
- package/lib/pdf/song_builder.d.ts +38 -0
- package/lib/pdf/template_helpers/metadata_processor.d.ts +14 -0
- package/lib/pdf/template_helpers/when.d.ts +13 -0
- package/lib/pdf/template_helpers/when_callback.d.ts +2 -0
- package/lib/pdf/template_helpers/when_clause.d.ts +8 -0
- package/lib/pdf/template_helpers.d.ts +64 -0
- package/lib/pdf/utilities.d.ts +35 -0
- package/lib/pdf/version.d.ts +2 -0
- package/package.json +20 -2
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import Key from './key';
|
|
2
|
+
import { Accidental, ChordType } from './constants';
|
|
3
|
+
interface ChordProperties {
|
|
4
|
+
root?: Key | null;
|
|
5
|
+
suffix?: string | null;
|
|
6
|
+
quality?: string | null;
|
|
7
|
+
extensions?: string | null;
|
|
8
|
+
bass?: Key | null;
|
|
9
|
+
optional?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ChordConstructorOptions {
|
|
12
|
+
base?: string | number | null;
|
|
13
|
+
accidental?: Accidental | null;
|
|
14
|
+
suffix?: string | null;
|
|
15
|
+
quality?: string | null;
|
|
16
|
+
extensions?: string | null;
|
|
17
|
+
bassBase?: string | number | null;
|
|
18
|
+
bassAccidental?: Accidental | null;
|
|
19
|
+
root?: Key | null;
|
|
20
|
+
bass?: Key | null;
|
|
21
|
+
chordType?: ChordType | null;
|
|
22
|
+
optional?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Represents a Chord, consisting of a root, suffix (quality) and bass
|
|
26
|
+
*/
|
|
27
|
+
declare class Chord implements ChordProperties {
|
|
28
|
+
bass: Key | null;
|
|
29
|
+
root: Key | null;
|
|
30
|
+
private _suffix;
|
|
31
|
+
private _quality;
|
|
32
|
+
private _extensions;
|
|
33
|
+
get suffix(): string | null;
|
|
34
|
+
get quality(): string | null;
|
|
35
|
+
get extensions(): string | null;
|
|
36
|
+
optional: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Tries to parse a chord string into a chord
|
|
39
|
+
* Any leading or trailing whitespace is removed first, so a chord like ` \n E/G# \r ` is valid.
|
|
40
|
+
* @param chordString the chord string, eg `Esus4/G#` or `1sus4/#3`.
|
|
41
|
+
* @returns {Chord|null}
|
|
42
|
+
*/
|
|
43
|
+
static parse(chordString: string): Chord | null;
|
|
44
|
+
static parseOrFail(chordString: string): Chord;
|
|
45
|
+
/**
|
|
46
|
+
* Returns a deep copy of the chord
|
|
47
|
+
* @returns {Chord}
|
|
48
|
+
*/
|
|
49
|
+
clone(): Chord;
|
|
50
|
+
/**
|
|
51
|
+
* Converts the chord to a chord symbol, using the supplied key as a reference.
|
|
52
|
+
* For example, a numeric chord `#4` with reference key `E` will return the chord symbol `A#`.
|
|
53
|
+
* When the chord is already a chord symbol, it will return a clone of the object.
|
|
54
|
+
* @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a
|
|
55
|
+
* numeric or numeral.
|
|
56
|
+
* @returns {Chord} the chord symbol
|
|
57
|
+
*/
|
|
58
|
+
toChordSymbol(referenceKey?: Key | string | null): Chord;
|
|
59
|
+
/**
|
|
60
|
+
* Converts the chord to a chord symbol string, using the supplied key as a reference.
|
|
61
|
+
* For example, a numeric chord `#4` with reference key `E` will return the chord symbol `A#`.
|
|
62
|
+
* When the chord is already a chord symbol, it will return a string version of the chord.
|
|
63
|
+
* @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a
|
|
64
|
+
* numeric or numeral.
|
|
65
|
+
* @returns {string} the chord symbol string
|
|
66
|
+
* @see {toChordSymbol}
|
|
67
|
+
*/
|
|
68
|
+
toChordSymbolString(referenceKey?: Key | string | null): string;
|
|
69
|
+
/**
|
|
70
|
+
* Determines whether the chord is a chord symbol
|
|
71
|
+
* @returns {boolean}
|
|
72
|
+
*/
|
|
73
|
+
isChordSymbol(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Converts the chord to a chord solfege, using the supplied key as a reference.
|
|
76
|
+
* For example, a numeric chord `#4` with reference key `Mi` will return the chord symbol `La#`.
|
|
77
|
+
* When the chord is already a chord solfege, it will return a clone of the object.
|
|
78
|
+
* @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a
|
|
79
|
+
* numeric or numeral.
|
|
80
|
+
* @returns {Chord} the chord solfege
|
|
81
|
+
*/
|
|
82
|
+
toChordSolfege(referenceKey?: Key | string | null): Chord;
|
|
83
|
+
/**
|
|
84
|
+
* Converts the chord to a chord solfege string, using the supplied key as a reference.
|
|
85
|
+
* For example, a numeric chord `#4` with reference key `E` will return the chord solfege `A#`.
|
|
86
|
+
* When the chord is already a chord solfege, it will return a string version of the chord.
|
|
87
|
+
* @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a
|
|
88
|
+
* numeric or numeral.
|
|
89
|
+
* @returns {string} the chord solfege string
|
|
90
|
+
* @see {toChordSolfege}
|
|
91
|
+
*/
|
|
92
|
+
toChordSolfegeString(referenceKey?: Key | string | null): string;
|
|
93
|
+
/**
|
|
94
|
+
* Determines whether the chord is a chord solfege
|
|
95
|
+
* @returns {boolean}
|
|
96
|
+
*/
|
|
97
|
+
isChordSolfege(): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Converts the chord to a numeric chord, using the supplied key as a reference.
|
|
100
|
+
* For example, a chord symbol A# with reference key E will return the numeric chord #4.
|
|
101
|
+
* @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a chord symbol
|
|
102
|
+
* @returns {Chord} the numeric chord
|
|
103
|
+
*/
|
|
104
|
+
toNumeric(referenceKey?: Key | string | null): Chord;
|
|
105
|
+
/**
|
|
106
|
+
* Converts the chord to a numeral chord, using the supplied key as a reference.
|
|
107
|
+
* For example, a chord symbol A# with reference key E will return the numeral chord #IV.
|
|
108
|
+
* @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a chord symbol
|
|
109
|
+
* @returns {Chord} the numeral chord
|
|
110
|
+
*/
|
|
111
|
+
toNumeral(referenceKey?: Key | string | null): Chord;
|
|
112
|
+
/**
|
|
113
|
+
* Converts the chord to a numeral chord string, using the supplied kye as a reference.
|
|
114
|
+
* For example, a chord symbol A# with reference key E will return the numeral chord #4.
|
|
115
|
+
* @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a chord symbol
|
|
116
|
+
* @returns {string} the numeral chord string
|
|
117
|
+
* @see {toNumeral}
|
|
118
|
+
*/
|
|
119
|
+
toNumeralString(referenceKey?: Key | string | null): string;
|
|
120
|
+
/**
|
|
121
|
+
* Determines whether the chord is numeric
|
|
122
|
+
* @returns {boolean}
|
|
123
|
+
*/
|
|
124
|
+
isNumeric(): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Converts the chord to a numeric chord string, using the supplied kye as a reference.
|
|
127
|
+
* For example, a chord symbol A# with reference key E will return the numeric chord #4.
|
|
128
|
+
* @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a chord symbol
|
|
129
|
+
* @returns {string} the numeric chord string
|
|
130
|
+
* @see {toNumeric}
|
|
131
|
+
*/
|
|
132
|
+
toNumericString(referenceKey?: Key | string | null): string;
|
|
133
|
+
/**
|
|
134
|
+
* Determines whether the chord is a numeral
|
|
135
|
+
* @returns {boolean}
|
|
136
|
+
*/
|
|
137
|
+
isNumeral(): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Converts the chord to a string, eg `Esus4/G#` or `1sus4/#3`
|
|
140
|
+
* @param {Object} [configuration={}] options
|
|
141
|
+
* @param {boolean} [configuration.useUnicodeModifier=false] Whether or not to use unicode modifiers.
|
|
142
|
+
* This will make `#` (sharp) look like `♯` and `b` (flat) look like `♭`
|
|
143
|
+
* @returns {string} the chord string
|
|
144
|
+
*/
|
|
145
|
+
toString({ useUnicodeModifier }?: {
|
|
146
|
+
useUnicodeModifier?: boolean | undefined;
|
|
147
|
+
}): string;
|
|
148
|
+
/**
|
|
149
|
+
* Normalizes the chord root and bass notes:
|
|
150
|
+
* - Fab becomes Mi
|
|
151
|
+
* - Dob becomes Si
|
|
152
|
+
* - Si# becomes Do
|
|
153
|
+
* - Mi# becomes Fa
|
|
154
|
+
* - Fb becomes E
|
|
155
|
+
* - Cb becomes B
|
|
156
|
+
* - B# becomes C
|
|
157
|
+
* - E# becomes F
|
|
158
|
+
* - 4b becomes 3
|
|
159
|
+
* - 1b becomes 7
|
|
160
|
+
* - 7# becomes 1
|
|
161
|
+
* - 3# becomes 4
|
|
162
|
+
*
|
|
163
|
+
* Besides that it normalizes the suffix if `normalizeSuffix` is `true`.
|
|
164
|
+
* For example, `sus2` becomes `2`, `sus4` becomes `sus`.
|
|
165
|
+
* All suffix normalizations can be found in `src/normalize_mappings/suffix-mapping.txt`.
|
|
166
|
+
*
|
|
167
|
+
* When the chord is minor, bass notes are normalized off of the relative major
|
|
168
|
+
* of the root note. For example, `Em/A#` becomes `Em/Bb`.
|
|
169
|
+
* @param {Key|string} [key=null] the key to normalize to
|
|
170
|
+
* @param {Object} [options={}] options
|
|
171
|
+
* @param {boolean} [options.normalizeSuffix=true] whether to normalize the chord suffix after transposing
|
|
172
|
+
* @returns {Chord} the normalized chord
|
|
173
|
+
*/
|
|
174
|
+
normalize(key?: Key | string | null, { normalizeSuffix }?: {
|
|
175
|
+
normalizeSuffix?: boolean;
|
|
176
|
+
}): Chord;
|
|
177
|
+
/**
|
|
178
|
+
* Switches to the specified accidental
|
|
179
|
+
* @param newAccidental the accidental to use: `'#'` or `'b'`
|
|
180
|
+
* @returns {Chord} the new, changed chord
|
|
181
|
+
*/
|
|
182
|
+
useAccidental(newAccidental: Accidental): Chord;
|
|
183
|
+
/**
|
|
184
|
+
* @deprecated Use useAccidental instead
|
|
185
|
+
*/
|
|
186
|
+
useModifier(newAccidental: Accidental): Chord;
|
|
187
|
+
/**
|
|
188
|
+
* Transposes the chord up by 1 semitone. Eg. A becomes A#, Eb becomes E
|
|
189
|
+
* @returns {Chord} the new, transposed chord
|
|
190
|
+
*/
|
|
191
|
+
transposeUp(): Chord;
|
|
192
|
+
/**
|
|
193
|
+
* Transposes the chord down by 1 semitone. Eg. A# becomes A, E becomes Eb
|
|
194
|
+
* @returns {Chord} the new, transposed chord
|
|
195
|
+
*/
|
|
196
|
+
transposeDown(): Chord;
|
|
197
|
+
/**
|
|
198
|
+
* Transposes the chord by the specified number of semitones
|
|
199
|
+
* @param delta de number of semitones
|
|
200
|
+
* @returns {Chord} the new, transposed chord
|
|
201
|
+
*/
|
|
202
|
+
transpose(delta: number): Chord;
|
|
203
|
+
constructor(options: ChordConstructorOptions);
|
|
204
|
+
equals(otherChord: Chord): boolean;
|
|
205
|
+
static determineRoot(options: ChordConstructorOptions & {
|
|
206
|
+
suffix?: string | null;
|
|
207
|
+
}): Key | null;
|
|
208
|
+
static determineBass(options: ChordConstructorOptions): Key | null;
|
|
209
|
+
isMinor(): boolean;
|
|
210
|
+
makeMinor(): Chord;
|
|
211
|
+
set(properties: ChordProperties): Chord;
|
|
212
|
+
private determineSuffixProps;
|
|
213
|
+
private is;
|
|
214
|
+
private transform;
|
|
215
|
+
private get normalizedSuffix();
|
|
216
|
+
private prepareKeyForConversion;
|
|
217
|
+
private finalizeConvertedChord;
|
|
218
|
+
}
|
|
219
|
+
export default Chord;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Fret, NonSoundingString, OpenFret } from '../constants';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether the given fret is an open fret (unfingered, open string).
|
|
4
|
+
* @param fret - The fret to check.
|
|
5
|
+
* @returns `true` if the fret is an open fret, `false` otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isOpenFret(fret: Fret): fret is OpenFret;
|
|
8
|
+
/**
|
|
9
|
+
* Checks whether the given fret represents a non-sounding (muted/damped) string.
|
|
10
|
+
* @param fret - The fret to check.
|
|
11
|
+
* @returns `true` if the fret represents a non-sounding string, `false` otherwise.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isNonSoundingString(fret: Fret): fret is NonSoundingString;
|
|
14
|
+
/**
|
|
15
|
+
* Represents a chord definition.
|
|
16
|
+
*
|
|
17
|
+
* Definitions are made using the `{chord}` or `{define}` directive.
|
|
18
|
+
* A chord definitions overrides a previous chord definition for the exact same chord.
|
|
19
|
+
*
|
|
20
|
+
* @see https://chordpro.org/chordpro/directives-define/
|
|
21
|
+
* @see https://chordpro.org/chordpro/directives-chord/
|
|
22
|
+
*/
|
|
23
|
+
declare class ChordDefinition {
|
|
24
|
+
/**
|
|
25
|
+
* The chord name, e.g. `C`, `Dm`, `G7`.
|
|
26
|
+
* @type {string}
|
|
27
|
+
*/
|
|
28
|
+
name: string;
|
|
29
|
+
/**
|
|
30
|
+
* Defines the offset for the chord, which is the position of the topmost finger.
|
|
31
|
+
* The offset must be 1 or higher.
|
|
32
|
+
* @type {number}
|
|
33
|
+
*/
|
|
34
|
+
baseFret: number;
|
|
35
|
+
/**
|
|
36
|
+
* Defines the string positions.
|
|
37
|
+
* Strings are enumerated from left (lowest) to right (highest), as they appear in the chord diagrams.
|
|
38
|
+
* Fret positions are relative to the offset minus one, so with base-fret 1 (the default),
|
|
39
|
+
* the topmost fret position is 1. With base-fret 3, fret position 1 indicates the 3rd position.
|
|
40
|
+
* `0` (zero) denotes an open string. Use `-1`, `N` or `x` to denote a non-sounding string.
|
|
41
|
+
* @type {Fret[]}
|
|
42
|
+
*/
|
|
43
|
+
frets: Fret[];
|
|
44
|
+
/**
|
|
45
|
+
* defines finger settings. This part may be omitted.
|
|
46
|
+
*
|
|
47
|
+
* For the frets and the fingers positions, there must be exactly as many positions as there are strings,
|
|
48
|
+
* which is 6 by default. For the fingers positions, values corresponding to open or damped strings are ignored.
|
|
49
|
+
* Finger settings may be numeric (0 .. 9) or uppercase letters (A .. Z).
|
|
50
|
+
* Note that the values -, x, X, and N are used to designate a string without finger setting.
|
|
51
|
+
* @type {number[]}
|
|
52
|
+
*/
|
|
53
|
+
fingers: number[];
|
|
54
|
+
constructor(name: string, baseFret: number, frets: Fret[], fingers?: number[]);
|
|
55
|
+
/**
|
|
56
|
+
* Parses a chord definition in the form of:
|
|
57
|
+
* - <name> base-fret <offset> frets <pos> <pos> … <pos>
|
|
58
|
+
* - <name> base-fret <offset> frets <pos> <pos> … <pos> fingers <pos> <pos> … <pos>
|
|
59
|
+
* @param chordDefinition
|
|
60
|
+
* @returns {ChordDefinition}
|
|
61
|
+
* @see https://chordpro.org/chordpro/directives-define/#common-usage
|
|
62
|
+
*/
|
|
63
|
+
static parse(chordDefinition: string): ChordDefinition;
|
|
64
|
+
clone(): ChordDefinition;
|
|
65
|
+
}
|
|
66
|
+
export default ChordDefinition;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ChordDefinition from './chord_definition';
|
|
2
|
+
export type DefinitionSet = Record<string, ChordDefinition>;
|
|
3
|
+
declare class ChordDefinitionSet {
|
|
4
|
+
definitions: DefinitionSet;
|
|
5
|
+
constructor(definitions?: DefinitionSet);
|
|
6
|
+
get(chord: string): ChordDefinition | null;
|
|
7
|
+
withDefaults(): ChordDefinitionSet;
|
|
8
|
+
add(chord: string, definition: ChordDefinition): void;
|
|
9
|
+
has(chord: string): boolean;
|
|
10
|
+
clone(): ChordDefinitionSet;
|
|
11
|
+
}
|
|
12
|
+
export default ChordDefinitionSet;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Renderer } from './renderer';
|
|
2
|
+
import { FingerNumber, FretNumber, StringNumber } from '../constants';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a barre (bar) in a chord diagram, where one finger presses multiple strings at the same fret.
|
|
5
|
+
*/
|
|
6
|
+
export interface Barre {
|
|
7
|
+
/** The starting string number (lowest). */
|
|
8
|
+
from: StringNumber;
|
|
9
|
+
/** The ending string number (highest). */
|
|
10
|
+
to: StringNumber;
|
|
11
|
+
/** The fret position of the barre. */
|
|
12
|
+
fret: FretNumber;
|
|
13
|
+
}
|
|
14
|
+
type StringList = StringNumber[];
|
|
15
|
+
/**
|
|
16
|
+
* Represents a finger position marker on a specific string and fret in a chord diagram.
|
|
17
|
+
*/
|
|
18
|
+
export interface StringMarker {
|
|
19
|
+
/** The string number where the finger is placed. */
|
|
20
|
+
string: StringNumber;
|
|
21
|
+
/** The fret number where the finger is placed. */
|
|
22
|
+
fret: FretNumber;
|
|
23
|
+
/** Optional finger number (1-4) used to press this position. */
|
|
24
|
+
finger?: FingerNumber;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Defines the structure of a chord diagram, including finger positions, barres, and string states.
|
|
28
|
+
*/
|
|
29
|
+
export interface ChordDiagramDefinition {
|
|
30
|
+
/** Array of barres in the chord. */
|
|
31
|
+
barres: Barre[];
|
|
32
|
+
/** The chord name displayed as the diagram title. */
|
|
33
|
+
chord: string;
|
|
34
|
+
/** Number of frets to display in the diagram. */
|
|
35
|
+
fretCount: number;
|
|
36
|
+
/** Array of finger position markers. */
|
|
37
|
+
markers: StringMarker[];
|
|
38
|
+
/** String numbers that are played open (unfingered). */
|
|
39
|
+
openStrings: StringList;
|
|
40
|
+
/** Total number of strings on the instrument. */
|
|
41
|
+
stringCount: number;
|
|
42
|
+
/** String numbers that are muted/not played. */
|
|
43
|
+
unusedStrings: StringList;
|
|
44
|
+
/** The starting fret position (1 for standard position, higher for transposed chords). */
|
|
45
|
+
baseFret: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Configuration options for rendering a chord diagram, controlling dimensions, colors, and visual styling.
|
|
49
|
+
*/
|
|
50
|
+
export interface ChordDiagramRenderingConfig {
|
|
51
|
+
/** Vertical position of the chord title. */
|
|
52
|
+
titleY: number;
|
|
53
|
+
/** Width of the guitar neck area. */
|
|
54
|
+
neckWidth: number;
|
|
55
|
+
/** Height of the guitar neck area. */
|
|
56
|
+
neckHeight: number;
|
|
57
|
+
/** Thickness of the nut (top bar) at the first fret. */
|
|
58
|
+
nutThickness: number;
|
|
59
|
+
/** Color of the nut. */
|
|
60
|
+
nutColor: number | string;
|
|
61
|
+
/** Thickness of regular fret bars. */
|
|
62
|
+
fretThickness: number;
|
|
63
|
+
/** Color of the fret lines. */
|
|
64
|
+
fretColor: number | string;
|
|
65
|
+
/** Color of the strings. */
|
|
66
|
+
stringColor: number | string;
|
|
67
|
+
/** Size of open/muted string indicators above the nut. */
|
|
68
|
+
stringIndicatorSize: number;
|
|
69
|
+
/** Size of finger position markers on the fretboard. */
|
|
70
|
+
fingerIndicatorSize: number;
|
|
71
|
+
/** Vertical offset adjustment for finger indicators. */
|
|
72
|
+
fingerIndicatorOffset: number;
|
|
73
|
+
/** Thickness of the string lines. */
|
|
74
|
+
stringThickness: number;
|
|
75
|
+
/** Thickness of the fret lines. */
|
|
76
|
+
fretLineThickness: number;
|
|
77
|
+
/** Line thickness for open string (circle) indicators. */
|
|
78
|
+
openStringIndicatorThickness: number;
|
|
79
|
+
/** Line thickness for muted string (X) indicators. */
|
|
80
|
+
unusedStringIndicatorThickness: number;
|
|
81
|
+
/** Line thickness for finger position markers. */
|
|
82
|
+
markerThickness: number;
|
|
83
|
+
/** Line thickness for barre indicators. */
|
|
84
|
+
barreThickness: number;
|
|
85
|
+
/** Font size for the chord title. */
|
|
86
|
+
titleFontSize: number;
|
|
87
|
+
/** Font size for the base fret number (when transposed). */
|
|
88
|
+
baseFretFontSize: number;
|
|
89
|
+
/** Font size for finger numbers below the diagram. */
|
|
90
|
+
fingerNumberFontSize: number;
|
|
91
|
+
/** Whether to display finger numbers below the diagram. */
|
|
92
|
+
showFingerNumbers: boolean;
|
|
93
|
+
/** Horizontal spacing between multiple diagrams. */
|
|
94
|
+
diagramSpacing: number;
|
|
95
|
+
/** Maximum number of diagrams per row (optional). */
|
|
96
|
+
maxDiagramsPerRow?: number | null;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Default configuration values for rendering chord diagrams.
|
|
100
|
+
*/
|
|
101
|
+
export declare const DefaultChordDiagramRenderingConfig: ChordDiagramRenderingConfig;
|
|
102
|
+
/**
|
|
103
|
+
* Renders a visual chord diagram for guitar or similar stringed instruments.
|
|
104
|
+
*
|
|
105
|
+
* A chord diagram displays finger positions, barres, open strings, and muted strings
|
|
106
|
+
* on a graphical representation of the instrument's fretboard.
|
|
107
|
+
*/
|
|
108
|
+
declare class ChordDiagram {
|
|
109
|
+
chordDiagramDefinition: ChordDiagramDefinition;
|
|
110
|
+
renderer?: Renderer;
|
|
111
|
+
config: ChordDiagramRenderingConfig;
|
|
112
|
+
constructor(chordDiagramDefinition: Partial<ChordDiagramDefinition>, config?: Partial<ChordDiagramRenderingConfig>);
|
|
113
|
+
get neckX(): number;
|
|
114
|
+
get neckY(): number;
|
|
115
|
+
get stringIndicatorY(): number;
|
|
116
|
+
get fingerNumberIndicatorsY(): number;
|
|
117
|
+
get nutThicknessCorrection(): number;
|
|
118
|
+
render(renderer: Renderer): void;
|
|
119
|
+
renderTitle(renderer: Renderer): void;
|
|
120
|
+
renderStrings(renderer: Renderer): void;
|
|
121
|
+
renderNut(renderer: Renderer): void;
|
|
122
|
+
private renderTransposedNut;
|
|
123
|
+
private renderStandardNut;
|
|
124
|
+
renderFrets(renderer: Renderer): void;
|
|
125
|
+
renderOpenStringIndicators(renderer: Renderer): void;
|
|
126
|
+
renderUnusedStringIndicators(renderer: Renderer): void;
|
|
127
|
+
renderStringMarkers(renderer: Renderer): void;
|
|
128
|
+
renderBarres(renderer: Renderer): void;
|
|
129
|
+
renderFingerNumberIndicators(renderer: Renderer): void;
|
|
130
|
+
}
|
|
131
|
+
export default ChordDiagram;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DimensionOpts, FillColorOpts, FillOpts, PositionOpts, RadiusOpts, Renderer, SizeOpts, ThicknessOpts } from './renderer';
|
|
2
|
+
import DocWrapper from '../formatter/pdf_formatter/doc_wrapper';
|
|
3
|
+
import { ChordDiagramFontConfigurations } from '../formatter/configuration';
|
|
4
|
+
/**
|
|
5
|
+
* Renderer implementation for drawing chord diagrams to a jsPDF document.
|
|
6
|
+
*/
|
|
7
|
+
declare class JsPDFRenderer implements Renderer {
|
|
8
|
+
#private;
|
|
9
|
+
doc: DocWrapper;
|
|
10
|
+
height: number;
|
|
11
|
+
width: number;
|
|
12
|
+
fonts: ChordDiagramFontConfigurations;
|
|
13
|
+
constructor(doc: DocWrapper, { x, y, width, fonts, }: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
fonts: ChordDiagramFontConfigurations;
|
|
18
|
+
});
|
|
19
|
+
static calculateHeight(width: number): number;
|
|
20
|
+
circle({ x, y, size, fill, thickness, }: FillOpts & PositionOpts & SizeOpts & ThicknessOpts): void;
|
|
21
|
+
line({ x1, y1, x2, y2, thickness, color, }: {
|
|
22
|
+
x1: number;
|
|
23
|
+
y1: number;
|
|
24
|
+
x2: number;
|
|
25
|
+
y2: number;
|
|
26
|
+
} & ThicknessOpts & FillColorOpts): void;
|
|
27
|
+
rect({ x, y, width, height, fill, thickness, radius, color, }: DimensionOpts & FillOpts & PositionOpts & RadiusOpts & ThicknessOpts & FillColorOpts): void;
|
|
28
|
+
text(text: string, { fontStyle, x, y }: {
|
|
29
|
+
fontSize: number;
|
|
30
|
+
fontStyle?: string;
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
}): void;
|
|
34
|
+
private scale;
|
|
35
|
+
private tx;
|
|
36
|
+
private ty;
|
|
37
|
+
private withFontConfiguration;
|
|
38
|
+
private withLineWidth;
|
|
39
|
+
}
|
|
40
|
+
export default JsPDFRenderer;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface RadiusOpts {
|
|
2
|
+
radius: number;
|
|
3
|
+
}
|
|
4
|
+
export interface FillOpts {
|
|
5
|
+
fill?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface HeightOpts {
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
export interface PositionOpts {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}
|
|
14
|
+
export interface SizeOpts {
|
|
15
|
+
size: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ThicknessOpts {
|
|
18
|
+
thickness: number;
|
|
19
|
+
}
|
|
20
|
+
export interface FillColorOpts {
|
|
21
|
+
color?: number | string;
|
|
22
|
+
}
|
|
23
|
+
interface WidthOpts {
|
|
24
|
+
width: number;
|
|
25
|
+
}
|
|
26
|
+
export type DimensionOpts = WidthOpts & HeightOpts;
|
|
27
|
+
export interface Renderer {
|
|
28
|
+
circle({ x, y, size, fill, thickness, }: FillOpts & PositionOpts & SizeOpts & ThicknessOpts): void;
|
|
29
|
+
line({ x1, y1, x2, y2, thickness, }: {
|
|
30
|
+
x1: number;
|
|
31
|
+
y1: number;
|
|
32
|
+
x2: number;
|
|
33
|
+
y2: number;
|
|
34
|
+
} & ThicknessOpts & FillColorOpts): void;
|
|
35
|
+
rect({ x, y, width, height, fill, thickness, radius, }: DimensionOpts & FillOpts & PositionOpts & RadiusOpts & ThicknessOpts): void;
|
|
36
|
+
text(text: string, { fontSize, fontStyle, x, y, }: {
|
|
37
|
+
fontSize: number;
|
|
38
|
+
fontStyle?: string;
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
}): void;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type Line from './line';
|
|
2
|
+
import TraceInfo from './trace_info';
|
|
3
|
+
declare abstract class AstComponent {
|
|
4
|
+
parentLine: Line | null;
|
|
5
|
+
line: number | null;
|
|
6
|
+
column: number | null;
|
|
7
|
+
offset: number | null;
|
|
8
|
+
protected constructor(traceInfo?: TraceInfo | null);
|
|
9
|
+
abstract clone(): AstComponent;
|
|
10
|
+
}
|
|
11
|
+
export default AstComponent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ChordLyricsPair from './chord_lyrics_pair';
|
|
2
|
+
import Comment from './comment';
|
|
3
|
+
import Evaluatable from './chord_pro/evaluatable';
|
|
4
|
+
import Literal from './chord_pro/literal';
|
|
5
|
+
import SoftLineBreak from './soft_line_break';
|
|
6
|
+
import Tag from './tag';
|
|
7
|
+
import Ternary from './chord_pro/ternary';
|
|
8
|
+
type AstType = ChordLyricsPair | Comment | Tag | Ternary | Evaluatable | Literal | SoftLineBreak;
|
|
9
|
+
export default AstType;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import Chord from '../chord';
|
|
2
|
+
import Key from '../key';
|
|
3
|
+
import type Line from './line';
|
|
4
|
+
import { Accidental } from '../constants';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a chord with the corresponding (partial) lyrics
|
|
7
|
+
*/
|
|
8
|
+
declare class ChordLyricsPair {
|
|
9
|
+
chords: string;
|
|
10
|
+
lyrics: string | null;
|
|
11
|
+
annotation: string | null;
|
|
12
|
+
isRhythmSymbol: boolean;
|
|
13
|
+
parentLine: Line | null;
|
|
14
|
+
private _chordObj;
|
|
15
|
+
/**
|
|
16
|
+
* Initialises a ChordLyricsPair
|
|
17
|
+
* @param {string} chords The chords
|
|
18
|
+
* @param {string | null} lyrics The lyrics
|
|
19
|
+
* @param {string | null} annotation The annotation
|
|
20
|
+
* @param {Chord | null} chordObj Optional pre-parsed Chord object
|
|
21
|
+
* @param {boolean} isRhythmSymbol Whether this pair represents a rhythm symbol
|
|
22
|
+
*/
|
|
23
|
+
constructor(chords?: string, lyrics?: string | null, annotation?: string | null, chordObj?: Chord | null, isRhythmSymbol?: boolean);
|
|
24
|
+
/** Returns the Chord object if available, otherwise parses from string */
|
|
25
|
+
get chord(): Chord | null;
|
|
26
|
+
/**
|
|
27
|
+
* Indicates whether a ChordLyricsPair should be visible in a formatted chord sheet (except for ChordPro sheets)
|
|
28
|
+
* @returns {boolean}
|
|
29
|
+
*/
|
|
30
|
+
isRenderable(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Indicates whether the ChordLyricsPair has non-empty lyrics.
|
|
33
|
+
*/
|
|
34
|
+
hasLyrics(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Returns a deep copy of the ChordLyricsPair, useful when programmatically transforming a song
|
|
37
|
+
* @returns {ChordLyricsPair}
|
|
38
|
+
*/
|
|
39
|
+
clone(): ChordLyricsPair;
|
|
40
|
+
toString(): string;
|
|
41
|
+
set({ chords, lyrics, annotation, chordObj, isRhythmSymbol, }: {
|
|
42
|
+
chords?: string;
|
|
43
|
+
lyrics?: string;
|
|
44
|
+
annotation?: string;
|
|
45
|
+
chordObj?: Chord | null;
|
|
46
|
+
isRhythmSymbol?: boolean;
|
|
47
|
+
}): ChordLyricsPair;
|
|
48
|
+
setLyrics(lyrics: string): ChordLyricsPair;
|
|
49
|
+
setAnnotation(annotation: string): ChordLyricsPair;
|
|
50
|
+
transpose(delta: number, key?: string | Key | null, { normalizeChordSuffix }?: {
|
|
51
|
+
normalizeChordSuffix: boolean;
|
|
52
|
+
}): ChordLyricsPair;
|
|
53
|
+
useAccidental(accidental: Accidental): ChordLyricsPair;
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Use useAccidental instead
|
|
56
|
+
*/
|
|
57
|
+
useModifier(accidental: Accidental): ChordLyricsPair;
|
|
58
|
+
changeChord(func: (chord: Chord) => Chord): ChordLyricsPair;
|
|
59
|
+
}
|
|
60
|
+
export default ChordLyricsPair;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Evaluatable from './evaluatable';
|
|
2
|
+
import Metadata from '../metadata';
|
|
3
|
+
declare class Composite extends Evaluatable {
|
|
4
|
+
expressions: Evaluatable[];
|
|
5
|
+
variable: string | null;
|
|
6
|
+
constructor(expressions: Evaluatable[], variable?: string | null);
|
|
7
|
+
evaluate(metadata: Metadata, metadataSeparator: string): string;
|
|
8
|
+
isRenderable(): boolean;
|
|
9
|
+
clone(): Composite;
|
|
10
|
+
}
|
|
11
|
+
export default Composite;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import AstComponent from '../ast_component';
|
|
2
|
+
import Metadata from '../metadata';
|
|
3
|
+
declare abstract class Evaluatable extends AstComponent {
|
|
4
|
+
abstract evaluate(_metadata: Metadata, _metadataSeparator: string, _variable?: string | null): string;
|
|
5
|
+
abstract clone(): Evaluatable;
|
|
6
|
+
}
|
|
7
|
+
export default Evaluatable;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Evaluatable from './evaluatable';
|
|
2
|
+
import Metadata from '../metadata';
|
|
3
|
+
import TraceInfo from '../trace_info';
|
|
4
|
+
export type TernaryProperties = TraceInfo & {
|
|
5
|
+
variable?: string | null;
|
|
6
|
+
valueTest?: string | null;
|
|
7
|
+
trueExpression?: Evaluatable[];
|
|
8
|
+
falseExpression?: Evaluatable[];
|
|
9
|
+
};
|
|
10
|
+
declare class Ternary extends Evaluatable {
|
|
11
|
+
variable: string | null;
|
|
12
|
+
valueTest: string | null;
|
|
13
|
+
trueExpression: Evaluatable[];
|
|
14
|
+
falseExpression: Evaluatable[];
|
|
15
|
+
constructor({ variable, valueTest, trueExpression, falseExpression, line, column, offset, }: TernaryProperties);
|
|
16
|
+
/**
|
|
17
|
+
* Evaluate the meta expression
|
|
18
|
+
* @param {Metadata} metadata The metadata object to use for evaluating the expression
|
|
19
|
+
* @param {string} [metadataSeparator=null] The metadata separator to use if necessary
|
|
20
|
+
* @returns {string} The evaluated expression
|
|
21
|
+
*/
|
|
22
|
+
evaluate(metadata: Metadata, metadataSeparator: string, upperContext?: string | null): string;
|
|
23
|
+
evaluateToString(value: string[] | string, metadataSeparator: string): string;
|
|
24
|
+
evaluateWithVariable(metadata: Metadata, metadataSeparator: string): string;
|
|
25
|
+
evaluateForTruthyValue(metadata: Metadata, metadataSeparator: string, value: string | string[]): string;
|
|
26
|
+
isRenderable(): boolean;
|
|
27
|
+
clone(): Ternary;
|
|
28
|
+
}
|
|
29
|
+
export default Ternary;
|