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,124 @@
1
+ import { Accidental, AccidentalMaybe, ChordType } from './constants';
2
+ interface KeyProperties {
3
+ grade?: number | null;
4
+ number?: number | null;
5
+ type?: ChordType;
6
+ minor?: boolean;
7
+ accidental?: Accidental | null;
8
+ referenceKeyGrade?: number | null;
9
+ referenceKeyMode?: string | null;
10
+ preferredAccidental?: Accidental | null;
11
+ explicitAccidental?: boolean;
12
+ }
13
+ interface ConstructorOptions {
14
+ grade?: number | null;
15
+ number?: number | null;
16
+ minor: boolean;
17
+ type: ChordType;
18
+ accidental: Accidental | null;
19
+ referenceKeyGrade?: number | null;
20
+ referenceKeyMode?: string | null;
21
+ originalKeyString?: string | null;
22
+ preferredAccidental: Accidental | null;
23
+ explicitAccidental?: boolean;
24
+ }
25
+ /**
26
+ * Represents a key, such as Eb (symbol), #3 (numeric) or VII (numeral).
27
+ *
28
+ * The only function considered public API is `Key.distance`
29
+ */
30
+ declare class Key implements KeyProperties {
31
+ grade: number | null;
32
+ number: number | null;
33
+ accidental: Accidental | null;
34
+ type: ChordType;
35
+ get unicodeAccidental(): string | null;
36
+ /** @deprecated Use unicodeAccidental instead */
37
+ get unicodeModifier(): string | null;
38
+ /** @deprecated Use accidental instead */
39
+ get modifier(): Accidental | null;
40
+ /** @deprecated Use preferredAccidental instead */
41
+ get preferredModifier(): Accidental | null;
42
+ minor: boolean;
43
+ referenceKeyGrade: number | null;
44
+ referenceKeyMode: string | null;
45
+ originalKeyString: string | null;
46
+ preferredAccidental: Accidental | null;
47
+ explicitAccidental: boolean;
48
+ static parse(keyString: string | null): null | Key;
49
+ static parseAsType(trimmed: string, keyType: ChordType): Key | null;
50
+ static resolve({ key, keyType, minor, accidental, }: {
51
+ key: string | number;
52
+ keyType: ChordType;
53
+ minor: string | boolean;
54
+ accidental: Accidental | null;
55
+ }): Key | null;
56
+ static getNumberFromKey(keyString: string, keyType: ChordType): number;
57
+ static keyWithAccidental(key: string, accidental: Accidental | null, type: ChordType): string;
58
+ /** @deprecated Use keyWithAccidental instead */
59
+ static keyWithModifier(key: string, accidental: Accidental | null, type: ChordType): string;
60
+ static toGrade(key: string, accidental: AccidentalMaybe, type: ChordType, isMinor: boolean): number | null;
61
+ static isMinor(key: string, keyType: ChordType, minor: string | undefined | boolean): boolean;
62
+ static parseOrFail(keyString: string | null): Key;
63
+ static wrap(keyStringOrObject: Key | string | null): Key | null;
64
+ static wrapOrFail(keyStringOrObject?: Key | string | null): Key;
65
+ static toString(keyStringOrObject: Key | string): string;
66
+ /**
67
+ * Calculates the distance in semitones between one key and another.
68
+ * @param {Key | string} oneKey the key
69
+ * @param {Key | string} otherKey the other key
70
+ * @return {number} the distance in semitones
71
+ */
72
+ static distance(oneKey: Key | string, otherKey: Key | string): number;
73
+ constructor({ grade, number, minor, type, accidental, referenceKeyGrade, referenceKeyMode, originalKeyString, preferredAccidental, explicitAccidental, }: ConstructorOptions);
74
+ distanceTo(otherKey: Key | string): number;
75
+ get effectiveGrade(): number;
76
+ isMinor(): boolean;
77
+ makeMinor(): Key;
78
+ get relativeMajor(): Key;
79
+ get relativeMinor(): Key;
80
+ toMajor(): Key;
81
+ clone(): Key;
82
+ private ensureGrade;
83
+ private calculateGradeFromNumber;
84
+ toChordSymbol(key: Key | string | null, referenceKeyWasMinor?: boolean): Key;
85
+ toChordSolfege(key: Key | string | null, referenceKeyWasMinor?: boolean): Key;
86
+ private convertToChordType;
87
+ private handleMinorKeyConversion;
88
+ toChordSymbolString(key: Key): string;
89
+ toChordSolfegeString(key: Key): string;
90
+ is(type: ChordType): boolean;
91
+ isNumeric(): boolean;
92
+ isChordSymbol(): boolean;
93
+ isChordSolfege(): boolean;
94
+ isNumeral(): boolean;
95
+ equals(otherKey: Key): boolean;
96
+ static equals(oneKey: Key | null, otherKey: Key | null): boolean;
97
+ toNumeric(key?: Key | string | null): Key;
98
+ toNumericString(key?: Key | null): string;
99
+ toNumeral(key?: Key | string | null): Key;
100
+ toNumeralString(key?: Key | null): string;
101
+ toString({ showMinor, useUnicodeModifier }?: {
102
+ showMinor?: boolean | undefined;
103
+ useUnicodeModifier?: boolean | undefined;
104
+ }): string;
105
+ get note(): string;
106
+ private getNoteForNumber;
107
+ get minorSign(): "" | "m";
108
+ private isNaturalMinor;
109
+ transpose(delta: number): Key;
110
+ changeGrade(delta: any): Key;
111
+ transposeUp(): Key;
112
+ transposeDown(): Key;
113
+ canBeFlat(): boolean;
114
+ canBeSharp(): boolean;
115
+ setGrade(newGrade: number): Key;
116
+ static shiftGrade(grade: number): number;
117
+ useAccidental(newAccidental: Accidental | null): Key;
118
+ /** @deprecated Use useAccidental instead */
119
+ useModifier(newAccidental: Accidental | null): Key;
120
+ normalize(): Key;
121
+ normalizeEnharmonics(key: Key | string | null): Key;
122
+ private set;
123
+ }
124
+ export default Key;
@@ -0,0 +1,3 @@
1
+ export declare const majorKeys: Record<'symbol' | 'solfege', string[]>;
2
+ export declare const minorKeys: Record<'symbol' | 'solfege', string[]>;
3
+ export declare const capos: Record<'symbol' | 'solfege', Record<string, Record<string, string>>>;
@@ -0,0 +1,25 @@
1
+ import { ConditionalRule } from '../../formatter/configuration';
2
+ declare class Condition {
3
+ rule: ConditionalRule;
4
+ metadata: Record<string, any>;
5
+ constructor(rule: ConditionalRule, metadata: Record<string, any>);
6
+ evaluate(): boolean;
7
+ private evaluateSingleCondition;
8
+ private all;
9
+ private and;
10
+ private contains;
11
+ private equals;
12
+ private exists;
13
+ private firstPage;
14
+ private greaterThan;
15
+ private greaterThanEqual;
16
+ private in;
17
+ private lastPage;
18
+ private lessThan;
19
+ private lessThanEqual;
20
+ private like;
21
+ private notEquals;
22
+ private notIn;
23
+ private or;
24
+ }
25
+ export default Condition;
@@ -0,0 +1,33 @@
1
+ import { ColumnConfig, Margins, MeasurementBasedLayoutConfig } from '../../formatter/configuration';
2
+ declare class Dimensions {
3
+ pageWidth: number;
4
+ pageHeight: number;
5
+ layoutConfig: MeasurementBasedLayoutConfig;
6
+ columns: ColumnConfig;
7
+ constructor(pageWidth: number, pageHeight: number, layoutConfig: MeasurementBasedLayoutConfig, columns: ColumnConfig);
8
+ get margins(): Margins;
9
+ get minX(): number;
10
+ get maxX(): number;
11
+ get minY(): number;
12
+ get maxY(): number;
13
+ /**
14
+ * Calculates the optimal number of columns based on available width and column constraints
15
+ */
16
+ calculateOptimalColumnCount(availableWidth: number, columnSpacing: number, minColumnWidth?: number, maxColumnWidth?: number): number;
17
+ private findMaxColumnsWithinBounds;
18
+ private evaluateColumnCount;
19
+ private fitMaxColumnsWithMinWidth;
20
+ private fitMaxColumns;
21
+ /**
22
+ * Calculates the effective column spacing, adjusting it when columns would exceed maxColumnWidth
23
+ * Note: Single columns are not constrained by maxColumnWidth and use full available width
24
+ * When only minColumnWidth is specified, columns expand to fill available space equally
25
+ */
26
+ calculateEffectiveColumnSpacing(columnCount: number, availableWidth: number, baseColumnSpacing: number, maxColumnWidth?: number, minColumnWidth?: number): number;
27
+ private calculateAdjustedSpacing;
28
+ get effectiveColumnCount(): number;
29
+ get effectiveColumnSpacing(): number;
30
+ get availableSpace(): number;
31
+ get columnWidth(): number;
32
+ }
33
+ export default Dimensions;
@@ -0,0 +1,7 @@
1
+ export { LayoutEngine } from './layout_engine';
2
+ export { ItemProcessor } from './item_processor';
3
+ export { LayoutFactory } from './layout_factory';
4
+ export { LineBreaker } from './line_breaker';
5
+ export * from './layout_helpers';
6
+ export { BreakPoint, MeasuredItem, LineLayout, LayoutConfig, ParagraphLayoutResult, } from './types';
7
+ export { ParagraphSplitter } from './paragraph_splitter';
@@ -0,0 +1,70 @@
1
+ import ChordLyricsPair from '../../chord_sheet/chord_lyrics_pair';
2
+ import Line from '../../chord_sheet/line';
3
+ import { Measurer } from '../measurement';
4
+ import SoftLineBreak from '../../chord_sheet/soft_line_break';
5
+ import Song from '../../chord_sheet/song';
6
+ import Tag from '../../chord_sheet/tag';
7
+ import { LayoutConfig, MeasuredItem } from './types';
8
+ /**
9
+ * Processes and measures different types of items in a chord sheet
10
+ */
11
+ export declare class ItemProcessor {
12
+ readonly measurer: Measurer;
13
+ readonly config: LayoutConfig;
14
+ private readonly song;
15
+ constructor(measurer: Measurer, config: LayoutConfig, song: Song);
16
+ /**
17
+ * Measure all items in a line
18
+ */
19
+ measureLineItems(line: Line, lyricsOnly?: boolean): MeasuredItem[];
20
+ /**
21
+ * Process a chord-lyrics pair
22
+ */
23
+ processChordLyricsPair(pair: ChordLyricsPair, nextItemParam: any, line: Line, lyricsOnly?: boolean): MeasuredItem[];
24
+ private handleLyricsOnlyMode;
25
+ private cleanNextItemHyphens;
26
+ private processSplitItems;
27
+ private processSingleSplitItem;
28
+ private measureChordLyricsPair;
29
+ private getAdjustedChordsAndLyrics;
30
+ private renderChordText;
31
+ private calculateMeasurements;
32
+ private getAdjustedChordWidth;
33
+ /**
34
+ * Process a soft line break
35
+ */
36
+ processSoftLineBreak(softLineBreak: SoftLineBreak): MeasuredItem;
37
+ /**
38
+ * Process a tag (comment or section delimiter)
39
+ */
40
+ processTag(tag: Tag): MeasuredItem[];
41
+ private createMeasuredTagItem;
42
+ /**
43
+ * Split a measured item if it doesn't fit in the available width
44
+ */
45
+ splitMeasuredItem(item: MeasuredItem, availableWidth: number): [MeasuredItem, MeasuredItem | null];
46
+ /**
47
+ * Removes hyphens from lyrics for lyrics-only mode
48
+ */
49
+ removeHyphens(lyrics: string): string;
50
+ /**
51
+ * Split a chord-lyrics pair at natural break points (commas)
52
+ */
53
+ splitChordLyricsPair(pair: ChordLyricsPair, lyricsOnly?: boolean): (ChordLyricsPair | SoftLineBreak)[];
54
+ /**
55
+ * Find the next item with lyrics
56
+ */
57
+ findNextItemWithLyrics(currentLine: MeasuredItem[], items: MeasuredItem[], index: number): MeasuredItem | null;
58
+ /**
59
+ * Capitalize the first word of lyrics
60
+ */
61
+ capitalizeFirstWord(lyrics: string): string;
62
+ /**
63
+ * Get the width of a space character
64
+ */
65
+ private getSpaceWidth;
66
+ /**
67
+ * Get chord spacing as a string of spaces
68
+ */
69
+ private getChordSpacingAsSpaces;
70
+ }
@@ -0,0 +1,67 @@
1
+ import { Measurer } from '../measurement';
2
+ import Song from '../../chord_sheet/song';
3
+ import { LayoutConfig, ParagraphLayoutResult } from './types';
4
+ /**
5
+ * Engine for layout calculations
6
+ */
7
+ export declare class LayoutEngine {
8
+ private song;
9
+ private measurer;
10
+ private config;
11
+ private paragraphSplitter;
12
+ private itemProcessor;
13
+ private layoutFactory;
14
+ private lineBreaker;
15
+ private sectionCache;
16
+ constructor(song: Song, measurer: Measurer, config: LayoutConfig);
17
+ /**
18
+ * Normalize section label by removing repeat indicators like "(2x)", "(3x)", etc.
19
+ * @param label The section label to normalize
20
+ * @returns The normalized label
21
+ */
22
+ private normalizeSectionLabel;
23
+ /**
24
+ * Get the cache key for a section based on its normalized label
25
+ * @param paragraph The paragraph to get the cache key for
26
+ * @returns The cache key or null if the paragraph doesn't have a label
27
+ */
28
+ private getSectionCacheKey;
29
+ private extractLabelFromFirstItem;
30
+ /**
31
+ * Process repeated sections by modifying the song's bodyParagraphs array
32
+ * This is called in the constructor to preprocess the song before layout computation
33
+ */
34
+ private processRepeatedSections;
35
+ private processParagraph;
36
+ private shouldSkipParagraphIndex;
37
+ private addUncachedParagraph;
38
+ private handleParagraphWithCacheKey;
39
+ private cacheFirstOccurrence;
40
+ private handleRepeatedSection;
41
+ private handleTitleOnlyMode;
42
+ private collectTitleParagraphs;
43
+ private shouldIncludeTitle;
44
+ private resolveTitleOnlyParagraph;
45
+ private handleFullMode;
46
+ private buildFullModeLines;
47
+ private consolidateTitles;
48
+ private addTitleSeparator;
49
+ private buildTitleSeparatorItems;
50
+ private createTitleOnlyParagraph;
51
+ private cloneParagraph;
52
+ private cloneItem;
53
+ /**
54
+ * Compute layouts for all paragraphs in the song
55
+ */
56
+ computeParagraphLayouts(): ParagraphLayoutResult[];
57
+ private processParagraphLayout;
58
+ private computeLineTypeCounts;
59
+ private shouldSkipParagraphLayout;
60
+ private adjustParagraphLayouts;
61
+ private calculateNextSimulationState;
62
+ private addParagraphLayout;
63
+ /**
64
+ * Compute layout for a single paragraph
65
+ */
66
+ private computeParagraphLayout;
67
+ }
@@ -0,0 +1,22 @@
1
+ import Line from '../../chord_sheet/line';
2
+ import { LayoutConfig, LineLayout, MeasuredItem } from './types';
3
+ /**
4
+ * Factory for creating different types of layouts
5
+ */
6
+ export declare class LayoutFactory {
7
+ private readonly config;
8
+ constructor(config: LayoutConfig);
9
+ /**
10
+ * Create a line layout from measured items
11
+ */
12
+ createLineLayout(items: MeasuredItem[], line: Line): LineLayout;
13
+ private analyzeLineContent;
14
+ private determineLineType;
15
+ private calculateLineHeight;
16
+ private getBaseHeightAndFont;
17
+ private addFontHeight;
18
+ /**
19
+ * Create a column break line layout
20
+ */
21
+ createColumnBreakLayout(): LineLayout;
22
+ }
@@ -0,0 +1,35 @@
1
+ import { LayoutConfig, LineLayout } from './types';
2
+ /**
3
+ * Create a column break line layout
4
+ */
5
+ export declare function createColumnBreakLineLayout(): LineLayout;
6
+ /**
7
+ * Calculate the total height of a set of line layouts
8
+ */
9
+ export declare function calculateTotalHeight(lineLayouts: LineLayout[][]): number;
10
+ /**
11
+ * Check if a line layout represents a column break
12
+ */
13
+ export declare function isColumnBreakLayout(lineLayout: LineLayout[]): boolean;
14
+ /**
15
+ * Update the position based on layout content
16
+ */
17
+ export declare function updatePosition(layout: LineLayout[], currentY: number, currentColumn: number, config: LayoutConfig): {
18
+ newY: number;
19
+ newColumn: number;
20
+ };
21
+ /**
22
+ * Count different types of lines within layouts
23
+ */
24
+ export declare function countLineTypes(lineLayouts: LineLayout[][]): {
25
+ chordLyricPairLines: number;
26
+ commentLines: number;
27
+ sectionLabelLines: number;
28
+ tagLines: number;
29
+ emptyLines: number;
30
+ nonLyricLines: number;
31
+ };
32
+ /**
33
+ * Determine if a paragraph should be skipped in lyrics-only mode
34
+ */
35
+ export declare function shouldSkipParagraph(lineLayouts: LineLayout[][], lyricsOnly?: boolean): boolean;
@@ -0,0 +1,54 @@
1
+ import { ItemProcessor } from './item_processor';
2
+ import { LayoutFactory } from './layout_factory';
3
+ import Line from '../../chord_sheet/line';
4
+ import { LineLayout } from './types';
5
+ /**
6
+ * Handles breaking lines into layouts based on available width
7
+ */
8
+ export declare class LineBreaker {
9
+ private readonly itemProcessor;
10
+ private readonly layoutFactory;
11
+ constructor(itemProcessor: ItemProcessor, layoutFactory: LayoutFactory);
12
+ /**
13
+ * Break a line into layouts that fit within the available width
14
+ */
15
+ breakLineIntoLayouts(line: Line, availableWidth: number, lyricsOnly?: boolean): LineLayout[];
16
+ /**
17
+ * Recursively break content into layouts that fit within the available width
18
+ */
19
+ private breakContent;
20
+ /**
21
+ * Handle content with no soft breaks
22
+ */
23
+ private handleNoSoftBreaks;
24
+ /**
25
+ * Consolidate consecutive soft line breaks into single breaks
26
+ */
27
+ private consolidateConsecutiveSoftBreaks;
28
+ private skipConsecutiveSoftBreaks;
29
+ private findBreakIndex;
30
+ private handleOversizedFirstItem;
31
+ private analyzeContent;
32
+ private shouldReturnSingleLayout;
33
+ private splitAtBestSoftBreak;
34
+ private removeTrailingComma;
35
+ /**
36
+ * Calculate the total width of items up to (but not including) the given index
37
+ */
38
+ private getWidthUpToIndex;
39
+ /**
40
+ * Remeasure the width of lyrics after modification
41
+ */
42
+ private remeasureLyrics;
43
+ /**
44
+ * Recalculate the full chord-lyric pair width (similar to ItemProcessor logic)
45
+ */
46
+ private recalculateChordLyricWidth;
47
+ private measureChordAndLyricWidths;
48
+ private adjustChordWidth;
49
+ private shouldSkipChordSpacing;
50
+ /**
51
+ * Capitalize the first letter of the next item with lyrics
52
+ */
53
+ private capitalizeNextItem;
54
+ }
@@ -0,0 +1,5 @@
1
+ export { ParagraphSplitter } from './paragraph_splitter';
2
+ export { ParagraphSplitStrategy } from '../types';
3
+ export { ThreeOrLessLinesParagraphSplitStrategy } from './strategies/three_or_less_lines_paragraph_split_strategy';
4
+ export { FourLinesParagraphSplitStrategy } from './strategies/four_lines_paragraph_split_strategy';
5
+ export { FiveOrMoreLinesParagraphSplitStrategy } from './strategies/five_or_more_lines_paragraph_split_strategy';
@@ -0,0 +1,5 @@
1
+ import { LineLayout } from '../types';
2
+ export declare class ParagraphSplitter {
3
+ splitParagraph(lineLayouts: LineLayout[][], currentY: number, columnStartY: number, columnBottomY: number, chordLyricLineCount: number): LineLayout[][];
4
+ private createStrategy;
5
+ }
@@ -0,0 +1,14 @@
1
+ import { LineLayout, ParagraphSplitStrategy } from '../../types';
2
+ export declare class FiveOrMoreLinesParagraphSplitStrategy implements ParagraphSplitStrategy {
3
+ private chordLyricLineCount;
4
+ private totalChordLyricPairLines;
5
+ constructor(chordLyricLineCount: number);
6
+ splitParagraph(lineLayouts: LineLayout[][], currentY: number, columnStartY: number, columnBottomY: number): LineLayout[][];
7
+ private trySplitParagraph;
8
+ private selectSplit;
9
+ private buildSplitResult;
10
+ private flattenLineLayouts;
11
+ private findAcceptableSplits;
12
+ private partitionLineLayouts;
13
+ private partitionReducer;
14
+ }
@@ -0,0 +1,8 @@
1
+ import { LineLayout, ParagraphSplitStrategy } from '../../types';
2
+ export declare class FourLinesParagraphSplitStrategy implements ParagraphSplitStrategy {
3
+ splitParagraph(lineLayouts: LineLayout[][], currentY: number, columnStartY: number, columnBottomY: number): LineLayout[][];
4
+ private findSplitMetadata;
5
+ private summarizeLineLayout;
6
+ private buildSplitResult;
7
+ private prependColumnBreakIfNeeded;
8
+ }
@@ -0,0 +1,4 @@
1
+ import { LineLayout, ParagraphSplitStrategy } from '../../types';
2
+ export declare class ThreeOrLessLinesParagraphSplitStrategy implements ParagraphSplitStrategy {
3
+ splitParagraph(lineLayouts: LineLayout[][], currentY: number, columnStartY: number, columnBottomY: number): LineLayout[][];
4
+ }
@@ -0,0 +1,8 @@
1
+ import Tag from '../../chord_sheet/tag';
2
+ declare class TitleSeparatorTag extends Tag {
3
+ constructor();
4
+ get value(): string;
5
+ set value(newValue: string);
6
+ clone(): Tag;
7
+ }
8
+ export default TitleSeparatorTag;
@@ -0,0 +1,98 @@
1
+ import ChordLyricsPair from '../../chord_sheet/chord_lyrics_pair';
2
+ import { FontConfiguration } from '../../formatter/configuration';
3
+ import Line from '../../chord_sheet/line';
4
+ import SoftLineBreak from '../../chord_sheet/soft_line_break';
5
+ import Tag from '../../chord_sheet/tag';
6
+ export interface Measurer {
7
+ measureTextWidth(text: string, font: {
8
+ size: number;
9
+ lineHeight?: number;
10
+ }): number;
11
+ measureTextHeight(text: string, font: {
12
+ size: number;
13
+ lineHeight?: number;
14
+ }): number;
15
+ splitTextToSize(text: string, maxWidth: number, font: {
16
+ size: number;
17
+ lineHeight?: number;
18
+ }): string[];
19
+ }
20
+ /**
21
+ * Represents a break point in text for line wrapping
22
+ */
23
+ export interface BreakPoint {
24
+ index: number;
25
+ type: 'space' | 'hyphen' | 'comma' | 'other';
26
+ }
27
+ /**
28
+ * Represents a measured chord-lyrics pair with position information
29
+ */
30
+ export interface MeasuredItem {
31
+ item: ChordLyricsPair | Tag | SoftLineBreak | null;
32
+ width: number;
33
+ chordHeight?: number;
34
+ chordLyricWidthDifference?: number;
35
+ }
36
+ /**
37
+ * Represents a single line in the layout
38
+ */
39
+ export interface LineLayout {
40
+ type: 'ChordLyricsPair' | 'Comment' | 'SectionLabel' | 'Tag' | 'Empty';
41
+ lineHeight: number;
42
+ items: MeasuredItem[];
43
+ line: Line;
44
+ }
45
+ /**
46
+ * Represents a paragraph in the layout
47
+ */
48
+ /**
49
+ * Complete layout for a song
50
+ */
51
+ /**
52
+ * Configuration for the layout engine
53
+ */
54
+ export interface LayoutConfig {
55
+ width: number;
56
+ fonts: {
57
+ chord: FontConfiguration;
58
+ lyrics: FontConfiguration;
59
+ comment: FontConfiguration;
60
+ sectionLabel: FontConfiguration;
61
+ };
62
+ chordSpacing: number;
63
+ chordLyricSpacing: number;
64
+ linePadding: number;
65
+ useUnicodeModifiers: boolean;
66
+ normalizeChords: boolean;
67
+ minY: number;
68
+ columnWidth: number;
69
+ columnCount?: number;
70
+ columnSpacing: number;
71
+ minColumnWidth?: number;
72
+ maxColumnWidth?: number;
73
+ paragraphSpacing: number;
74
+ columnBottomY: number;
75
+ displayLyricsOnly?: boolean;
76
+ decapo: boolean;
77
+ repeatedSections?: 'hide' | 'title_only' | 'lyrics_only' | 'full';
78
+ }
79
+ export interface ParagraphLayoutResult {
80
+ units: LineLayout[][];
81
+ addSpacing: boolean;
82
+ sectionType: string;
83
+ }
84
+ /**
85
+ * Strategy interface for paragraph splitting
86
+ */
87
+ export interface ParagraphSplitStrategy {
88
+ /**
89
+ * Split a paragraph into parts that fit within column constraints
90
+ *
91
+ * @param lineLayouts - The layout of the paragraph to split
92
+ * @param currentY - Current vertical position in the column
93
+ * @param columnStartY - The starting Y position of columns
94
+ * @param columnBottomY - The bottom Y position of columns
95
+ * @returns The layout with column breaks inserted as needed
96
+ */
97
+ splitParagraph(lineLayouts: LineLayout[][], currentY: number, columnStartY: number, columnBottomY: number): LineLayout[][];
98
+ }
@@ -0,0 +1,18 @@
1
+ import { FontConfiguration } from '../../formatter/configuration';
2
+ import { BaseMeasurer, TextDimensions } from './measurer';
3
+ /**
4
+ * Measures text using Canvas API
5
+ */
6
+ export declare class CanvasMeasurer extends BaseMeasurer {
7
+ private canvas;
8
+ private context;
9
+ constructor();
10
+ /**
11
+ * Sets font configuration on the canvas context
12
+ * @param fontConfig The font configuration to apply
13
+ */
14
+ private setFont;
15
+ measureText(text: string, fontConfig: FontConfiguration): TextDimensions;
16
+ splitTextToSize(text: string, maxWidth: number, fontConfig: FontConfiguration): string[];
17
+ private measureWidth;
18
+ }
@@ -0,0 +1,21 @@
1
+ import { FontConfiguration } from '../../formatter/configuration';
2
+ import { BaseMeasurer, TextDimensions } from './measurer';
3
+ /**
4
+ * Measures text using DOM elements
5
+ */
6
+ export declare class DomMeasurer extends BaseMeasurer {
7
+ private measureElement;
8
+ constructor();
9
+ /**
10
+ * Cleans up the DOM element when no longer needed
11
+ */
12
+ dispose(): void;
13
+ /**
14
+ * Sets font configuration on the measurement element
15
+ * @param fontConfig The font configuration to apply
16
+ */
17
+ private setFont;
18
+ measureText(text: string, fontConfig: FontConfiguration): TextDimensions;
19
+ splitTextToSize(text: string, maxWidth: number, fontConfig: FontConfiguration): string[];
20
+ private measureWidth;
21
+ }
@@ -0,0 +1,4 @@
1
+ export * from './measurer';
2
+ export * from './js_pdf_measurer';
3
+ export * from './canvas_measurer';
4
+ export * from './dom_measurer';
@@ -0,0 +1,12 @@
1
+ import DocWrapper from '../../formatter/pdf_formatter/doc_wrapper';
2
+ import { FontConfiguration } from '../../formatter/configuration';
3
+ import { BaseMeasurer, TextDimensions } from './measurer';
4
+ /**
5
+ * Measures text using jsPDF
6
+ */
7
+ export declare class JsPdfMeasurer extends BaseMeasurer {
8
+ private doc;
9
+ constructor(doc: DocWrapper);
10
+ measureText(text: string, fontConfig: FontConfiguration): TextDimensions;
11
+ splitTextToSize(text: string, maxWidth: number, fontConfig: FontConfiguration): string[];
12
+ }