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,2 @@
1
+ declare const enharmonics: Record<string, Record<string, string>>;
2
+ export default enharmonics;
@@ -0,0 +1,2 @@
1
+ declare const mapping: Record<string, string>;
2
+ export default mapping;
@@ -0,0 +1,6 @@
1
+ export declare function stripPangoMarkup(text: string): string;
2
+ export interface PangoRenderer {
3
+ convert(text: string): string;
4
+ }
5
+ export declare function pangoToHtml(text: string): string;
6
+ export declare const defaultPangoRenderer: PangoRenderer;
@@ -0,0 +1,55 @@
1
+ export interface FilePosition {
2
+ offset: number;
3
+ line: number;
4
+ column: number;
5
+ }
6
+ export interface FileRange {
7
+ start: FilePosition;
8
+ end: FilePosition;
9
+ source: string;
10
+ }
11
+ export interface LiteralExpectation {
12
+ type: "literal";
13
+ text: string;
14
+ ignoreCase: boolean;
15
+ }
16
+ export interface ClassParts extends Array<string | ClassParts> {
17
+ }
18
+ export interface ClassExpectation {
19
+ type: "class";
20
+ parts: ClassParts;
21
+ inverted: boolean;
22
+ ignoreCase: boolean;
23
+ }
24
+ export interface AnyExpectation {
25
+ type: "any";
26
+ }
27
+ export interface EndExpectation {
28
+ type: "end";
29
+ }
30
+ export interface OtherExpectation {
31
+ type: "other";
32
+ description: string;
33
+ }
34
+ export type Expectation = LiteralExpectation | ClassExpectation | AnyExpectation | EndExpectation | OtherExpectation;
35
+ export declare class PeggySyntaxError extends Error {
36
+ static buildMessage(expected: Expectation[], found: string | null): string;
37
+ message: string;
38
+ expected: Expectation[];
39
+ found: string | null;
40
+ location: FileRange;
41
+ name: string;
42
+ constructor(message: string, expected: Expectation[], found: string | null, location: FileRange);
43
+ format(sources: {
44
+ grammarSource?: string;
45
+ text: string;
46
+ }[]): string;
47
+ }
48
+ export interface ParseOptions {
49
+ filename?: string;
50
+ startRule?: string;
51
+ tracer?: any;
52
+ [key: string]: any;
53
+ }
54
+ export type ParseFunction = (input: string, options?: ParseOptions) => any;
55
+ export declare const parse: ParseFunction;
@@ -0,0 +1,55 @@
1
+ export interface FilePosition {
2
+ offset: number;
3
+ line: number;
4
+ column: number;
5
+ }
6
+ export interface FileRange {
7
+ start: FilePosition;
8
+ end: FilePosition;
9
+ source: string;
10
+ }
11
+ export interface LiteralExpectation {
12
+ type: "literal";
13
+ text: string;
14
+ ignoreCase: boolean;
15
+ }
16
+ export interface ClassParts extends Array<string | ClassParts> {
17
+ }
18
+ export interface ClassExpectation {
19
+ type: "class";
20
+ parts: ClassParts;
21
+ inverted: boolean;
22
+ ignoreCase: boolean;
23
+ }
24
+ export interface AnyExpectation {
25
+ type: "any";
26
+ }
27
+ export interface EndExpectation {
28
+ type: "end";
29
+ }
30
+ export interface OtherExpectation {
31
+ type: "other";
32
+ description: string;
33
+ }
34
+ export type Expectation = LiteralExpectation | ClassExpectation | AnyExpectation | EndExpectation | OtherExpectation;
35
+ export declare class PeggySyntaxError extends Error {
36
+ static buildMessage(expected: Expectation[], found: string | null): string;
37
+ message: string;
38
+ expected: Expectation[];
39
+ found: string | null;
40
+ location: FileRange;
41
+ name: string;
42
+ constructor(message: string, expected: Expectation[], found: string | null, location: FileRange);
43
+ format(sources: {
44
+ grammarSource?: string;
45
+ text: string;
46
+ }[]): string;
47
+ }
48
+ export interface ParseOptions {
49
+ filename?: string;
50
+ startRule?: string;
51
+ tracer?: any;
52
+ [key: string]: any;
53
+ }
54
+ export type ParseFunction = (input: string, options?: ParseOptions) => any;
55
+ export declare const parse: ParseFunction;
@@ -0,0 +1,15 @@
1
+ import { SerializedChordLyricsPair, SerializedItem, SerializedLine, SerializedSoftLineBreak, SerializedTag } from '../../serialized_types';
2
+ import { FileRange } from './peg_parser';
3
+ export declare function buildLine(items: any[]): SerializedLine;
4
+ export declare function buildSection(startTag: SerializedTag, endTag: SerializedTag, content: string): SerializedLine[];
5
+ export declare function buildTag(name: string, value: Partial<{
6
+ value: string | null;
7
+ attributes: Record<string, string>;
8
+ }> | null, selector: {
9
+ value: string | null;
10
+ isNegated: boolean;
11
+ } | null, location: FileRange): SerializedTag;
12
+ export declare function stringSplitReplace(string: string, search: string, replaceMatch: (subString: string) => any, replaceRest?: (subString: string) => any): any[];
13
+ export declare function applySoftLineBreaks(lyrics: string): SerializedChordLyricsPair[];
14
+ export declare function breakChordLyricsPairOnSoftLineBreak(chords: string, lyrics: string): (SerializedChordLyricsPair | SerializedSoftLineBreak)[];
15
+ export declare function combineChordLyricsPairs(items: SerializedItem[], chopFirstWord?: boolean): SerializedItem[];
@@ -0,0 +1,55 @@
1
+ export interface FilePosition {
2
+ offset: number;
3
+ line: number;
4
+ column: number;
5
+ }
6
+ export interface FileRange {
7
+ start: FilePosition;
8
+ end: FilePosition;
9
+ source: string;
10
+ }
11
+ export interface LiteralExpectation {
12
+ type: "literal";
13
+ text: string;
14
+ ignoreCase: boolean;
15
+ }
16
+ export interface ClassParts extends Array<string | ClassParts> {
17
+ }
18
+ export interface ClassExpectation {
19
+ type: "class";
20
+ parts: ClassParts;
21
+ inverted: boolean;
22
+ ignoreCase: boolean;
23
+ }
24
+ export interface AnyExpectation {
25
+ type: "any";
26
+ }
27
+ export interface EndExpectation {
28
+ type: "end";
29
+ }
30
+ export interface OtherExpectation {
31
+ type: "other";
32
+ description: string;
33
+ }
34
+ export type Expectation = LiteralExpectation | ClassExpectation | AnyExpectation | EndExpectation | OtherExpectation;
35
+ export declare class PeggySyntaxError extends Error {
36
+ static buildMessage(expected: Expectation[], found: string | null): string;
37
+ message: string;
38
+ expected: Expectation[];
39
+ found: string | null;
40
+ location: FileRange;
41
+ name: string;
42
+ constructor(message: string, expected: Expectation[], found: string | null, location: FileRange);
43
+ format(sources: {
44
+ grammarSource?: string;
45
+ text: string;
46
+ }[]): string;
47
+ }
48
+ export interface ParseOptions {
49
+ filename?: string;
50
+ startRule?: string;
51
+ tracer?: any;
52
+ [key: string]: any;
53
+ }
54
+ export type ParseFunction = (input: string, options?: ParseOptions) => any;
55
+ export declare const parse: ParseFunction;
@@ -0,0 +1,32 @@
1
+ import ParserWarning from './parser_warning';
2
+ import Song from '../chord_sheet/song';
3
+ import { ParseOptions } from './chord_pro/peg_parser';
4
+ export type ChordProParserOptions = ParseOptions & {
5
+ softLineBreaks?: boolean;
6
+ chopFirstWord?: boolean;
7
+ };
8
+ /**
9
+ * Parses a ChordPro chord sheet
10
+ */
11
+ declare class ChordProParser {
12
+ song?: Song;
13
+ /**
14
+ * All warnings raised during parsing the chord sheet
15
+ * @member
16
+ * @type {ParserWarning[]}
17
+ */
18
+ get warnings(): ParserWarning[];
19
+ /**
20
+ * Parses a ChordPro chord sheet into a song
21
+ * @param {string} chordSheet the ChordPro chord sheet
22
+ * @param {ChordProParserOptions} options Parser options.
23
+ * @param {ChordProParserOptions.softLineBreaks} options.softLineBreaks=false If true, a backslash
24
+ * followed by * a space is treated as a soft line break
25
+ * @param {ChordProParserOptions.chopFirstWord} options.chopFirstWord=true If true, only the first lyric
26
+ * word is paired with the chord, the rest of the lyric is put in a separate chord lyric pair
27
+ * @see https://peggyjs.org/documentation.html#using-the-parser
28
+ * @returns {Song} The parsed song
29
+ */
30
+ parse(chordSheet: string, options?: ChordProParserOptions): Song;
31
+ }
32
+ export default ChordProParser;
@@ -0,0 +1,57 @@
1
+ import ChordLyricsPair from '../chord_sheet/chord_lyrics_pair';
2
+ import Line from '../chord_sheet/line';
3
+ import Song from '../chord_sheet/song';
4
+ import SongBuilder from '../song_builder';
5
+ /**
6
+ * Parses a normal chord sheet
7
+ *
8
+ * ChordSheetParser is deprecated, please use ChordsOverWordsParser.
9
+ *
10
+ * ChordsOverWordsParser aims to support any kind of chord, whereas ChordSheetParser lacks
11
+ * support for many variations. Besides that, some chordpro feature have been ported back
12
+ * to ChordsOverWordsParser, which adds some interesting functionality.
13
+ */
14
+ declare class ChordSheetParser {
15
+ processingText: boolean;
16
+ preserveWhitespace: boolean;
17
+ song: Song;
18
+ songBuilder: SongBuilder;
19
+ songLine: Line | null;
20
+ chordLyricsPair: ChordLyricsPair | null;
21
+ lines: string[];
22
+ currentLine: number;
23
+ lineCount: number;
24
+ /**
25
+ * Instantiate a chord sheet parser
26
+ * ChordSheetParser is deprecated, please use ChordsOverWordsParser.
27
+ * @param {Object} [options={}] options
28
+ * @param {boolean} [options.preserveWhitespace=true] whether to preserve trailing whitespace for chords
29
+ * @deprecated
30
+ */
31
+ constructor({ preserveWhitespace }?: {
32
+ preserveWhitespace?: boolean;
33
+ }, showDeprecationWarning?: boolean);
34
+ /**
35
+ * Parses a chord sheet into a song
36
+ * @param {string} chordSheet The ChordPro chord sheet
37
+ * @param {Object} [options={}] Optional parser options
38
+ * @param {Song} [options.song=null] The {@link Song} to store the song data in
39
+ * @returns {Song} The parsed song
40
+ */
41
+ parse(chordSheet: string, { song }?: {
42
+ song?: Song;
43
+ }): Song;
44
+ endOfSong(): void;
45
+ parseLine(line: any): void;
46
+ parseNonEmptyLine(line: any): void;
47
+ initialize(document: any, song?: Song | null): void;
48
+ readLine(): string;
49
+ hasNextLine(): boolean;
50
+ parseLyricsWithChords(chordsLine: any, lyricsLine: any): void;
51
+ processCharacters(chordsLine: any, lyricsLine: any): number;
52
+ mapLyricsCharacter(columnMap: number[], column: number, lyricsLine: string, lastIndex: number): number;
53
+ addCharacter(chr: any, nextChar: any): void;
54
+ shouldAddCharacterToChords(nextChar: any): any;
55
+ ensureChordLyricsPairInitialized(): void;
56
+ }
57
+ export default ChordSheetParser;
@@ -0,0 +1,33 @@
1
+ import { SerializedChord, SerializedLine } from '../../serialized_types';
2
+ type CarriageReturn = '\r';
3
+ type LineFeed = '\n';
4
+ type CarriageReturnLineFeed = '\r\n';
5
+ type NewLine = CarriageReturn | LineFeed | CarriageReturnLineFeed;
6
+ type Lyrics = string;
7
+ type Chord = {
8
+ column: number;
9
+ value: string;
10
+ } & SerializedChord;
11
+ interface RhythmSymbol {
12
+ type: 'symbol';
13
+ value: '/' | '|' | '-' | 'x';
14
+ column: number;
15
+ }
16
+ interface NoChord {
17
+ type: 'noChord';
18
+ value: string;
19
+ column: number;
20
+ }
21
+ type DirectionLine = SerializedLine;
22
+ type InlineMetadata = SerializedLine;
23
+ interface ChordsLine {
24
+ type: 'chordsLine';
25
+ items: (Chord | RhythmSymbol | NoChord)[];
26
+ }
27
+ interface LyricsLine {
28
+ type: 'lyricsLine';
29
+ content: Lyrics;
30
+ }
31
+ type ChordSheetLine = DirectionLine | InlineMetadata | ChordsLine | LyricsLine;
32
+ export declare function composeChordSheetContents(newLine: NewLine | null, lines: ChordSheetLine[], trailingLine: ChordSheetLine | null, chopFirstWord: boolean): SerializedLine[];
33
+ export {};
@@ -0,0 +1,55 @@
1
+ export interface FilePosition {
2
+ offset: number;
3
+ line: number;
4
+ column: number;
5
+ }
6
+ export interface FileRange {
7
+ start: FilePosition;
8
+ end: FilePosition;
9
+ source: string;
10
+ }
11
+ export interface LiteralExpectation {
12
+ type: "literal";
13
+ text: string;
14
+ ignoreCase: boolean;
15
+ }
16
+ export interface ClassParts extends Array<string | ClassParts> {
17
+ }
18
+ export interface ClassExpectation {
19
+ type: "class";
20
+ parts: ClassParts;
21
+ inverted: boolean;
22
+ ignoreCase: boolean;
23
+ }
24
+ export interface AnyExpectation {
25
+ type: "any";
26
+ }
27
+ export interface EndExpectation {
28
+ type: "end";
29
+ }
30
+ export interface OtherExpectation {
31
+ type: "other";
32
+ description: string;
33
+ }
34
+ export type Expectation = LiteralExpectation | ClassExpectation | AnyExpectation | EndExpectation | OtherExpectation;
35
+ export declare class PeggySyntaxError extends Error {
36
+ static buildMessage(expected: Expectation[], found: string | null): string;
37
+ message: string;
38
+ expected: Expectation[];
39
+ found: string | null;
40
+ location: FileRange;
41
+ name: string;
42
+ constructor(message: string, expected: Expectation[], found: string | null, location: FileRange);
43
+ format(sources: {
44
+ grammarSource?: string;
45
+ text: string;
46
+ }[]): string;
47
+ }
48
+ export interface ParseOptions {
49
+ filename?: string;
50
+ startRule?: string;
51
+ tracer?: any;
52
+ [key: string]: any;
53
+ }
54
+ export type ParseFunction = (input: string, options?: ParseOptions) => any;
55
+ export declare const parse: ParseFunction;
@@ -0,0 +1,67 @@
1
+ import ParserWarning from './parser_warning';
2
+ import Song from '../chord_sheet/song';
3
+ import { ParseOptions } from './chords_over_words/peg_parser';
4
+ export type ChordsOverWordsParserOptions = ParseOptions & {
5
+ softLineBreaks?: boolean;
6
+ chopFirstWord?: boolean;
7
+ };
8
+ /**
9
+ * Parses a chords over words sheet into a song
10
+ *
11
+ * It support "regular" chord sheets:
12
+ *
13
+ * Am C/G F C
14
+ * Let it be, let it be, let it be, let it be
15
+ * C G F C/E Dm C
16
+ * Whisper words of wisdom, let it be
17
+ *
18
+ * Additionally, some chordpro features have been "ported back". For example, you can use chordpro directives:
19
+ *
20
+ * {title: Let it be}
21
+ * {key: C}
22
+ * Chorus 1:
23
+ * Am
24
+ * Let it be
25
+ *
26
+ * For convenience, you can leave out the brackets:
27
+ *
28
+ * title: Let it be
29
+ * Chorus 1:
30
+ * Am
31
+ * Let it be
32
+ *
33
+ * You can even use a markdown style frontmatter separator to separate the header from the song:
34
+ *
35
+ * title: Let it be
36
+ * key: C
37
+ * ---
38
+ * Chorus 1:
39
+ * Am C/G F C
40
+ * Let it be, let it be, let it be, let it be
41
+ * C G F C/E Dm C
42
+ * Whisper words of wisdom, let it be
43
+ *
44
+ * `ChordsOverWordsParser` is the better version of `ChordSheetParser`, which is deprecated.
45
+ */
46
+ declare class ChordsOverWordsParser {
47
+ song?: Song;
48
+ /**
49
+ * All warnings raised during parsing the chord sheet
50
+ * @member
51
+ * @type {ParserWarning[]}
52
+ */
53
+ get warnings(): ParserWarning[];
54
+ /**
55
+ * Parses a chords over words sheet into a song
56
+ * @param {string} chordSheet the chords over words sheet
57
+ * @param {ChordsOverWordsParserOptions} options Parser options.
58
+ * @param {ChordsOverWordsParserOptions.softLineBreaks} options.softLineBreaks=false If true, a backslash
59
+ * followed by a space is treated as a soft line break
60
+ * @param {ChordsOverWordsParserOptions.chopFirstWord} options.chopFirstWord=true If true, only the first lyric
61
+ * word is paired with the chord, the rest of the lyric is put in a separate chord lyric pair
62
+ * @see https://peggyjs.org/documentation.html#using-the-parser
63
+ * @returns {Song} The parsed song
64
+ */
65
+ parse(chordSheet: string, options?: ChordsOverWordsParserOptions): Song;
66
+ }
67
+ export default ChordsOverWordsParser;
@@ -0,0 +1,4 @@
1
+ declare class NullTracer {
2
+ trace(): void;
3
+ }
4
+ export default NullTracer;
@@ -0,0 +1,3 @@
1
+ export declare function isWideCharacter(ch: string): boolean;
2
+ export declare function buildVisualColumnMap(lyricsLine: string): number[];
3
+ export declare function chopFirstWord(string: string): (string | null)[];
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Represents a parser warning, currently only used by ChordProParser.
3
+ */
4
+ declare class ParserWarning {
5
+ /**
6
+ * The warning message
7
+ * @member
8
+ * @type {string}
9
+ */
10
+ message: string;
11
+ /**
12
+ * The chord sheet line number on which the warning occurred
13
+ * @member
14
+ * @type {number}
15
+ */
16
+ lineNumber: number | null;
17
+ /**
18
+ * The chord sheet column on which the warning occurred
19
+ * @member
20
+ * @type {number}
21
+ */
22
+ column: number | null;
23
+ /**
24
+ * @hideconstructor
25
+ */
26
+ constructor(message: string, lineNumber: number | null, column: number | null);
27
+ /**
28
+ * Returns a stringified version of the warning
29
+ * @returns {string} The string warning
30
+ */
31
+ toString(): string;
32
+ }
33
+ export default ParserWarning;
@@ -0,0 +1,46 @@
1
+ import ChordSheetParser from './chord_sheet_parser';
2
+ /**
3
+ * Parses an Ultimate Guitar chord sheet with metadata
4
+ * Inherits from {@link ChordSheetParser}
5
+ */
6
+ declare class UltimateGuitarParser extends ChordSheetParser {
7
+ currentSectionType: string | null;
8
+ pendingRepeatNotation: string | null;
9
+ /**
10
+ * Instantiate a chord sheet parser
11
+ * @param {Object} [options={}] options
12
+ * @param {boolean} [options.preserveWhitespace=true] whether to preserve trailing whitespace for chords
13
+ */
14
+ constructor({ preserveWhitespace }?: {
15
+ preserveWhitespace?: boolean;
16
+ });
17
+ parseLine(line: string): void;
18
+ private parseRegularLine;
19
+ parseNonEmptyLine(line: string): void;
20
+ private parseChordLineWithNextLine;
21
+ private unreadLine;
22
+ private isNonLyricsLine;
23
+ private parseChordsOnly;
24
+ parseLyricsWithChords(chordsLine: string, lyricsLine: string): void;
25
+ processCharacters(chordsLine: string, lyricsLine: string): number;
26
+ addCharacter(chr: string, nextChar: string): void;
27
+ shouldAddCharacterToChords(nextChar: string): boolean;
28
+ ensureChordLyricsPairInitialized(): void;
29
+ private extractRepeatNotation;
30
+ private applyRepeatNotation;
31
+ parseUGMetadata(line: string): boolean;
32
+ private extractCapoValue;
33
+ parseVerseDirective(line: string): boolean;
34
+ parseChorusDirective(line: string): boolean;
35
+ parseBridgeDirective(line: string): boolean;
36
+ parsePartDirective(line: string): boolean;
37
+ parseMetadata(line: string): boolean;
38
+ isSectionEnd(): boolean;
39
+ endOfSong(): void;
40
+ startSection(sectionType: string, label: string): void;
41
+ endSection({ addNewLine }?: {
42
+ addNewLine?: boolean | undefined;
43
+ }): void;
44
+ startNewLine(): void;
45
+ }
46
+ export default UltimateGuitarParser;
@@ -0,0 +1,2 @@
1
+ export { default as PdfFormatter } from './formatter/pdf_formatter';
2
+ export { JsPdfMeasurer } from './layout/measurement';
@@ -0,0 +1,82 @@
1
+ import { DomMeasurer } from '../../layout/measurement';
2
+ import { FontConfiguration } from '../../formatter/configuration';
3
+ declare type HTMLElement = any;
4
+ /**
5
+ * HtmlWrapper is responsible for managing the DOM elements for the chord sheet
6
+ */
7
+ declare class HtmlDocWrapper {
8
+ container: HTMLElement;
9
+ pages: HTMLElement[];
10
+ currentPage: number;
11
+ totalPages: number;
12
+ pageSize: {
13
+ width: number;
14
+ height: number;
15
+ };
16
+ measurer: DomMeasurer;
17
+ constructor(container: HTMLElement, pageSize: {
18
+ width: number;
19
+ height: number;
20
+ });
21
+ /**
22
+ * Creates a new page in the container
23
+ */
24
+ createPage(): HTMLElement;
25
+ get pageStyles(): Record<string, string>;
26
+ /**
27
+ * Creates a new page and advances to it
28
+ */
29
+ newPage(): void;
30
+ /**
31
+ * Sets the current page
32
+ */
33
+ setPage(pageNumber: number): void;
34
+ /**
35
+ * Gets the current page element
36
+ */
37
+ getCurrentPage(): HTMLElement;
38
+ /**
39
+ * Adds an element to the current page at the specified position
40
+ */
41
+ addElement(element: HTMLElement, x: number, y: number): void;
42
+ /**
43
+ * Gets text dimensions using the DOM measurer
44
+ */
45
+ getTextDimensions(text: string, font: FontConfiguration): {
46
+ w: number;
47
+ h: number;
48
+ };
49
+ /**
50
+ * Gets text width using the DOM measurer
51
+ */
52
+ getTextWidth(text: string, font: FontConfiguration): number;
53
+ /**
54
+ * Splits text to fit within a maximum width
55
+ */
56
+ splitTextToSize(text: string, maxWidth: number, font: FontConfiguration): string[];
57
+ /**
58
+ * Sets the font style (no-op in HTML renderer)
59
+ */
60
+ setFontStyle(_font: FontConfiguration): void;
61
+ /**
62
+ * Sets line style for drawing (no-op in HTML renderer)
63
+ */
64
+ setLineStyle(_style: any): void;
65
+ /**
66
+ * Resets line dash style (no-op in HTML renderer)
67
+ */
68
+ resetDash(): void;
69
+ /**
70
+ * Executes a callback for each page
71
+ */
72
+ eachPage(callback: (page: HTMLElement, index: number) => void): void;
73
+ /**
74
+ * Gets the container element
75
+ */
76
+ getContainer(): HTMLElement;
77
+ /**
78
+ * Clean up resources
79
+ */
80
+ dispose(): void;
81
+ }
82
+ export default HtmlDocWrapper;
@@ -0,0 +1,58 @@
1
+ import { FontConfiguration } from '../../formatter/configuration';
2
+ import { PositionedElement } from '../renderer';
3
+ declare type HTMLElement = any;
4
+ declare type CSSStyleDeclaration = any;
5
+ /**
6
+ * Configuration for HTML element styling
7
+ */
8
+ export interface HtmlStylerConfig {
9
+ cssClassPrefix?: string;
10
+ cssClasses?: Record<string, string>;
11
+ }
12
+ /**
13
+ * Handles styling of HTML elements for the positioned HTML renderer.
14
+ * Extracted to improve modularity and reduce file size.
15
+ */
16
+ export declare class HtmlElementStyler {
17
+ private config;
18
+ constructor(config: HtmlStylerConfig);
19
+ /**
20
+ * Gets the CSS class prefix
21
+ */
22
+ get prefix(): string;
23
+ /**
24
+ * Applies styles to an HTML element based on its positioned element data
25
+ */
26
+ applyElementStyle(htmlElement: HTMLElement, element: PositionedElement): void;
27
+ /**
28
+ * Gets conditional CSS styles from font configuration
29
+ */
30
+ getConditionalStyles(style: FontConfiguration): Partial<CSSStyleDeclaration>;
31
+ /**
32
+ * Gets type-specific styles for different element types
33
+ */
34
+ getTypeSpecificStyles(element: PositionedElement): Partial<CSSStyleDeclaration>;
35
+ /**
36
+ * Gets chord-specific styles
37
+ */
38
+ chordStyles(element: PositionedElement): Partial<CSSStyleDeclaration>;
39
+ /**
40
+ * Applies font styles to an HTML element
41
+ */
42
+ applyFontStyle(element: HTMLElement, style: FontConfiguration): void;
43
+ /**
44
+ * Applies ellipsis styling to an element
45
+ */
46
+ applyEllipsisStyle(element: HTMLElement, width: number): void;
47
+ /**
48
+ * Creates a class name string with the configured prefix
49
+ */
50
+ createClassName(...classes: (string | undefined)[]): string;
51
+ /**
52
+ * Gets the custom CSS class for an element type if configured
53
+ */
54
+ getCustomClass(elementType: string): string | undefined;
55
+ private getNormalizedFontStyles;
56
+ private normalizeColor;
57
+ }
58
+ export default HtmlElementStyler;