chordsheetjs 7.16.0 → 7.17.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.
- package/README.md +1 -0
- package/lib/bundle.js +31 -21
- package/lib/index.js +31 -21
- package/lib/index.js.map +1 -1
- package/lib/main.d.ts +12 -9
- package/lib/main.d.ts.map +1 -1
- package/lib/module.js +31 -21
- package/lib/module.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1128,6 +1128,7 @@ https://chordpro.org/chordpro/directives-env_bridge/, https://chordpro.org/chord
|
|
|
1128
1128
|
| [configuration.key] | [<code>Key</code>](#Key) \| <code>string</code> | <code></code> | <p>The key to use for rendering. The chord sheet will be transposed from the song's original key (as indicated by the <code>{key}</code> directive) to the specified key. Note that transposing will only work if the original song key is set.</p> |
|
|
1129
1129
|
| [configuration.expandChorusDirective] | <code>boolean</code> | <code>false</code> | <p>Whether or not to expand <code>{chorus}</code> directives by rendering the last defined chorus inline after the directive.</p> |
|
|
1130
1130
|
| [configuration.useUnicodeModifiers] | <code>boolean</code> | <code>false</code> | <p>Whether or not to use unicode flat and sharp symbols.</p> |
|
|
1131
|
+
| [configuration.normalizeChords] | <code>boolean</code> | <code>true</code> | <p>Whether or not to automatically normalize chords</p> |
|
|
1131
1132
|
|
|
1132
1133
|
<a name="HtmlDivFormatter"></a>
|
|
1133
1134
|
|
package/lib/bundle.js
CHANGED
|
@@ -2703,7 +2703,8 @@ const $bbcfd2c49e8e9957$export$78c0028a34264234 = {
|
|
|
2703
2703
|
},
|
|
2704
2704
|
key: null,
|
|
2705
2705
|
expandChorusDirective: false,
|
|
2706
|
-
useUnicodeModifiers: false
|
|
2706
|
+
useUnicodeModifiers: false,
|
|
2707
|
+
normalizeChords: true
|
|
2707
2708
|
};
|
|
2708
2709
|
class $bbcfd2c49e8e9957$var$Configuration {
|
|
2709
2710
|
constructor(configuration = $bbcfd2c49e8e9957$export$78c0028a34264234){
|
|
@@ -2714,6 +2715,7 @@ class $bbcfd2c49e8e9957$var$Configuration {
|
|
|
2714
2715
|
this.evaluate = !!mergedConfig.evaluate;
|
|
2715
2716
|
this.expandChorusDirective = !!mergedConfig.expandChorusDirective;
|
|
2716
2717
|
this.useUnicodeModifiers = !!mergedConfig.useUnicodeModifiers;
|
|
2718
|
+
this.normalizeChords = !!mergedConfig.normalizeChords;
|
|
2717
2719
|
this.metadata = new (0, $71c330be198ce421$export$2e2bcd8739ae039)(configuration.metadata);
|
|
2718
2720
|
this.key = configuration.key ? (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).wrap(configuration.key) : null;
|
|
2719
2721
|
this.configuration = configuration;
|
|
@@ -2731,18 +2733,19 @@ var $bbcfd2c49e8e9957$export$2e2bcd8739ae039 = $bbcfd2c49e8e9957$var$Configurati
|
|
|
2731
2733
|
/**
|
|
2732
2734
|
* Instantiate
|
|
2733
2735
|
* @param {Object} [configuration={}] options
|
|
2734
|
-
* @param {boolean} [configuration.evaluate=false] Whether or not to evaluate meta expressions.
|
|
2735
|
-
* meta expressions, see: https://bit.ly/2SC9c2u
|
|
2736
|
+
* @param {boolean} [configuration.evaluate=false] Whether or not to evaluate meta expressions.
|
|
2737
|
+
* For more info about meta expressions, see: https://bit.ly/2SC9c2u
|
|
2736
2738
|
* @param {object} [configuration.metadata={}]
|
|
2737
|
-
* @param {string} [configuration.metadata.separator=", "] The separator to be used when rendering a
|
|
2738
|
-
* that has multiple values. See: https://bit.ly/2SC9c2u
|
|
2739
|
-
* @param {Key|string} [configuration.key=null] The key to use for rendering. The chord sheet will be
|
|
2740
|
-
* from the song's original key (as indicated by the `{key}` directive) to the specified key.
|
|
2741
|
-
* Note that transposing will only work
|
|
2742
|
-
* if the original song key is set.
|
|
2739
|
+
* @param {string} [configuration.metadata.separator=", "] The separator to be used when rendering a
|
|
2740
|
+
* metadata value that has multiple values. See: https://bit.ly/2SC9c2u
|
|
2741
|
+
* @param {Key|string} [configuration.key=null] The key to use for rendering. The chord sheet will be
|
|
2742
|
+
* transposed from the song's original key (as indicated by the `{key}` directive) to the specified key.
|
|
2743
|
+
* Note that transposing will only work if the original song key is set.
|
|
2743
2744
|
* @param {boolean} [configuration.expandChorusDirective=false] Whether or not to expand `{chorus}` directives
|
|
2744
2745
|
* by rendering the last defined chorus inline after the directive.
|
|
2745
|
-
* @param {boolean} [configuration.useUnicodeModifiers=false] Whether or not to use unicode flat and sharp
|
|
2746
|
+
* @param {boolean} [configuration.useUnicodeModifiers=false] Whether or not to use unicode flat and sharp
|
|
2747
|
+
* symbols.
|
|
2748
|
+
* @param {boolean} [configuration.normalizeChords=true] Whether or not to automatically normalize chords
|
|
2746
2749
|
*/ constructor(configuration = null){
|
|
2747
2750
|
this.configuration = new (0, $bbcfd2c49e8e9957$export$2e2bcd8739ae039)(configuration || {});
|
|
2748
2751
|
}
|
|
@@ -8234,14 +8237,16 @@ function $dfecd32049fa58e9$var$chordTransposeDistance(capo, transposeKey, songKe
|
|
|
8234
8237
|
}
|
|
8235
8238
|
return transpose;
|
|
8236
8239
|
}
|
|
8237
|
-
function $dfecd32049fa58e9$export$596ec52955da9472(chordString, line, song, { renderKey: renderKey = null , useUnicodeModifier: useUnicodeModifier = false } = {}) {
|
|
8240
|
+
function $dfecd32049fa58e9$export$596ec52955da9472(chordString, line, song, { renderKey: renderKey = null , useUnicodeModifier: useUnicodeModifier = false , normalizeChords: normalizeChords = true } = {}) {
|
|
8238
8241
|
const chord = (0, $26f57998457eb2d4$export$2e2bcd8739ae039).parse(chordString);
|
|
8239
8242
|
const songKey = song.key;
|
|
8240
8243
|
const capo = parseInt(song.metadata.getSingle((0, $5e9ede69210ec54a$export$866f445d49bad88e)), 10);
|
|
8241
8244
|
if (!chord) return chordString;
|
|
8242
8245
|
const effectiveTransposeDistance = $dfecd32049fa58e9$var$chordTransposeDistance(capo, line.transposeKey, songKey, renderKey);
|
|
8243
8246
|
const effectiveKey = renderKey || (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).wrap(line.key || song.key)?.transpose(effectiveTransposeDistance) || null;
|
|
8244
|
-
|
|
8247
|
+
const transposedChord = chord.transpose(effectiveTransposeDistance);
|
|
8248
|
+
const normalizedChord = normalizeChords ? transposedChord.normalize(effectiveKey) : transposedChord;
|
|
8249
|
+
return normalizedChord.toString({
|
|
8245
8250
|
useUnicodeModifier: useUnicodeModifier
|
|
8246
8251
|
});
|
|
8247
8252
|
}
|
|
@@ -8316,7 +8321,8 @@ var $93f055b77b2d269f$export$2e2bcd8739ae039 = ({ configuration: configuration ,
|
|
|
8316
8321
|
<div class="column">
|
|
8317
8322
|
<div class="chord"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.chordFont)}>${(0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, song, {
|
|
8318
8323
|
renderKey: key,
|
|
8319
|
-
useUnicodeModifier: configuration.useUnicodeModifiers
|
|
8324
|
+
useUnicodeModifier: configuration.useUnicodeModifiers,
|
|
8325
|
+
normalizeChords: configuration.normalizeChords
|
|
8320
8326
|
})}</div>
|
|
8321
8327
|
<div class="lyrics"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.textFont)}>${item.lyrics}</div>
|
|
8322
8328
|
</div>
|
|
@@ -8403,7 +8409,8 @@ var $5381a6b1b90601c7$export$2e2bcd8739ae039 = ({ configuration: configuration ,
|
|
|
8403
8409
|
${(0, $376e205ced98486b$export$a55877ca9db47377)((0, $376e205ced98486b$export$17c9e635b932873b)(item), ()=>`
|
|
8404
8410
|
<td class="chord"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.chordFont)}>${(0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, song, {
|
|
8405
8411
|
renderKey: key,
|
|
8406
|
-
useUnicodeModifier: configuration.useUnicodeModifiers
|
|
8412
|
+
useUnicodeModifier: configuration.useUnicodeModifiers,
|
|
8413
|
+
normalizeChords: configuration.normalizeChords
|
|
8407
8414
|
})}</td>
|
|
8408
8415
|
`)}
|
|
8409
8416
|
`)}
|
|
@@ -8548,22 +8555,25 @@ var $5b02ea769c63fd56$export$2e2bcd8739ae039 = $5b02ea769c63fd56$var$HtmlTableFo
|
|
|
8548
8555
|
return null;
|
|
8549
8556
|
}
|
|
8550
8557
|
chordLyricsPairLength(chordLyricsPair, line) {
|
|
8551
|
-
const chords = (
|
|
8552
|
-
renderKey: this.configuration.key
|
|
8553
|
-
});
|
|
8558
|
+
const chords = this.renderChords(chordLyricsPair, line);
|
|
8554
8559
|
const { lyrics: lyrics } = chordLyricsPair;
|
|
8555
8560
|
const chordsLength = (chords || "").length;
|
|
8556
8561
|
const lyricsLength = (lyrics || "").length;
|
|
8557
8562
|
if (chordsLength >= lyricsLength) return chordsLength + 1;
|
|
8558
8563
|
return Math.max(chordsLength, lyricsLength);
|
|
8559
8564
|
}
|
|
8565
|
+
renderChords(chordLyricsPair, line) {
|
|
8566
|
+
const chords = (0, $dfecd32049fa58e9$export$596ec52955da9472)(chordLyricsPair.chords, line, this.song, {
|
|
8567
|
+
renderKey: this.configuration.key,
|
|
8568
|
+
useUnicodeModifier: this.configuration.useUnicodeModifiers,
|
|
8569
|
+
normalizeChords: this.configuration.normalizeChords
|
|
8570
|
+
});
|
|
8571
|
+
return chords;
|
|
8572
|
+
}
|
|
8560
8573
|
formatItemTop(item, _metadata, line) {
|
|
8561
8574
|
if (item instanceof (0, $5e9ede69210ec54a$export$2e2bcd8739ae039) && item.isRenderable()) return item.value || "";
|
|
8562
8575
|
if (item instanceof (0, $d454f4215ba01af2$export$2e2bcd8739ae039)) {
|
|
8563
|
-
const chords = (
|
|
8564
|
-
renderKey: this.configuration.key,
|
|
8565
|
-
useUnicodeModifier: this.configuration.useUnicodeModifiers
|
|
8566
|
-
});
|
|
8576
|
+
const chords = this.renderChords(item, line);
|
|
8567
8577
|
return (0, $21a34a464e7bc609$export$bc3bea8325045070)(chords, this.chordLyricsPairLength(item, line));
|
|
8568
8578
|
}
|
|
8569
8579
|
return "";
|
package/lib/index.js
CHANGED
|
@@ -2702,7 +2702,8 @@ const $bbcfd2c49e8e9957$export$78c0028a34264234 = {
|
|
|
2702
2702
|
},
|
|
2703
2703
|
key: null,
|
|
2704
2704
|
expandChorusDirective: false,
|
|
2705
|
-
useUnicodeModifiers: false
|
|
2705
|
+
useUnicodeModifiers: false,
|
|
2706
|
+
normalizeChords: true
|
|
2706
2707
|
};
|
|
2707
2708
|
class $bbcfd2c49e8e9957$var$Configuration {
|
|
2708
2709
|
constructor(configuration = $bbcfd2c49e8e9957$export$78c0028a34264234){
|
|
@@ -2713,6 +2714,7 @@ class $bbcfd2c49e8e9957$var$Configuration {
|
|
|
2713
2714
|
this.evaluate = !!mergedConfig.evaluate;
|
|
2714
2715
|
this.expandChorusDirective = !!mergedConfig.expandChorusDirective;
|
|
2715
2716
|
this.useUnicodeModifiers = !!mergedConfig.useUnicodeModifiers;
|
|
2717
|
+
this.normalizeChords = !!mergedConfig.normalizeChords;
|
|
2716
2718
|
this.metadata = new (0, $71c330be198ce421$export$2e2bcd8739ae039)(configuration.metadata);
|
|
2717
2719
|
this.key = configuration.key ? (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).wrap(configuration.key) : null;
|
|
2718
2720
|
this.configuration = configuration;
|
|
@@ -2730,18 +2732,19 @@ var $bbcfd2c49e8e9957$export$2e2bcd8739ae039 = $bbcfd2c49e8e9957$var$Configurati
|
|
|
2730
2732
|
/**
|
|
2731
2733
|
* Instantiate
|
|
2732
2734
|
* @param {Object} [configuration={}] options
|
|
2733
|
-
* @param {boolean} [configuration.evaluate=false] Whether or not to evaluate meta expressions.
|
|
2734
|
-
* meta expressions, see: https://bit.ly/2SC9c2u
|
|
2735
|
+
* @param {boolean} [configuration.evaluate=false] Whether or not to evaluate meta expressions.
|
|
2736
|
+
* For more info about meta expressions, see: https://bit.ly/2SC9c2u
|
|
2735
2737
|
* @param {object} [configuration.metadata={}]
|
|
2736
|
-
* @param {string} [configuration.metadata.separator=", "] The separator to be used when rendering a
|
|
2737
|
-
* that has multiple values. See: https://bit.ly/2SC9c2u
|
|
2738
|
-
* @param {Key|string} [configuration.key=null] The key to use for rendering. The chord sheet will be
|
|
2739
|
-
* from the song's original key (as indicated by the `{key}` directive) to the specified key.
|
|
2740
|
-
* Note that transposing will only work
|
|
2741
|
-
* if the original song key is set.
|
|
2738
|
+
* @param {string} [configuration.metadata.separator=", "] The separator to be used when rendering a
|
|
2739
|
+
* metadata value that has multiple values. See: https://bit.ly/2SC9c2u
|
|
2740
|
+
* @param {Key|string} [configuration.key=null] The key to use for rendering. The chord sheet will be
|
|
2741
|
+
* transposed from the song's original key (as indicated by the `{key}` directive) to the specified key.
|
|
2742
|
+
* Note that transposing will only work if the original song key is set.
|
|
2742
2743
|
* @param {boolean} [configuration.expandChorusDirective=false] Whether or not to expand `{chorus}` directives
|
|
2743
2744
|
* by rendering the last defined chorus inline after the directive.
|
|
2744
|
-
* @param {boolean} [configuration.useUnicodeModifiers=false] Whether or not to use unicode flat and sharp
|
|
2745
|
+
* @param {boolean} [configuration.useUnicodeModifiers=false] Whether or not to use unicode flat and sharp
|
|
2746
|
+
* symbols.
|
|
2747
|
+
* @param {boolean} [configuration.normalizeChords=true] Whether or not to automatically normalize chords
|
|
2745
2748
|
*/ constructor(configuration = null){
|
|
2746
2749
|
this.configuration = new (0, $bbcfd2c49e8e9957$export$2e2bcd8739ae039)(configuration || {});
|
|
2747
2750
|
}
|
|
@@ -8233,14 +8236,16 @@ function $dfecd32049fa58e9$var$chordTransposeDistance(capo, transposeKey, songKe
|
|
|
8233
8236
|
}
|
|
8234
8237
|
return transpose;
|
|
8235
8238
|
}
|
|
8236
|
-
function $dfecd32049fa58e9$export$596ec52955da9472(chordString, line, song, { renderKey: renderKey = null , useUnicodeModifier: useUnicodeModifier = false } = {}) {
|
|
8239
|
+
function $dfecd32049fa58e9$export$596ec52955da9472(chordString, line, song, { renderKey: renderKey = null , useUnicodeModifier: useUnicodeModifier = false , normalizeChords: normalizeChords = true } = {}) {
|
|
8237
8240
|
const chord = (0, $26f57998457eb2d4$export$2e2bcd8739ae039).parse(chordString);
|
|
8238
8241
|
const songKey = song.key;
|
|
8239
8242
|
const capo = parseInt(song.metadata.getSingle((0, $5e9ede69210ec54a$export$866f445d49bad88e)), 10);
|
|
8240
8243
|
if (!chord) return chordString;
|
|
8241
8244
|
const effectiveTransposeDistance = $dfecd32049fa58e9$var$chordTransposeDistance(capo, line.transposeKey, songKey, renderKey);
|
|
8242
8245
|
const effectiveKey = renderKey || (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).wrap(line.key || song.key)?.transpose(effectiveTransposeDistance) || null;
|
|
8243
|
-
|
|
8246
|
+
const transposedChord = chord.transpose(effectiveTransposeDistance);
|
|
8247
|
+
const normalizedChord = normalizeChords ? transposedChord.normalize(effectiveKey) : transposedChord;
|
|
8248
|
+
return normalizedChord.toString({
|
|
8244
8249
|
useUnicodeModifier: useUnicodeModifier
|
|
8245
8250
|
});
|
|
8246
8251
|
}
|
|
@@ -8315,7 +8320,8 @@ var $93f055b77b2d269f$export$2e2bcd8739ae039 = ({ configuration: configuration ,
|
|
|
8315
8320
|
<div class="column">
|
|
8316
8321
|
<div class="chord"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.chordFont)}>${(0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, song, {
|
|
8317
8322
|
renderKey: key,
|
|
8318
|
-
useUnicodeModifier: configuration.useUnicodeModifiers
|
|
8323
|
+
useUnicodeModifier: configuration.useUnicodeModifiers,
|
|
8324
|
+
normalizeChords: configuration.normalizeChords
|
|
8319
8325
|
})}</div>
|
|
8320
8326
|
<div class="lyrics"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.textFont)}>${item.lyrics}</div>
|
|
8321
8327
|
</div>
|
|
@@ -8402,7 +8408,8 @@ var $5381a6b1b90601c7$export$2e2bcd8739ae039 = ({ configuration: configuration ,
|
|
|
8402
8408
|
${(0, $376e205ced98486b$export$a55877ca9db47377)((0, $376e205ced98486b$export$17c9e635b932873b)(item), ()=>`
|
|
8403
8409
|
<td class="chord"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.chordFont)}>${(0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, song, {
|
|
8404
8410
|
renderKey: key,
|
|
8405
|
-
useUnicodeModifier: configuration.useUnicodeModifiers
|
|
8411
|
+
useUnicodeModifier: configuration.useUnicodeModifiers,
|
|
8412
|
+
normalizeChords: configuration.normalizeChords
|
|
8406
8413
|
})}</td>
|
|
8407
8414
|
`)}
|
|
8408
8415
|
`)}
|
|
@@ -8547,22 +8554,25 @@ var $5b02ea769c63fd56$export$2e2bcd8739ae039 = $5b02ea769c63fd56$var$HtmlTableFo
|
|
|
8547
8554
|
return null;
|
|
8548
8555
|
}
|
|
8549
8556
|
chordLyricsPairLength(chordLyricsPair, line) {
|
|
8550
|
-
const chords = (
|
|
8551
|
-
renderKey: this.configuration.key
|
|
8552
|
-
});
|
|
8557
|
+
const chords = this.renderChords(chordLyricsPair, line);
|
|
8553
8558
|
const { lyrics: lyrics } = chordLyricsPair;
|
|
8554
8559
|
const chordsLength = (chords || "").length;
|
|
8555
8560
|
const lyricsLength = (lyrics || "").length;
|
|
8556
8561
|
if (chordsLength >= lyricsLength) return chordsLength + 1;
|
|
8557
8562
|
return Math.max(chordsLength, lyricsLength);
|
|
8558
8563
|
}
|
|
8564
|
+
renderChords(chordLyricsPair, line) {
|
|
8565
|
+
const chords = (0, $dfecd32049fa58e9$export$596ec52955da9472)(chordLyricsPair.chords, line, this.song, {
|
|
8566
|
+
renderKey: this.configuration.key,
|
|
8567
|
+
useUnicodeModifier: this.configuration.useUnicodeModifiers,
|
|
8568
|
+
normalizeChords: this.configuration.normalizeChords
|
|
8569
|
+
});
|
|
8570
|
+
return chords;
|
|
8571
|
+
}
|
|
8559
8572
|
formatItemTop(item, _metadata, line) {
|
|
8560
8573
|
if (item instanceof (0, $5e9ede69210ec54a$export$2e2bcd8739ae039) && item.isRenderable()) return item.value || "";
|
|
8561
8574
|
if (item instanceof (0, $d454f4215ba01af2$export$2e2bcd8739ae039)) {
|
|
8562
|
-
const chords = (
|
|
8563
|
-
renderKey: this.configuration.key,
|
|
8564
|
-
useUnicodeModifier: this.configuration.useUnicodeModifiers
|
|
8565
|
-
});
|
|
8575
|
+
const chords = this.renderChords(item, line);
|
|
8566
8576
|
return (0, $21a34a464e7bc609$export$bc3bea8325045070)(chords, this.chordLyricsPairLength(item, line));
|
|
8567
8577
|
}
|
|
8568
8578
|
return "";
|