chordsheetjs 15.0.0 → 15.1.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.
Files changed (132) hide show
  1. package/lib/bundle.js +95 -1
  2. package/lib/bundle.min.js +53 -53
  3. package/lib/index.js +24 -1
  4. package/lib/index.js.map +1 -1
  5. package/lib/main.d.ts +91 -1
  6. package/lib/main.d.ts.map +1 -1
  7. package/lib/module.js +23 -2
  8. package/lib/module.js.map +1 -1
  9. package/lib/pdf/index.js +31007 -17454
  10. package/lib/pdf/index.js.map +1 -0
  11. package/lib/pdf/main.d.ts +1696 -0
  12. package/lib/pdf/main.d.ts.map +1 -0
  13. package/lib/pdf/module.js +30966 -17386
  14. package/lib/pdf/module.js.map +1 -0
  15. package/package.json +2 -2
  16. package/lib/pdf/chord.d.ts +0 -219
  17. package/lib/pdf/chord_definition/chord_definition.d.ts +0 -66
  18. package/lib/pdf/chord_definition/chord_definition_set.d.ts +0 -12
  19. package/lib/pdf/chord_diagram/chord_diagram.d.ts +0 -131
  20. package/lib/pdf/chord_diagram/js_pdf_renderer.d.ts +0 -40
  21. package/lib/pdf/chord_diagram/renderer.d.ts +0 -43
  22. package/lib/pdf/chord_parsing_error.d.ts +0 -2
  23. package/lib/pdf/chord_sheet/ast_component.d.ts +0 -11
  24. package/lib/pdf/chord_sheet/ast_type.d.ts +0 -9
  25. package/lib/pdf/chord_sheet/chord_lyrics_pair.d.ts +0 -60
  26. package/lib/pdf/chord_sheet/chord_pro/composite.d.ts +0 -11
  27. package/lib/pdf/chord_sheet/chord_pro/evaluatable.d.ts +0 -7
  28. package/lib/pdf/chord_sheet/chord_pro/evaluation_error.d.ts +0 -7
  29. package/lib/pdf/chord_sheet/chord_pro/literal.d.ts +0 -9
  30. package/lib/pdf/chord_sheet/chord_pro/ternary.d.ts +0 -29
  31. package/lib/pdf/chord_sheet/comment.d.ts +0 -21
  32. package/lib/pdf/chord_sheet/font.d.ts +0 -47
  33. package/lib/pdf/chord_sheet/font_size.d.ts +0 -33
  34. package/lib/pdf/chord_sheet/font_stack.d.ts +0 -13
  35. package/lib/pdf/chord_sheet/item.d.ts +0 -7
  36. package/lib/pdf/chord_sheet/line.d.ts +0 -130
  37. package/lib/pdf/chord_sheet/line_expander.d.ts +0 -12
  38. package/lib/pdf/chord_sheet/metadata.d.ts +0 -71
  39. package/lib/pdf/chord_sheet/metadata_accessors.d.ts +0 -18
  40. package/lib/pdf/chord_sheet/paragraph.d.ts +0 -48
  41. package/lib/pdf/chord_sheet/soft_line_break.d.ts +0 -15
  42. package/lib/pdf/chord_sheet/song.d.ts +0 -253
  43. package/lib/pdf/chord_sheet/song_mapper.d.ts +0 -15
  44. package/lib/pdf/chord_sheet/standard_metadata_providers.d.ts +0 -5
  45. package/lib/pdf/chord_sheet/tag.d.ts +0 -104
  46. package/lib/pdf/chord_sheet/tag_interpreter.d.ts +0 -14
  47. package/lib/pdf/chord_sheet/tags.d.ts +0 -259
  48. package/lib/pdf/chord_sheet/trace_info.d.ts +0 -6
  49. package/lib/pdf/chord_sheet_serializer.d.ts +0 -49
  50. package/lib/pdf/constants.d.ts +0 -117
  51. package/lib/pdf/formatter/chord_pro_formatter.d.ts +0 -39
  52. package/lib/pdf/formatter/chord_renderer.d.ts +0 -30
  53. package/lib/pdf/formatter/chords_over_words_formatter.d.ts +0 -33
  54. package/lib/pdf/formatter/configuration/base_configuration.d.ts +0 -58
  55. package/lib/pdf/formatter/configuration/default_config_manager.d.ts +0 -31
  56. package/lib/pdf/formatter/configuration/html_configuration.d.ts +0 -37
  57. package/lib/pdf/formatter/configuration/index.d.ts +0 -13
  58. package/lib/pdf/formatter/configuration/measured_html_configuration.d.ts +0 -38
  59. package/lib/pdf/formatter/configuration/measurement_based_configuration.d.ts +0 -204
  60. package/lib/pdf/formatter/configuration/pdf_configuration.d.ts +0 -16
  61. package/lib/pdf/formatter/formatter.d.ts +0 -38
  62. package/lib/pdf/formatter/formatting_context.d.ts +0 -7
  63. package/lib/pdf/formatter/html_div_formatter.d.ts +0 -9
  64. package/lib/pdf/formatter/html_formatter.d.ts +0 -60
  65. package/lib/pdf/formatter/html_table_formatter.d.ts +0 -10
  66. package/lib/pdf/formatter/measured_html_formatter.d.ts +0 -43
  67. package/lib/pdf/formatter/measurement_based_formatter.d.ts +0 -19
  68. package/lib/pdf/formatter/pdf_formatter/doc_wrapper.d.ts +0 -53
  69. package/lib/pdf/formatter/pdf_formatter/fonts/NimbusSansLFonts.base64.d.ts +0 -4
  70. package/lib/pdf/formatter/pdf_formatter/types.d.ts +0 -34
  71. package/lib/pdf/formatter/pdf_formatter.d.ts +0 -40
  72. package/lib/pdf/formatter/templates/html_div_formatter.d.ts +0 -3
  73. package/lib/pdf/formatter/templates/html_table_formatter.d.ts +0 -3
  74. package/lib/pdf/formatter/text_formatter.d.ts +0 -35
  75. package/lib/pdf/helpers.d.ts +0 -42
  76. package/lib/pdf/index.d.ts +0 -126
  77. package/lib/pdf/key.d.ts +0 -124
  78. package/lib/pdf/key_config.d.ts +0 -3
  79. package/lib/pdf/layout/engine/condition.d.ts +0 -25
  80. package/lib/pdf/layout/engine/dimensions.d.ts +0 -33
  81. package/lib/pdf/layout/engine/index.d.ts +0 -7
  82. package/lib/pdf/layout/engine/item_processor.d.ts +0 -70
  83. package/lib/pdf/layout/engine/layout_engine.d.ts +0 -67
  84. package/lib/pdf/layout/engine/layout_factory.d.ts +0 -22
  85. package/lib/pdf/layout/engine/layout_helpers.d.ts +0 -35
  86. package/lib/pdf/layout/engine/line_breaker.d.ts +0 -54
  87. package/lib/pdf/layout/engine/paragraph_splitter/index.d.ts +0 -5
  88. package/lib/pdf/layout/engine/paragraph_splitter/paragraph_splitter.d.ts +0 -5
  89. package/lib/pdf/layout/engine/paragraph_splitter/strategies/five_or_more_lines_paragraph_split_strategy.d.ts +0 -14
  90. package/lib/pdf/layout/engine/paragraph_splitter/strategies/four_lines_paragraph_split_strategy.d.ts +0 -8
  91. package/lib/pdf/layout/engine/paragraph_splitter/strategies/three_or_less_lines_paragraph_split_strategy.d.ts +0 -4
  92. package/lib/pdf/layout/engine/title_separator_tag.d.ts +0 -8
  93. package/lib/pdf/layout/engine/types.d.ts +0 -98
  94. package/lib/pdf/layout/measurement/canvas_measurer.d.ts +0 -18
  95. package/lib/pdf/layout/measurement/dom_measurer.d.ts +0 -21
  96. package/lib/pdf/layout/measurement/index.d.ts +0 -4
  97. package/lib/pdf/layout/measurement/js_pdf_measurer.d.ts +0 -12
  98. package/lib/pdf/layout/measurement/measurer.d.ts +0 -52
  99. package/lib/pdf/normalize_mappings/enharmonic-normalize.d.ts +0 -2
  100. package/lib/pdf/normalize_mappings/suffix-normalize-mapping.d.ts +0 -2
  101. package/lib/pdf/pango/pango_helpers.d.ts +0 -6
  102. package/lib/pdf/parser/chord/peg_parser.d.ts +0 -55
  103. package/lib/pdf/parser/chord_definition/peg_parser.d.ts +0 -55
  104. package/lib/pdf/parser/chord_pro/helpers.d.ts +0 -15
  105. package/lib/pdf/parser/chord_pro/peg_parser.d.ts +0 -55
  106. package/lib/pdf/parser/chord_pro_parser.d.ts +0 -32
  107. package/lib/pdf/parser/chord_sheet_parser.d.ts +0 -57
  108. package/lib/pdf/parser/chords_over_words/helpers.d.ts +0 -33
  109. package/lib/pdf/parser/chords_over_words/peg_parser.d.ts +0 -55
  110. package/lib/pdf/parser/chords_over_words_parser.d.ts +0 -67
  111. package/lib/pdf/parser/null_tracer.d.ts +0 -4
  112. package/lib/pdf/parser/parser_helpers.d.ts +0 -3
  113. package/lib/pdf/parser/parser_warning.d.ts +0 -33
  114. package/lib/pdf/parser/ultimate_guitar_parser.d.ts +0 -46
  115. package/lib/pdf/pdf.d.ts +0 -2
  116. package/lib/pdf/rendering/html/html_doc_wrapper.d.ts +0 -82
  117. package/lib/pdf/rendering/html/html_element_styler.d.ts +0 -58
  118. package/lib/pdf/rendering/html/positioned_html_renderer.d.ts +0 -85
  119. package/lib/pdf/rendering/pdf/js_pdf_renderer.d.ts +0 -46
  120. package/lib/pdf/rendering/pdf/pdf_chord_diagram_renderer.d.ts +0 -118
  121. package/lib/pdf/rendering/renderer.d.ts +0 -273
  122. package/lib/pdf/rendering/shared/layout_section_renderer.d.ts +0 -93
  123. package/lib/pdf/scales.d.ts +0 -3
  124. package/lib/pdf/serialized_types.d.ts +0 -76
  125. package/lib/pdf/song_builder.d.ts +0 -38
  126. package/lib/pdf/template_helpers/metadata_processor.d.ts +0 -14
  127. package/lib/pdf/template_helpers/when.d.ts +0 -13
  128. package/lib/pdf/template_helpers/when_callback.d.ts +0 -2
  129. package/lib/pdf/template_helpers/when_clause.d.ts +0 -8
  130. package/lib/pdf/template_helpers.d.ts +0 -64
  131. package/lib/pdf/utilities.d.ts +0 -35
  132. package/lib/pdf/version.d.ts +0 -2
@@ -0,0 +1,1696 @@
1
+ import { ImageCompression, ImageOptions, RGBAData, TextOptionsLight, jsPDFOptions } from "jspdf";
2
+ import { Blob } from "buffer";
3
+ interface PdfDoc {
4
+ get internal(): {
5
+ pageSize: {
6
+ getWidth(): number;
7
+ };
8
+ };
9
+ addImage(imageData: string | HTMLImageElement | HTMLCanvasElement | Uint8Array | RGBAData, format: string, x: number, y: number, width: number, height: number, alias?: string, compression?: ImageCompression, rotation?: number): PdfDoc;
10
+ addImage(imageData: string | HTMLImageElement | HTMLCanvasElement | Uint8Array | RGBAData, x: number, y: number, width: number, height: number, alias?: string, compression?: ImageCompression, rotation?: number): PdfDoc;
11
+ addImage(options: ImageOptions): PdfDoc;
12
+ circle(x: number, y: number, r: number, style?: string | null): PdfDoc;
13
+ getTextDimensions(text: string, options?: TextOptionsLight): {
14
+ w: number;
15
+ h: number;
16
+ };
17
+ line(x1: number, y1: number, x2: number, y2: number, style?: string | null): PdfDoc;
18
+ roundedRect(x: number, y: number, w: number, h: number, rx: number, ry: number, style?: string | null): PdfDoc;
19
+ save(filename: string, options: {
20
+ returnPromise: true;
21
+ }): Promise<void>;
22
+ save(filename?: string): PdfDoc;
23
+ setDrawColor(ch1: string | number, ch2?: number, ch3?: number, ch4?: number): PdfDoc;
24
+ setFont(fontName: string, fontStyle?: string, fontWeight?: string | number): PdfDoc;
25
+ setFontSize(size: number): PdfDoc;
26
+ setPage(page: number): PdfDoc;
27
+ setLineWidth(width: number): PdfDoc;
28
+ setTextColor(ch1: string): PdfDoc;
29
+ setTextColor(ch1: number): PdfDoc;
30
+ setTextColor(ch1: number, ch2: number, ch3: number, ch4?: number): PdfDoc;
31
+ text(text: string | string[], x: number, y: number, options?: TextOptionsLight, transform?: any): PdfDoc;
32
+ addFileToVFS(fileName: string, data: string): PdfDoc;
33
+ addFont(postScriptName: string, id: string, fontStyle: string, fontWeight?: string | number, encoding?: 'StandardEncoding' | 'MacRomanEncoding' | 'Identity-H' | 'WinAnsiEncoding', isStandardFont?: boolean): string;
34
+ }
35
+ type PdfConstructor = new (options?: jsPDFOptions) => PdfDoc;
36
+ type ParagraphType = 'abc' | 'bridge' | 'chorus' | 'grid' | 'indeterminate' | 'ly' | 'none' | 'svg' | 'tab' | 'textblock' | 'verse' | 'part' | string;
37
+ type Accidental = '#' | 'b';
38
+ type NoAccidental = 'NM';
39
+ type AccidentalMaybe = Accidental | NoAccidental;
40
+ type ChordType = 'symbol' | 'solfege' | 'numeric' | 'numeral';
41
+ type FretNumber = number;
42
+ type OpenFret = 0;
43
+ type NonSoundingString = '-1' | 'N' | 'x';
44
+ type Fret = FretNumber | OpenFret | NonSoundingString;
45
+ type ContentType = 'tab' | 'abc' | 'ly' | 'svg' | 'grid' | 'textblock';
46
+ interface ChordProperties {
47
+ root?: Key | null;
48
+ suffix?: string | null;
49
+ quality?: string | null;
50
+ extensions?: string | null;
51
+ bass?: Key | null;
52
+ optional?: boolean;
53
+ }
54
+ interface ChordConstructorOptions {
55
+ base?: string | number | null;
56
+ accidental?: Accidental | null;
57
+ suffix?: string | null;
58
+ quality?: string | null;
59
+ extensions?: string | null;
60
+ bassBase?: string | number | null;
61
+ bassAccidental?: Accidental | null;
62
+ root?: Key | null;
63
+ bass?: Key | null;
64
+ chordType?: ChordType | null;
65
+ optional?: boolean;
66
+ }
67
+ /**
68
+ * Represents a Chord, consisting of a root, suffix (quality) and bass
69
+ */
70
+ declare class Chord implements ChordProperties {
71
+ bass: Key | null;
72
+ root: Key | null;
73
+ get suffix(): string | null;
74
+ get quality(): string | null;
75
+ get extensions(): string | null;
76
+ optional: boolean;
77
+ /**
78
+ * Tries to parse a chord string into a chord
79
+ * Any leading or trailing whitespace is removed first, so a chord like ` \n E/G# \r ` is valid.
80
+ * @param chordString the chord string, eg `Esus4/G#` or `1sus4/#3`.
81
+ * @returns {Chord|null}
82
+ */
83
+ static parse(chordString: string): Chord | null;
84
+ static parseOrFail(chordString: string): Chord;
85
+ /**
86
+ * Returns a deep copy of the chord
87
+ * @returns {Chord}
88
+ */
89
+ clone(): Chord;
90
+ /**
91
+ * Converts the chord to a chord symbol, using the supplied key as a reference.
92
+ * For example, a numeric chord `#4` with reference key `E` will return the chord symbol `A#`.
93
+ * When the chord is already a chord symbol, it will return a clone of the object.
94
+ * @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a
95
+ * numeric or numeral.
96
+ * @returns {Chord} the chord symbol
97
+ */
98
+ toChordSymbol(referenceKey?: Key | string | null): Chord;
99
+ /**
100
+ * Converts the chord to a chord symbol string, using the supplied key as a reference.
101
+ * For example, a numeric chord `#4` with reference key `E` will return the chord symbol `A#`.
102
+ * When the chord is already a chord symbol, it will return a string version of the chord.
103
+ * @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a
104
+ * numeric or numeral.
105
+ * @returns {string} the chord symbol string
106
+ * @see {toChordSymbol}
107
+ */
108
+ toChordSymbolString(referenceKey?: Key | string | null): string;
109
+ /**
110
+ * Determines whether the chord is a chord symbol
111
+ * @returns {boolean}
112
+ */
113
+ isChordSymbol(): boolean;
114
+ /**
115
+ * Converts the chord to a chord solfege, using the supplied key as a reference.
116
+ * For example, a numeric chord `#4` with reference key `Mi` will return the chord symbol `La#`.
117
+ * When the chord is already a chord solfege, it will return a clone of the object.
118
+ * @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a
119
+ * numeric or numeral.
120
+ * @returns {Chord} the chord solfege
121
+ */
122
+ toChordSolfege(referenceKey?: Key | string | null): Chord;
123
+ /**
124
+ * Converts the chord to a chord solfege string, using the supplied key as a reference.
125
+ * For example, a numeric chord `#4` with reference key `E` will return the chord solfege `A#`.
126
+ * When the chord is already a chord solfege, it will return a string version of the chord.
127
+ * @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a
128
+ * numeric or numeral.
129
+ * @returns {string} the chord solfege string
130
+ * @see {toChordSolfege}
131
+ */
132
+ toChordSolfegeString(referenceKey?: Key | string | null): string;
133
+ /**
134
+ * Determines whether the chord is a chord solfege
135
+ * @returns {boolean}
136
+ */
137
+ isChordSolfege(): boolean;
138
+ /**
139
+ * Converts the chord to a numeric chord, using the supplied key as a reference.
140
+ * For example, a chord symbol A# with reference key E will return the numeric chord #4.
141
+ * @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a chord symbol
142
+ * @returns {Chord} the numeric chord
143
+ */
144
+ toNumeric(referenceKey?: Key | string | null): Chord;
145
+ /**
146
+ * Converts the chord to a numeral chord, using the supplied key as a reference.
147
+ * For example, a chord symbol A# with reference key E will return the numeral chord #IV.
148
+ * @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a chord symbol
149
+ * @returns {Chord} the numeral chord
150
+ */
151
+ toNumeral(referenceKey?: Key | string | null): Chord;
152
+ /**
153
+ * Converts the chord to a numeral chord string, using the supplied kye as a reference.
154
+ * For example, a chord symbol A# with reference key E will return the numeral chord #4.
155
+ * @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a chord symbol
156
+ * @returns {string} the numeral chord string
157
+ * @see {toNumeral}
158
+ */
159
+ toNumeralString(referenceKey?: Key | string | null): string;
160
+ /**
161
+ * Determines whether the chord is numeric
162
+ * @returns {boolean}
163
+ */
164
+ isNumeric(): boolean;
165
+ /**
166
+ * Converts the chord to a numeric chord string, using the supplied kye as a reference.
167
+ * For example, a chord symbol A# with reference key E will return the numeric chord #4.
168
+ * @param {Key|string|null} [referenceKey=null] the reference key. The key is required when converting a chord symbol
169
+ * @returns {string} the numeric chord string
170
+ * @see {toNumeric}
171
+ */
172
+ toNumericString(referenceKey?: Key | string | null): string;
173
+ /**
174
+ * Determines whether the chord is a numeral
175
+ * @returns {boolean}
176
+ */
177
+ isNumeral(): boolean;
178
+ /**
179
+ * Converts the chord to a string, eg `Esus4/G#` or `1sus4/#3`
180
+ * @param {Object} [configuration={}] options
181
+ * @param {boolean} [configuration.useUnicodeModifier=false] Whether or not to use unicode modifiers.
182
+ * This will make `#` (sharp) look like `♯` and `b` (flat) look like `♭`
183
+ * @returns {string} the chord string
184
+ */
185
+ toString({ useUnicodeModifier }?: {
186
+ useUnicodeModifier?: boolean | undefined;
187
+ }): string;
188
+ /**
189
+ * Normalizes the chord root and bass notes:
190
+ * - Fab becomes Mi
191
+ * - Dob becomes Si
192
+ * - Si# becomes Do
193
+ * - Mi# becomes Fa
194
+ * - Fb becomes E
195
+ * - Cb becomes B
196
+ * - B# becomes C
197
+ * - E# becomes F
198
+ * - 4b becomes 3
199
+ * - 1b becomes 7
200
+ * - 7# becomes 1
201
+ * - 3# becomes 4
202
+ *
203
+ * Besides that it normalizes the suffix if `normalizeSuffix` is `true`.
204
+ * For example, `sus2` becomes `2`, `sus4` becomes `sus`.
205
+ * All suffix normalizations can be found in `src/normalize_mappings/suffix-mapping.txt`.
206
+ *
207
+ * When the chord is minor, bass notes are normalized off of the relative major
208
+ * of the root note. For example, `Em/A#` becomes `Em/Bb`.
209
+ * @param {Key|string} [key=null] the key to normalize to
210
+ * @param {Object} [options={}] options
211
+ * @param {boolean} [options.normalizeSuffix=true] whether to normalize the chord suffix after transposing
212
+ * @returns {Chord} the normalized chord
213
+ */
214
+ normalize(key?: Key | string | null, { normalizeSuffix }?: {
215
+ normalizeSuffix?: boolean;
216
+ }): Chord;
217
+ /**
218
+ * Switches to the specified accidental
219
+ * @param newAccidental the accidental to use: `'#'` or `'b'`
220
+ * @returns {Chord} the new, changed chord
221
+ */
222
+ useAccidental(newAccidental: Accidental): Chord;
223
+ /**
224
+ * @deprecated Use useAccidental instead
225
+ */
226
+ useModifier(newAccidental: Accidental): Chord;
227
+ /**
228
+ * Transposes the chord up by 1 semitone. Eg. A becomes A#, Eb becomes E
229
+ * @returns {Chord} the new, transposed chord
230
+ */
231
+ transposeUp(): Chord;
232
+ /**
233
+ * Transposes the chord down by 1 semitone. Eg. A# becomes A, E becomes Eb
234
+ * @returns {Chord} the new, transposed chord
235
+ */
236
+ transposeDown(): Chord;
237
+ /**
238
+ * Transposes the chord by the specified number of semitones
239
+ * @param delta de number of semitones
240
+ * @returns {Chord} the new, transposed chord
241
+ */
242
+ transpose(delta: number): Chord;
243
+ constructor(options: ChordConstructorOptions);
244
+ equals(otherChord: Chord): boolean;
245
+ static determineRoot(options: ChordConstructorOptions & {
246
+ suffix?: string | null;
247
+ }): Key | null;
248
+ static determineBass(options: ChordConstructorOptions): Key | null;
249
+ isMinor(): boolean;
250
+ makeMinor(): Chord;
251
+ set(properties: ChordProperties): Chord;
252
+ private get normalizedSuffix();
253
+ }
254
+ /**
255
+ * Represents a comment. See https://www.chordpro.org/chordpro/chordpro-file-format-specification/#overview
256
+ */
257
+ declare class Comment {
258
+ content: string;
259
+ parentLine: Line | null;
260
+ constructor(content: string);
261
+ /**
262
+ * Indicates whether a Comment should be visible in a formatted chord sheet (except for ChordPro sheets)
263
+ * @returns {boolean}
264
+ */
265
+ isRenderable(): boolean;
266
+ /**
267
+ * Returns a deep copy of the Comment, useful when programmatically transforming a song
268
+ * @returns {Comment}
269
+ */
270
+ clone(): Comment;
271
+ toString(): string;
272
+ }
273
+ type Size = 'px' | '%';
274
+ declare class FontSize {
275
+ /**
276
+ * The size unit, either `"px"` or `"%"`
277
+ * @member {string}
278
+ */
279
+ unit: Size;
280
+ /**
281
+ * The font size
282
+ * @member {number}
283
+ */
284
+ fontSize: number;
285
+ constructor(fontSize: number, kind: Size);
286
+ clone(): FontSize;
287
+ multiply(percentage: any): FontSize;
288
+ /**
289
+ * Stringifies the font size by concatenating size and unit
290
+ *
291
+ * @example
292
+ * // Returns "30px"
293
+ * new FontSize(30, 'px').toString()
294
+ * @example
295
+ * // Returns "120%"
296
+ * new FontSize(120, '%').toString()
297
+ *
298
+ * @return {string} The font size
299
+ */
300
+ toString(): string;
301
+ static parse(fontSize: string, parent: FontSize | null): FontSize;
302
+ static parseNotANumber(parent: FontSize | null): FontSize;
303
+ static parsePercentage(parsedFontSize: number, parent: FontSize | null): FontSize;
304
+ }
305
+ interface FontProperties {
306
+ font?: string | null;
307
+ size?: FontSize | null;
308
+ colour?: string | null;
309
+ }
310
+ declare class Font {
311
+ /**
312
+ * The font
313
+ * @member {string | null}
314
+ */
315
+ font: string | null;
316
+ /**
317
+ * The font size, expressed in either pixels or percentage.
318
+ * @member {FontSize | null}
319
+ */
320
+ size: FontSize | null;
321
+ /**
322
+ * The font color
323
+ * @member {string | null}
324
+ */
325
+ colour: string | null;
326
+ constructor({ font, size, colour }?: FontProperties);
327
+ clone(): Font;
328
+ /**
329
+ * Converts the font, size and color to a CSS string.
330
+ * If possible, font and size are combined to the `font` shorthand.
331
+ * If `font` contains double quotes (`"`) those will be converted to single quotes (`'`).
332
+ *
333
+ * @example
334
+ * // Returns "font-family: 'Times New Roman'"
335
+ * new Font({ font: '"Times New Roman"' }).toCssString()
336
+ * @example
337
+ * // Returns "color: red; font-family: Verdana"
338
+ * new Font({ font: 'Verdana', colour: 'red' }).toCssString()
339
+ * @example
340
+ * // Returns "font: 30px Verdana"
341
+ * new Font({ font: 'Verdana', size: '30' }).toCssString()
342
+ * @example
343
+ * // Returns "color: blue; font: 30% Verdana"
344
+ * new Font({ font: 'Verdana', size: '30%', colour: 'blue' }).toCssString()
345
+ *
346
+ * @return {string} The CSS string
347
+ */
348
+ toCssString(): string;
349
+ }
350
+ interface TraceInfo {
351
+ line?: number | null;
352
+ column?: number | null;
353
+ offset?: number | null;
354
+ }
355
+ declare abstract class AstComponent {
356
+ parentLine: Line | null;
357
+ line: number | null;
358
+ column: number | null;
359
+ offset: number | null;
360
+ protected constructor(traceInfo?: TraceInfo | null);
361
+ abstract clone(): AstComponent;
362
+ }
363
+ declare abstract class MetadataAccessors {
364
+ abstract getMetadataValue(_name: string): string | string[] | null;
365
+ abstract getSingleMetadataValue(_name: string): string | null;
366
+ get key(): string | null;
367
+ get title(): string | null;
368
+ get subtitle(): string | null;
369
+ get capo(): string | string[] | null;
370
+ get duration(): string | null;
371
+ get tempo(): string | null;
372
+ get time(): string | string[] | null;
373
+ get year(): string | null;
374
+ get album(): string | string[] | null;
375
+ get copyright(): string | null;
376
+ get lyricist(): string | string[] | null;
377
+ get artist(): string | string[] | null;
378
+ get composer(): string | string[] | null;
379
+ }
380
+ /**
381
+ * Represents a chord definition.
382
+ *
383
+ * Definitions are made using the `{chord}` or `{define}` directive.
384
+ * A chord definitions overrides a previous chord definition for the exact same chord.
385
+ *
386
+ * @see https://chordpro.org/chordpro/directives-define/
387
+ * @see https://chordpro.org/chordpro/directives-chord/
388
+ */
389
+ declare class ChordDefinition {
390
+ /**
391
+ * The chord name, e.g. `C`, `Dm`, `G7`.
392
+ * @type {string}
393
+ */
394
+ name: string;
395
+ /**
396
+ * Defines the offset for the chord, which is the position of the topmost finger.
397
+ * The offset must be 1 or higher.
398
+ * @type {number}
399
+ */
400
+ baseFret: number;
401
+ /**
402
+ * Defines the string positions.
403
+ * Strings are enumerated from left (lowest) to right (highest), as they appear in the chord diagrams.
404
+ * Fret positions are relative to the offset minus one, so with base-fret 1 (the default),
405
+ * the topmost fret position is 1. With base-fret 3, fret position 1 indicates the 3rd position.
406
+ * `0` (zero) denotes an open string. Use `-1`, `N` or `x` to denote a non-sounding string.
407
+ * @type {Fret[]}
408
+ */
409
+ frets: Fret[];
410
+ /**
411
+ * defines finger settings. This part may be omitted.
412
+ *
413
+ * For the frets and the fingers positions, there must be exactly as many positions as there are strings,
414
+ * which is 6 by default. For the fingers positions, values corresponding to open or damped strings are ignored.
415
+ * Finger settings may be numeric (0 .. 9) or uppercase letters (A .. Z).
416
+ * Note that the values -, x, X, and N are used to designate a string without finger setting.
417
+ * @type {number[]}
418
+ */
419
+ fingers: number[];
420
+ constructor(name: string, baseFret: number, frets: Fret[], fingers?: number[]);
421
+ /**
422
+ * Parses a chord definition in the form of:
423
+ * - <name> base-fret <offset> frets <pos> <pos> … <pos>
424
+ * - <name> base-fret <offset> frets <pos> <pos> … <pos> fingers <pos> <pos> … <pos>
425
+ * @param chordDefinition
426
+ * @returns {ChordDefinition}
427
+ * @see https://chordpro.org/chordpro/directives-define/#common-usage
428
+ */
429
+ static parse(chordDefinition: string): ChordDefinition;
430
+ clone(): ChordDefinition;
431
+ }
432
+ /**
433
+ * Represents a tag/directive. See https://www.chordpro.org/chordpro/chordpro-directives/
434
+ */
435
+ declare class Tag extends AstComponent {
436
+ _isMetaTag: boolean;
437
+ _originalName: string;
438
+ _name: string;
439
+ _value: string;
440
+ chordDefinition?: ChordDefinition;
441
+ selector: string | null;
442
+ isNegated: boolean;
443
+ /**
444
+ * The tag attributes. For example, section related tags can have a label:
445
+ * `{start_of_verse: label="Verse 1"}`
446
+ * @type {Record<string, string>}
447
+ */
448
+ attributes: Record<string, string>;
449
+ constructor(name: string, value?: string | null, traceInfo?: TraceInfo | null, attributes?: Record<string, string>, selector?: string | null, isNegated?: boolean);
450
+ static parse(tag: string | Tag): Tag | null;
451
+ static parseWithRegex(tag: string, regex: RegExp): Tag | null;
452
+ static parseOrFail(tag: string | Tag): Tag;
453
+ get label(): string;
454
+ isSectionDelimiter(): boolean;
455
+ isSectionStart(): boolean;
456
+ isSectionEnd(): boolean;
457
+ isInlineFontTag(): boolean;
458
+ /**
459
+ * Checks whether the tag is a comment tag ({comment} or {c}).
460
+ */
461
+ isComment(): boolean;
462
+ /**
463
+ * Checks whether the tag is an image tag ({image}).
464
+ */
465
+ isImage(): boolean;
466
+ set name(name: string);
467
+ /**
468
+ * The tag full name. When the original tag used the short name, `name` will return the full name.
469
+ * @member
470
+ * @type {string}
471
+ */
472
+ get name(): string;
473
+ /**
474
+ * The original tag name that was used to construct the tag.
475
+ * @member
476
+ * @type {string}
477
+ */
478
+ get originalName(): string;
479
+ set value(value: string);
480
+ /**
481
+ * The tag value
482
+ * @member
483
+ * @type {string}
484
+ */
485
+ get value(): string;
486
+ /**
487
+ * Checks whether the tag value is a non-empty string.
488
+ * @returns {boolean}
489
+ */
490
+ hasValue(): boolean;
491
+ hasAttributes(): boolean;
492
+ hasLabel(): boolean;
493
+ /**
494
+ * Checks whether the tag is usually rendered inline. It currently only applies to comment tags.
495
+ * @returns {boolean}
496
+ */
497
+ isRenderable(): boolean;
498
+ /**
499
+ * Check whether this tag's label (if any) should be rendered, as applicable to tags like
500
+ * `start_of_verse` and `start_of_chorus`.
501
+ * See https://chordpro.org/chordpro/directives-env_chorus/, https://chordpro.org/chordpro/directives-env_verse/,
502
+ * https://chordpro.org/chordpro/directives-env_bridge/, https://chordpro.org/chordpro/directives-env_tab/
503
+ */
504
+ hasRenderableLabel(): boolean;
505
+ /**
506
+ * Checks whether the tag is a standard meta tag, a custom meta directive (`{x_some_name}`)
507
+ * or a non-standard meta tag (`{meta: name value}`)
508
+ * @returns {boolean}
509
+ */
510
+ isMetaTag(): boolean;
511
+ /**
512
+ * Checks whether this tag is a standard meta tag or a custom meta directive (`{x_some_name}`)
513
+ * @returns {boolean}
514
+ */
515
+ isStandardOrCustomMetaTag(): boolean;
516
+ /**
517
+ * Returns a clone of the tag.
518
+ * @returns {Tag} The cloned tag
519
+ */
520
+ clone(): Tag;
521
+ toString(): string;
522
+ set({ value }: {
523
+ value: string;
524
+ }): Tag;
525
+ setAttribute(name: string, value: string): Tag;
526
+ }
527
+ type MetadataProvider = () => string | null;
528
+ /**
529
+ * Stores song metadata. Properties can be accessed using the get() method:
530
+ *
531
+ * const metadata = new Metadata({ author: 'John' });
532
+ * metadata.get('author') // => 'John'
533
+ *
534
+ * See {@link Metadata#get}
535
+ */
536
+ declare class Metadata extends MetadataAccessors implements Iterable<[string, string | string[]]> {
537
+ metadata: Record<string, string | string[]>;
538
+ providers: Map<string, MetadataProvider>;
539
+ constructor(metadata?: Record<string, string | string[]> | Metadata);
540
+ merge(metadata?: Record<string, string | string[]> | Metadata): Metadata;
541
+ contains(key: string): boolean;
542
+ add(key: string, value: string): void;
543
+ appendValue(key: string, value: string): void;
544
+ setProvider(key: string, provider: MetadataProvider): void;
545
+ set(key: string, value: string | null): void;
546
+ getMetadataValue(name: string): string | string[] | null;
547
+ getSingleMetadataValue(name: string): string | null;
548
+ /**
549
+ * Reads a metadata value by key. This method supports simple value lookup, as well as fetching single array values.
550
+ *
551
+ * This method deprecates direct property access, eg: metadata['author']
552
+ *
553
+ * @example
554
+ * const metadata = new Metadata({ lyricist: 'Pete', author: ['John', 'Mary'] });
555
+ * metadata.get('lyricist') // => 'Pete'
556
+ * metadata.get('author') // => ['John', 'Mary']
557
+ * metadata.get('author.1') // => 'John'
558
+ * metadata.get('author.2') // => 'Mary'
559
+ *
560
+ * Using a negative index will start counting at the end of the list:
561
+ *
562
+ * const metadata = new Metadata({ lyricist: 'Pete', author: ['John', 'Mary'] });
563
+ * metadata.get('author.-1') // => 'Mary'
564
+ * metadata.get('author.-2') // => 'John'
565
+ *
566
+ * @param prop the property name
567
+ * @returns {Array<String>|String} the metadata value(s). If there is only one value, it will return a String,
568
+ * else it returns an array of strings.
569
+ */
570
+ get(prop: string): string | string[] | null;
571
+ /**
572
+ * Returns all metadata values, including provider values and generated values like `_key`.
573
+ * @returns {Object.<string, string|string[]>} the metadata values
574
+ */
575
+ all(): Record<string, string | string[]>;
576
+ ownMetadata(): Record<string, string | string[]>;
577
+ [Symbol.iterator](): IterableIterator<[string, string | string[]]>;
578
+ /**
579
+ * Returns a single metadata value. If the actual value is an array, it returns the first value. Else, it returns
580
+ * the value.
581
+ * @ignore
582
+ * @param {string} prop the property name
583
+ * @returns {String} The metadata value
584
+ */
585
+ getSingle(prop: string): string | null;
586
+ parseArrayKey(prop: string): [string, number] | null;
587
+ getArrayItem(prop: string): string | null;
588
+ /**
589
+ * Returns a deep clone of this Metadata object
590
+ * @returns {Metadata} the cloned Metadata object
591
+ */
592
+ clone(): Metadata;
593
+ calculateKeyFromCapo(): string | null;
594
+ assign(metadata: Record<string, string | string[] | null>): void;
595
+ }
596
+ declare abstract class Evaluatable extends AstComponent {
597
+ abstract evaluate(_metadata: Metadata, _metadataSeparator: string, _variable?: string | null): string;
598
+ abstract clone(): Evaluatable;
599
+ }
600
+ declare class Literal extends Evaluatable {
601
+ string: string;
602
+ constructor(string: string);
603
+ evaluate(): string;
604
+ isRenderable(): boolean;
605
+ clone(): Literal;
606
+ }
607
+ type TernaryProperties = TraceInfo & {
608
+ variable?: string | null;
609
+ valueTest?: string | null;
610
+ trueExpression?: Evaluatable[];
611
+ falseExpression?: Evaluatable[];
612
+ };
613
+ declare class Ternary extends Evaluatable {
614
+ variable: string | null;
615
+ valueTest: string | null;
616
+ trueExpression: Evaluatable[];
617
+ falseExpression: Evaluatable[];
618
+ constructor({ variable, valueTest, trueExpression, falseExpression, line, column, offset, }: TernaryProperties);
619
+ /**
620
+ * Evaluate the meta expression
621
+ * @param {Metadata} metadata The metadata object to use for evaluating the expression
622
+ * @param {string} [metadataSeparator=null] The metadata separator to use if necessary
623
+ * @returns {string} The evaluated expression
624
+ */
625
+ evaluate(metadata: Metadata, metadataSeparator: string, upperContext?: string | null): string;
626
+ evaluateToString(value: string[] | string, metadataSeparator: string): string;
627
+ evaluateWithVariable(metadata: Metadata, metadataSeparator: string): string;
628
+ evaluateForTruthyValue(metadata: Metadata, metadataSeparator: string, value: string | string[]): string;
629
+ isRenderable(): boolean;
630
+ clone(): Ternary;
631
+ }
632
+ type Item = ChordLyricsPair | Comment | Tag | Ternary | Literal;
633
+ type MapItemFunc = (_item: Item) => Item | null;
634
+ /**
635
+ * Represents a line in a chord sheet, consisting of items of type ChordLyricsPair or Tag
636
+ */
637
+ declare class Line {
638
+ /**
639
+ * The items ({@link ChordLyricsPair} or {@link Tag} or {@link Comment}) of which the line consists
640
+ * @type {Array.<(ChordLyricsPair|Tag|Comment)>}
641
+ */
642
+ items: Item[];
643
+ /**
644
+ * The line type, This is set by the ChordProParser when it read tags like {start_of_chorus} or {start_of_verse}
645
+ * It uses the following mapping to determine the line type from directives:
646
+ * - `start_of_abc` => {@link ABC}
647
+ * - `start_of_bridge` => {@link BRIDGE}
648
+ * - `start_of_chorus` => {@link CHORUS}
649
+ * - `start_of_grid` => {@link GRID}
650
+ * - `start_of_ly` => {@link LILYPOND}
651
+ * - `start_of_tab` => {@link TAB}
652
+ * - `start_of_verse` => {@link VERSE}
653
+ *
654
+ * There are two special cases:
655
+ * - {@link INDETERMINATE} when the paragraph lines do not have a consistent type
656
+ * - {@link NONE} when no type is derived
657
+ * @type {string}
658
+ */
659
+ type: string;
660
+ currentChordLyricsPair: ChordLyricsPair;
661
+ key: string | null;
662
+ transposeKey: string | null;
663
+ lineNumber: number | null;
664
+ selector: string | null;
665
+ selectorIsNegated: boolean;
666
+ /**
667
+ * The text font that applies to this line. Is derived from the directives:
668
+ * `textfont`, `textsize` and `textcolour`
669
+ * See: https://www.chordpro.org/chordpro/directives-props_text_legacy/
670
+ * @type {Font}
671
+ */
672
+ textFont: Font;
673
+ /**
674
+ * The chord font that applies to this line. Is derived from the directives:
675
+ * `chordfont`, `chordsize` and `chordcolour`
676
+ * See: https://www.chordpro.org/chordpro/directives-props_chord_legacy/
677
+ * @type {Font}
678
+ */
679
+ chordFont: Font;
680
+ constructor({ type, items }?: {
681
+ type: string;
682
+ items: Item[];
683
+ });
684
+ /**
685
+ * Indicates whether the line contains any items
686
+ * @returns {boolean}
687
+ */
688
+ isEmpty(): boolean;
689
+ /**
690
+ * Adds an item ({@link ChordLyricsPair} or {@link Tag}) to the line
691
+ * @param {ChordLyricsPair|Tag} item The item to be added
692
+ */
693
+ addItem(item: Item): void;
694
+ /**
695
+ * Indicates whether the line contains items that are renderable
696
+ * @returns {boolean}
697
+ */
698
+ hasRenderableItems(): boolean;
699
+ /**
700
+ * Returns a deep copy of the line and all of its items
701
+ * @returns {Line}
702
+ */
703
+ clone(): Line;
704
+ mapItems(func: MapItemFunc | null): Line;
705
+ /**
706
+ * Indicates whether the line type is {@link BRIDGE}
707
+ * @returns {boolean}
708
+ */
709
+ isBridge(): boolean;
710
+ /**
711
+ * Indicates whether the line type is {@link CHORUS}
712
+ * @returns {boolean}
713
+ */
714
+ isChorus(): boolean;
715
+ /**
716
+ * Indicates whether the line type is {@link GRID}
717
+ * @returns {boolean}
718
+ */
719
+ isGrid(): boolean;
720
+ /**
721
+ * Indicates whether the line type is {@link TAB}
722
+ * @returns {boolean}
723
+ */
724
+ isTab(): boolean;
725
+ /**
726
+ * Indicates whether the line type is {@link VERSE}
727
+ * @returns {boolean}
728
+ */
729
+ isVerse(): boolean;
730
+ /**
731
+ * Indicates whether the line type is {@link PART}
732
+ * @returns {boolean}
733
+ */
734
+ isPart(): boolean;
735
+ /**
736
+ * Indicates whether the line contains items that are renderable. Please use {@link hasRenderableItems}
737
+ * @deprecated
738
+ * @returns {boolean}
739
+ */
740
+ hasContent(): boolean;
741
+ addChordLyricsPair(chords?: ChordLyricsPair | string | null, lyrics?: null): ChordLyricsPair;
742
+ ensureChordLyricsPair(): void;
743
+ chords(chr: string): void;
744
+ lyrics(chr: string): void;
745
+ addTag(nameOrTag: Tag | string, value?: string | null): Tag;
746
+ addComment(content: Comment | string): Comment;
747
+ set(properties: {
748
+ type?: string;
749
+ items?: Item[];
750
+ }): Line;
751
+ get _tag(): Tag | null;
752
+ isSectionStart(): boolean;
753
+ isSectionEnd(): boolean;
754
+ }
755
+ /**
756
+ * Represents a chord with the corresponding (partial) lyrics
757
+ */
758
+ declare class ChordLyricsPair {
759
+ chords: string;
760
+ lyrics: string | null;
761
+ annotation: string | null;
762
+ isRhythmSymbol: boolean;
763
+ parentLine: Line | null;
764
+ /**
765
+ * Initialises a ChordLyricsPair
766
+ * @param {string} chords The chords
767
+ * @param {string | null} lyrics The lyrics
768
+ * @param {string | null} annotation The annotation
769
+ * @param {Chord | null} chordObj Optional pre-parsed Chord object
770
+ * @param {boolean} isRhythmSymbol Whether this pair represents a rhythm symbol
771
+ */
772
+ constructor(chords?: string, lyrics?: string | null, annotation?: string | null, chordObj?: Chord | null, isRhythmSymbol?: boolean);
773
+ /** Returns the Chord object if available, otherwise parses from string */
774
+ get chord(): Chord | null;
775
+ /**
776
+ * Indicates whether a ChordLyricsPair should be visible in a formatted chord sheet (except for ChordPro sheets)
777
+ * @returns {boolean}
778
+ */
779
+ isRenderable(): boolean;
780
+ /**
781
+ * Indicates whether the ChordLyricsPair has non-empty lyrics.
782
+ */
783
+ hasLyrics(): boolean;
784
+ /**
785
+ * Returns a deep copy of the ChordLyricsPair, useful when programmatically transforming a song
786
+ * @returns {ChordLyricsPair}
787
+ */
788
+ clone(): ChordLyricsPair;
789
+ toString(): string;
790
+ set({ chords, lyrics, annotation, chordObj, isRhythmSymbol, }: {
791
+ chords?: string;
792
+ lyrics?: string;
793
+ annotation?: string;
794
+ chordObj?: Chord | null;
795
+ isRhythmSymbol?: boolean;
796
+ }): ChordLyricsPair;
797
+ setLyrics(lyrics: string): ChordLyricsPair;
798
+ setAnnotation(annotation: string): ChordLyricsPair;
799
+ transpose(delta: number, key?: string | Key | null, { normalizeChordSuffix }?: {
800
+ normalizeChordSuffix: boolean;
801
+ }): ChordLyricsPair;
802
+ useAccidental(accidental: Accidental): ChordLyricsPair;
803
+ /**
804
+ * @deprecated Use useAccidental instead
805
+ */
806
+ useModifier(accidental: Accidental): ChordLyricsPair;
807
+ changeChord(func: (chord: Chord) => Chord): ChordLyricsPair;
808
+ }
809
+ /**
810
+ * Utility type that creates a deep partial type
811
+ * This makes all properties optional recursively through the entire object
812
+ */
813
+ type DeepPartial<T> = T extends object ? {
814
+ [P in keyof T]?: DeepPartial<T[P]>;
815
+ } : T;
816
+ interface KeyProperties {
817
+ grade?: number | null;
818
+ number?: number | null;
819
+ type?: ChordType;
820
+ minor?: boolean;
821
+ accidental?: Accidental | null;
822
+ referenceKeyGrade?: number | null;
823
+ referenceKeyMode?: string | null;
824
+ preferredAccidental?: Accidental | null;
825
+ explicitAccidental?: boolean;
826
+ }
827
+ interface ConstructorOptions {
828
+ grade?: number | null;
829
+ number?: number | null;
830
+ minor: boolean;
831
+ type: ChordType;
832
+ accidental: Accidental | null;
833
+ referenceKeyGrade?: number | null;
834
+ referenceKeyMode?: string | null;
835
+ originalKeyString?: string | null;
836
+ preferredAccidental: Accidental | null;
837
+ explicitAccidental?: boolean;
838
+ }
839
+ /**
840
+ * Represents a key, such as Eb (symbol), #3 (numeric) or VII (numeral).
841
+ *
842
+ * The only function considered public API is `Key.distance`
843
+ */
844
+ declare class Key implements KeyProperties {
845
+ grade: number | null;
846
+ number: number | null;
847
+ accidental: Accidental | null;
848
+ type: ChordType;
849
+ get unicodeAccidental(): string | null;
850
+ /** @deprecated Use unicodeAccidental instead */
851
+ get unicodeModifier(): string | null;
852
+ /** @deprecated Use accidental instead */
853
+ get modifier(): Accidental | null;
854
+ /** @deprecated Use preferredAccidental instead */
855
+ get preferredModifier(): Accidental | null;
856
+ minor: boolean;
857
+ referenceKeyGrade: number | null;
858
+ referenceKeyMode: string | null;
859
+ originalKeyString: string | null;
860
+ preferredAccidental: Accidental | null;
861
+ explicitAccidental: boolean;
862
+ static parse(keyString: string | null): null | Key;
863
+ static parseAsType(trimmed: string, keyType: ChordType): Key | null;
864
+ static resolve({ key, keyType, minor, accidental, }: {
865
+ key: string | number;
866
+ keyType: ChordType;
867
+ minor: string | boolean;
868
+ accidental: Accidental | null;
869
+ }): Key | null;
870
+ static getNumberFromKey(keyString: string, keyType: ChordType): number;
871
+ static keyWithAccidental(key: string, accidental: Accidental | null, type: ChordType): string;
872
+ /** @deprecated Use keyWithAccidental instead */
873
+ static keyWithModifier(key: string, accidental: Accidental | null, type: ChordType): string;
874
+ static toGrade(key: string, accidental: AccidentalMaybe, type: ChordType, isMinor: boolean): number | null;
875
+ static isMinor(key: string, keyType: ChordType, minor: string | undefined | boolean): boolean;
876
+ static parseOrFail(keyString: string | null): Key;
877
+ static wrap(keyStringOrObject: Key | string | null): Key | null;
878
+ static wrapOrFail(keyStringOrObject?: Key | string | null): Key;
879
+ static toString(keyStringOrObject: Key | string): string;
880
+ /**
881
+ * Calculates the distance in semitones between one key and another.
882
+ * @param {Key | string} oneKey the key
883
+ * @param {Key | string} otherKey the other key
884
+ * @return {number} the distance in semitones
885
+ */
886
+ static distance(oneKey: Key | string, otherKey: Key | string): number;
887
+ constructor({ grade, number, minor, type, accidental, referenceKeyGrade, referenceKeyMode, originalKeyString, preferredAccidental, explicitAccidental, }: ConstructorOptions);
888
+ distanceTo(otherKey: Key | string): number;
889
+ get effectiveGrade(): number;
890
+ isMinor(): boolean;
891
+ makeMinor(): Key;
892
+ get relativeMajor(): Key;
893
+ get relativeMinor(): Key;
894
+ toMajor(): Key;
895
+ clone(): Key;
896
+ toChordSymbol(key: Key | string | null, referenceKeyWasMinor?: boolean): Key;
897
+ toChordSolfege(key: Key | string | null, referenceKeyWasMinor?: boolean): Key;
898
+ toChordSymbolString(key: Key): string;
899
+ toChordSolfegeString(key: Key): string;
900
+ is(type: ChordType): boolean;
901
+ isNumeric(): boolean;
902
+ isChordSymbol(): boolean;
903
+ isChordSolfege(): boolean;
904
+ isNumeral(): boolean;
905
+ equals(otherKey: Key): boolean;
906
+ static equals(oneKey: Key | null, otherKey: Key | null): boolean;
907
+ toNumeric(key?: Key | string | null): Key;
908
+ toNumericString(key?: Key | null): string;
909
+ toNumeral(key?: Key | string | null): Key;
910
+ toNumeralString(key?: Key | null): string;
911
+ toString({ showMinor, useUnicodeModifier }?: {
912
+ showMinor?: boolean | undefined;
913
+ useUnicodeModifier?: boolean | undefined;
914
+ }): string;
915
+ get note(): string;
916
+ get minorSign(): "" | "m";
917
+ transpose(delta: number): Key;
918
+ changeGrade(delta: any): Key;
919
+ transposeUp(): Key;
920
+ transposeDown(): Key;
921
+ canBeFlat(): boolean;
922
+ canBeSharp(): boolean;
923
+ setGrade(newGrade: number): Key;
924
+ static shiftGrade(grade: number): number;
925
+ useAccidental(newAccidental: Accidental | null): Key;
926
+ /** @deprecated Use useAccidental instead */
927
+ useModifier(newAccidental: Accidental | null): Key;
928
+ normalize(): Key;
929
+ normalizeEnharmonics(key: Key | string | null): Key;
930
+ }
931
+ type Delegate = (_string: string) => string;
932
+ interface MetadataRule {
933
+ match: string | string[] | RegExp | ((key: string) => boolean);
934
+ visible?: boolean;
935
+ sortMethod?: 'preserve' | 'alphabetical' | 'custom';
936
+ customSort?: (a: string, b: string) => number;
937
+ }
938
+ interface MetadataConfiguration {
939
+ separator: string;
940
+ order: (string | MetadataRule)[];
941
+ }
942
+ interface InstrumentConfiguration {
943
+ type?: string;
944
+ description?: string;
945
+ tuning?: string;
946
+ }
947
+ interface UserConfigurationProperties {
948
+ name?: string;
949
+ fullname?: string;
950
+ }
951
+ interface BaseFormatterConfiguration {
952
+ decapo: boolean;
953
+ delegates: Partial<Record<ContentType, Delegate>>;
954
+ evaluate: boolean;
955
+ expandChorusDirective: boolean;
956
+ instrument: InstrumentConfiguration | null;
957
+ key: Key | null;
958
+ metadata: MetadataConfiguration;
959
+ normalizeChords: boolean;
960
+ useUnicodeModifiers: boolean;
961
+ user: UserConfigurationProperties | null;
962
+ }
963
+ /**
964
+ * Configuration options for rendering a chord diagram, controlling dimensions, colors, and visual styling.
965
+ */
966
+ interface ChordDiagramRenderingConfig {
967
+ /** Vertical position of the chord title. */
968
+ titleY: number;
969
+ /** Width of the guitar neck area. */
970
+ neckWidth: number;
971
+ /** Height of the guitar neck area. */
972
+ neckHeight: number;
973
+ /** Thickness of the nut (top bar) at the first fret. */
974
+ nutThickness: number;
975
+ /** Color of the nut. */
976
+ nutColor: number | string;
977
+ /** Thickness of regular fret bars. */
978
+ fretThickness: number;
979
+ /** Color of the fret lines. */
980
+ fretColor: number | string;
981
+ /** Color of the strings. */
982
+ stringColor: number | string;
983
+ /** Size of open/muted string indicators above the nut. */
984
+ stringIndicatorSize: number;
985
+ /** Size of finger position markers on the fretboard. */
986
+ fingerIndicatorSize: number;
987
+ /** Vertical offset adjustment for finger indicators. */
988
+ fingerIndicatorOffset: number;
989
+ /** Thickness of the string lines. */
990
+ stringThickness: number;
991
+ /** Thickness of the fret lines. */
992
+ fretLineThickness: number;
993
+ /** Line thickness for open string (circle) indicators. */
994
+ openStringIndicatorThickness: number;
995
+ /** Line thickness for muted string (X) indicators. */
996
+ unusedStringIndicatorThickness: number;
997
+ /** Line thickness for finger position markers. */
998
+ markerThickness: number;
999
+ /** Line thickness for barre indicators. */
1000
+ barreThickness: number;
1001
+ /** Font size for the chord title. */
1002
+ titleFontSize: number;
1003
+ /** Font size for the base fret number (when transposed). */
1004
+ baseFretFontSize: number;
1005
+ /** Font size for finger numbers below the diagram. */
1006
+ fingerNumberFontSize: number;
1007
+ /** Whether to display finger numbers below the diagram. */
1008
+ showFingerNumbers: boolean;
1009
+ /** Horizontal spacing between multiple diagrams. */
1010
+ diagramSpacing: number;
1011
+ /** Maximum number of diagrams per row (optional). */
1012
+ maxDiagramsPerRow?: number | null;
1013
+ }
1014
+ interface PDFLayoutConfig extends MeasurementBasedLayoutConfig {
1015
+ header: MeasurementBasedLayoutConfig['header'];
1016
+ footer: MeasurementBasedLayoutConfig['footer'];
1017
+ sections: SectionsConfig;
1018
+ chordDiagrams: ChordDiagramsConfig;
1019
+ }
1020
+ interface PDFFormatterConfiguration extends MeasurementBasedFormatterConfiguration {
1021
+ version: string;
1022
+ layout: PDFLayoutConfig;
1023
+ }
1024
+ /**
1025
+ * Base formatter class that provides configuration handling for all formatters
1026
+ */
1027
+ declare class Formatter<T extends BaseFormatterConfiguration = BaseFormatterConfiguration> {
1028
+ configuration: T;
1029
+ /**
1030
+ * Instantiate
1031
+ * @param {DeepPartial<T>} [configuration={}] options
1032
+ * @param {boolean} [configuration.evaluate=false] Whether or not to evaluate meta expressions.
1033
+ * For more info about meta expressions, see: https://bit.ly/2SC9c2u
1034
+ * @param {object} [configuration.metadata={}]
1035
+ * @param {string} [configuration.metadata.separator=", "] The separator to be used when rendering a
1036
+ * metadata value that has multiple values. See: https://bit.ly/2SC9c2u
1037
+ * @param {Key|string} [configuration.key=null] The key to use for rendering. The chord sheet will be
1038
+ * transposed from the song's original key (as indicated by the `{key}` directive) to the specified key.
1039
+ * Note that transposing will only work if the original song key is set.
1040
+ * @param {boolean} [configuration.expandChorusDirective=false] Whether or not to expand `{chorus}` directives
1041
+ * by rendering the last defined chorus inline after the directive.
1042
+ * @param {boolean} [configuration.useUnicodeModifiers=false] Whether or not to use unicode flat and sharp
1043
+ * symbols.
1044
+ * @param {boolean} [configuration.normalizeChords=true] Whether or not to automatically normalize chords
1045
+ */
1046
+ constructor(configuration?: DeepPartial<T>);
1047
+ /**
1048
+ * Configure the formatter with new options
1049
+ * @param {DeepPartial<T>} config New configuration options
1050
+ * @returns {this} The formatter instance for chaining
1051
+ */
1052
+ configure(config: DeepPartial<T>): this;
1053
+ /**
1054
+ * Get the default configuration for this formatter type
1055
+ * Should be implemented by subclasses to return the appropriate default configuration
1056
+ */
1057
+ protected getDefaultConfiguration(): T;
1058
+ }
1059
+ type DefinitionSet = Record<string, ChordDefinition>;
1060
+ declare class ChordDefinitionSet {
1061
+ definitions: DefinitionSet;
1062
+ constructor(definitions?: DefinitionSet);
1063
+ get(chord: string): ChordDefinition | null;
1064
+ withDefaults(): ChordDefinitionSet;
1065
+ add(chord: string, definition: ChordDefinition): void;
1066
+ has(chord: string): boolean;
1067
+ clone(): ChordDefinitionSet;
1068
+ }
1069
+ interface FormattingContext {
1070
+ configuration: BaseFormatterConfiguration;
1071
+ metadata: Metadata;
1072
+ }
1073
+ /**
1074
+ * Represents a paragraph of lines in a chord sheet
1075
+ */
1076
+ declare class Paragraph {
1077
+ /**
1078
+ * The {@link Line} items of which the paragraph consists
1079
+ * @member
1080
+ * @type {Line[]}
1081
+ */
1082
+ lines: Line[];
1083
+ addLine(line: any): void;
1084
+ /**
1085
+ * Indicates whether the paragraph only contains literals. If true, {@link contents} can be used to retrieve
1086
+ * the paragraph contents as one string where lines are separated by newlines.
1087
+ * @see {@link contents}
1088
+ * @returns {boolean}
1089
+ */
1090
+ isLiteral(): boolean;
1091
+ /**
1092
+ * Returns the paragraph contents as one string where lines are separated by newlines
1093
+ * @returns {string}
1094
+ */
1095
+ get contents(): string;
1096
+ /**
1097
+ * Returns the label of the paragraph. The label is the value of the first section delimiter tag
1098
+ * in the first line.
1099
+ * @returns {string|null}
1100
+ */
1101
+ get label(): string | null;
1102
+ /**
1103
+ * Tries to determine the common type for all lines. If the types for all lines are equal, it returns that type.
1104
+ * If not, it returns {@link INDETERMINATE}
1105
+ * For the possible values, see {@link Line.type}
1106
+ * @returns {string}
1107
+ */
1108
+ get type(): string;
1109
+ get selector(): string | null;
1110
+ get selectorIsNegated(): boolean;
1111
+ /**
1112
+ * Indicates whether the paragraph contains lines with renderable items.
1113
+ * @see {@link Line.hasRenderableItems}
1114
+ * @returns {boolean}
1115
+ */
1116
+ hasRenderableItems(): boolean;
1117
+ isEmpty(): boolean;
1118
+ }
1119
+ /**
1120
+ * Represents a parser warning, currently only used by ChordProParser.
1121
+ */
1122
+ declare class ParserWarning {
1123
+ /**
1124
+ * The warning message
1125
+ * @member
1126
+ * @type {string}
1127
+ */
1128
+ message: string;
1129
+ /**
1130
+ * The chord sheet line number on which the warning occurred
1131
+ * @member
1132
+ * @type {number}
1133
+ */
1134
+ lineNumber: number | null;
1135
+ /**
1136
+ * The chord sheet column on which the warning occurred
1137
+ * @member
1138
+ * @type {number}
1139
+ */
1140
+ column: number | null;
1141
+ /**
1142
+ * @hideconstructor
1143
+ */
1144
+ constructor(message: string, lineNumber: number | null, column: number | null);
1145
+ /**
1146
+ * Returns a stringified version of the warning
1147
+ * @returns {string} The string warning
1148
+ */
1149
+ toString(): string;
1150
+ }
1151
+ type MapItemsCallback = (_item: Item) => Item | Item[] | null;
1152
+ /**
1153
+ * Represents a song in a chord sheet. Currently a chord sheet can only have one song.
1154
+ */
1155
+ declare class Song extends MetadataAccessors {
1156
+ /**
1157
+ * The {@link Line} items of which the song consists
1158
+ * @member {Line[]}
1159
+ */
1160
+ lines: Line[];
1161
+ _bodyLines: Line[] | null;
1162
+ _bodyParagraphs: Paragraph[] | null;
1163
+ _renderParagraphs: Paragraph[] | null;
1164
+ warnings: ParserWarning[];
1165
+ _metadata: Metadata | null;
1166
+ /**
1167
+ * Creates a new {Song} instance
1168
+ * @param metadata {Record<string, string | string[]>|Metadata} predefined metadata
1169
+ */
1170
+ constructor(metadata?: Record<string, string | string[]> | Metadata | null);
1171
+ /** Returns song lines, skipping leading empty/meta-only lines. @returns {Line[]} */
1172
+ get bodyLines(): Line[];
1173
+ /** Returns song paragraphs, skipping paragraphs with only empty lines. @returns {Paragraph[]} */
1174
+ get bodyParagraphs(): Paragraph[];
1175
+ get renderParagraphs(): Paragraph[];
1176
+ set renderParagraphs(paragraphs: Paragraph[]);
1177
+ selectRenderableItems(items: (Line | Paragraph)[]): (Line | Paragraph)[];
1178
+ /** The {@link Paragraph} items of which the song consists @member {Paragraph[]} */
1179
+ get paragraphs(): Paragraph[];
1180
+ /** The body paragraphs with any `{chorus}` tag expanded into the targeted chorus */
1181
+ get expandedBodyParagraphs(): Paragraph[];
1182
+ filterParagraphs(paragraphs: Paragraph[], configuration: Configuration): Paragraph[];
1183
+ linesToParagraphs(lines: Line[]): Paragraph[];
1184
+ /** Returns a deep clone of the song @returns {Song} */
1185
+ clone(): Song;
1186
+ getMetadataValue(name: string): string | string[] | null;
1187
+ getSingleMetadataValue(name: string): string | null;
1188
+ /**
1189
+ * Returns a copy of the song with the key value set to the specified key. It changes:
1190
+ * - the value for `key` in the {@link metadata} set
1191
+ * - any existing `key` directive
1192
+ * @param {number|null} key the key. Passing `null` will:
1193
+ * - remove the current key from {@link metadata}
1194
+ * - remove any `key` directive
1195
+ * @returns {Song} The changed song
1196
+ */
1197
+ setKey(key: string | number | null): Song;
1198
+ /**
1199
+ * Returns a copy of the song with the key value set to the specified capo. It changes:
1200
+ * - the value for `capo` in the {@link metadata} set
1201
+ * - any existing `capo` directive
1202
+ * @param {number|null} capo the capo. Passing `null` will:
1203
+ * - remove the current key from {@link metadata}
1204
+ * - remove any `capo` directive
1205
+ * @returns {Song} The changed song
1206
+ */
1207
+ setCapo(capo: number | null): Song;
1208
+ /**
1209
+ * Transposes the song by the specified delta. It will:
1210
+ * - transpose all chords, see: {@link Chord#transpose}
1211
+ * - transpose the song key in {@link metadata}
1212
+ * - update any existing `key` directive
1213
+ * @param {number} delta The number of semitones (positive or negative) to transpose with
1214
+ * @param {Object} [options={}] options
1215
+ * @param {boolean} [options.normalizeChordSuffix=false] whether to normalize the chord suffixes after transposing
1216
+ * @returns {Song} The transposed song
1217
+ */
1218
+ transpose(delta: number, { accidental, normalizeChordSuffix }?: {
1219
+ accidental?: Accidental | null;
1220
+ normalizeChordSuffix?: boolean;
1221
+ }): Song;
1222
+ /**
1223
+ * Transposes the song up by one semitone. It will:
1224
+ * - transpose all chords, see: {@link Chord#transpose}
1225
+ * - transpose the song key in {@link metadata}
1226
+ * - update any existing `key` directive
1227
+ * @param {Object} [options={}] options
1228
+ * @param {boolean} [options.normalizeChordSuffix=false] whether to normalize the chord suffixes after transposing
1229
+ * @returns {Song} The transposed song
1230
+ */
1231
+ transposeUp({ normalizeChordSuffix }?: {
1232
+ normalizeChordSuffix?: boolean;
1233
+ }): Song;
1234
+ /**
1235
+ * Transposes the song down by one semitone. It will:
1236
+ * - transpose all chords, see: {@link Chord#transpose}
1237
+ * - transpose the song key in {@link metadata}
1238
+ * - update any existing `key` directive
1239
+ * @param {Object} [options={}] options
1240
+ * @param {boolean} [options.normalizeChordSuffix=false] whether to normalize the chord suffixes after transposing
1241
+ * @returns {Song} The transposed song
1242
+ */
1243
+ transposeDown({ normalizeChordSuffix }?: {
1244
+ normalizeChordSuffix?: boolean;
1245
+ }): Song;
1246
+ /**
1247
+ * Returns a copy of the song with the key set to the specified key. It changes:
1248
+ * - the value for `key` in the {@link metadata} set
1249
+ * - any existing `key` directive
1250
+ * - all chords, those are transposed according to the distance between the current and the new key
1251
+ * @param {string} newKey The new key.
1252
+ * @returns {Song} The changed song
1253
+ */
1254
+ changeKey(newKey: string | Key): Song;
1255
+ /**
1256
+ * Returns a copy of the song with all chords changed to the specified accidental.
1257
+ *
1258
+ * Examples:
1259
+ *
1260
+ * ```js
1261
+ * song.useAccidental('#');
1262
+ * song.useAccidental('b');
1263
+ * ```
1264
+ *
1265
+ * @param {Accidental} accidental the new accidental
1266
+ * @returns {Song} the changed song
1267
+ */
1268
+ useAccidental(accidental: Accidental): Song;
1269
+ /**
1270
+ * @deprecated Use useAccidental instead
1271
+ */
1272
+ useModifier(accidental: Accidental): Song;
1273
+ /**
1274
+ * Returns a copy of the song with all chords normalized to the specified key. See {@link Chord#normalize}.
1275
+ * @param key the key to normalize to
1276
+ * @param options options
1277
+ * @param options.normalizeSuffix whether to normalize the chord suffixes
1278
+ */
1279
+ normalizeChords(key?: Key | string | null, { normalizeSuffix }?: {
1280
+ normalizeSuffix?: boolean;
1281
+ }): Song;
1282
+ mapChordLyricsPairs(func: (pair: ChordLyricsPair) => ChordLyricsPair): Song;
1283
+ changeChords(func: (chord: Chord) => Chord): Song;
1284
+ get currentKey(): Key | null;
1285
+ requireCurrentKey(): Key;
1286
+ /**
1287
+ * Returns a copy of the song with the directive value(s) set to the specified value(s).
1288
+ * - when there is a matching directive in the song, it will update the directive
1289
+ * - when there is no matching directive, it will be inserted
1290
+ * If `value` is `null` it will act as a delete, any directive matching `name` will be removed.
1291
+ *
1292
+ * @example
1293
+ * ```javascript
1294
+ * song.changeMetadata('author', 'John');
1295
+ * song.changeMetadata('composer', ['Jane', 'John']);
1296
+ * song.changeMetadata('key', null); // Remove key directive
1297
+ * ```
1298
+ * @param name The directive name
1299
+ * @param {string | string[] | null} value The value to set, or `null` to remove the directive
1300
+ * @return {Song} The changed song
1301
+ */
1302
+ changeMetadata(name: string, value: string | string[] | null): Song;
1303
+ /**
1304
+ * Returns a copy of the song with the metadata changed. It will:
1305
+ * - update the metadata
1306
+ * - update any existing directive matching the metadata key
1307
+ * - insert a new directive if it does not exist
1308
+ * @example
1309
+ * ```javascript
1310
+ * song.changeMetadata({
1311
+ * author: 'John',
1312
+ * composer: ['Jane', 'John'],
1313
+ * key: null, // Remove key directive
1314
+ * });
1315
+ * ```
1316
+ * @param {Record<string, string | string[] | null>} metadata The metadata to change
1317
+ */
1318
+ changeMetadata(metadata: Record<string, string | string[] | null>): Song;
1319
+ addLine(line: Line): void;
1320
+ /**
1321
+ * Change the song contents inline. Return a new {@link Item} to replace it. Return `null` to remove it.
1322
+ * @example
1323
+ * // transpose all chords:
1324
+ * song.mapItems((item) => {
1325
+ * if (item instanceof ChordLyricsPair) {
1326
+ * return item.transpose(2, 'D');
1327
+ * }
1328
+ *
1329
+ * return item;
1330
+ * });
1331
+ * @param {MapItemsCallback} func the callback function
1332
+ * @returns {Song} the changed song
1333
+ */
1334
+ mapItems(func: MapItemsCallback): Song;
1335
+ foreachItem(func: (_item: Item) => void): void;
1336
+ /**
1337
+ * Returns all unique chords used in the song
1338
+ * @returns {string[]} the chords
1339
+ */
1340
+ getChords(): string[];
1341
+ /**
1342
+ * Returns all chord definitions from the song.
1343
+ * Definitions are made using the `{chord}` or `{define}` directive.
1344
+ * A chord definitions overrides a previous chord definition for the exact same chord.
1345
+ * @returns {Record<string, ChordDefinition>} the chord definitions
1346
+ * @see https://chordpro.org/chordpro/directives-define/
1347
+ * @see https://chordpro.org/chordpro/directives-chord/
1348
+ */
1349
+ getChordDefinitions(context?: FormattingContext): Record<string, ChordDefinition>;
1350
+ /**
1351
+ * The song's metadata. When there is only one value for an entry, the value is a string. Else, the value is
1352
+ * an array containing all unique values for the entry.
1353
+ * @type {Metadata}
1354
+ */
1355
+ get metadata(): Metadata;
1356
+ getMetadata(configuration?: Configuration): Metadata;
1357
+ get chordDefinitions(): ChordDefinitionSet;
1358
+ /**
1359
+ * Change the song contents inline. Return a new {@link Line} to replace it. Return `null` to remove it.
1360
+ * @example
1361
+ * // remove lines with only Tags:
1362
+ * song.mapLines((line) => {
1363
+ * if (line.items.every(item => item instanceof Tag)) {
1364
+ * return null;
1365
+ * }
1366
+ *
1367
+ * return line;
1368
+ * });
1369
+ * @param {MapLinesCallback} func the callback function
1370
+ * @returns {Song} the changed song
1371
+ */
1372
+ mapLines(func: (_line: Line) => Line | null): Song;
1373
+ }
1374
+ interface TextDimensions {
1375
+ width: number;
1376
+ height: number;
1377
+ }
1378
+ interface Measurer {
1379
+ /**
1380
+ * Measures the dimensions of text with the given font configuration
1381
+ * @param text The text to measure
1382
+ * @param fontConfig The font configuration to apply
1383
+ * @returns The dimensions of the text
1384
+ */
1385
+ measureText(text: string, fontConfig: FontConfiguration): TextDimensions;
1386
+ /**
1387
+ * Measures the width of text with the given font configuration
1388
+ * @param text The text to measure
1389
+ * @param fontConfig The font configuration to apply
1390
+ * @returns The width of the text
1391
+ */
1392
+ measureTextWidth(text: string, fontConfig: FontConfiguration): number;
1393
+ /**
1394
+ * Measures the height of text with the given font configuration
1395
+ * @param text The text to measure
1396
+ * @param fontConfig The font configuration to apply
1397
+ * @returns The height of the text
1398
+ */
1399
+ measureTextHeight(text: string, fontConfig: FontConfiguration): number;
1400
+ /**
1401
+ * Splits text into lines that fit within the given width
1402
+ * @param text The text to split
1403
+ * @param maxWidth The maximum width of each line
1404
+ * @param fontConfig The font configuration to apply
1405
+ * @returns The lines of text
1406
+ */
1407
+ splitTextToSize(text: string, maxWidth: number, fontConfig: FontConfiguration): string[];
1408
+ }
1409
+ /**
1410
+ * Base class for implementing measurers with common functionality
1411
+ */
1412
+ declare abstract class BaseMeasurer implements Measurer {
1413
+ abstract measureText(text: string, fontConfig: FontConfiguration): TextDimensions;
1414
+ measureTextWidth(text: string, fontConfig: FontConfiguration): number;
1415
+ measureTextHeight(text: string, fontConfig: FontConfiguration): number;
1416
+ abstract splitTextToSize(text: string, maxWidth: number, fontConfig: FontConfiguration): string[];
1417
+ protected splitTextWithMeasure(text: string, maxWidth: number, measure: (value: string) => number): string[];
1418
+ protected wrapParagraph(paragraph: string, maxWidth: number, measure: (value: string) => number): string[];
1419
+ protected splitWord(word: string, maxWidth: number, measure: (value: string) => number): {
1420
+ lines: string[];
1421
+ remainder: string;
1422
+ };
1423
+ }
1424
+ /**
1425
+ * Measures text using jsPDF
1426
+ */
1427
+ export class JsPdfMeasurer extends BaseMeasurer {
1428
+ constructor(doc: DocWrapper);
1429
+ measureText(text: string, fontConfig: FontConfiguration): TextDimensions;
1430
+ splitTextToSize(text: string, maxWidth: number, fontConfig: FontConfiguration): string[];
1431
+ }
1432
+ /**
1433
+ * Base formatter for formatters that need measurements to position elements
1434
+ */
1435
+ declare abstract class MeasurementBasedFormatter<T extends MeasurementBasedFormatterConfiguration = MeasurementBasedFormatterConfiguration> extends Formatter<T> {
1436
+ /**
1437
+ * Instantiate a measurement-based formatter.
1438
+ * @param configuration - The formatter configuration.
1439
+ */
1440
+ constructor(configuration?: DeepPartial<T>);
1441
+ /**
1442
+ * Get the default configuration for this formatter type
1443
+ * Uses the measurement-based default configuration
1444
+ */
1445
+ protected getDefaultConfiguration(): T;
1446
+ }
1447
+ interface Margins {
1448
+ top: number;
1449
+ bottom: number;
1450
+ left: number;
1451
+ right: number;
1452
+ }
1453
+ type FontSection = 'title' | 'subtitle' | 'metadata' | 'text' | 'chord' | 'comment' | 'annotation' | 'sectionLabel';
1454
+ type Alignment = 'left' | 'center' | 'right' | number;
1455
+ type MeasurerType = 'canvas' | 'dom' | 'jspdf';
1456
+ type ConditionRule = Partial<{
1457
+ equals: any;
1458
+ not_equals: any;
1459
+ greater_than: number;
1460
+ greater_than_equal: number;
1461
+ less_than: number;
1462
+ less_than_equal: number;
1463
+ like: string;
1464
+ contains: string;
1465
+ in: any[];
1466
+ not_in: any[];
1467
+ all: any[];
1468
+ exists: boolean;
1469
+ first: boolean;
1470
+ last: boolean;
1471
+ }>;
1472
+ type SingleCondition = Record<string, ConditionRule>;
1473
+ type ConditionalRule = Partial<{
1474
+ and: SingleCondition[];
1475
+ or: SingleCondition[];
1476
+ }> | SingleCondition;
1477
+ interface Position {
1478
+ x: Alignment;
1479
+ y: number;
1480
+ width?: number;
1481
+ height?: number;
1482
+ offsetX?: number;
1483
+ clip?: boolean;
1484
+ ellipsis?: boolean;
1485
+ }
1486
+ interface Dimension {
1487
+ width: number;
1488
+ height: number;
1489
+ }
1490
+ interface FontConfiguration {
1491
+ name: string;
1492
+ style: string;
1493
+ weight?: string | number;
1494
+ size: number;
1495
+ lineHeight?: number;
1496
+ color: string | number;
1497
+ underline?: boolean;
1498
+ inherit?: string;
1499
+ textTransform?: string;
1500
+ textDecoration?: string;
1501
+ letterSpacing?: string;
1502
+ }
1503
+ type FontConfigurations = Record<FontSection, FontConfiguration>;
1504
+ type ChordDiagramFontConfigurations = Record<'title' | 'fingerings' | 'baseFret', FontConfiguration>;
1505
+ interface SectionDisplay {
1506
+ labelStyle?: 'uppercase';
1507
+ showLabel?: boolean;
1508
+ lyricsOnly?: boolean;
1509
+ indent?: number;
1510
+ compact?: boolean;
1511
+ repeatedSections?: 'hide' | 'title_only' | 'lyrics_only' | 'full';
1512
+ }
1513
+ interface SectionTypeConfig {
1514
+ fonts?: FontConfigurations;
1515
+ display?: SectionDisplay;
1516
+ overrides?: {
1517
+ condition: ConditionalRule;
1518
+ display: Partial<SectionDisplay>;
1519
+ }[];
1520
+ }
1521
+ interface ColumnConfig {
1522
+ columnCount?: number;
1523
+ columnSpacing: number;
1524
+ minColumnWidth?: number;
1525
+ maxColumnWidth?: number;
1526
+ }
1527
+ interface SectionsConfig {
1528
+ global: {
1529
+ columnWidth: number;
1530
+ spacingBottom?: number;
1531
+ spacingAfter?: number;
1532
+ chordLyricSpacing: number;
1533
+ linePadding: number;
1534
+ paragraphSpacing?: number;
1535
+ chordSpacing: number;
1536
+ } & ColumnConfig;
1537
+ base: SectionTypeConfig;
1538
+ types?: Record<ParagraphType, SectionTypeConfig | undefined>;
1539
+ }
1540
+ interface ILayoutContentItem {
1541
+ type: string;
1542
+ position: Position;
1543
+ condition?: ConditionalRule;
1544
+ }
1545
+ interface LayoutContentItemWithText extends ILayoutContentItem {
1546
+ type: 'text';
1547
+ style: FontConfiguration;
1548
+ value?: string;
1549
+ template?: string;
1550
+ cssClass?: string;
1551
+ elementStyle?: Record<string, string>;
1552
+ }
1553
+ interface LayoutContentItemWithValue extends LayoutContentItemWithText {
1554
+ value: string;
1555
+ }
1556
+ interface LayoutContentItemWithTemplate extends LayoutContentItemWithText {
1557
+ template: string;
1558
+ }
1559
+ interface LayoutContentItemWithImage extends ILayoutContentItem {
1560
+ type: 'image';
1561
+ src: string;
1562
+ position: Position;
1563
+ compression: ImageCompression;
1564
+ size: Dimension;
1565
+ alias?: string;
1566
+ rotation?: number;
1567
+ }
1568
+ interface LineStyle {
1569
+ color: string;
1570
+ width: number;
1571
+ dash?: number[];
1572
+ }
1573
+ interface LayoutContentItemWithLine {
1574
+ type: 'line';
1575
+ style: LineStyle;
1576
+ position: {
1577
+ x?: number;
1578
+ y: number;
1579
+ width: number | 'auto';
1580
+ height?: number;
1581
+ };
1582
+ condition?: ConditionalRule;
1583
+ }
1584
+ type LayoutContentItem = LayoutContentItemWithValue | LayoutContentItemWithTemplate | LayoutContentItemWithImage | LayoutContentItemWithLine;
1585
+ interface LayoutItem {
1586
+ height: number;
1587
+ content: LayoutContentItem[];
1588
+ }
1589
+ interface ChordDiagramOverrides {
1590
+ hide?: boolean;
1591
+ definition?: string;
1592
+ }
1593
+ interface ChordDiagramsConfig {
1594
+ enabled: boolean;
1595
+ renderingConfig?: ChordDiagramRenderingConfig;
1596
+ definitions?: {
1597
+ hiddenChords: string[];
1598
+ };
1599
+ overrides?: {
1600
+ global?: Record<string, ChordDiagramOverrides>;
1601
+ byKey?: Record<string, Record<string, ChordDiagramOverrides>>;
1602
+ };
1603
+ fonts: ChordDiagramFontConfigurations;
1604
+ }
1605
+ interface MeasurementBasedLayoutConfig {
1606
+ global: {
1607
+ margins: Margins;
1608
+ };
1609
+ header: LayoutItem;
1610
+ footer: LayoutItem;
1611
+ sections?: SectionsConfig;
1612
+ chordDiagrams?: ChordDiagramsConfig;
1613
+ }
1614
+ interface MeasurementBasedFormatterConfiguration extends BaseFormatterConfiguration {
1615
+ fonts: FontConfigurations;
1616
+ measurer: MeasurerType;
1617
+ layout: MeasurementBasedLayoutConfig;
1618
+ }
1619
+ type Configuration = BaseFormatterConfiguration;
1620
+ declare class DocWrapper {
1621
+ currentPage: number;
1622
+ fontConfiguration: FontConfiguration;
1623
+ totalPages: number;
1624
+ doc: any;
1625
+ static setup(docConstructor: PdfConstructor, options?: jsPDFOptions): DocWrapper;
1626
+ constructor(DocConstructor: PdfConstructor, options: jsPDFOptions);
1627
+ get pageSize(): {
1628
+ width: number;
1629
+ height: number;
1630
+ };
1631
+ save(filename: string): void;
1632
+ output(): any;
1633
+ eachPage(callback: () => void): void;
1634
+ newPage(): void;
1635
+ setPage(page: number): void;
1636
+ setFont(fontName: string, fontStyle?: string, fontWeight?: string | number): void;
1637
+ getFont(): any;
1638
+ getFontSize(): any;
1639
+ getFillColor(): any;
1640
+ setFillColor(color: number | string): void;
1641
+ setFontStyle(styleConfig: FontConfiguration): void;
1642
+ setFontSize(size: number): void;
1643
+ withFontConfiguration(fontConfiguration: FontConfiguration | null, callback: () => any): any;
1644
+ setTextColor(color: string | number): void;
1645
+ getTextDimensions(text: string, fontStyle?: FontConfiguration): {
1646
+ w: number;
1647
+ h: number;
1648
+ };
1649
+ getTextWidth(text: string, fontStyle?: FontConfiguration): number;
1650
+ getTextHeight(text: string, fontStyle?: FontConfiguration): number;
1651
+ getSpaceWidth(): number;
1652
+ text(text: string, x: number, y: number, style?: FontConfiguration): void;
1653
+ setDrawColor(color: number | string): void;
1654
+ setLineWidth(width: number): void;
1655
+ splitTextToSize(text: string | null, maxWidth: number, fontStyle?: FontConfiguration): any;
1656
+ addImage(imageData: string, format: string, x: number, y: number, width: number, height: number, alias?: string, compression?: ImageCompression, rotation?: number): void;
1657
+ setLineStyle(style: LineStyle): void;
1658
+ resetDash(): void;
1659
+ line(x1: number, y1: number, x2: number, y2: number): void;
1660
+ circle(x: number, y: number, r: number, style?: string | null): void;
1661
+ roundedRect(x: number, y: number, w: number, h: number, rx: number, ry: number, style?: string | null): void;
1662
+ rect(x: number, y: number, w: number, h: number, style?: string | null): void;
1663
+ withDrawColor(drawColor: number | string, callback: () => void): void;
1664
+ withFillColor(fillColor: number | string, callback: () => void): void;
1665
+ withFontSize(fontSize: number, callback: () => void): void;
1666
+ withLineWidth(lineWidth: number, callback: () => void): void;
1667
+ }
1668
+ /**
1669
+ * PdfFormatter formats a song into a PDF document.
1670
+ */
1671
+ export class PdfFormatter extends MeasurementBasedFormatter<PDFFormatterConfiguration> {
1672
+ /**
1673
+ * Get the default configuration for PDF formatter
1674
+ */
1675
+ protected getDefaultConfiguration(): PDFFormatterConfiguration;
1676
+ /**
1677
+ * Formats a song into a PDF.
1678
+ * @param song - The song to format.
1679
+ * @param docConstructor - The PDF document constructor.
1680
+ */
1681
+ format(song: Song, docConstructor?: PdfConstructor): void;
1682
+ /**
1683
+ * Save the formatted document as a PDF file
1684
+ */
1685
+ save(): void;
1686
+ /**
1687
+ * Generate the PDF as a Blob object
1688
+ */
1689
+ generatePDF(): Promise<Blob>;
1690
+ /**
1691
+ * Get the document wrapper - primarily for testing purposes.
1692
+ */
1693
+ getDocumentWrapper(): DocWrapper;
1694
+ }
1695
+
1696
+ //# sourceMappingURL=main.d.ts.map