chordsheetjs 14.6.1 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +12 -3
  2. package/lib/bundle.js +25728 -66671
  3. package/lib/bundle.min.js +148 -7118
  4. package/lib/index.js +1 -7770
  5. package/lib/index.js.map +1 -1
  6. package/lib/main.d.ts +2 -131
  7. package/lib/main.d.ts.map +1 -1
  8. package/lib/module.js +2 -7769
  9. package/lib/module.js.map +1 -1
  10. package/lib/pdf/chord.d.ts +219 -0
  11. package/lib/pdf/chord_definition/chord_definition.d.ts +66 -0
  12. package/lib/pdf/chord_definition/chord_definition_set.d.ts +12 -0
  13. package/lib/pdf/chord_diagram/chord_diagram.d.ts +131 -0
  14. package/lib/pdf/chord_diagram/js_pdf_renderer.d.ts +40 -0
  15. package/lib/pdf/chord_diagram/renderer.d.ts +43 -0
  16. package/lib/pdf/chord_parsing_error.d.ts +2 -0
  17. package/lib/pdf/chord_sheet/ast_component.d.ts +11 -0
  18. package/lib/pdf/chord_sheet/ast_type.d.ts +9 -0
  19. package/lib/pdf/chord_sheet/chord_lyrics_pair.d.ts +60 -0
  20. package/lib/pdf/chord_sheet/chord_pro/composite.d.ts +11 -0
  21. package/lib/pdf/chord_sheet/chord_pro/evaluatable.d.ts +7 -0
  22. package/lib/pdf/chord_sheet/chord_pro/evaluation_error.d.ts +7 -0
  23. package/lib/pdf/chord_sheet/chord_pro/literal.d.ts +9 -0
  24. package/lib/pdf/chord_sheet/chord_pro/ternary.d.ts +29 -0
  25. package/lib/pdf/chord_sheet/comment.d.ts +21 -0
  26. package/lib/pdf/chord_sheet/font.d.ts +47 -0
  27. package/lib/pdf/chord_sheet/font_size.d.ts +33 -0
  28. package/lib/pdf/chord_sheet/font_stack.d.ts +13 -0
  29. package/lib/pdf/chord_sheet/item.d.ts +7 -0
  30. package/lib/pdf/chord_sheet/line.d.ts +130 -0
  31. package/lib/pdf/chord_sheet/line_expander.d.ts +12 -0
  32. package/lib/pdf/chord_sheet/metadata.d.ts +71 -0
  33. package/lib/pdf/chord_sheet/metadata_accessors.d.ts +18 -0
  34. package/lib/pdf/chord_sheet/paragraph.d.ts +48 -0
  35. package/lib/pdf/chord_sheet/soft_line_break.d.ts +15 -0
  36. package/lib/pdf/chord_sheet/song.d.ts +253 -0
  37. package/lib/pdf/chord_sheet/song_mapper.d.ts +15 -0
  38. package/lib/pdf/chord_sheet/standard_metadata_providers.d.ts +5 -0
  39. package/lib/pdf/chord_sheet/tag.d.ts +104 -0
  40. package/lib/pdf/chord_sheet/tag_interpreter.d.ts +14 -0
  41. package/lib/pdf/chord_sheet/tags.d.ts +259 -0
  42. package/lib/pdf/chord_sheet/trace_info.d.ts +6 -0
  43. package/lib/pdf/chord_sheet_serializer.d.ts +49 -0
  44. package/lib/pdf/constants.d.ts +117 -0
  45. package/lib/pdf/formatter/chord_pro_formatter.d.ts +39 -0
  46. package/lib/pdf/formatter/chord_renderer.d.ts +30 -0
  47. package/lib/pdf/formatter/chords_over_words_formatter.d.ts +33 -0
  48. package/lib/pdf/formatter/configuration/base_configuration.d.ts +58 -0
  49. package/lib/pdf/formatter/configuration/default_config_manager.d.ts +31 -0
  50. package/lib/pdf/formatter/configuration/html_configuration.d.ts +37 -0
  51. package/lib/pdf/formatter/configuration/index.d.ts +13 -0
  52. package/lib/pdf/formatter/configuration/measured_html_configuration.d.ts +38 -0
  53. package/lib/pdf/formatter/configuration/measurement_based_configuration.d.ts +204 -0
  54. package/lib/pdf/formatter/configuration/pdf_configuration.d.ts +16 -0
  55. package/lib/pdf/formatter/formatter.d.ts +38 -0
  56. package/lib/pdf/formatter/formatting_context.d.ts +7 -0
  57. package/lib/pdf/formatter/html_div_formatter.d.ts +9 -0
  58. package/lib/pdf/formatter/html_formatter.d.ts +60 -0
  59. package/lib/pdf/formatter/html_table_formatter.d.ts +10 -0
  60. package/lib/pdf/formatter/measured_html_formatter.d.ts +43 -0
  61. package/lib/pdf/formatter/measurement_based_formatter.d.ts +19 -0
  62. package/lib/pdf/formatter/pdf_formatter/doc_wrapper.d.ts +53 -0
  63. package/lib/pdf/formatter/pdf_formatter/fonts/NimbusSansLFonts.base64.d.ts +4 -0
  64. package/lib/pdf/formatter/pdf_formatter/types.d.ts +34 -0
  65. package/lib/pdf/formatter/pdf_formatter.d.ts +40 -0
  66. package/lib/pdf/formatter/templates/html_div_formatter.d.ts +3 -0
  67. package/lib/pdf/formatter/templates/html_table_formatter.d.ts +3 -0
  68. package/lib/pdf/formatter/text_formatter.d.ts +35 -0
  69. package/lib/pdf/helpers.d.ts +42 -0
  70. package/lib/pdf/index.d.ts +126 -0
  71. package/lib/pdf/index.js +24369 -0
  72. package/lib/pdf/key.d.ts +124 -0
  73. package/lib/pdf/key_config.d.ts +3 -0
  74. package/lib/pdf/layout/engine/condition.d.ts +25 -0
  75. package/lib/pdf/layout/engine/dimensions.d.ts +33 -0
  76. package/lib/pdf/layout/engine/index.d.ts +7 -0
  77. package/lib/pdf/layout/engine/item_processor.d.ts +70 -0
  78. package/lib/pdf/layout/engine/layout_engine.d.ts +67 -0
  79. package/lib/pdf/layout/engine/layout_factory.d.ts +22 -0
  80. package/lib/pdf/layout/engine/layout_helpers.d.ts +35 -0
  81. package/lib/pdf/layout/engine/line_breaker.d.ts +54 -0
  82. package/lib/pdf/layout/engine/paragraph_splitter/index.d.ts +5 -0
  83. package/lib/pdf/layout/engine/paragraph_splitter/paragraph_splitter.d.ts +5 -0
  84. package/lib/pdf/layout/engine/paragraph_splitter/strategies/five_or_more_lines_paragraph_split_strategy.d.ts +14 -0
  85. package/lib/pdf/layout/engine/paragraph_splitter/strategies/four_lines_paragraph_split_strategy.d.ts +8 -0
  86. package/lib/pdf/layout/engine/paragraph_splitter/strategies/three_or_less_lines_paragraph_split_strategy.d.ts +4 -0
  87. package/lib/pdf/layout/engine/title_separator_tag.d.ts +8 -0
  88. package/lib/pdf/layout/engine/types.d.ts +98 -0
  89. package/lib/pdf/layout/measurement/canvas_measurer.d.ts +18 -0
  90. package/lib/pdf/layout/measurement/dom_measurer.d.ts +21 -0
  91. package/lib/pdf/layout/measurement/index.d.ts +4 -0
  92. package/lib/pdf/layout/measurement/js_pdf_measurer.d.ts +12 -0
  93. package/lib/pdf/layout/measurement/measurer.d.ts +52 -0
  94. package/lib/pdf/module.js +24336 -0
  95. package/lib/pdf/normalize_mappings/enharmonic-normalize.d.ts +2 -0
  96. package/lib/pdf/normalize_mappings/suffix-normalize-mapping.d.ts +2 -0
  97. package/lib/pdf/pango/pango_helpers.d.ts +6 -0
  98. package/lib/pdf/parser/chord/peg_parser.d.ts +55 -0
  99. package/lib/pdf/parser/chord_definition/peg_parser.d.ts +55 -0
  100. package/lib/pdf/parser/chord_pro/helpers.d.ts +15 -0
  101. package/lib/pdf/parser/chord_pro/peg_parser.d.ts +55 -0
  102. package/lib/pdf/parser/chord_pro_parser.d.ts +32 -0
  103. package/lib/pdf/parser/chord_sheet_parser.d.ts +57 -0
  104. package/lib/pdf/parser/chords_over_words/helpers.d.ts +33 -0
  105. package/lib/pdf/parser/chords_over_words/peg_parser.d.ts +55 -0
  106. package/lib/pdf/parser/chords_over_words_parser.d.ts +67 -0
  107. package/lib/pdf/parser/null_tracer.d.ts +4 -0
  108. package/lib/pdf/parser/parser_helpers.d.ts +3 -0
  109. package/lib/pdf/parser/parser_warning.d.ts +33 -0
  110. package/lib/pdf/parser/ultimate_guitar_parser.d.ts +46 -0
  111. package/lib/pdf/pdf.d.ts +2 -0
  112. package/lib/pdf/rendering/html/html_doc_wrapper.d.ts +82 -0
  113. package/lib/pdf/rendering/html/html_element_styler.d.ts +58 -0
  114. package/lib/pdf/rendering/html/positioned_html_renderer.d.ts +85 -0
  115. package/lib/pdf/rendering/pdf/js_pdf_renderer.d.ts +46 -0
  116. package/lib/pdf/rendering/pdf/pdf_chord_diagram_renderer.d.ts +118 -0
  117. package/lib/pdf/rendering/renderer.d.ts +273 -0
  118. package/lib/pdf/rendering/shared/layout_section_renderer.d.ts +93 -0
  119. package/lib/pdf/scales.d.ts +3 -0
  120. package/lib/pdf/serialized_types.d.ts +76 -0
  121. package/lib/pdf/song_builder.d.ts +38 -0
  122. package/lib/pdf/template_helpers/metadata_processor.d.ts +14 -0
  123. package/lib/pdf/template_helpers/when.d.ts +13 -0
  124. package/lib/pdf/template_helpers/when_callback.d.ts +2 -0
  125. package/lib/pdf/template_helpers/when_clause.d.ts +8 -0
  126. package/lib/pdf/template_helpers.d.ts +64 -0
  127. package/lib/pdf/utilities.d.ts +35 -0
  128. package/lib/pdf/version.d.ts +2 -0
  129. package/package.json +20 -2
@@ -0,0 +1,21 @@
1
+ import type Line from './line';
2
+ /**
3
+ * Represents a comment. See https://www.chordpro.org/chordpro/chordpro-file-format-specification/#overview
4
+ */
5
+ declare class Comment {
6
+ content: string;
7
+ parentLine: Line | null;
8
+ constructor(content: string);
9
+ /**
10
+ * Indicates whether a Comment should be visible in a formatted chord sheet (except for ChordPro sheets)
11
+ * @returns {boolean}
12
+ */
13
+ isRenderable(): boolean;
14
+ /**
15
+ * Returns a deep copy of the Comment, useful when programmatically transforming a song
16
+ * @returns {Comment}
17
+ */
18
+ clone(): Comment;
19
+ toString(): string;
20
+ }
21
+ export default Comment;
@@ -0,0 +1,47 @@
1
+ import FontSize from './font_size';
2
+ interface FontProperties {
3
+ font?: string | null;
4
+ size?: FontSize | null;
5
+ colour?: string | null;
6
+ }
7
+ declare class Font {
8
+ /**
9
+ * The font
10
+ * @member {string | null}
11
+ */
12
+ font: string | null;
13
+ /**
14
+ * The font size, expressed in either pixels or percentage.
15
+ * @member {FontSize | null}
16
+ */
17
+ size: FontSize | null;
18
+ /**
19
+ * The font color
20
+ * @member {string | null}
21
+ */
22
+ colour: string | null;
23
+ constructor({ font, size, colour }?: FontProperties);
24
+ clone(): Font;
25
+ /**
26
+ * Converts the font, size and color to a CSS string.
27
+ * If possible, font and size are combined to the `font` shorthand.
28
+ * If `font` contains double quotes (`"`) those will be converted to single quotes (`'`).
29
+ *
30
+ * @example
31
+ * // Returns "font-family: 'Times New Roman'"
32
+ * new Font({ font: '"Times New Roman"' }).toCssString()
33
+ * @example
34
+ * // Returns "color: red; font-family: Verdana"
35
+ * new Font({ font: 'Verdana', colour: 'red' }).toCssString()
36
+ * @example
37
+ * // Returns "font: 30px Verdana"
38
+ * new Font({ font: 'Verdana', size: '30' }).toCssString()
39
+ * @example
40
+ * // Returns "color: blue; font: 30% Verdana"
41
+ * new Font({ font: 'Verdana', size: '30%', colour: 'blue' }).toCssString()
42
+ *
43
+ * @return {string} The CSS string
44
+ */
45
+ toCssString(): string;
46
+ }
47
+ export default Font;
@@ -0,0 +1,33 @@
1
+ type Size = 'px' | '%';
2
+ declare class FontSize {
3
+ /**
4
+ * The size unit, either `"px"` or `"%"`
5
+ * @member {string}
6
+ */
7
+ unit: Size;
8
+ /**
9
+ * The font size
10
+ * @member {number}
11
+ */
12
+ fontSize: number;
13
+ constructor(fontSize: number, kind: Size);
14
+ clone(): FontSize;
15
+ multiply(percentage: any): FontSize;
16
+ /**
17
+ * Stringifies the font size by concatenating size and unit
18
+ *
19
+ * @example
20
+ * // Returns "30px"
21
+ * new FontSize(30, 'px').toString()
22
+ * @example
23
+ * // Returns "120%"
24
+ * new FontSize(120, '%').toString()
25
+ *
26
+ * @return {string} The font size
27
+ */
28
+ toString(): string;
29
+ static parse(fontSize: string, parent: FontSize | null): FontSize;
30
+ static parseNotANumber(parent: FontSize | null): FontSize;
31
+ static parsePercentage(parsedFontSize: number, parent: FontSize | null): FontSize;
32
+ }
33
+ export default FontSize;
@@ -0,0 +1,13 @@
1
+ import Font from './font';
2
+ import FontSize from './font_size';
3
+ import Tag from './tag';
4
+ declare class FontStack {
5
+ fontAndColourStacks: Record<string, string[]>;
6
+ sizeStacks: Record<string, FontSize[]>;
7
+ textFont: Font;
8
+ chordFont: Font;
9
+ applyTag(tag: Tag): void;
10
+ private pushOrPopTag;
11
+ private pushOrPopSizeTag;
12
+ }
13
+ export default FontStack;
@@ -0,0 +1,7 @@
1
+ import ChordLyricsPair from './chord_lyrics_pair';
2
+ import Comment from './comment';
3
+ import Literal from './chord_pro/literal';
4
+ import Tag from './tag';
5
+ import Ternary from './chord_pro/ternary';
6
+ type Item = ChordLyricsPair | Comment | Tag | Ternary | Literal;
7
+ export default Item;
@@ -0,0 +1,130 @@
1
+ import ChordLyricsPair from './chord_lyrics_pair';
2
+ import Comment from './comment';
3
+ import Font from './font';
4
+ import Item from './item';
5
+ import Tag from './tag';
6
+ import { ContentType, PartTypes } from '../serialized_types';
7
+ type MapItemFunc = (_item: Item) => Item | null;
8
+ export type LineType = 'bridge' | 'chorus' | 'none' | 'tab' | 'verse' | ContentType | 'indeterminate' | PartTypes;
9
+ /**
10
+ * Represents a line in a chord sheet, consisting of items of type ChordLyricsPair or Tag
11
+ */
12
+ declare class Line {
13
+ /**
14
+ * The items ({@link ChordLyricsPair} or {@link Tag} or {@link Comment}) of which the line consists
15
+ * @type {Array.<(ChordLyricsPair|Tag|Comment)>}
16
+ */
17
+ items: Item[];
18
+ /**
19
+ * The line type, This is set by the ChordProParser when it read tags like {start_of_chorus} or {start_of_verse}
20
+ * It uses the following mapping to determine the line type from directives:
21
+ * - `start_of_abc` => {@link ABC}
22
+ * - `start_of_bridge` => {@link BRIDGE}
23
+ * - `start_of_chorus` => {@link CHORUS}
24
+ * - `start_of_grid` => {@link GRID}
25
+ * - `start_of_ly` => {@link LILYPOND}
26
+ * - `start_of_tab` => {@link TAB}
27
+ * - `start_of_verse` => {@link VERSE}
28
+ *
29
+ * There are two special cases:
30
+ * - {@link INDETERMINATE} when the paragraph lines do not have a consistent type
31
+ * - {@link NONE} when no type is derived
32
+ * @type {string}
33
+ */
34
+ type: string;
35
+ currentChordLyricsPair: ChordLyricsPair;
36
+ key: string | null;
37
+ transposeKey: string | null;
38
+ lineNumber: number | null;
39
+ selector: string | null;
40
+ selectorIsNegated: boolean;
41
+ /**
42
+ * The text font that applies to this line. Is derived from the directives:
43
+ * `textfont`, `textsize` and `textcolour`
44
+ * See: https://www.chordpro.org/chordpro/directives-props_text_legacy/
45
+ * @type {Font}
46
+ */
47
+ textFont: Font;
48
+ /**
49
+ * The chord font that applies to this line. Is derived from the directives:
50
+ * `chordfont`, `chordsize` and `chordcolour`
51
+ * See: https://www.chordpro.org/chordpro/directives-props_chord_legacy/
52
+ * @type {Font}
53
+ */
54
+ chordFont: Font;
55
+ constructor({ type, items }?: {
56
+ type: string;
57
+ items: Item[];
58
+ });
59
+ /**
60
+ * Indicates whether the line contains any items
61
+ * @returns {boolean}
62
+ */
63
+ isEmpty(): boolean;
64
+ /**
65
+ * Adds an item ({@link ChordLyricsPair} or {@link Tag}) to the line
66
+ * @param {ChordLyricsPair|Tag} item The item to be added
67
+ */
68
+ addItem(item: Item): void;
69
+ /**
70
+ * Indicates whether the line contains items that are renderable
71
+ * @returns {boolean}
72
+ */
73
+ hasRenderableItems(): boolean;
74
+ /**
75
+ * Returns a deep copy of the line and all of its items
76
+ * @returns {Line}
77
+ */
78
+ clone(): Line;
79
+ mapItems(func: MapItemFunc | null): Line;
80
+ /**
81
+ * Indicates whether the line type is {@link BRIDGE}
82
+ * @returns {boolean}
83
+ */
84
+ isBridge(): boolean;
85
+ /**
86
+ * Indicates whether the line type is {@link CHORUS}
87
+ * @returns {boolean}
88
+ */
89
+ isChorus(): boolean;
90
+ /**
91
+ * Indicates whether the line type is {@link GRID}
92
+ * @returns {boolean}
93
+ */
94
+ isGrid(): boolean;
95
+ /**
96
+ * Indicates whether the line type is {@link TAB}
97
+ * @returns {boolean}
98
+ */
99
+ isTab(): boolean;
100
+ /**
101
+ * Indicates whether the line type is {@link VERSE}
102
+ * @returns {boolean}
103
+ */
104
+ isVerse(): boolean;
105
+ /**
106
+ * Indicates whether the line type is {@link PART}
107
+ * @returns {boolean}
108
+ */
109
+ isPart(): boolean;
110
+ /**
111
+ * Indicates whether the line contains items that are renderable. Please use {@link hasRenderableItems}
112
+ * @deprecated
113
+ * @returns {boolean}
114
+ */
115
+ hasContent(): boolean;
116
+ addChordLyricsPair(chords?: ChordLyricsPair | string | null, lyrics?: null): ChordLyricsPair;
117
+ ensureChordLyricsPair(): void;
118
+ chords(chr: string): void;
119
+ lyrics(chr: string): void;
120
+ addTag(nameOrTag: Tag | string, value?: string | null): Tag;
121
+ addComment(content: Comment | string): Comment;
122
+ set(properties: {
123
+ type?: string;
124
+ items?: Item[];
125
+ }): Line;
126
+ get _tag(): Tag | null;
127
+ isSectionStart(): boolean;
128
+ isSectionEnd(): boolean;
129
+ }
130
+ export default Line;
@@ -0,0 +1,12 @@
1
+ import Line from './line';
2
+ import Song from './song';
3
+ declare class LineExpander {
4
+ line: Line;
5
+ song: Song;
6
+ static expand(line: Line, song: Song): Line[];
7
+ constructor(line: Line, song: Song);
8
+ expand(): Line[];
9
+ private getLastChorusBefore;
10
+ private lineHasMoreThanChorusDirectives;
11
+ }
12
+ export default LineExpander;
@@ -0,0 +1,71 @@
1
+ import MetadataAccessors from './metadata_accessors';
2
+ type MetadataProvider = () => string | null;
3
+ /**
4
+ * Stores song metadata. Properties can be accessed using the get() method:
5
+ *
6
+ * const metadata = new Metadata({ author: 'John' });
7
+ * metadata.get('author') // => 'John'
8
+ *
9
+ * See {@link Metadata#get}
10
+ */
11
+ declare class Metadata extends MetadataAccessors implements Iterable<[string, string | string[]]> {
12
+ metadata: Record<string, string | string[]>;
13
+ providers: Map<string, MetadataProvider>;
14
+ constructor(metadata?: Record<string, string | string[]> | Metadata);
15
+ merge(metadata?: Record<string, string | string[]> | Metadata): Metadata;
16
+ contains(key: string): boolean;
17
+ add(key: string, value: string): void;
18
+ appendValue(key: string, value: string): void;
19
+ setProvider(key: string, provider: MetadataProvider): void;
20
+ set(key: string, value: string | null): void;
21
+ getMetadataValue(name: string): string | string[] | null;
22
+ getSingleMetadataValue(name: string): string | null;
23
+ /**
24
+ * Reads a metadata value by key. This method supports simple value lookup, as well as fetching single array values.
25
+ *
26
+ * This method deprecates direct property access, eg: metadata['author']
27
+ *
28
+ * @example
29
+ * const metadata = new Metadata({ lyricist: 'Pete', author: ['John', 'Mary'] });
30
+ * metadata.get('lyricist') // => 'Pete'
31
+ * metadata.get('author') // => ['John', 'Mary']
32
+ * metadata.get('author.1') // => 'John'
33
+ * metadata.get('author.2') // => 'Mary'
34
+ *
35
+ * Using a negative index will start counting at the end of the list:
36
+ *
37
+ * const metadata = new Metadata({ lyricist: 'Pete', author: ['John', 'Mary'] });
38
+ * metadata.get('author.-1') // => 'Mary'
39
+ * metadata.get('author.-2') // => 'John'
40
+ *
41
+ * @param prop the property name
42
+ * @returns {Array<String>|String} the metadata value(s). If there is only one value, it will return a String,
43
+ * else it returns an array of strings.
44
+ */
45
+ get(prop: string): string | string[] | null;
46
+ /**
47
+ * Returns all metadata values, including provider values and generated values like `_key`.
48
+ * @returns {Object.<string, string|string[]>} the metadata values
49
+ */
50
+ all(): Record<string, string | string[]>;
51
+ ownMetadata(): Record<string, string | string[]>;
52
+ [Symbol.iterator](): IterableIterator<[string, string | string[]]>;
53
+ /**
54
+ * Returns a single metadata value. If the actual value is an array, it returns the first value. Else, it returns
55
+ * the value.
56
+ * @ignore
57
+ * @param {string} prop the property name
58
+ * @returns {String} The metadata value
59
+ */
60
+ getSingle(prop: string): string | null;
61
+ parseArrayKey(prop: string): [string, number] | null;
62
+ getArrayItem(prop: string): string | null;
63
+ /**
64
+ * Returns a deep clone of this Metadata object
65
+ * @returns {Metadata} the cloned Metadata object
66
+ */
67
+ clone(): Metadata;
68
+ calculateKeyFromCapo(): string | null;
69
+ assign(metadata: Record<string, string | string[] | null>): void;
70
+ }
71
+ export default Metadata;
@@ -0,0 +1,18 @@
1
+ declare abstract class MetadataAccessors {
2
+ abstract getMetadataValue(_name: string): string | string[] | null;
3
+ abstract getSingleMetadataValue(_name: string): string | null;
4
+ get key(): string | null;
5
+ get title(): string | null;
6
+ get subtitle(): string | null;
7
+ get capo(): string | string[] | null;
8
+ get duration(): string | null;
9
+ get tempo(): string | null;
10
+ get time(): string | string[] | null;
11
+ get year(): string | null;
12
+ get album(): string | string[] | null;
13
+ get copyright(): string | null;
14
+ get lyricist(): string | string[] | null;
15
+ get artist(): string | string[] | null;
16
+ get composer(): string | string[] | null;
17
+ }
18
+ export default MetadataAccessors;
@@ -0,0 +1,48 @@
1
+ import Line from './line';
2
+ /**
3
+ * Represents a paragraph of lines in a chord sheet
4
+ */
5
+ declare class Paragraph {
6
+ /**
7
+ * The {@link Line} items of which the paragraph consists
8
+ * @member
9
+ * @type {Line[]}
10
+ */
11
+ lines: Line[];
12
+ addLine(line: any): void;
13
+ /**
14
+ * Indicates whether the paragraph only contains literals. If true, {@link contents} can be used to retrieve
15
+ * the paragraph contents as one string where lines are separated by newlines.
16
+ * @see {@link contents}
17
+ * @returns {boolean}
18
+ */
19
+ isLiteral(): boolean;
20
+ /**
21
+ * Returns the paragraph contents as one string where lines are separated by newlines
22
+ * @returns {string}
23
+ */
24
+ get contents(): string;
25
+ /**
26
+ * Returns the label of the paragraph. The label is the value of the first section delimiter tag
27
+ * in the first line.
28
+ * @returns {string|null}
29
+ */
30
+ get label(): string | null;
31
+ /**
32
+ * Tries to determine the common type for all lines. If the types for all lines are equal, it returns that type.
33
+ * If not, it returns {@link INDETERMINATE}
34
+ * For the possible values, see {@link Line.type}
35
+ * @returns {string}
36
+ */
37
+ get type(): string;
38
+ get selector(): string | null;
39
+ get selectorIsNegated(): boolean;
40
+ /**
41
+ * Indicates whether the paragraph contains lines with renderable items.
42
+ * @see {@link Line.hasRenderableItems}
43
+ * @returns {boolean}
44
+ */
45
+ hasRenderableItems(): boolean;
46
+ isEmpty(): boolean;
47
+ }
48
+ export default Paragraph;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Represents a soft line break in the lyrics, typically rendered as a space or optional break point.
3
+ */
4
+ declare class SoftLineBreak {
5
+ /**
6
+ * The content of the soft line break, defaults to a single space.
7
+ */
8
+ content: string;
9
+ constructor(content?: string);
10
+ /**
11
+ * Returns a copy of the SoftLineBreak.
12
+ */
13
+ clone(): SoftLineBreak;
14
+ }
15
+ export default SoftLineBreak;
@@ -0,0 +1,253 @@
1
+ import Chord from '../chord';
2
+ import ChordDefinition from '../chord_definition/chord_definition';
3
+ import ChordDefinitionSet from '../chord_definition/chord_definition_set';
4
+ import ChordLyricsPair from './chord_lyrics_pair';
5
+ import Configuration from '../formatter/configuration';
6
+ import FormattingContext from '../formatter/formatting_context';
7
+ import Item from './item';
8
+ import Key from '../key';
9
+ import Line from './line';
10
+ import Metadata from './metadata';
11
+ import MetadataAccessors from './metadata_accessors';
12
+ import Paragraph from './paragraph';
13
+ import ParserWarning from '../parser/parser_warning';
14
+ import { Accidental } from '../constants';
15
+ type MapItemsCallback = (_item: Item) => Item | Item[] | null;
16
+ /**
17
+ * Represents a song in a chord sheet. Currently a chord sheet can only have one song.
18
+ */
19
+ declare class Song extends MetadataAccessors {
20
+ /**
21
+ * The {@link Line} items of which the song consists
22
+ * @member {Line[]}
23
+ */
24
+ lines: Line[];
25
+ _bodyLines: Line[] | null;
26
+ _bodyParagraphs: Paragraph[] | null;
27
+ _renderParagraphs: Paragraph[] | null;
28
+ warnings: ParserWarning[];
29
+ _metadata: Metadata | null;
30
+ /**
31
+ * Creates a new {Song} instance
32
+ * @param metadata {Record<string, string | string[]>|Metadata} predefined metadata
33
+ */
34
+ constructor(metadata?: Record<string, string | string[]> | Metadata | null);
35
+ /** Returns song lines, skipping leading empty/meta-only lines. @returns {Line[]} */
36
+ get bodyLines(): Line[];
37
+ /** Returns song paragraphs, skipping paragraphs with only empty lines. @returns {Paragraph[]} */
38
+ get bodyParagraphs(): Paragraph[];
39
+ get renderParagraphs(): Paragraph[];
40
+ set renderParagraphs(paragraphs: Paragraph[]);
41
+ selectRenderableItems(items: (Line | Paragraph)[]): (Line | Paragraph)[];
42
+ /** The {@link Paragraph} items of which the song consists @member {Paragraph[]} */
43
+ get paragraphs(): Paragraph[];
44
+ /** The body paragraphs with any `{chorus}` tag expanded into the targeted chorus */
45
+ get expandedBodyParagraphs(): Paragraph[];
46
+ filterParagraphs(paragraphs: Paragraph[], configuration: Configuration): Paragraph[];
47
+ linesToParagraphs(lines: Line[]): Paragraph[];
48
+ /** Returns a deep clone of the song @returns {Song} */
49
+ clone(): Song;
50
+ getMetadataValue(name: string): string | string[] | null;
51
+ getSingleMetadataValue(name: string): string | null;
52
+ /**
53
+ * Returns a copy of the song with the key value set to the specified key. It changes:
54
+ * - the value for `key` in the {@link metadata} set
55
+ * - any existing `key` directive
56
+ * @param {number|null} key the key. Passing `null` will:
57
+ * - remove the current key from {@link metadata}
58
+ * - remove any `key` directive
59
+ * @returns {Song} The changed song
60
+ */
61
+ setKey(key: string | number | null): Song;
62
+ /**
63
+ * Returns a copy of the song with the key value set to the specified capo. It changes:
64
+ * - the value for `capo` in the {@link metadata} set
65
+ * - any existing `capo` directive
66
+ * @param {number|null} capo the capo. Passing `null` will:
67
+ * - remove the current key from {@link metadata}
68
+ * - remove any `capo` directive
69
+ * @returns {Song} The changed song
70
+ */
71
+ setCapo(capo: number | null): Song;
72
+ private updateDirectives;
73
+ private changeOrDeleteDirectives;
74
+ private insertDirectives;
75
+ private findInsertIndex;
76
+ private isInsertionPoint;
77
+ private adjustInsertIndex;
78
+ private createMetadataLines;
79
+ private prepareLinesToInsert;
80
+ private spliceLines;
81
+ /**
82
+ * Transposes the song by the specified delta. It will:
83
+ * - transpose all chords, see: {@link Chord#transpose}
84
+ * - transpose the song key in {@link metadata}
85
+ * - update any existing `key` directive
86
+ * @param {number} delta The number of semitones (positive or negative) to transpose with
87
+ * @param {Object} [options={}] options
88
+ * @param {boolean} [options.normalizeChordSuffix=false] whether to normalize the chord suffixes after transposing
89
+ * @returns {Song} The transposed song
90
+ */
91
+ transpose(delta: number, { accidental, normalizeChordSuffix }?: {
92
+ accidental?: Accidental | null;
93
+ normalizeChordSuffix?: boolean;
94
+ }): Song;
95
+ private static transposeChordLyricsPair;
96
+ private static transposeLiteral;
97
+ /**
98
+ * Transposes the song up by one semitone. It will:
99
+ * - transpose all chords, see: {@link Chord#transpose}
100
+ * - transpose the song key in {@link metadata}
101
+ * - update any existing `key` directive
102
+ * @param {Object} [options={}] options
103
+ * @param {boolean} [options.normalizeChordSuffix=false] whether to normalize the chord suffixes after transposing
104
+ * @returns {Song} The transposed song
105
+ */
106
+ transposeUp({ normalizeChordSuffix }?: {
107
+ normalizeChordSuffix?: boolean;
108
+ }): Song;
109
+ /**
110
+ * Transposes the song down by one semitone. It will:
111
+ * - transpose all chords, see: {@link Chord#transpose}
112
+ * - transpose the song key in {@link metadata}
113
+ * - update any existing `key` directive
114
+ * @param {Object} [options={}] options
115
+ * @param {boolean} [options.normalizeChordSuffix=false] whether to normalize the chord suffixes after transposing
116
+ * @returns {Song} The transposed song
117
+ */
118
+ transposeDown({ normalizeChordSuffix }?: {
119
+ normalizeChordSuffix?: boolean;
120
+ }): Song;
121
+ /**
122
+ * Returns a copy of the song with the key set to the specified key. It changes:
123
+ * - the value for `key` in the {@link metadata} set
124
+ * - any existing `key` directive
125
+ * - all chords, those are transposed according to the distance between the current and the new key
126
+ * @param {string} newKey The new key.
127
+ * @returns {Song} The changed song
128
+ */
129
+ changeKey(newKey: string | Key): Song;
130
+ /**
131
+ * Returns a copy of the song with all chords changed to the specified accidental.
132
+ *
133
+ * Examples:
134
+ *
135
+ * ```js
136
+ * song.useAccidental('#');
137
+ * song.useAccidental('b');
138
+ * ```
139
+ *
140
+ * @param {Accidental} accidental the new accidental
141
+ * @returns {Song} the changed song
142
+ */
143
+ useAccidental(accidental: Accidental): Song;
144
+ /**
145
+ * @deprecated Use useAccidental instead
146
+ */
147
+ useModifier(accidental: Accidental): Song;
148
+ /**
149
+ * Returns a copy of the song with all chords normalized to the specified key. See {@link Chord#normalize}.
150
+ * @param key the key to normalize to
151
+ * @param options options
152
+ * @param options.normalizeSuffix whether to normalize the chord suffixes
153
+ */
154
+ normalizeChords(key?: Key | string | null, { normalizeSuffix }?: {
155
+ normalizeSuffix?: boolean;
156
+ }): Song;
157
+ mapChordLyricsPairs(func: (pair: ChordLyricsPair) => ChordLyricsPair): Song;
158
+ changeChords(func: (chord: Chord) => Chord): Song;
159
+ private static isMusicalSection;
160
+ private static mapChordsInLiteral;
161
+ get currentKey(): Key | null;
162
+ requireCurrentKey(): Key;
163
+ /**
164
+ * Returns a copy of the song with the directive value(s) set to the specified value(s).
165
+ * - when there is a matching directive in the song, it will update the directive
166
+ * - when there is no matching directive, it will be inserted
167
+ * If `value` is `null` it will act as a delete, any directive matching `name` will be removed.
168
+ *
169
+ * @example
170
+ * ```javascript
171
+ * song.changeMetadata('author', 'John');
172
+ * song.changeMetadata('composer', ['Jane', 'John']);
173
+ * song.changeMetadata('key', null); // Remove key directive
174
+ * ```
175
+ * @param name The directive name
176
+ * @param {string | string[] | null} value The value to set, or `null` to remove the directive
177
+ * @return {Song} The changed song
178
+ */
179
+ changeMetadata(name: string, value: string | string[] | null): Song;
180
+ /**
181
+ * Returns a copy of the song with the metadata changed. It will:
182
+ * - update the metadata
183
+ * - update any existing directive matching the metadata key
184
+ * - insert a new directive if it does not exist
185
+ * @example
186
+ * ```javascript
187
+ * song.changeMetadata({
188
+ * author: 'John',
189
+ * composer: ['Jane', 'John'],
190
+ * key: null, // Remove key directive
191
+ * });
192
+ * ```
193
+ * @param {Record<string, string | string[] | null>} metadata The metadata to change
194
+ */
195
+ changeMetadata(metadata: Record<string, string | string[] | null>): Song;
196
+ addLine(line: Line): void;
197
+ /**
198
+ * Change the song contents inline. Return a new {@link Item} to replace it. Return `null` to remove it.
199
+ * @example
200
+ * // transpose all chords:
201
+ * song.mapItems((item) => {
202
+ * if (item instanceof ChordLyricsPair) {
203
+ * return item.transpose(2, 'D');
204
+ * }
205
+ *
206
+ * return item;
207
+ * });
208
+ * @param {MapItemsCallback} func the callback function
209
+ * @returns {Song} the changed song
210
+ */
211
+ mapItems(func: MapItemsCallback): Song;
212
+ foreachItem(func: (_item: Item) => void): void;
213
+ /**
214
+ * Returns all unique chords used in the song
215
+ * @returns {string[]} the chords
216
+ */
217
+ getChords(): string[];
218
+ /**
219
+ * Returns all chord definitions from the song.
220
+ * Definitions are made using the `{chord}` or `{define}` directive.
221
+ * A chord definitions overrides a previous chord definition for the exact same chord.
222
+ * @returns {Record<string, ChordDefinition>} the chord definitions
223
+ * @see https://chordpro.org/chordpro/directives-define/
224
+ * @see https://chordpro.org/chordpro/directives-chord/
225
+ */
226
+ getChordDefinitions(context?: FormattingContext): Record<string, ChordDefinition>;
227
+ /**
228
+ * The song's metadata. When there is only one value for an entry, the value is a string. Else, the value is
229
+ * an array containing all unique values for the entry.
230
+ * @type {Metadata}
231
+ */
232
+ get metadata(): Metadata;
233
+ getMetadata(configuration?: Configuration): Metadata;
234
+ get chordDefinitions(): ChordDefinitionSet;
235
+ /**
236
+ * Change the song contents inline. Return a new {@link Line} to replace it. Return `null` to remove it.
237
+ * @example
238
+ * // remove lines with only Tags:
239
+ * song.mapLines((line) => {
240
+ * if (line.items.every(item => item instanceof Tag)) {
241
+ * return null;
242
+ * }
243
+ *
244
+ * return line;
245
+ * });
246
+ * @param {MapLinesCallback} func the callback function
247
+ * @returns {Song} the changed song
248
+ */
249
+ mapLines(func: (_line: Line) => Line | null): Song;
250
+ private updateItem;
251
+ private removeItem;
252
+ }
253
+ export default Song;