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/index.js CHANGED
@@ -746,6 +746,7 @@ const $8c370f6299188657$export$82f9bd327a40ea54 = {
746
746
  key: null,
747
747
  metadata: $8c370f6299188657$export$a014e67b549cbef4,
748
748
  normalizeChords: true,
749
+ normalizeChordSuffix: true,
749
750
  useUnicodeModifiers: false,
750
751
  user: null
751
752
  };
@@ -13942,6 +13943,7 @@ const $c2be399211dfbcbd$var$defaultConstructorOptions = {
13942
13943
  contextKey: null,
13943
13944
  decapo: false,
13944
13945
  normalizeChords: true,
13946
+ normalizeChordSuffix: true,
13945
13947
  renderKey: null,
13946
13948
  songKey: null,
13947
13949
  style: null,
@@ -13957,6 +13959,7 @@ class $c2be399211dfbcbd$var$ChordRenderer {
13957
13959
  this.capo = config.decapo ? config.capo : 0;
13958
13960
  this.contextKey = config.contextKey;
13959
13961
  this.normalizeChords = config.normalizeChords;
13962
+ this.normalizeChordSuffix = config.normalizeChordSuffix;
13960
13963
  this.renderKey = config.renderKey;
13961
13964
  this.songKey = config.songKey;
13962
13965
  this.style = config.style;
@@ -13969,7 +13972,9 @@ class $c2be399211dfbcbd$var$ChordRenderer {
13969
13972
  return (0, $21a34a464e7bc609$export$79570e60478bce41)(chord, [
13970
13973
  (c)=>c.transpose(this.effectiveTransposeDistance),
13971
13974
  (c)=>this.accidental ? c.useAccidental(this.accidental) : c,
13972
- (c)=>this.normalizeChords ? c.normalize(this.effectiveKey) : c,
13975
+ (c)=>this.normalizeChords ? c.normalize(this.effectiveKey, {
13976
+ normalizeSuffix: this.normalizeChordSuffix
13977
+ }) : c,
13973
13978
  (c)=>this.changeChordType(c)
13974
13979
  ]).toString({
13975
13980
  useUnicodeModifier: this.useUnicodeModifier
@@ -14369,13 +14374,38 @@ function $dfecd32049fa58e9$export$fd31a53e6281557e(transposeKey, songKey) {
14369
14374
  if (/^\d+$/.test(transposeKey)) return parseInt(transposeKey, 10);
14370
14375
  return (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).distance(songKey, transposeKey);
14371
14376
  }
14372
- function $dfecd32049fa58e9$export$596ec52955da9472(chordString, line, song, { renderKey: renderKey = null, useUnicodeModifier: useUnicodeModifier = false, normalizeChords: normalizeChords = true, decapo: decapo = false } = {}) {
14377
+ /**
14378
+ * Renders a chord in the context of a line and song and taking into account some options
14379
+ * @param chordString The chord to render
14380
+ * @param line The line the chord is in
14381
+ * @param song The song the line is in
14382
+ * @param renderKey The key to render the chord in. If not provided, the line key will be used,
14383
+ * or the song key if the line key is not provided.
14384
+ * @param useUnicodeModifier Whether to use unicode modifiers ('\u266f'/'\u266d') or plain text ('#'/'b').
14385
+ * Default `false`.
14386
+ * @param normalizeChords Whether to normalize the chord to the key (default `true`)
14387
+ * @param normalizeChordSuffix Whether to normalize the chord suffix (e.g. `sus2` to `2`, `maj7` to `ma7`).
14388
+ * Only takes effect when `normalizeChords` is `true`. Default `true`.
14389
+ * @param decapo Whether to transpose all chords to eliminate the capo (default `false`)
14390
+ */ const $dfecd32049fa58e9$var$renderChordDefaults = {
14391
+ renderKey: null,
14392
+ useUnicodeModifier: false,
14393
+ normalizeChords: true,
14394
+ normalizeChordSuffix: true,
14395
+ decapo: false
14396
+ };
14397
+ function $dfecd32049fa58e9$export$596ec52955da9472(chordString, line, song, options = {}) {
14398
+ const { renderKey: renderKey, useUnicodeModifier: useUnicodeModifier, normalizeChords: normalizeChords, normalizeChordSuffix: normalizeChordSuffix, decapo: decapo } = {
14399
+ ...$dfecd32049fa58e9$var$renderChordDefaults,
14400
+ ...options
14401
+ };
14373
14402
  const capoString = song.metadata.getSingle((0, $b8d0f3e3723cd084$export$866f445d49bad88e));
14374
14403
  return new (0, $c2be399211dfbcbd$export$2e2bcd8739ae039)({
14375
14404
  capo: capoString ? parseInt(capoString, 10) : 0,
14376
14405
  contextKey: (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).wrap(line.key || song.key),
14377
14406
  decapo: decapo,
14378
14407
  normalizeChords: normalizeChords,
14408
+ normalizeChordSuffix: normalizeChordSuffix,
14379
14409
  renderKey: renderKey,
14380
14410
  songKey: (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).wrap(song.key),
14381
14411
  style: song.metadata.getSingle((0, $b8d0f3e3723cd084$export$d8cbdf44b1f66df1)),
@@ -20877,6 +20907,9 @@ var $f3be006db03d6687$export$2e2bcd8739ae039 = $f3be006db03d6687$var$Condition;
20877
20907
  * @param {boolean} [configuration.useUnicodeModifiers=false] Whether or not to use unicode flat and sharp
20878
20908
  * symbols.
20879
20909
  * @param {boolean} [configuration.normalizeChords=true] Whether or not to automatically normalize chords
20910
+ * @param {boolean} [configuration.normalizeChordSuffix=true] Whether to normalize chord suffixes (e.g.
20911
+ * `sus2` to `2`, `maj7` to `ma7`). Only takes effect when `normalizeChords` is `true`. Defaults to `false`
20912
+ * for {@link ChordProFormatter} so ChordPro round-trips preserve the user's suffix variant.
20880
20913
  */ constructor(configuration = {}){
20881
20914
  const defaultConfig = this.getDefaultConfiguration();
20882
20915
  this.configuration = (0, $21a34a464e7bc609$export$5d86b86a654a7039)(defaultConfig, configuration);
@@ -21151,9 +21184,16 @@ var $5dfeb7121ee98007$export$2e2bcd8739ae039 = $5dfeb7121ee98007$var$When;
21151
21184
 
21152
21185
 
21153
21186
 
21187
+
21154
21188
  /**
21155
21189
  * Formats a song into a ChordPro chord sheet
21156
21190
  */ class $b601b9602157ea5f$var$ChordProFormatter extends (0, $0055ecb09272ba2d$export$2e2bcd8739ae039) {
21191
+ getDefaultConfiguration() {
21192
+ return {
21193
+ ...(0, $34c988d232665944$export$cb4529290f33d264)(),
21194
+ normalizeChordSuffix: false
21195
+ };
21196
+ }
21157
21197
  /**
21158
21198
  * Formats a song into a ChordPro chord sheet.
21159
21199
  * @param {Song} song The song to be formatted
@@ -21279,7 +21319,9 @@ var $5dfeb7121ee98007$export$2e2bcd8739ae039 = $5dfeb7121ee98007$var$When;
21279
21319
  if (chordLyricsPair.chords) {
21280
21320
  const chordObj = chordLyricsPair.chord;
21281
21321
  if (!chordObj) return `[${chordLyricsPair.chords}]`;
21282
- const finalChord = this.configuration.normalizeChords ? chordObj.normalize() : chordObj;
21322
+ const finalChord = this.configuration.normalizeChords ? chordObj.normalize(null, {
21323
+ normalizeSuffix: this.configuration.normalizeChordSuffix
21324
+ }) : chordObj;
21283
21325
  return `[${finalChord}]`;
21284
21326
  }
21285
21327
  if (chordLyricsPair.annotation) return `[*${chordLyricsPair.annotation}]`;
@@ -21596,6 +21638,7 @@ var $c049675f48c823b2$export$2e2bcd8739ae039 = $c049675f48c823b2$var$ChordSheetP
21596
21638
  return (0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, this.song, {
21597
21639
  renderKey: this.configuration.key,
21598
21640
  normalizeChords: this.configuration.normalizeChords,
21641
+ normalizeChordSuffix: this.configuration.normalizeChordSuffix,
21599
21642
  decapo: this.configuration.decapo
21600
21643
  });
21601
21644
  }
@@ -34141,6 +34184,7 @@ var $93f055b77b2d269f$export$2e2bcd8739ae039 = ({ configuration: configuration,
34141
34184
  renderKey: key,
34142
34185
  useUnicodeModifier: configuration.useUnicodeModifiers,
34143
34186
  normalizeChords: configuration.normalizeChords,
34187
+ normalizeChordSuffix: configuration.normalizeChordSuffix,
34144
34188
  decapo: configuration.decapo
34145
34189
  })}
34146
34190
  </div>
@@ -34340,6 +34384,7 @@ var $5381a6b1b90601c7$export$2e2bcd8739ae039 = ({ configuration: configuration,
34340
34384
  renderKey: key,
34341
34385
  useUnicodeModifier: configuration.useUnicodeModifiers,
34342
34386
  normalizeChords: configuration.normalizeChords,
34387
+ normalizeChordSuffix: configuration.normalizeChordSuffix,
34343
34388
  decapo: configuration.decapo
34344
34389
  })}</td>
34345
34390
  `;
@@ -35800,6 +35845,7 @@ class $2f9d0306025b5d6b$export$e6ce86b8bc39728b {
35800
35845
  renderKey: null,
35801
35846
  useUnicodeModifier: this.config.useUnicodeModifiers,
35802
35847
  normalizeChords: this.config.normalizeChords,
35848
+ normalizeChordSuffix: this.config.normalizeChordSuffix,
35803
35849
  decapo: this.config.decapo
35804
35850
  });
35805
35851
  }
@@ -36876,6 +36922,7 @@ class $b507f24a204c2802$export$12b762d1038ddc6b {
36876
36922
  linePadding: this.configuration.layout.sections.global.linePadding,
36877
36923
  useUnicodeModifiers: this.configuration.useUnicodeModifiers,
36878
36924
  normalizeChords: this.configuration.normalizeChords,
36925
+ normalizeChordSuffix: this.configuration.normalizeChordSuffix,
36879
36926
  // Column and page layout information
36880
36927
  minY: dimensions.minY,
36881
36928
  columnWidth: dimensions.columnWidth,
@@ -37141,7 +37188,7 @@ const $db9c80925e255cd2$var$endSectionTags = {
37141
37188
  var $db9c80925e255cd2$export$2e2bcd8739ae039 = $db9c80925e255cd2$var$UltimateGuitarParser;
37142
37189
 
37143
37190
 
37144
- var $7491059d3a8d9eaa$export$2e2bcd8739ae039 = '15.2.1';
37191
+ var $7491059d3a8d9eaa$export$2e2bcd8739ae039 = '15.3.1';
37145
37192
 
37146
37193
 
37147
37194
 
@@ -37417,6 +37464,7 @@ var $376e205ced98486b$export$2e2bcd8739ae039 = {
37417
37464
  renderKey: this.configuration.key,
37418
37465
  useUnicodeModifier: this.configuration.useUnicodeModifiers,
37419
37466
  normalizeChords: this.configuration.normalizeChords,
37467
+ normalizeChordSuffix: this.configuration.normalizeChordSuffix,
37420
37468
  decapo: this.configuration.decapo
37421
37469
  });
37422
37470
  return chords;
@@ -37878,6 +37926,7 @@ var $5751ce07ce8c1517$export$2e2bcd8739ae039 = $5751ce07ce8c1517$var$JsPdfRender
37878
37926
  linePadding: this.configuration.layout.sections.global.linePadding,
37879
37927
  useUnicodeModifiers: this.configuration.useUnicodeModifiers,
37880
37928
  normalizeChords: this.configuration.normalizeChords,
37929
+ normalizeChordSuffix: this.configuration.normalizeChordSuffix,
37881
37930
  // Column and page layout information
37882
37931
  minY: dimensions.minY,
37883
37932
  columnWidth: dimensions.columnWidth,