chordsheetjs 15.2.1 → 15.3.1

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.
package/lib/pdf/module.js CHANGED
@@ -739,6 +739,7 @@ const $663e568e94e22dc9$export$82f9bd327a40ea54 = {
739
739
  key: null,
740
740
  metadata: $663e568e94e22dc9$export$a014e67b549cbef4,
741
741
  normalizeChords: true,
742
+ normalizeChordSuffix: true,
742
743
  useUnicodeModifiers: false,
743
744
  user: null
744
745
  };
@@ -13935,6 +13936,7 @@ const $f5e27e8faa22bf25$var$defaultConstructorOptions = {
13935
13936
  contextKey: null,
13936
13937
  decapo: false,
13937
13938
  normalizeChords: true,
13939
+ normalizeChordSuffix: true,
13938
13940
  renderKey: null,
13939
13941
  songKey: null,
13940
13942
  style: null,
@@ -13950,6 +13952,7 @@ class $f5e27e8faa22bf25$var$ChordRenderer {
13950
13952
  this.capo = config.decapo ? config.capo : 0;
13951
13953
  this.contextKey = config.contextKey;
13952
13954
  this.normalizeChords = config.normalizeChords;
13955
+ this.normalizeChordSuffix = config.normalizeChordSuffix;
13953
13956
  this.renderKey = config.renderKey;
13954
13957
  this.songKey = config.songKey;
13955
13958
  this.style = config.style;
@@ -13962,7 +13965,9 @@ class $f5e27e8faa22bf25$var$ChordRenderer {
13962
13965
  return (0, $974bd1d260bb1d53$export$79570e60478bce41)(chord, [
13963
13966
  (c)=>c.transpose(this.effectiveTransposeDistance),
13964
13967
  (c)=>this.accidental ? c.useAccidental(this.accidental) : c,
13965
- (c)=>this.normalizeChords ? c.normalize(this.effectiveKey) : c,
13968
+ (c)=>this.normalizeChords ? c.normalize(this.effectiveKey, {
13969
+ normalizeSuffix: this.normalizeChordSuffix
13970
+ }) : c,
13966
13971
  (c)=>this.changeChordType(c)
13967
13972
  ]).toString({
13968
13973
  useUnicodeModifier: this.useUnicodeModifier
@@ -14362,13 +14367,38 @@ function $e2e1ea6dd3b7d2e1$export$fd31a53e6281557e(transposeKey, songKey) {
14362
14367
  if (/^\d+$/.test(transposeKey)) return parseInt(transposeKey, 10);
14363
14368
  return (0, $918eb2016ac61e41$export$2e2bcd8739ae039).distance(songKey, transposeKey);
14364
14369
  }
14365
- function $e2e1ea6dd3b7d2e1$export$596ec52955da9472(chordString, line, song, { renderKey: renderKey = null, useUnicodeModifier: useUnicodeModifier = false, normalizeChords: normalizeChords = true, decapo: decapo = false } = {}) {
14370
+ /**
14371
+ * Renders a chord in the context of a line and song and taking into account some options
14372
+ * @param chordString The chord to render
14373
+ * @param line The line the chord is in
14374
+ * @param song The song the line is in
14375
+ * @param renderKey The key to render the chord in. If not provided, the line key will be used,
14376
+ * or the song key if the line key is not provided.
14377
+ * @param useUnicodeModifier Whether to use unicode modifiers ('\u266f'/'\u266d') or plain text ('#'/'b').
14378
+ * Default `false`.
14379
+ * @param normalizeChords Whether to normalize the chord to the key (default `true`)
14380
+ * @param normalizeChordSuffix Whether to normalize the chord suffix (e.g. `sus2` to `2`, `maj7` to `ma7`).
14381
+ * Only takes effect when `normalizeChords` is `true`. Default `true`.
14382
+ * @param decapo Whether to transpose all chords to eliminate the capo (default `false`)
14383
+ */ const $e2e1ea6dd3b7d2e1$var$renderChordDefaults = {
14384
+ renderKey: null,
14385
+ useUnicodeModifier: false,
14386
+ normalizeChords: true,
14387
+ normalizeChordSuffix: true,
14388
+ decapo: false
14389
+ };
14390
+ function $e2e1ea6dd3b7d2e1$export$596ec52955da9472(chordString, line, song, options = {}) {
14391
+ const { renderKey: renderKey, useUnicodeModifier: useUnicodeModifier, normalizeChords: normalizeChords, normalizeChordSuffix: normalizeChordSuffix, decapo: decapo } = {
14392
+ ...$e2e1ea6dd3b7d2e1$var$renderChordDefaults,
14393
+ ...options
14394
+ };
14366
14395
  const capoString = song.metadata.getSingle((0, $fc279350ee3ca664$export$866f445d49bad88e));
14367
14396
  return new (0, $f5e27e8faa22bf25$export$2e2bcd8739ae039)({
14368
14397
  capo: capoString ? parseInt(capoString, 10) : 0,
14369
14398
  contextKey: (0, $918eb2016ac61e41$export$2e2bcd8739ae039).wrap(line.key || song.key),
14370
14399
  decapo: decapo,
14371
14400
  normalizeChords: normalizeChords,
14401
+ normalizeChordSuffix: normalizeChordSuffix,
14372
14402
  renderKey: renderKey,
14373
14403
  songKey: (0, $918eb2016ac61e41$export$2e2bcd8739ae039).wrap(song.key),
14374
14404
  style: song.metadata.getSingle((0, $fc279350ee3ca664$export$d8cbdf44b1f66df1)),
@@ -20870,6 +20900,9 @@ var $790f30d4710befe7$export$2e2bcd8739ae039 = $790f30d4710befe7$var$Condition;
20870
20900
  * @param {boolean} [configuration.useUnicodeModifiers=false] Whether or not to use unicode flat and sharp
20871
20901
  * symbols.
20872
20902
  * @param {boolean} [configuration.normalizeChords=true] Whether or not to automatically normalize chords
20903
+ * @param {boolean} [configuration.normalizeChordSuffix=true] Whether to normalize chord suffixes (e.g.
20904
+ * `sus2` to `2`, `maj7` to `ma7`). Only takes effect when `normalizeChords` is `true`. Defaults to `false`
20905
+ * for {@link ChordProFormatter} so ChordPro round-trips preserve the user's suffix variant.
20873
20906
  */ constructor(configuration = {}){
20874
20907
  const defaultConfig = this.getDefaultConfiguration();
20875
20908
  this.configuration = (0, $974bd1d260bb1d53$export$5d86b86a654a7039)(defaultConfig, configuration);
@@ -21144,9 +21177,16 @@ var $c1baef5f0178006c$export$2e2bcd8739ae039 = $c1baef5f0178006c$var$When;
21144
21177
 
21145
21178
 
21146
21179
 
21180
+
21147
21181
  /**
21148
21182
  * Formats a song into a ChordPro chord sheet
21149
21183
  */ class $feb758e68dd351a4$var$ChordProFormatter extends (0, $2dfa852662754780$export$2e2bcd8739ae039) {
21184
+ getDefaultConfiguration() {
21185
+ return {
21186
+ ...(0, $a4496115a7f17554$export$cb4529290f33d264)(),
21187
+ normalizeChordSuffix: false
21188
+ };
21189
+ }
21150
21190
  /**
21151
21191
  * Formats a song into a ChordPro chord sheet.
21152
21192
  * @param {Song} song The song to be formatted
@@ -21272,7 +21312,9 @@ var $c1baef5f0178006c$export$2e2bcd8739ae039 = $c1baef5f0178006c$var$When;
21272
21312
  if (chordLyricsPair.chords) {
21273
21313
  const chordObj = chordLyricsPair.chord;
21274
21314
  if (!chordObj) return `[${chordLyricsPair.chords}]`;
21275
- const finalChord = this.configuration.normalizeChords ? chordObj.normalize() : chordObj;
21315
+ const finalChord = this.configuration.normalizeChords ? chordObj.normalize(null, {
21316
+ normalizeSuffix: this.configuration.normalizeChordSuffix
21317
+ }) : chordObj;
21276
21318
  return `[${finalChord}]`;
21277
21319
  }
21278
21320
  if (chordLyricsPair.annotation) return `[*${chordLyricsPair.annotation}]`;
@@ -21589,6 +21631,7 @@ var $9c17b505581d81bb$export$2e2bcd8739ae039 = $9c17b505581d81bb$var$ChordSheetP
21589
21631
  return (0, $e2e1ea6dd3b7d2e1$export$596ec52955da9472)(item.chords, line, this.song, {
21590
21632
  renderKey: this.configuration.key,
21591
21633
  normalizeChords: this.configuration.normalizeChords,
21634
+ normalizeChordSuffix: this.configuration.normalizeChordSuffix,
21592
21635
  decapo: this.configuration.decapo
21593
21636
  });
21594
21637
  }
@@ -34134,6 +34177,7 @@ var $d6c38f6287712fb1$export$2e2bcd8739ae039 = ({ configuration: configuration,
34134
34177
  renderKey: key,
34135
34178
  useUnicodeModifier: configuration.useUnicodeModifiers,
34136
34179
  normalizeChords: configuration.normalizeChords,
34180
+ normalizeChordSuffix: configuration.normalizeChordSuffix,
34137
34181
  decapo: configuration.decapo
34138
34182
  })}
34139
34183
  </div>
@@ -34333,6 +34377,7 @@ var $9940e2d1d4d0b0b9$export$2e2bcd8739ae039 = ({ configuration: configuration,
34333
34377
  renderKey: key,
34334
34378
  useUnicodeModifier: configuration.useUnicodeModifiers,
34335
34379
  normalizeChords: configuration.normalizeChords,
34380
+ normalizeChordSuffix: configuration.normalizeChordSuffix,
34336
34381
  decapo: configuration.decapo
34337
34382
  })}</td>
34338
34383
  `;
@@ -35793,6 +35838,7 @@ class $b5b6826de720b411$export$e6ce86b8bc39728b {
35793
35838
  renderKey: null,
35794
35839
  useUnicodeModifier: this.config.useUnicodeModifiers,
35795
35840
  normalizeChords: this.config.normalizeChords,
35841
+ normalizeChordSuffix: this.config.normalizeChordSuffix,
35796
35842
  decapo: this.config.decapo
35797
35843
  });
35798
35844
  }
@@ -36869,6 +36915,7 @@ class $850a89b14e4b94eb$export$12b762d1038ddc6b {
36869
36915
  linePadding: this.configuration.layout.sections.global.linePadding,
36870
36916
  useUnicodeModifiers: this.configuration.useUnicodeModifiers,
36871
36917
  normalizeChords: this.configuration.normalizeChords,
36918
+ normalizeChordSuffix: this.configuration.normalizeChordSuffix,
36872
36919
  // Column and page layout information
36873
36920
  minY: dimensions.minY,
36874
36921
  columnWidth: dimensions.columnWidth,
@@ -37134,7 +37181,7 @@ const $7c59209366f6488e$var$endSectionTags = {
37134
37181
  var $7c59209366f6488e$export$2e2bcd8739ae039 = $7c59209366f6488e$var$UltimateGuitarParser;
37135
37182
 
37136
37183
 
37137
- var $3e7872a494b653a9$export$2e2bcd8739ae039 = '15.2.1';
37184
+ var $3e7872a494b653a9$export$2e2bcd8739ae039 = '15.3.1';
37138
37185
 
37139
37186
 
37140
37187
 
@@ -37410,6 +37457,7 @@ var $a2a605be2775ff64$export$2e2bcd8739ae039 = {
37410
37457
  renderKey: this.configuration.key,
37411
37458
  useUnicodeModifier: this.configuration.useUnicodeModifiers,
37412
37459
  normalizeChords: this.configuration.normalizeChords,
37460
+ normalizeChordSuffix: this.configuration.normalizeChordSuffix,
37413
37461
  decapo: this.configuration.decapo
37414
37462
  });
37415
37463
  return chords;
@@ -37871,6 +37919,7 @@ var $5ad5f749425e7fe5$export$2e2bcd8739ae039 = $5ad5f749425e7fe5$var$JsPdfRender
37871
37919
  linePadding: this.configuration.layout.sections.global.linePadding,
37872
37920
  useUnicodeModifiers: this.configuration.useUnicodeModifiers,
37873
37921
  normalizeChords: this.configuration.normalizeChords,
37922
+ normalizeChordSuffix: this.configuration.normalizeChordSuffix,
37874
37923
  // Column and page layout information
37875
37924
  minY: dimensions.minY,
37876
37925
  columnWidth: dimensions.columnWidth,