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/index.js CHANGED
@@ -5607,6 +5607,7 @@ const $287d3e472e1fbd90$export$82f9bd327a40ea54 = {
5607
5607
  key: null,
5608
5608
  metadata: $287d3e472e1fbd90$export$a014e67b549cbef4,
5609
5609
  normalizeChords: true,
5610
+ normalizeChordSuffix: true,
5610
5611
  useUnicodeModifiers: false,
5611
5612
  user: null
5612
5613
  };
@@ -6373,6 +6374,9 @@ const $fe1d3ba9df1ecad5$export$693785c2cb536a68 = (formatterType, specificDefaul
6373
6374
  * @param {boolean} [configuration.useUnicodeModifiers=false] Whether or not to use unicode flat and sharp
6374
6375
  * symbols.
6375
6376
  * @param {boolean} [configuration.normalizeChords=true] Whether or not to automatically normalize chords
6377
+ * @param {boolean} [configuration.normalizeChordSuffix=true] Whether to normalize chord suffixes (e.g.
6378
+ * `sus2` to `2`, `maj7` to `ma7`). Only takes effect when `normalizeChords` is `true`. Defaults to `false`
6379
+ * for {@link ChordProFormatter} so ChordPro round-trips preserve the user's suffix variant.
6376
6380
  */ constructor(configuration = {}){
6377
6381
  const defaultConfig = this.getDefaultConfiguration();
6378
6382
  this.configuration = (0, $28a2fcb6fb95a147$export$5d86b86a654a7039)(defaultConfig, configuration);
@@ -6524,9 +6528,16 @@ class $15f1d40e3d1ed3a0$var$Ternary extends (0, $8e2590a06c021dbf$export$2e2bcd8
6524
6528
  var $15f1d40e3d1ed3a0$export$2e2bcd8739ae039 = $15f1d40e3d1ed3a0$var$Ternary;
6525
6529
 
6526
6530
 
6531
+
6527
6532
  /**
6528
6533
  * Formats a song into a ChordPro chord sheet
6529
6534
  */ class $244a67400187e14e$var$ChordProFormatter extends (0, $ed0d9ddbbe7224cd$export$2e2bcd8739ae039) {
6535
+ getDefaultConfiguration() {
6536
+ return {
6537
+ ...(0, $fe1d3ba9df1ecad5$export$cb4529290f33d264)(),
6538
+ normalizeChordSuffix: false
6539
+ };
6540
+ }
6530
6541
  /**
6531
6542
  * Formats a song into a ChordPro chord sheet.
6532
6543
  * @param {Song} song The song to be formatted
@@ -6652,7 +6663,9 @@ var $15f1d40e3d1ed3a0$export$2e2bcd8739ae039 = $15f1d40e3d1ed3a0$var$Ternary;
6652
6663
  if (chordLyricsPair.chords) {
6653
6664
  const chordObj = chordLyricsPair.chord;
6654
6665
  if (!chordObj) return `[${chordLyricsPair.chords}]`;
6655
- const finalChord = this.configuration.normalizeChords ? chordObj.normalize() : chordObj;
6666
+ const finalChord = this.configuration.normalizeChords ? chordObj.normalize(null, {
6667
+ normalizeSuffix: this.configuration.normalizeChordSuffix
6668
+ }) : chordObj;
6656
6669
  return `[${finalChord}]`;
6657
6670
  }
6658
6671
  if (chordLyricsPair.annotation) return `[*${chordLyricsPair.annotation}]`;
@@ -7620,6 +7633,7 @@ const $e02a17f5a26edf19$var$defaultConstructorOptions = {
7620
7633
  contextKey: null,
7621
7634
  decapo: false,
7622
7635
  normalizeChords: true,
7636
+ normalizeChordSuffix: true,
7623
7637
  renderKey: null,
7624
7638
  songKey: null,
7625
7639
  style: null,
@@ -7635,6 +7649,7 @@ class $e02a17f5a26edf19$var$ChordRenderer {
7635
7649
  this.capo = config.decapo ? config.capo : 0;
7636
7650
  this.contextKey = config.contextKey;
7637
7651
  this.normalizeChords = config.normalizeChords;
7652
+ this.normalizeChordSuffix = config.normalizeChordSuffix;
7638
7653
  this.renderKey = config.renderKey;
7639
7654
  this.songKey = config.songKey;
7640
7655
  this.style = config.style;
@@ -7647,7 +7662,9 @@ class $e02a17f5a26edf19$var$ChordRenderer {
7647
7662
  return (0, $28a2fcb6fb95a147$export$79570e60478bce41)(chord, [
7648
7663
  (c)=>c.transpose(this.effectiveTransposeDistance),
7649
7664
  (c)=>this.accidental ? c.useAccidental(this.accidental) : c,
7650
- (c)=>this.normalizeChords ? c.normalize(this.effectiveKey) : c,
7665
+ (c)=>this.normalizeChords ? c.normalize(this.effectiveKey, {
7666
+ normalizeSuffix: this.normalizeChordSuffix
7667
+ }) : c,
7651
7668
  (c)=>this.changeChordType(c)
7652
7669
  ]).toString({
7653
7670
  useUnicodeModifier: this.useUnicodeModifier
@@ -8047,13 +8064,38 @@ function $2ce1086ce25c9ac0$export$fd31a53e6281557e(transposeKey, songKey) {
8047
8064
  if (/^\d+$/.test(transposeKey)) return parseInt(transposeKey, 10);
8048
8065
  return (0, $c2d6ab25ad00308f$export$2e2bcd8739ae039).distance(songKey, transposeKey);
8049
8066
  }
8050
- function $2ce1086ce25c9ac0$export$596ec52955da9472(chordString, line, song, { renderKey: renderKey = null, useUnicodeModifier: useUnicodeModifier = false, normalizeChords: normalizeChords = true, decapo: decapo = false } = {}) {
8067
+ /**
8068
+ * Renders a chord in the context of a line and song and taking into account some options
8069
+ * @param chordString The chord to render
8070
+ * @param line The line the chord is in
8071
+ * @param song The song the line is in
8072
+ * @param renderKey The key to render the chord in. If not provided, the line key will be used,
8073
+ * or the song key if the line key is not provided.
8074
+ * @param useUnicodeModifier Whether to use unicode modifiers ('\u266f'/'\u266d') or plain text ('#'/'b').
8075
+ * Default `false`.
8076
+ * @param normalizeChords Whether to normalize the chord to the key (default `true`)
8077
+ * @param normalizeChordSuffix Whether to normalize the chord suffix (e.g. `sus2` to `2`, `maj7` to `ma7`).
8078
+ * Only takes effect when `normalizeChords` is `true`. Default `true`.
8079
+ * @param decapo Whether to transpose all chords to eliminate the capo (default `false`)
8080
+ */ const $2ce1086ce25c9ac0$var$renderChordDefaults = {
8081
+ renderKey: null,
8082
+ useUnicodeModifier: false,
8083
+ normalizeChords: true,
8084
+ normalizeChordSuffix: true,
8085
+ decapo: false
8086
+ };
8087
+ function $2ce1086ce25c9ac0$export$596ec52955da9472(chordString, line, song, options = {}) {
8088
+ const { renderKey: renderKey, useUnicodeModifier: useUnicodeModifier, normalizeChords: normalizeChords, normalizeChordSuffix: normalizeChordSuffix, decapo: decapo } = {
8089
+ ...$2ce1086ce25c9ac0$var$renderChordDefaults,
8090
+ ...options
8091
+ };
8051
8092
  const capoString = song.metadata.getSingle((0, $d21c5c7a462f3c34$export$866f445d49bad88e));
8052
8093
  return new (0, $e02a17f5a26edf19$export$2e2bcd8739ae039)({
8053
8094
  capo: capoString ? parseInt(capoString, 10) : 0,
8054
8095
  contextKey: (0, $c2d6ab25ad00308f$export$2e2bcd8739ae039).wrap(line.key || song.key),
8055
8096
  decapo: decapo,
8056
8097
  normalizeChords: normalizeChords,
8098
+ normalizeChordSuffix: normalizeChordSuffix,
8057
8099
  renderKey: renderKey,
8058
8100
  songKey: (0, $c2d6ab25ad00308f$export$2e2bcd8739ae039).wrap(song.key),
8059
8101
  style: song.metadata.getSingle((0, $d21c5c7a462f3c34$export$d8cbdf44b1f66df1)),
@@ -13989,6 +14031,7 @@ var $f9c5006b26957916$export$2e2bcd8739ae039 = {
13989
14031
  return (0, $2ce1086ce25c9ac0$export$596ec52955da9472)(item.chords, line, this.song, {
13990
14032
  renderKey: this.configuration.key,
13991
14033
  normalizeChords: this.configuration.normalizeChords,
14034
+ normalizeChordSuffix: this.configuration.normalizeChordSuffix,
13992
14035
  decapo: this.configuration.decapo
13993
14036
  });
13994
14037
  }
@@ -26534,6 +26577,7 @@ var $1408adfd7317f0b6$export$2e2bcd8739ae039 = ({ configuration: configuration,
26534
26577
  renderKey: key,
26535
26578
  useUnicodeModifier: configuration.useUnicodeModifiers,
26536
26579
  normalizeChords: configuration.normalizeChords,
26580
+ normalizeChordSuffix: configuration.normalizeChordSuffix,
26537
26581
  decapo: configuration.decapo
26538
26582
  })}
26539
26583
  </div>
@@ -26733,6 +26777,7 @@ var $396f7048979e89c9$export$2e2bcd8739ae039 = ({ configuration: configuration,
26733
26777
  renderKey: key,
26734
26778
  useUnicodeModifier: configuration.useUnicodeModifiers,
26735
26779
  normalizeChords: configuration.normalizeChords,
26780
+ normalizeChordSuffix: configuration.normalizeChordSuffix,
26736
26781
  decapo: configuration.decapo
26737
26782
  })}</td>
26738
26783
  `;
@@ -27661,6 +27706,7 @@ var $bdd8c6196670168a$export$2e2bcd8739ae039 = $bdd8c6196670168a$var$Condition;
27661
27706
  renderKey: this.configuration.key,
27662
27707
  useUnicodeModifier: this.configuration.useUnicodeModifiers,
27663
27708
  normalizeChords: this.configuration.normalizeChords,
27709
+ normalizeChordSuffix: this.configuration.normalizeChordSuffix,
27664
27710
  decapo: this.configuration.decapo
27665
27711
  });
27666
27712
  return chords;
@@ -28789,6 +28835,7 @@ class $9c53a1d7fff20a4a$export$e6ce86b8bc39728b {
28789
28835
  renderKey: null,
28790
28836
  useUnicodeModifier: this.config.useUnicodeModifiers,
28791
28837
  normalizeChords: this.config.normalizeChords,
28838
+ normalizeChordSuffix: this.config.normalizeChordSuffix,
28792
28839
  decapo: this.config.decapo
28793
28840
  });
28794
28841
  }
@@ -29865,6 +29912,7 @@ class $7fa32b9e3992eddb$export$12b762d1038ddc6b {
29865
29912
  linePadding: this.configuration.layout.sections.global.linePadding,
29866
29913
  useUnicodeModifiers: this.configuration.useUnicodeModifiers,
29867
29914
  normalizeChords: this.configuration.normalizeChords,
29915
+ normalizeChordSuffix: this.configuration.normalizeChordSuffix,
29868
29916
  // Column and page layout information
29869
29917
  minY: dimensions.minY,
29870
29918
  columnWidth: dimensions.columnWidth,
@@ -30130,7 +30178,7 @@ const $a5a21ced491ea51f$var$endSectionTags = {
30130
30178
  var $a5a21ced491ea51f$export$2e2bcd8739ae039 = $a5a21ced491ea51f$var$UltimateGuitarParser;
30131
30179
 
30132
30180
 
30133
- var $ae92e002ce14f11a$export$2e2bcd8739ae039 = '15.2.1';
30181
+ var $ae92e002ce14f11a$export$2e2bcd8739ae039 = '15.3.1';
30134
30182
 
30135
30183
 
30136
30184