chordsheetjs 6.1.0 → 6.2.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 (42) hide show
  1. package/README.md +423 -571
  2. package/lib/bundle.js +15353 -0
  3. package/lib/index.js +6253 -216
  4. package/lib/index.js.map +1 -0
  5. package/lib/main.d.ts +1062 -0
  6. package/lib/main.d.ts.map +1 -0
  7. package/package.json +43 -21
  8. package/.husky/pre-commit +0 -5
  9. package/lib/chord.js +0 -496
  10. package/lib/chord_sheet/chord_lyrics_pair.js +0 -80
  11. package/lib/chord_sheet/chord_pro/composite.js +0 -54
  12. package/lib/chord_sheet/chord_pro/evaluation_error.js +0 -58
  13. package/lib/chord_sheet/chord_pro/literal.js +0 -42
  14. package/lib/chord_sheet/chord_pro/ternary.js +0 -126
  15. package/lib/chord_sheet/comment.js +0 -55
  16. package/lib/chord_sheet/line.js +0 -207
  17. package/lib/chord_sheet/metadata.js +0 -216
  18. package/lib/chord_sheet/paragraph.js +0 -88
  19. package/lib/chord_sheet/song.js +0 -531
  20. package/lib/chord_sheet/tag.js +0 -359
  21. package/lib/chord_sheet_serializer.js +0 -278
  22. package/lib/constants.js +0 -54
  23. package/lib/formatter/chord_pro_formatter.js +0 -184
  24. package/lib/formatter/html_div_formatter.js +0 -130
  25. package/lib/formatter/html_formatter.js +0 -44
  26. package/lib/formatter/html_table_formatter.js +0 -154
  27. package/lib/formatter/templates/html_div_formatter.js +0 -544
  28. package/lib/formatter/templates/html_table_formatter.js +0 -731
  29. package/lib/formatter/text_formatter.js +0 -184
  30. package/lib/helpers.js +0 -56
  31. package/lib/key.js +0 -386
  32. package/lib/normalize_mappings/enharmonic-normalize.js +0 -124
  33. package/lib/normalize_mappings/generate-suffix-normalize-mapping.js +0 -36
  34. package/lib/normalize_mappings/suffix-normalize-mapping.js +0 -914
  35. package/lib/note.js +0 -264
  36. package/lib/parser/chord_pro_parser.js +0 -64
  37. package/lib/parser/chord_pro_peg_parser.js +0 -2069
  38. package/lib/parser/chord_sheet_parser.js +0 -175
  39. package/lib/parser/parser_warning.js +0 -62
  40. package/lib/parser/ultimate_guitar_parser.js +0 -154
  41. package/lib/template_helpers.js +0 -98
  42. package/lib/utilities.js +0 -110
package/lib/main.d.ts ADDED
@@ -0,0 +1,1062 @@
1
+ export class Literal {
2
+ string: string;
3
+ constructor(expression: any);
4
+ evaluate(): string;
5
+ isRenderable(): boolean;
6
+ clone(): Literal;
7
+ }
8
+ /**
9
+ * Used to mark a paragraph as verse
10
+ * @constant
11
+ * @type {string}
12
+ */
13
+ export const VERSE = "verse";
14
+ /**
15
+ * Used to mark a paragraph as chorus
16
+ * @constant
17
+ * @type {string}
18
+ */
19
+ export const CHORUS = "chorus";
20
+ /**
21
+ * Used to mark a paragraph as not containing a line marked with a type
22
+ * @constant
23
+ * @type {string}
24
+ */
25
+ export const NONE = "none";
26
+ /**
27
+ * Used to mark a paragraph as containing lines with both verse and chorus type
28
+ * @constant
29
+ * @type {string}
30
+ */
31
+ export const INDETERMINATE = "indeterminate";
32
+ /**
33
+ * Used to mark a paragraph as tab
34
+ * @constant
35
+ * @type {string}
36
+ */
37
+ export const TAB = "tab";
38
+ export const SYMBOL = "symbol";
39
+ export const NUMERIC = "numeric";
40
+ declare class Note {
41
+ _note: string;
42
+ type: string;
43
+ minor: boolean;
44
+ constructor({ note, type, minor }: {
45
+ note: any;
46
+ type: any;
47
+ minor?: boolean;
48
+ });
49
+ static parse(note: any): Note;
50
+ toNumeral(): Note;
51
+ toNumeric(): Note;
52
+ isMinor(): boolean;
53
+ equals(otherNote: any): boolean;
54
+ clone(): Note;
55
+ up(): Note;
56
+ down(): Note;
57
+ isOneOf(...options: any[]): boolean;
58
+ isNumeric(): boolean;
59
+ isChordSymbol(): boolean;
60
+ isNumeral(): boolean;
61
+ is(noteType: any): boolean;
62
+ getTransposeDistance(minorKey: any): any;
63
+ change(delta: any): Note;
64
+ get note(): string;
65
+ toString(): string;
66
+ }
67
+ export class Key {
68
+ note: Note;
69
+ modifier?: string;
70
+ minor: boolean;
71
+ static parse(keyString: any): any;
72
+ static wrap(keyStringOrObject: any): any;
73
+ static toString(keyStringOrObject: any): string;
74
+ static distance(oneKey: any, otherKey: any): any;
75
+ distanceTo(otherKey: any): number;
76
+ constructor({ note, modifier, minor }: {
77
+ note: any;
78
+ modifier?: any;
79
+ minor?: boolean;
80
+ });
81
+ isMinor(): boolean;
82
+ clone(): Key;
83
+ toChordSymbol(key: any): any;
84
+ toChordSymbolString(key: any): any;
85
+ is(type: any): boolean;
86
+ isNumeric(): boolean;
87
+ isChordSymbol(): boolean;
88
+ isNumeral(): boolean;
89
+ equals({ note, modifier }: {
90
+ note: any;
91
+ modifier?: any;
92
+ }): boolean;
93
+ toNumeric(key?: Key): Key;
94
+ toNumericString(key?: any): string;
95
+ toNumeral(key?: any): Key;
96
+ toNumeralString(key?: any): string;
97
+ toString(): string;
98
+ transpose(delta: any): Key;
99
+ transposeUp(): Key;
100
+ transposeDown(): Key;
101
+ useModifier(newModifier: any): Key;
102
+ normalize(): Key;
103
+ normalizeEnharmonics(key: any): any;
104
+ }
105
+ /**
106
+ * Represents a Chord, consisting of a root, suffix (quality) and bass
107
+ */
108
+ export class Chord {
109
+ root: Key;
110
+ suffix?: string;
111
+ bass?: Key;
112
+ /**
113
+ * Tries to parse a chord string into a chord
114
+ * @param chordString the chord string, eg `Esus4/G#` or `1sus4/#3`
115
+ * @returns {null|Chord}
116
+ */
117
+ static parse(chordString: any): any;
118
+ /**
119
+ * Returns a deep copy of the chord
120
+ * @returns {Chord}
121
+ */
122
+ clone(): Chord;
123
+ /**
124
+ * Converts the chord to a chord symbol, using the supplied key as a reference.
125
+ * For example, a numeric chord `#4` with reference key `E` will return the chord symbol `A#`.
126
+ * When the chord is already a chord symbol, it will return a clone of the object.
127
+ * @param {Key|string} [key=null] the reference key
128
+ * @returns {Chord} the chord symbol
129
+ */
130
+ toChordSymbol(key?: any): Chord;
131
+ /**
132
+ * Converts the chord to a chord symbol string, using the supplied key as a reference.
133
+ * For example, a numeric chord `#4` with reference key `E` will return the chord symbol `A#`.
134
+ * When the chord is already a chord symbol, it will return a string version of the chord.
135
+ * @param {Key|string} [key=null] the reference key
136
+ * @returns {string} the chord symbol string
137
+ * @see {toChordSymbol}
138
+ */
139
+ toChordSymbolString(key?: any): string;
140
+ /**
141
+ * Determines whether the chord is a chord symbol
142
+ * @returns {boolean}
143
+ */
144
+ isChordSymbol(): boolean;
145
+ /**
146
+ * Converts the chord to a numeric chord, using the supplied key as a reference.
147
+ * For example, a chord symbol A# with reference key E will return the numeric chord #4.
148
+ * @param {Key|string} [key=null] the reference key
149
+ * @returns {Chord} the numeric chord
150
+ */
151
+ toNumeric(key?: any): Chord;
152
+ /**
153
+ * Converts the chord to a numeral chord, using the supplied key as a reference.
154
+ * For example, a chord symbol A# with reference key E will return the numeral chord #IV.
155
+ * @param {Key|string|null} key the reference key. The key is required when converting a chord symbol
156
+ * @returns {Chord} the numeral chord
157
+ */
158
+ toNumeral(key?: any): Chord;
159
+ /**
160
+ * Converts the chord to a numeral chord string, using the supplied kye as a reference.
161
+ * For example, a chord symbol A# with reference key E will return the numeral chord #4.
162
+ * @param {Key|string} [key=null] the reference key
163
+ * @returns {string} the numeral chord string
164
+ * @see {toNumeral}
165
+ */
166
+ toNumeralString(key?: any): string;
167
+ /**
168
+ * Determines whether the chord is numeric
169
+ * @returns {boolean}
170
+ */
171
+ isNumeric(): boolean;
172
+ /**
173
+ * Converts the chord to a numeric chord string, using the supplied kye as a reference.
174
+ * For example, a chord symbol A# with reference key E will return the numeric chord #4.
175
+ * @param {Key|string} [key=null] the reference key
176
+ * @returns {string} the numeric chord string
177
+ * @see {toNumeric}
178
+ */
179
+ toNumericString(key?: any): string;
180
+ /**
181
+ * Determines whether the chord is a numeral
182
+ * @returns {boolean}
183
+ */
184
+ isNumeral(): boolean;
185
+ /**
186
+ * Converts the chord to a string, eg `Esus4/G#` or `1sus4/#3`
187
+ * @returns {string} the chord string
188
+ */
189
+ toString(): string;
190
+ /**
191
+ * Normalizes the chord root and bass notes:
192
+ * - Fb becomes E
193
+ * - Cb becomes B
194
+ * - B# becomes C
195
+ * - E# becomes F
196
+ * - 4b becomes 3
197
+ * - 1b becomes 7
198
+ * - 7# becomes 1
199
+ * - 3# becomes 4
200
+ *
201
+ * Besides that it normalizes the suffix. For example, `sus2` becomes `2`, `sus4` becomes `sus`.
202
+ * All suffix normalizations can be found in `src/normalize_mappings/suffix-mapping.txt`.
203
+ *
204
+ * @returns {Chord} the normalized chord
205
+ */
206
+ normalize(key?: any): Chord;
207
+ /**
208
+ * Switches to the specified modifier
209
+ * @param newModifier the modifier to use: `'#'` or `'b'`
210
+ * @returns {Chord} the new, changed chord
211
+ */
212
+ useModifier(newModifier: any): Chord;
213
+ /**
214
+ * Transposes the chord up by 1 semitone. Eg. A becomes A#, Eb becomes E
215
+ * @returns {Chord} the new, transposed chord
216
+ */
217
+ transposeUp(): Chord;
218
+ /**
219
+ * Transposes the chord down by 1 semitone. Eg. A# becomes A, E becomes Eb
220
+ * @returns {Chord} the new, transposed chord
221
+ */
222
+ transposeDown(): Chord;
223
+ /**
224
+ * Transposes the chord by the specified number of semitones
225
+ * @param delta de number of semitones
226
+ * @returns {Chord} the new, transposed chord
227
+ */
228
+ transpose(delta: any): Chord;
229
+ constructor({ base, modifier, suffix, bassBase, bassModifier, root, bass, }: {
230
+ base?: any;
231
+ modifier?: any;
232
+ suffix?: any;
233
+ bassBase?: any;
234
+ bassModifier?: any;
235
+ root?: any;
236
+ bass?: any;
237
+ });
238
+ makeMinor(): Chord;
239
+ set(properties: any): Chord;
240
+ private get rootNote();
241
+ }
242
+ /**
243
+ * Tries to parse a chord string into a chord
244
+ * @param chordString the chord string, eg Esus4/G# or 1sus4/#3
245
+ * @deprecated Please use {@link Chord.parse} instead
246
+ * @returns {null|Chord}
247
+ */
248
+ export function parseChord(chordString: any): any;
249
+ /**
250
+ * Represents a chord with the corresponding (partial) lyrics
251
+ */
252
+ export class ChordLyricsPair {
253
+ chords: string;
254
+ lyrics: string;
255
+ /**
256
+ * Initialises a ChordLyricsPair
257
+ * @param {string} chords The chords
258
+ * @param {string} lyrics The lyrics
259
+ */
260
+ constructor(chords?: string, lyrics?: string);
261
+ /**
262
+ * Indicates whether a ChordLyricsPair 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 ChordLyricsPair, useful when programmatically transforming a song
268
+ * @returns {ChordLyricsPair}
269
+ */
270
+ clone(): ChordLyricsPair;
271
+ toString(): string;
272
+ set(properties: any): ChordLyricsPair;
273
+ transpose(delta: number, key: string | Key): ChordLyricsPair;
274
+ }
275
+ interface TraceInfo {
276
+ line?: number;
277
+ column?: number;
278
+ offset?: number;
279
+ }
280
+ declare abstract class AstComponent {
281
+ line?: number;
282
+ column?: number;
283
+ offset?: number;
284
+ protected constructor(traceInfo?: TraceInfo);
285
+ abstract clone(): any;
286
+ }
287
+ /**
288
+ * Represents a tag/directive. See https://www.chordpro.org/chordpro/chordpro-directives/
289
+ */
290
+ export class Tag extends AstComponent {
291
+ _originalName: string;
292
+ _name: string;
293
+ _value?: string;
294
+ constructor(name: any, value?: string, traceInfo?: TraceInfo);
295
+ static parse(tag: any): Tag;
296
+ static parseWithRegex(tag: any, regex: any): Tag;
297
+ set name(name: string);
298
+ /**
299
+ * The tag full name. When the original tag used the short name, `name` will return the full name.
300
+ * @member
301
+ * @type {string}
302
+ */
303
+ get name(): string;
304
+ /**
305
+ * The original tag name that was used to construct the tag.
306
+ * @member
307
+ * @type {string}
308
+ */
309
+ get originalName(): string;
310
+ set value(value: string);
311
+ /**
312
+ * The tag value
313
+ * @member
314
+ * @type {string|null}
315
+ */
316
+ get value(): string;
317
+ /**
318
+ * Checks whether the tag value is a non-empty string.
319
+ * @returns {boolean}
320
+ */
321
+ hasValue(): boolean;
322
+ /**
323
+ * Checks whether the tag is usually rendered inline. It currently only applies to comment tags.
324
+ * @returns {boolean}
325
+ */
326
+ isRenderable(): boolean;
327
+ /**
328
+ * Checks whether the tag is either a standard meta tag or a custom meta directive (`{x_some_name}`)
329
+ * @returns {boolean}
330
+ */
331
+ isMetaTag(): boolean;
332
+ /**
333
+ * Returns a clone of the tag.
334
+ * @returns {Tag} The cloned tag
335
+ */
336
+ clone(): Tag;
337
+ toString(): string;
338
+ set({ value }: {
339
+ value: any;
340
+ }): Tag;
341
+ }
342
+ /**
343
+ * Represents a comment. See https://www.chordpro.org/chordpro/chordpro-file-format-specification/#overview
344
+ */
345
+ export class Comment {
346
+ content: string;
347
+ constructor(content: any);
348
+ /**
349
+ * Indicates whether a Comment should be visible in a formatted chord sheet (except for ChordPro sheets)
350
+ * @returns {boolean}
351
+ */
352
+ isRenderable(): boolean;
353
+ /**
354
+ * Returns a deep copy of the Comment, useful when programmatically transforming a song
355
+ * @returns {Comment}
356
+ */
357
+ clone(): Comment;
358
+ toString(): string;
359
+ }
360
+ declare abstract class MetadataAccessors {
361
+ abstract getMetadata(_name: string): string | string[];
362
+ get key(): string | string[];
363
+ get title(): string | string[];
364
+ get subtitle(): string | string[];
365
+ get capo(): string | string[];
366
+ get duration(): string | string[];
367
+ get tempo(): string | string[];
368
+ get time(): string | string[];
369
+ get year(): string | string[];
370
+ get album(): string | string[];
371
+ get copyright(): string | string[];
372
+ get lyricist(): string | string[];
373
+ get artist(): string | string[];
374
+ get composer(): string | string[];
375
+ }
376
+ /**
377
+ * Stores song metadata. Properties can be accessed using the get() method:
378
+ *
379
+ * const metadata = new Metadata({ author: 'John' });
380
+ * metadata.get('author') // => 'John'
381
+ *
382
+ * See {@link Metadata#get}
383
+ */
384
+ export class Metadata extends MetadataAccessors {
385
+ metadata: Record<string, string | string[]>;
386
+ constructor(metadata?: any);
387
+ contains(key: any): boolean;
388
+ add(key: any, value: any): void;
389
+ set(key: any, value: any): void;
390
+ getMetadata(name: string): string | string[];
391
+ /**
392
+ * Reads a metadata value by key. This method supports simple value lookup, as fetching single array values.
393
+ *
394
+ * This method deprecates direct property access, eg: metadata['author']
395
+ *
396
+ * Examples:
397
+ *
398
+ * const metadata = new Metadata({ lyricist: 'Pete', author: ['John', 'Mary'] });
399
+ * metadata.get('lyricist') // => 'Pete'
400
+ * metadata.get('author') // => ['John', 'Mary']
401
+ * metadata.get('author.1') // => 'John'
402
+ * metadata.get('author.2') // => 'Mary'
403
+ *
404
+ * Using a negative index will start counting at the end of the list:
405
+ *
406
+ * const metadata = new Metadata({ lyricist: 'Pete', author: ['John', 'Mary'] });
407
+ * metadata.get('author.-1') // => 'Mary'
408
+ * metadata.get('author.-2') // => 'John'
409
+ *
410
+ * @param prop the property name
411
+ * @returns {Array<String>|String} the metadata value(s). If there is only one value, it will return a String,
412
+ * else it returns an array of strings.
413
+ */
414
+ get(prop: any): any;
415
+ /**
416
+ * Returns a single metadata value. If the actual value is an array, it returns the first value. Else, it returns
417
+ * the value.
418
+ * @ignore
419
+ * @param {string} prop the property name
420
+ * @returns {String} The metadata value
421
+ */
422
+ getSingle(prop: any): any;
423
+ parseArrayKey(prop: any): any[];
424
+ getArrayItem(prop: any): string;
425
+ /**
426
+ * Returns a deep clone of this Metadata object
427
+ * @returns {Metadata} the cloned Metadata object
428
+ */
429
+ clone(): Metadata;
430
+ calculateKeyFromCapo(): any;
431
+ }
432
+ declare abstract class Evaluatable extends AstComponent {
433
+ abstract evaluate(_metadata: Metadata, _metadataSeparator: string, _variable: string): string;
434
+ }
435
+ export class Composite {
436
+ expressions: Evaluatable[];
437
+ variable?: string;
438
+ constructor(expressions: any, variable?: any);
439
+ evaluate(metadata: any, metadataSeparator: any): string;
440
+ isRenderable(): boolean;
441
+ clone(): Composite;
442
+ }
443
+ export class Ternary extends AstComponent {
444
+ variable?: string;
445
+ valueTest?: string;
446
+ trueExpression: AstComponent[];
447
+ falseExpression: AstComponent[];
448
+ constructor({ variable, valueTest, trueExpression, falseExpression, line, column, offset, }?: {
449
+ variable?: any;
450
+ valueTest?: any;
451
+ trueExpression?: any;
452
+ falseExpression?: any;
453
+ line?: any;
454
+ column?: any;
455
+ offset?: any;
456
+ });
457
+ /**
458
+ * Evaluate the meta expression
459
+ * @param {Metadata} metadata The metadata object to use for evaluating the expression
460
+ * @param {string} [metadataSeparator=null] The metadata separator to use if necessary
461
+ * @returns {string} The evaluated expression
462
+ */
463
+ evaluate(metadata: any, metadataSeparator?: any, upperContext?: any): any;
464
+ evaluateToString(value: any, metadataSeparator: any): any;
465
+ evaluateWithVariable(metadata: any, metadataSeparator: any): any;
466
+ evaluateForTruthyValue(metadata: any, metadataSeparator: any, value: any): any;
467
+ isRenderable(): boolean;
468
+ clone(): Ternary;
469
+ }
470
+ type Item = ChordLyricsPair | Comment | Tag | Ternary;
471
+ type LineType = 'verse' | 'chorus' | 'none';
472
+ /**
473
+ * Represents a line in a chord sheet, consisting of items of type ChordLyricsPair or Tag
474
+ */
475
+ export class Line {
476
+ /**
477
+ * The items ({@link ChordLyricsPair} or {@link Tag} or {@link Comment}) of which the line consists
478
+ * @member
479
+ * @type {Array.<(ChordLyricsPair|Tag|Comment)>}
480
+ */
481
+ items: Item[];
482
+ /**
483
+ * The line type, This is set by the ChordProParser when it read tags like {start_of_chorus} or {start_of_verse}
484
+ * Values can be {@link VERSE}, {@link CHORUS} or {@link NONE}
485
+ * @member
486
+ * @type {string}
487
+ */
488
+ type: LineType;
489
+ /**
490
+ * @ignore
491
+ * @type {ChordLyricsPair}
492
+ */
493
+ currentChordLyricsPair: ChordLyricsPair;
494
+ /**
495
+ * @ignore
496
+ * @type {string|null}
497
+ */
498
+ key?: string;
499
+ /**
500
+ * @ignore
501
+ * @type {string|null}
502
+ */
503
+ transposeKey?: string;
504
+ constructor({ type, items }?: {
505
+ type: LineType;
506
+ items: Item[];
507
+ });
508
+ /**
509
+ * Indicates whether the line contains any items
510
+ * @returns {boolean}
511
+ */
512
+ isEmpty(): boolean;
513
+ /**
514
+ * Adds an item ({@link ChordLyricsPair} or {@link Tag}) to the line
515
+ * @param {ChordLyricsPair|Tag} item The item to be added
516
+ */
517
+ addItem(item: Item): void;
518
+ /**
519
+ * Indicates whether the line contains items that are renderable
520
+ * @returns {boolean}
521
+ */
522
+ hasRenderableItems(): boolean;
523
+ /**
524
+ * Returns a deep copy of the line and all of its items
525
+ * @returns {Line}
526
+ */
527
+ clone(): Line;
528
+ mapItems(func: any): Line;
529
+ /**
530
+ * Indicates whether the line type is {@link VERSE}
531
+ * @returns {boolean}
532
+ */
533
+ isVerse(): boolean;
534
+ /**
535
+ * Indicates whether the line type is {@link CHORUS}
536
+ * @returns {boolean}
537
+ */
538
+ isChorus(): boolean;
539
+ /**
540
+ * Indicates whether the line contains items that are renderable. Please use {@link hasRenderableItems}
541
+ * @deprecated
542
+ * @returns {boolean}
543
+ */
544
+ hasContent(): boolean;
545
+ addChordLyricsPair(chords?: any, lyrics?: any): ChordLyricsPair;
546
+ ensureChordLyricsPair(): void;
547
+ chords(chr: any): void;
548
+ lyrics(chr: any): void;
549
+ addTag(name: any, value?: any): Tag;
550
+ addComment(content: any): Comment;
551
+ set(properties: any): Line;
552
+ }
553
+ /**
554
+ * Represents a paragraph of lines in a chord sheet
555
+ */
556
+ export class Paragraph {
557
+ /**
558
+ * The {@link Line} items of which the paragraph consists
559
+ * @member
560
+ * @type {Line[]}
561
+ */
562
+ lines: Line[];
563
+ addLine(line: any): void;
564
+ /**
565
+ * Tries to determine the common type for all lines. If the types for all lines are equal, it returns that type.
566
+ * If not, it returns {@link INDETERMINATE}
567
+ * @returns {string}
568
+ */
569
+ get type(): "indeterminate" | import("chord_sheet/line").LineType;
570
+ /**
571
+ * Indicates whether the paragraph contains lines with renderable items.
572
+ * @see {@link Line.hasRenderableItems}
573
+ * @returns {boolean}
574
+ */
575
+ hasRenderableItems(): boolean;
576
+ }
577
+ /**
578
+ * Represents a parser warning, currently only used by ChordProParser.
579
+ */
580
+ declare class ParserWarning {
581
+ /**
582
+ * The warning message
583
+ * @member
584
+ * @type {string}
585
+ */
586
+ message: string;
587
+ /**
588
+ * The chord sheet line number on which the warning occurred
589
+ * @member
590
+ * @type {number}
591
+ */
592
+ lineNumber: number;
593
+ /**
594
+ * The chord sheet column on which the warning occurred
595
+ * @member
596
+ * @type {number}
597
+ */
598
+ column: number;
599
+ /**
600
+ * @hideconstructor
601
+ */
602
+ constructor(message: string, lineNumber: number, column: number);
603
+ /**
604
+ * Returns a stringified version of the warning
605
+ * @returns {string} The string warning
606
+ */
607
+ toString(): string;
608
+ }
609
+ /**
610
+ * Represents a song in a chord sheet. Currently a chord sheet can only have one song.
611
+ */
612
+ export class Song extends MetadataAccessors {
613
+ /**
614
+ * The {@link Line} items of which the song consists
615
+ * @member {Line[]}
616
+ */
617
+ lines: Line[];
618
+ /**
619
+ * The {@link Paragraph} items of which the song consists
620
+ * @member {Paragraph[]}
621
+ */
622
+ paragraphs: Paragraph[];
623
+ /**
624
+ * The song's metadata. When there is only one value for an entry, the value is a string. Else, the value is
625
+ * an array containing all unique values for the entry.
626
+ * @type {Metadata}
627
+ */
628
+ metadata: Metadata;
629
+ currentLine?: Line;
630
+ currentParagraph?: Paragraph;
631
+ warnings: ParserWarning[];
632
+ sectionType: string;
633
+ currentKey?: string;
634
+ transposeKey?: string;
635
+ /**
636
+ * Creates a new {Song} instance
637
+ * @param metadata {Object|Metadata} predefined metadata
638
+ */
639
+ constructor(metadata?: {});
640
+ get previousLine(): Line;
641
+ /**
642
+ * Returns the song lines, skipping the leading empty lines (empty as in not rendering any content). This is useful
643
+ * if you want to skip the "header lines": the lines that only contain meta data.
644
+ * @returns {Line[]} The song body lines
645
+ */
646
+ get bodyLines(): any;
647
+ /**
648
+ * Returns the song paragraphs, skipping the paragraphs that only contain empty lines
649
+ * (empty as in not rendering any content)
650
+ * @see {@link bodyLines}
651
+ * @returns {Paragraph[]}
652
+ */
653
+ get bodyParagraphs(): any;
654
+ selectRenderableItems(targetProp: any, sourceProp: any): any;
655
+ chords(chr: any): void;
656
+ lyrics(chr: any): void;
657
+ addLine(): Line;
658
+ setCurrentLineType(sectionType: any): void;
659
+ flushLine(): void;
660
+ finish(): void;
661
+ ensureLine(): void;
662
+ addParagraph(): Paragraph;
663
+ ensureParagraph(): void;
664
+ addTag(tagContents: any): Tag;
665
+ setSectionTypeFromTag(tag: any): void;
666
+ startSection(sectionType: any, tag: any): void;
667
+ endSection(sectionType: any, tag: any): void;
668
+ checkCurrentSectionType(sectionType: any, tag: any): void;
669
+ addWarning(message: any, { line, column }: {
670
+ line: any;
671
+ column: any;
672
+ }): void;
673
+ addItem(item: any): void;
674
+ /**
675
+ * Returns a deep clone of the song
676
+ * @returns {Song} The cloned song
677
+ */
678
+ clone(): Song;
679
+ setMetadata(name: any, value: any): void;
680
+ /**
681
+ * The song's metadata. Please use {@link metadata} instead.
682
+ * @deprecated
683
+ * @returns {@link Metadata} The metadata
684
+ */
685
+ get metaData(): Metadata;
686
+ getMetadata(name: any): any;
687
+ /**
688
+ * Returns a copy of the song with the capo value set to the specified capo. It changes:
689
+ * - the value for `capo` in the `metadata` set
690
+ * - any existing `capo` directive)
691
+ * @param {number|null} capo the capo. Passing `null` will:
692
+ * - remove the current key from `metadata`
693
+ * - remove any `capo` directive
694
+ * @returns {Song} The changed song
695
+ */
696
+ setCapo(capo: any): any;
697
+ /**
698
+ * Returns a copy of the song with the key set to the specified key. It changes:
699
+ * - the value for `key` in the `metadata` set
700
+ * - any existing `key` directive
701
+ * - all chords, those are transposed according to the distance between the current and the new key
702
+ * @param {string} key The new key.
703
+ * @returns {Song} The changed song
704
+ */
705
+ setKey(key: any): Song;
706
+ }
707
+ /**
708
+ * Serializes a song into een plain object, and deserializes the serialized object back into a {@link Song}
709
+ */
710
+ export class ChordSheetSerializer {
711
+ song?: Song;
712
+ /**
713
+ * Serializes the chord sheet to a plain object, which can be converted to any format like JSON, XML etc
714
+ * Can be deserialized using {@link deserialize}
715
+ * @returns object A plain JS object containing all chord sheet data
716
+ */
717
+ serialize(song: any): {
718
+ type: string;
719
+ lines: any;
720
+ };
721
+ serializeLine(line: any): {
722
+ type: string;
723
+ items: any;
724
+ };
725
+ serializeItem(item: any): any;
726
+ serializeTag(tag: any): {
727
+ type: string;
728
+ name: any;
729
+ value: any;
730
+ };
731
+ serializeChordLyricsPair(chordLyricsPair: any): {
732
+ type: string;
733
+ chords: any;
734
+ lyrics: any;
735
+ };
736
+ serializeTernary(ternary: any): {
737
+ type: string;
738
+ variable: any;
739
+ valueTest: any;
740
+ trueExpression: any;
741
+ falseExpression: any;
742
+ };
743
+ serializeLiteral(literal: any): any;
744
+ serializeExpression(expression: any): any;
745
+ /**
746
+ * Deserializes a song that has been serialized using {@link serialize}
747
+ * @param {object} serializedSong The serialized song
748
+ * @returns {Song} The deserialized song
749
+ */
750
+ deserialize(serializedSong: any): Song;
751
+ parseAstComponent(astComponent: any): void | Literal | ChordLyricsPair | Tag | Comment | Ternary;
752
+ parseChordSheet(astComponent: any): void;
753
+ parseLine(astComponent: any): void;
754
+ parseChordLyricsPair(astComponent: any): ChordLyricsPair;
755
+ parseTag(astComponent: any): Tag;
756
+ parseComment(astComponent: any): Comment;
757
+ parseTernary(astComponent: any): Ternary;
758
+ parseExpression(expression: any): any;
759
+ }
760
+ /**
761
+ * Parses a ChordPro chord sheet
762
+ */
763
+ export class ChordProParser {
764
+ song?: Song;
765
+ /**
766
+ * Parses a ChordPro chord sheet into a song
767
+ * @param {string} chordProChordSheet the ChordPro chord sheet
768
+ * @returns {Song} The parsed song
769
+ */
770
+ parse(chordProChordSheet: any): Song;
771
+ /**
772
+ * All warnings raised during parsing the ChordPro chord sheet
773
+ * @member
774
+ * @type {ParserWarning[]}
775
+ */
776
+ get warnings(): import("parser/parser_warning").default[];
777
+ }
778
+ /**
779
+ * Parses a normal chord sheet
780
+ */
781
+ export class ChordSheetParser {
782
+ processingText: boolean;
783
+ preserveWhitespace: boolean;
784
+ song?: Song;
785
+ songLine?: Line;
786
+ chordLyricsPair?: ChordLyricsPair;
787
+ lines: string[];
788
+ currentLine: number;
789
+ lineCount: number;
790
+ /**
791
+ * Instantiate a chord sheet parser
792
+ * @param {Object} [options={}] options
793
+ * @param {boolean} [options.preserveWhitespace=true] whether to preserve trailing whitespace for chords
794
+ */
795
+ constructor({ preserveWhitespace }?: {
796
+ preserveWhitespace?: boolean;
797
+ });
798
+ /**
799
+ * Parses a chord sheet into a song
800
+ * @param {string} chordSheet The ChordPro chord sheet
801
+ * @param {Object} [options={}] Optional parser options
802
+ * @param {Song} [options.song=null] The {@link Song} to store the song data in
803
+ * @returns {Song} The parsed song
804
+ */
805
+ parse(chordSheet: any, { song }?: {
806
+ song?: any;
807
+ }): Song;
808
+ endOfSong(): void;
809
+ parseLine(line: any): void;
810
+ parseNonEmptyLine(line: any): void;
811
+ initialize(document: any, { song }?: {
812
+ song?: any;
813
+ }): void;
814
+ readLine(): string;
815
+ hasNextLine(): boolean;
816
+ parseLyricsWithChords(chordsLine: any, lyricsLine: any): void;
817
+ processCharacters(chordsLine: any, lyricsLine: any): void;
818
+ addCharacter(chr: any, nextChar: any): void;
819
+ shouldAddCharacterToChords(nextChar: any): boolean;
820
+ ensureChordLyricsPairInitialized(): void;
821
+ }
822
+ /**
823
+ * Parses an Ultimate Guitar chord sheet with metadata
824
+ * Inherits from {@link ChordSheetParser}
825
+ */
826
+ export class UltimateGuitarParser extends ChordSheetParser {
827
+ currentSectionType?: string;
828
+ parseLine(line: any): void;
829
+ isSectionEnd(): boolean;
830
+ endOfSong(): void;
831
+ startSection(sectionType: any): void;
832
+ endSection({ addNewLine }?: {
833
+ addNewLine?: boolean;
834
+ }): void;
835
+ startNewLine(): void;
836
+ }
837
+ declare class MetadataConfiguration {
838
+ separator?: string;
839
+ constructor({ separator }: {
840
+ separator: string;
841
+ });
842
+ }
843
+ declare class Configuration {
844
+ metadata?: MetadataConfiguration;
845
+ evaluate: boolean;
846
+ constructor({ evaluate, metadata }: {
847
+ evaluate?: boolean;
848
+ metadata?: {
849
+ separator: string;
850
+ };
851
+ });
852
+ get(key: string): any;
853
+ }
854
+ /**
855
+ * Base class for all formatters, taking care of receiving a configuration wrapping that inside a Configuration object
856
+ */
857
+ declare class Formatter {
858
+ configuration: Configuration;
859
+ /**
860
+ * Instantiate
861
+ * @param {Object} [configuration={}] options
862
+ * @param {boolean} [configuration.evaluate=false] Whether or not to evaluate meta expressions. For more info about
863
+ * meta expressions, see: https://bit.ly/2SC9c2u
864
+ * @param {object} [configuration.metadata={}]
865
+ * @param {string} [configuration.metadata.separator=", "] The separator to be used when rendering a metadata value
866
+ * that has multiple values. See: https://bit.ly/2SC9c2u
867
+ */
868
+ constructor(configuration?: {});
869
+ }
870
+ /**
871
+ * Formats a song into a plain text chord sheet
872
+ */
873
+ export class TextFormatter extends Formatter {
874
+ song?: Song;
875
+ /**
876
+ * Formats a song into a plain text chord sheet
877
+ * @param {Song} song The song to be formatted
878
+ * @returns {string} the chord sheet
879
+ */
880
+ format(song: any): string;
881
+ formatHeader(): string;
882
+ formatParagraphs(): any;
883
+ formatParagraph(paragraph: any, metadata: any): any;
884
+ formatLine(line: any, metadata: any): string;
885
+ formatTitle(title: any): string;
886
+ formatSubTitle(subtitle: any): string;
887
+ formatLineTop(line: any): any;
888
+ chordLyricsPairLength(chordLyricsPair: any, line: any): any;
889
+ formatItemTop(item: any, metadata: any, line: any): any;
890
+ formatLineBottom(line: any, metadata: any): any;
891
+ formatLineWithFormatter(line: any, formatter: any, metadata?: any): any;
892
+ formatItemBottom(item: any, metadata: any, line: any): any;
893
+ }
894
+ /**
895
+ * Acts as a base class for HTML formatters, taking care of whitelisting prototype property access.
896
+ */
897
+ declare class HtmlFormatter extends Formatter {
898
+ formatWithTemplate(song: any, template: any): any;
899
+ }
900
+ /**
901
+ * Formats a song into HTML. It uses TABLEs to align lyrics with chords, which makes the HTML for things like
902
+ * PDF conversion.
903
+ */
904
+ export class HtmlTableFormatter extends HtmlFormatter {
905
+ /**
906
+ * Formats a song into HTML.
907
+ * @param {Song} song The song to be formatted
908
+ * @returns {string} The HTML string
909
+ */
910
+ format(song: any): any;
911
+ /**
912
+ * Generates basic CSS, optionally scoped within the provided selector, to use with output generated by
913
+ * {@link HtmlTableFormatter}
914
+ *
915
+ * For example, execute cssString('.chordSheetViewer') will result in CSS like:
916
+ *
917
+ * .chordSheetViewer .paragraph {
918
+ * margin-bottom: 1em;
919
+ * }
920
+ *
921
+ * @param scope the CSS scope to use, for example `.chordSheetViewer`
922
+ * @returns {string} the CSS string
923
+ */
924
+ static cssString(scope?: string): string;
925
+ /**
926
+ * Basic CSS, in object style à la useStyles, to use with output generated by {@link HtmlTableFormatter}
927
+ * For a CSS string see {@link cssString}
928
+ *
929
+ * Example:
930
+ *
931
+ * '.paragraph': {
932
+ * marginBottom: '1em'
933
+ * }
934
+ *
935
+ * @return {Object.<string, Object.<string, string>>} the CSS object
936
+ */
937
+ static cssObject(): {
938
+ h1: {
939
+ fontSize: string;
940
+ };
941
+ h2: {
942
+ fontSize: string;
943
+ };
944
+ table: {
945
+ borderSpacing: string;
946
+ color: string;
947
+ };
948
+ td: {
949
+ padding: string;
950
+ };
951
+ '.chord:not(:last-child)': {
952
+ paddingRight: string;
953
+ };
954
+ '.paragraph': {
955
+ marginBottom: string;
956
+ };
957
+ };
958
+ }
959
+ /**
960
+ * Formats a song into HTML. It uses DIVs to align lyrics with chords, which makes it useful for responsive web pages.
961
+ */
962
+ export class HtmlDivFormatter extends HtmlFormatter {
963
+ /**
964
+ * Formats a song into HTML.
965
+ * @param {Song} song The song to be formatted
966
+ * @returns {string} The HTML string
967
+ */
968
+ format(song: any): any;
969
+ /**
970
+ * Generates basic CSS, optionally scoped within the provided selector, to use with output generated by
971
+ * {@link HtmlDivFormatter}
972
+ *
973
+ * For example, execute cssString('.chordSheetViewer') will result in CSS like:
974
+ *
975
+ * .chordSheetViewer .paragraph {
976
+ * margin-bottom: 1em;
977
+ * }
978
+ *
979
+ * @param scope the CSS scope to use, for example `.chordSheetViewer`
980
+ * @returns {string} the CSS string
981
+ */
982
+ static cssString(scope?: string): string;
983
+ /**
984
+ * Basic CSS, in object style à la useStyles, to use with output generated by {@link HtmlDivFormatter}
985
+ *
986
+ * Example:
987
+ *
988
+ * '.paragraph': {
989
+ * marginBottom: '1em'
990
+ * }
991
+ *
992
+ * For a CSS string see {@link cssString}
993
+ * @return {Object.<string, Object.<string, string>>} the CSS object
994
+ */
995
+ static cssObject(): {
996
+ '.chord:not(:last-child)': {
997
+ paddingRight: string;
998
+ };
999
+ '.paragraph': {
1000
+ marginBottom: string;
1001
+ };
1002
+ '.row': {
1003
+ display: string;
1004
+ };
1005
+ '.chord:after': {
1006
+ content: string;
1007
+ };
1008
+ '.lyrics:after': {
1009
+ content: string;
1010
+ };
1011
+ };
1012
+ }
1013
+ /**
1014
+ * Formats a song into a ChordPro chord sheet
1015
+ */
1016
+ export class ChordProFormatter extends Formatter {
1017
+ /**
1018
+ * Formats a song into a ChordPro chord sheet.
1019
+ * @param {Song} song The song to be formatted
1020
+ * @returns {string} The ChordPro string
1021
+ */
1022
+ format(song: any): any;
1023
+ formatLine(line: any, metadata: any): any;
1024
+ formatItem(item: any, metadata: any): any;
1025
+ formatOrEvaluateItem(item: any, metadata: any): any;
1026
+ formatTernary(ternary: any): string;
1027
+ formatValueTest(valueTest: any): string;
1028
+ formatExpressionRange(expressionRange: any): string;
1029
+ formatExpression(expression: any): string;
1030
+ formatTag(tag: any): string;
1031
+ formatChordLyricsPair(chordLyricsPair: any): string;
1032
+ formatChordLyricsPairChords(chordLyricsPair: any): string;
1033
+ formatChordLyricsPairLyrics(chordLyricsPair: any): any;
1034
+ }
1035
+ declare const _default: {
1036
+ ChordProParser: typeof ChordProParser;
1037
+ ChordSheetParser: typeof ChordSheetParser;
1038
+ UltimateGuitarParser: typeof UltimateGuitarParser;
1039
+ TextFormatter: typeof TextFormatter;
1040
+ HtmlTableFormatter: typeof HtmlTableFormatter;
1041
+ HtmlDivFormatter: typeof HtmlDivFormatter;
1042
+ ChordProFormatter: typeof ChordProFormatter;
1043
+ ChordLyricsPair: typeof ChordLyricsPair;
1044
+ Line: typeof Line;
1045
+ Song: typeof Song;
1046
+ Tag: typeof Tag;
1047
+ Comment: typeof Comment;
1048
+ Metadata: typeof Metadata;
1049
+ Paragraph: typeof Paragraph;
1050
+ Ternary: typeof Ternary;
1051
+ Composite: typeof Composite;
1052
+ Literal: typeof Literal;
1053
+ ChordSheetSerializer: typeof ChordSheetSerializer;
1054
+ CHORUS: string;
1055
+ INDETERMINATE: string;
1056
+ TAB: string;
1057
+ VERSE: string;
1058
+ NONE: string;
1059
+ };
1060
+ export default _default;
1061
+
1062
+ //# sourceMappingURL=main.d.ts.map