chordsheetjs 7.4.0 → 7.5.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/lib/bundle.js +38 -8
- package/lib/index.js +38 -8
- package/lib/index.js.map +1 -1
- package/lib/main.d.ts +4 -2
- package/lib/main.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/bundle.js
CHANGED
|
@@ -1800,7 +1800,12 @@ class $8fcf445ea0999053$var$Note {
|
|
|
1800
1800
|
return this._note;
|
|
1801
1801
|
}
|
|
1802
1802
|
toString() {
|
|
1803
|
-
|
|
1803
|
+
switch(this.type){
|
|
1804
|
+
case 0, $af8d31735c159a26$export$1321df9b16c30c6a:
|
|
1805
|
+
return `${this.minor ? this.note.toLowerCase() : this.note.toUpperCase()}`;
|
|
1806
|
+
default:
|
|
1807
|
+
return `${this.note}`;
|
|
1808
|
+
}
|
|
1804
1809
|
}
|
|
1805
1810
|
set(attributes) {
|
|
1806
1811
|
return new $8fcf445ea0999053$var$Note({
|
|
@@ -2029,6 +2034,7 @@ class $bff5407e03fdc8ee$var$Key {
|
|
|
2029
2034
|
this.note = note instanceof (0, $8fcf445ea0999053$export$2e2bcd8739ae039) ? note : (0, $8fcf445ea0999053$export$2e2bcd8739ae039).parse(note);
|
|
2030
2035
|
this.modifier = modifier || null;
|
|
2031
2036
|
this.minor = !!minor || false;
|
|
2037
|
+
if (this.minor) this.note.minor = true;
|
|
2032
2038
|
}
|
|
2033
2039
|
isMinor() {
|
|
2034
2040
|
return this.minor || this.note.isMinor();
|
|
@@ -2079,8 +2085,25 @@ class $bff5407e03fdc8ee$var$Key {
|
|
|
2079
2085
|
toNumeralString(key = null) {
|
|
2080
2086
|
return this.toNumeral(key).toString();
|
|
2081
2087
|
}
|
|
2082
|
-
toString() {
|
|
2083
|
-
|
|
2088
|
+
toString({ showMinor: showMinor = true } = {}) {
|
|
2089
|
+
switch(this.note.type){
|
|
2090
|
+
case 0, $af8d31735c159a26$export$27c95a7104c1f7aa:
|
|
2091
|
+
return this.formatChordSymbolString(showMinor);
|
|
2092
|
+
case 0, $af8d31735c159a26$export$4d318981b5a83836:
|
|
2093
|
+
return this.formatNumericString(showMinor);
|
|
2094
|
+
case 0, $af8d31735c159a26$export$1321df9b16c30c6a:
|
|
2095
|
+
return this.formatNumeralString();
|
|
2096
|
+
default:
|
|
2097
|
+
throw new Error(`Unexpected note type ${this.note.type}`);
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
formatChordSymbolString(showMinor) {
|
|
2101
|
+
return `${this.note}${this.modifier || ""}${this.minor && showMinor ? "m" : ""}`;
|
|
2102
|
+
}
|
|
2103
|
+
formatNumericString(showMinor) {
|
|
2104
|
+
return `${this.modifier || ""}${this.note}${this.minor && showMinor ? "m" : ""}`;
|
|
2105
|
+
}
|
|
2106
|
+
formatNumeralString() {
|
|
2084
2107
|
return `${this.modifier || ""}${this.note}`;
|
|
2085
2108
|
}
|
|
2086
2109
|
transpose(delta) {
|
|
@@ -2145,9 +2168,13 @@ class $bff5407e03fdc8ee$var$Key {
|
|
|
2145
2168
|
}
|
|
2146
2169
|
normalizeEnharmonics(key) {
|
|
2147
2170
|
if (key) {
|
|
2148
|
-
const rootKeyString =
|
|
2171
|
+
const rootKeyString = $bff5407e03fdc8ee$var$Key.wrap(key).toString({
|
|
2172
|
+
showMinor: true
|
|
2173
|
+
});
|
|
2149
2174
|
const enharmonics = (0, $6ebb068142750218$export$2e2bcd8739ae039)[rootKeyString];
|
|
2150
|
-
const thisKeyString = this.toString(
|
|
2175
|
+
const thisKeyString = this.toString({
|
|
2176
|
+
showMinor: false
|
|
2177
|
+
});
|
|
2151
2178
|
if (enharmonics && enharmonics[thisKeyString]) return $bff5407e03fdc8ee$var$Key.parse(enharmonics[thisKeyString]);
|
|
2152
2179
|
}
|
|
2153
2180
|
return this.clone();
|
|
@@ -3228,7 +3255,9 @@ const $26f57998457eb2d4$var$regexes = [
|
|
|
3228
3255
|
* Converts the chord to a string, eg `Esus4/G#` or `1sus4/#3`
|
|
3229
3256
|
* @returns {string} the chord string
|
|
3230
3257
|
*/ toString() {
|
|
3231
|
-
const chordString = this.root.toString(
|
|
3258
|
+
const chordString = this.root.toString({
|
|
3259
|
+
showMinor: false
|
|
3260
|
+
}) + (this.suffix || "");
|
|
3232
3261
|
if (this.bass) return `${chordString}/${this.bass.toString()}`;
|
|
3233
3262
|
return chordString;
|
|
3234
3263
|
}
|
|
@@ -3289,16 +3318,17 @@ const $26f57998457eb2d4$var$regexes = [
|
|
|
3289
3318
|
}
|
|
3290
3319
|
constructor({ base: base = null , modifier: modifier = null , suffix: suffix = null , bassBase: bassBase = null , bassModifier: bassModifier = null , root: root = null , bass: bass = null , }){
|
|
3291
3320
|
this.suffix = (0, $21a34a464e7bc609$export$ed9b06b5ee264ad3)(suffix);
|
|
3321
|
+
const isMinor = suffix && suffix[0] === "m" && suffix.substring(0, 3).toLowerCase() !== "maj";
|
|
3292
3322
|
this.root = root || new (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039)({
|
|
3293
3323
|
note: base,
|
|
3294
3324
|
modifier: modifier,
|
|
3295
|
-
minor:
|
|
3325
|
+
minor: isMinor
|
|
3296
3326
|
});
|
|
3297
3327
|
if (bass) this.bass = bass;
|
|
3298
3328
|
else if (bassBase) this.bass = new (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039)({
|
|
3299
3329
|
note: bassBase,
|
|
3300
3330
|
modifier: bassModifier,
|
|
3301
|
-
minor:
|
|
3331
|
+
minor: isMinor
|
|
3302
3332
|
});
|
|
3303
3333
|
else this.bass = null;
|
|
3304
3334
|
}
|
package/lib/index.js
CHANGED
|
@@ -1799,7 +1799,12 @@ class $8fcf445ea0999053$var$Note {
|
|
|
1799
1799
|
return this._note;
|
|
1800
1800
|
}
|
|
1801
1801
|
toString() {
|
|
1802
|
-
|
|
1802
|
+
switch(this.type){
|
|
1803
|
+
case 0, $af8d31735c159a26$export$1321df9b16c30c6a:
|
|
1804
|
+
return `${this.minor ? this.note.toLowerCase() : this.note.toUpperCase()}`;
|
|
1805
|
+
default:
|
|
1806
|
+
return `${this.note}`;
|
|
1807
|
+
}
|
|
1803
1808
|
}
|
|
1804
1809
|
set(attributes) {
|
|
1805
1810
|
return new $8fcf445ea0999053$var$Note({
|
|
@@ -2028,6 +2033,7 @@ class $bff5407e03fdc8ee$var$Key {
|
|
|
2028
2033
|
this.note = note instanceof (0, $8fcf445ea0999053$export$2e2bcd8739ae039) ? note : (0, $8fcf445ea0999053$export$2e2bcd8739ae039).parse(note);
|
|
2029
2034
|
this.modifier = modifier || null;
|
|
2030
2035
|
this.minor = !!minor || false;
|
|
2036
|
+
if (this.minor) this.note.minor = true;
|
|
2031
2037
|
}
|
|
2032
2038
|
isMinor() {
|
|
2033
2039
|
return this.minor || this.note.isMinor();
|
|
@@ -2078,8 +2084,25 @@ class $bff5407e03fdc8ee$var$Key {
|
|
|
2078
2084
|
toNumeralString(key = null) {
|
|
2079
2085
|
return this.toNumeral(key).toString();
|
|
2080
2086
|
}
|
|
2081
|
-
toString() {
|
|
2082
|
-
|
|
2087
|
+
toString({ showMinor: showMinor = true } = {}) {
|
|
2088
|
+
switch(this.note.type){
|
|
2089
|
+
case 0, $af8d31735c159a26$export$27c95a7104c1f7aa:
|
|
2090
|
+
return this.formatChordSymbolString(showMinor);
|
|
2091
|
+
case 0, $af8d31735c159a26$export$4d318981b5a83836:
|
|
2092
|
+
return this.formatNumericString(showMinor);
|
|
2093
|
+
case 0, $af8d31735c159a26$export$1321df9b16c30c6a:
|
|
2094
|
+
return this.formatNumeralString();
|
|
2095
|
+
default:
|
|
2096
|
+
throw new Error(`Unexpected note type ${this.note.type}`);
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
formatChordSymbolString(showMinor) {
|
|
2100
|
+
return `${this.note}${this.modifier || ""}${this.minor && showMinor ? "m" : ""}`;
|
|
2101
|
+
}
|
|
2102
|
+
formatNumericString(showMinor) {
|
|
2103
|
+
return `${this.modifier || ""}${this.note}${this.minor && showMinor ? "m" : ""}`;
|
|
2104
|
+
}
|
|
2105
|
+
formatNumeralString() {
|
|
2083
2106
|
return `${this.modifier || ""}${this.note}`;
|
|
2084
2107
|
}
|
|
2085
2108
|
transpose(delta) {
|
|
@@ -2144,9 +2167,13 @@ class $bff5407e03fdc8ee$var$Key {
|
|
|
2144
2167
|
}
|
|
2145
2168
|
normalizeEnharmonics(key) {
|
|
2146
2169
|
if (key) {
|
|
2147
|
-
const rootKeyString =
|
|
2170
|
+
const rootKeyString = $bff5407e03fdc8ee$var$Key.wrap(key).toString({
|
|
2171
|
+
showMinor: true
|
|
2172
|
+
});
|
|
2148
2173
|
const enharmonics = (0, $6ebb068142750218$export$2e2bcd8739ae039)[rootKeyString];
|
|
2149
|
-
const thisKeyString = this.toString(
|
|
2174
|
+
const thisKeyString = this.toString({
|
|
2175
|
+
showMinor: false
|
|
2176
|
+
});
|
|
2150
2177
|
if (enharmonics && enharmonics[thisKeyString]) return $bff5407e03fdc8ee$var$Key.parse(enharmonics[thisKeyString]);
|
|
2151
2178
|
}
|
|
2152
2179
|
return this.clone();
|
|
@@ -3227,7 +3254,9 @@ const $26f57998457eb2d4$var$regexes = [
|
|
|
3227
3254
|
* Converts the chord to a string, eg `Esus4/G#` or `1sus4/#3`
|
|
3228
3255
|
* @returns {string} the chord string
|
|
3229
3256
|
*/ toString() {
|
|
3230
|
-
const chordString = this.root.toString(
|
|
3257
|
+
const chordString = this.root.toString({
|
|
3258
|
+
showMinor: false
|
|
3259
|
+
}) + (this.suffix || "");
|
|
3231
3260
|
if (this.bass) return `${chordString}/${this.bass.toString()}`;
|
|
3232
3261
|
return chordString;
|
|
3233
3262
|
}
|
|
@@ -3288,16 +3317,17 @@ const $26f57998457eb2d4$var$regexes = [
|
|
|
3288
3317
|
}
|
|
3289
3318
|
constructor({ base: base = null , modifier: modifier = null , suffix: suffix = null , bassBase: bassBase = null , bassModifier: bassModifier = null , root: root = null , bass: bass = null , }){
|
|
3290
3319
|
this.suffix = (0, $21a34a464e7bc609$export$ed9b06b5ee264ad3)(suffix);
|
|
3320
|
+
const isMinor = suffix && suffix[0] === "m" && suffix.substring(0, 3).toLowerCase() !== "maj";
|
|
3291
3321
|
this.root = root || new (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039)({
|
|
3292
3322
|
note: base,
|
|
3293
3323
|
modifier: modifier,
|
|
3294
|
-
minor:
|
|
3324
|
+
minor: isMinor
|
|
3295
3325
|
});
|
|
3296
3326
|
if (bass) this.bass = bass;
|
|
3297
3327
|
else if (bassBase) this.bass = new (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039)({
|
|
3298
3328
|
note: bassBase,
|
|
3299
3329
|
modifier: bassModifier,
|
|
3300
|
-
minor:
|
|
3330
|
+
minor: isMinor
|
|
3301
3331
|
});
|
|
3302
3332
|
else this.bass = null;
|
|
3303
3333
|
}
|