chordsheetjs 10.2.0 → 10.3.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 +479 -466
- package/lib/bundle.js +35 -10
- package/lib/bundle.min.js +17 -17
- package/lib/index.js +35 -11
- package/lib/index.js.map +1 -1
- package/lib/main.d.ts +35 -35
- package/lib/main.d.ts.map +1 -1
- package/lib/module.js +35 -11
- package/lib/module.js.map +1 -1
- package/package.json +8 -11
package/lib/bundle.js
CHANGED
|
@@ -12079,14 +12079,23 @@ var ChordSheetJS = (() => {
|
|
|
12079
12079
|
transpose(delta, key = null, { normalizeChordSuffix } = {
|
|
12080
12080
|
normalizeChordSuffix: false
|
|
12081
12081
|
}) {
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
if (key) transposedChord = transposedChord.normalize(key, {
|
|
12082
|
+
return this.changeChord((chord) => {
|
|
12083
|
+
const transposedChord = chord.transpose(delta);
|
|
12084
|
+
if (key) return transposedChord.normalize(key, {
|
|
12086
12085
|
normalizeSuffix: normalizeChordSuffix
|
|
12087
12086
|
});
|
|
12087
|
+
return transposedChord;
|
|
12088
|
+
});
|
|
12089
|
+
}
|
|
12090
|
+
useModifier(modifier) {
|
|
12091
|
+
return this.changeChord((chord) => chord.useModifier(modifier));
|
|
12092
|
+
}
|
|
12093
|
+
changeChord(func) {
|
|
12094
|
+
const chordObj = (0, $177a605b8569b31c$export$2e2bcd8739ae039).parse(this.chords.trim());
|
|
12095
|
+
if (chordObj) {
|
|
12096
|
+
const changedChord = func(chordObj);
|
|
12088
12097
|
return this.set({
|
|
12089
|
-
chords:
|
|
12098
|
+
chords: changedChord.toString()
|
|
12090
12099
|
});
|
|
12091
12100
|
}
|
|
12092
12101
|
return this.clone();
|
|
@@ -14502,7 +14511,8 @@ to a key`);
|
|
|
14502
14511
|
}
|
|
14503
14512
|
function $51ced2cf8b50f946$export$54f22f5279737844(chords, lyrics) {
|
|
14504
14513
|
const pairs = $51ced2cf8b50f946$export$bb6f5ab929ea49e7(lyrics || "");
|
|
14505
|
-
|
|
14514
|
+
const [_first, ...rest] = pairs;
|
|
14515
|
+
let first = pairs[0];
|
|
14506
14516
|
let addedLeadingChord = null;
|
|
14507
14517
|
if (chords !== "") {
|
|
14508
14518
|
if (!first || first.type === "softLineBreak") addedLeadingChord = {
|
|
@@ -28161,10 +28171,25 @@ to a key`);
|
|
|
28161
28171
|
* @returns {Song} The changed song
|
|
28162
28172
|
*/
|
|
28163
28173
|
changeKey(newKey) {
|
|
28164
|
-
const
|
|
28165
|
-
|
|
28174
|
+
const currentKey = this.requireCurrentKey();
|
|
28175
|
+
const targetKey = (0, $c2d6ab25ad00308f$export$2e2bcd8739ae039).wrapOrFail(newKey);
|
|
28176
|
+
const delta = currentKey.distanceTo(targetKey);
|
|
28177
|
+
const transposedSong = this.transpose(delta);
|
|
28178
|
+
if (targetKey.modifier) return transposedSong.useModifier(targetKey.modifier);
|
|
28179
|
+
return transposedSong;
|
|
28180
|
+
}
|
|
28181
|
+
/**
|
|
28182
|
+
* Returns a copy of the song with all chords changed to the specified modifier.
|
|
28183
|
+
* @param {Modifier} modifier the new modifier
|
|
28184
|
+
* @returns {Song} the changed song
|
|
28185
|
+
*/
|
|
28186
|
+
useModifier(modifier) {
|
|
28187
|
+
return this.mapItems((item) => {
|
|
28188
|
+
if (item instanceof (0, $551a223fc13b5c10$export$2e2bcd8739ae039)) return item.useModifier(modifier);
|
|
28189
|
+
return item;
|
|
28190
|
+
});
|
|
28166
28191
|
}
|
|
28167
|
-
|
|
28192
|
+
requireCurrentKey() {
|
|
28168
28193
|
const wrappedKey = (0, $c2d6ab25ad00308f$export$2e2bcd8739ae039).wrap(this.key);
|
|
28169
28194
|
if (!wrappedKey) throw new Error(`
|
|
28170
28195
|
Cannot change song key, the original key is unknown.
|
|
@@ -28174,7 +28199,7 @@ Either ensure a key directive is present in the song (when using chordpro):
|
|
|
28174
28199
|
|
|
28175
28200
|
Or set the song key before changing key:
|
|
28176
28201
|
\`song.setKey('C');\``.substring(1));
|
|
28177
|
-
return wrappedKey
|
|
28202
|
+
return wrappedKey;
|
|
28178
28203
|
}
|
|
28179
28204
|
/**
|
|
28180
28205
|
* Returns a copy of the song with the directive value set to the specified value.
|