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,38 @@
1
+ import FontStack from './chord_sheet/font_stack';
2
+ import Item from './chord_sheet/item';
3
+ import Metadata from './chord_sheet/metadata';
4
+ import ParserWarning from './parser/parser_warning';
5
+ import Song from './chord_sheet/song';
6
+ import Tag from './chord_sheet/tag';
7
+ import TraceInfo from './chord_sheet/trace_info';
8
+ import Line from './chord_sheet/line';
9
+ declare class SongBuilder {
10
+ currentKey: string | null;
11
+ currentLine: Line | null;
12
+ fontStack: FontStack;
13
+ lines: Line[];
14
+ metadata: Metadata;
15
+ sectionType: string;
16
+ selector: string | null;
17
+ selectorIsNegated: boolean;
18
+ song: Song;
19
+ transposeKey: string | null;
20
+ warnings: ParserWarning[];
21
+ constructor(song: Song);
22
+ get previousLine(): Line | null;
23
+ addLine(line?: Line): Line;
24
+ setCurrentProperties(sectionType: string, selector?: string | null, isNegated?: boolean): void;
25
+ addItem(item: Item): void;
26
+ chords(chr: string): void;
27
+ lyrics(chr: string): void;
28
+ addTag(tagContents: string | Tag): Tag;
29
+ ensureLine(): void;
30
+ private applyTagOnSong;
31
+ private applyTagOnLine;
32
+ setSectionTypeFromTag(tag: Tag): void;
33
+ startSection(sectionType: string, tag: Tag): void;
34
+ endSection(sectionType: string, tag: Tag): void;
35
+ checkCurrentSectionType(sectionType: string, tag: Tag): void;
36
+ addWarning(message: string, { line, column }: TraceInfo): void;
37
+ }
38
+ export default SongBuilder;
@@ -0,0 +1,14 @@
1
+ import { MetadataConfiguration } from '../formatter/configuration';
2
+ declare class MetadataProcessor {
3
+ metadata: Record<string, string | string[]>;
4
+ config: MetadataConfiguration;
5
+ processedKeys: Set<string>;
6
+ result: [string, string | string[]][];
7
+ constructor(metadata: Record<string, string | string[]>, config: MetadataConfiguration);
8
+ process(): [string, string | string[]][];
9
+ private addMatchingKeys;
10
+ private findMatchingKeys;
11
+ private addItemByStringKey;
12
+ private sortKeys;
13
+ }
14
+ export default MetadataProcessor;
@@ -0,0 +1,13 @@
1
+ import WhenCallback from './when_callback';
2
+ import WhenClause from './when_clause';
3
+ declare class When {
4
+ condition: boolean;
5
+ clauses: WhenClause[];
6
+ constructor(condition: any, thenCallback?: WhenCallback);
7
+ then(thenCallback: WhenCallback): When;
8
+ elseWhen(condition: any, callback?: WhenCallback): When;
9
+ else(callback: WhenCallback): When;
10
+ private add;
11
+ toString(): string;
12
+ }
13
+ export default When;
@@ -0,0 +1,2 @@
1
+ type WhenCallback = () => string;
2
+ export default WhenCallback;
@@ -0,0 +1,8 @@
1
+ import WhenCallback from './when_callback';
2
+ declare class WhenClause {
3
+ condition: boolean;
4
+ callback: WhenCallback;
5
+ constructor(condition: any, callback: WhenCallback);
6
+ evaluate(otherClauses: WhenClause[]): string;
7
+ }
8
+ export default WhenClause;
@@ -0,0 +1,64 @@
1
+ import Evaluatable from './chord_sheet/chord_pro/evaluatable';
2
+ import Font from './chord_sheet/font';
3
+ import Item from './chord_sheet/item';
4
+ import Line from './chord_sheet/line';
5
+ import Metadata from './chord_sheet/metadata';
6
+ import { MetadataConfiguration } from './formatter/configuration/base_configuration';
7
+ import Paragraph from './chord_sheet/paragraph';
8
+ import Tag from './chord_sheet/tag';
9
+ import When from './template_helpers/when';
10
+ import WhenCallback from './template_helpers/when_callback';
11
+ import { renderChord } from './helpers';
12
+ import { hasChordContents, isEvaluatable } from './utilities';
13
+ import { Configuration, HtmlTemplateCssClasses } from './formatter/configuration';
14
+ type EachCallback = (_item: any) => string;
15
+ export { hasChordContents, isEvaluatable } from './utilities';
16
+ export { renderChord } from './helpers';
17
+ import { pangoToHtml, stripPangoMarkup } from './pango/pango_helpers';
18
+ export { pangoToHtml, stripPangoMarkup };
19
+ export declare function isChordLyricsPair(item: Item): boolean;
20
+ export declare function isRhythmSymbol(item: Item): boolean;
21
+ export declare function lineHasContents(line: Line): boolean;
22
+ export declare function isTag(item: Item): boolean;
23
+ export declare function isLiteral(item: Item): boolean;
24
+ export declare function isComment(item: Tag): boolean;
25
+ export declare function isImage(item: Tag): boolean;
26
+ export declare function imageTag(item: Tag): string;
27
+ export declare function isColumnBreak(item: Item): boolean;
28
+ export declare function isSoftLineBreak(item: Item): boolean;
29
+ export declare function stripHTML(string: string): string;
30
+ export declare function newlinesToBreaks(string: string): string;
31
+ export declare function renderSection(paragraph: Paragraph, configuration: Configuration): string;
32
+ export declare function each(collection: any[], callback: EachCallback): string;
33
+ export declare function when(condition: any, callback?: WhenCallback): When;
34
+ export declare function hasTextContents(line: Line): boolean;
35
+ export declare function lineClasses(line: Line, cssClasses: HtmlTemplateCssClasses): string;
36
+ export declare function paragraphClasses(paragraph: Paragraph, cssClasses: HtmlTemplateCssClasses): string;
37
+ export declare function evaluate(item: Evaluatable, metadata: Metadata, configuration: Configuration): string;
38
+ export declare function fontStyleTag(font: Font): string;
39
+ export declare function processMetadata(metadata: Record<string, string | string[]>, config: MetadataConfiguration): [string, string | string[]][];
40
+ declare const _default: {
41
+ isLiteral: typeof isLiteral;
42
+ isSoftLineBreak: typeof isSoftLineBreak;
43
+ isEvaluatable: typeof isEvaluatable;
44
+ isChordLyricsPair: typeof isChordLyricsPair;
45
+ lineHasContents: typeof lineHasContents;
46
+ isTag: typeof isTag;
47
+ isComment: typeof isComment;
48
+ isImage: typeof isImage;
49
+ isColumnBreak: typeof isColumnBreak;
50
+ stripHTML: typeof stripHTML;
51
+ each: typeof each;
52
+ when: typeof when;
53
+ hasTextContents: typeof hasTextContents;
54
+ lineClasses: typeof lineClasses;
55
+ paragraphClasses: typeof paragraphClasses;
56
+ evaluate: typeof evaluate;
57
+ fontStyleTag: typeof fontStyleTag;
58
+ renderChord: typeof renderChord;
59
+ hasChordContents: typeof hasChordContents;
60
+ pangoToHtml: typeof pangoToHtml;
61
+ stripPangoMarkup: typeof stripPangoMarkup;
62
+ processMetadata: typeof processMetadata;
63
+ };
64
+ export default _default;
@@ -0,0 +1,35 @@
1
+ import Item from './chord_sheet/item';
2
+ import Line from './chord_sheet/line';
3
+ import { Accidental, AccidentalMaybe, ChordType } from './constants';
4
+ export declare function callChain<T>(value: T, functions: ((_value: T) => T)[]): T;
5
+ export declare function hasChordContents(line: Line): boolean;
6
+ export declare function hasRemarkContents(line: Line): boolean;
7
+ export declare function isEvaluatable(item: Item): boolean;
8
+ export declare function padLeft(string: string, length: number): string;
9
+ type ObjectWithLength = any[] | string | null;
10
+ export declare function isPresent(object: ObjectWithLength): boolean;
11
+ type CssObject = Record<string, Record<string, string>>;
12
+ export declare function scopeCss(css: CssObject, scope?: string): string;
13
+ export declare function warn(message: string): void;
14
+ export declare function deprecate(message: string): void;
15
+ export declare function isEmptyString(string: string | null | undefined): boolean;
16
+ export declare function isMinor(key: string | number, keyType: ChordType, suffix: any): boolean;
17
+ export declare function normalizeLineEndings(string: string): string;
18
+ export declare function gradeToKey(options: {
19
+ type: ChordType;
20
+ accidental: AccidentalMaybe | null;
21
+ preferredAccidental: Accidental | null;
22
+ grade: number;
23
+ minor: boolean;
24
+ }): string;
25
+ export declare function normalizeChordSuffix(suffix: string | null): string | null;
26
+ declare let mergeConfigs: <T>(target: T, source: any) => T;
27
+ export { mergeConfigs };
28
+ /**
29
+ * Utility type that creates a deep partial type
30
+ * This makes all properties optional recursively through the entire object
31
+ */
32
+ export type DeepPartial<T> = T extends object ? {
33
+ [P in keyof T]?: DeepPartial<T[P]>;
34
+ } : T;
35
+ export declare function filterObject<T>(object: Record<string, T>, predicate: (key: string, value: T) => boolean): Record<string, T>;
@@ -0,0 +1,2 @@
1
+ declare const _default: "15.0.0";
2
+ export default _default;
package/package.json CHANGED
@@ -1,12 +1,24 @@
1
1
  {
2
2
  "name": "chordsheetjs",
3
3
  "author": "Martijn Versluis",
4
- "version": "14.6.1",
4
+ "version": "15.0.0",
5
5
  "description": "A JavaScript library for parsing and formatting chord sheets",
6
6
  "source": "src/index.ts",
7
7
  "main": "lib/index.js",
8
8
  "module": "lib/module.js",
9
9
  "types": "lib/main.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./lib/main.d.ts",
13
+ "import": "./lib/module.js",
14
+ "require": "./lib/index.js"
15
+ },
16
+ "./pdf": {
17
+ "types": "./lib/pdf/pdf.d.ts",
18
+ "import": "./lib/pdf/module.js",
19
+ "require": "./lib/pdf/index.js"
20
+ }
21
+ },
10
22
  "files": [
11
23
  "/lib"
12
24
  ],
@@ -51,6 +63,7 @@
51
63
  "globals": "^17.0.0",
52
64
  "jest": "^30.0.0",
53
65
  "js-levenshtein": "^1.1.6",
66
+ "jspdf": "^4.0.0",
54
67
  "parcel": "2.16.4",
55
68
  "peggy": "^5.0.2",
56
69
  "pegjs-backtrace": "^0.2.1",
@@ -86,8 +99,13 @@
86
99
  "test": "yarn unibuild lint && yarn unibuild test",
87
100
  "playground": "cd playground && parcel index.html --port=3300 --no-cache"
88
101
  },
89
- "dependencies": {
102
+ "peerDependencies": {
90
103
  "jspdf": "^4.0.0"
91
104
  },
105
+ "peerDependenciesMeta": {
106
+ "jspdf": {
107
+ "optional": true
108
+ }
109
+ },
92
110
  "packageManager": "yarn@4.2.2"
93
111
  }