chordsheetjs 12.3.0 → 12.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/README.md +1 -1
- package/lib/bundle.js +88 -67
- package/lib/bundle.min.js +44 -44
- package/lib/index.js +95 -75
- package/lib/index.js.map +1 -1
- package/lib/main.d.ts +16 -15
- package/lib/main.d.ts.map +1 -1
- package/lib/module.js +95 -75
- package/lib/module.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ChordSheetJS [](https://github.com/martijnversluis/ChordSheetJS/actions/workflows/ci.yml?query=branch%3Amaster) [](https://github.com/martijnversluis/ChordSheetJS/actions/workflows/release.yml)
|
|
2
2
|
|
|
3
3
|
A JavaScript library for parsing and formatting chord sheets
|
|
4
4
|
|
package/lib/bundle.js
CHANGED
|
@@ -5452,43 +5452,43 @@ ${error.stack}`);
|
|
|
5452
5452
|
var $cbaaf2a368d4190f$export$2e2bcd8739ae039 = $cbaaf2a368d4190f$var$LineExpander;
|
|
5453
5453
|
var $9047ab737bb447ce$var$MetadataAccessors = class {
|
|
5454
5454
|
get key() {
|
|
5455
|
-
return this.
|
|
5455
|
+
return this.getSingleMetadataValue((0, $d21c5c7a462f3c34$export$7167c830cefcb6b5));
|
|
5456
5456
|
}
|
|
5457
5457
|
get title() {
|
|
5458
|
-
return this.
|
|
5458
|
+
return this.getSingleMetadataValue((0, $d21c5c7a462f3c34$export$f1e53f710478ceb4));
|
|
5459
5459
|
}
|
|
5460
5460
|
get subtitle() {
|
|
5461
|
-
return this.
|
|
5461
|
+
return this.getSingleMetadataValue((0, $d21c5c7a462f3c34$export$5895c693c74b9cf4));
|
|
5462
5462
|
}
|
|
5463
5463
|
get capo() {
|
|
5464
|
-
return this.
|
|
5464
|
+
return this.getMetadataValue((0, $d21c5c7a462f3c34$export$866f445d49bad88e));
|
|
5465
5465
|
}
|
|
5466
5466
|
get duration() {
|
|
5467
|
-
return this.
|
|
5467
|
+
return this.getSingleMetadataValue((0, $d21c5c7a462f3c34$export$bacc88974c736870));
|
|
5468
5468
|
}
|
|
5469
5469
|
get tempo() {
|
|
5470
|
-
return this.
|
|
5470
|
+
return this.getSingleMetadataValue((0, $d21c5c7a462f3c34$export$bd8d57d0bc5a8478));
|
|
5471
5471
|
}
|
|
5472
5472
|
get time() {
|
|
5473
|
-
return this.
|
|
5473
|
+
return this.getMetadataValue((0, $d21c5c7a462f3c34$export$a9905336c0111a3a));
|
|
5474
5474
|
}
|
|
5475
5475
|
get year() {
|
|
5476
|
-
return this.
|
|
5476
|
+
return this.getSingleMetadataValue((0, $d21c5c7a462f3c34$export$90b88dc425a06a95));
|
|
5477
5477
|
}
|
|
5478
5478
|
get album() {
|
|
5479
|
-
return this.
|
|
5479
|
+
return this.getMetadataValue((0, $d21c5c7a462f3c34$export$10227cb086d1770c));
|
|
5480
5480
|
}
|
|
5481
5481
|
get copyright() {
|
|
5482
|
-
return this.
|
|
5482
|
+
return this.getSingleMetadataValue((0, $d21c5c7a462f3c34$export$4ab8c75045d12480));
|
|
5483
5483
|
}
|
|
5484
5484
|
get lyricist() {
|
|
5485
|
-
return this.
|
|
5485
|
+
return this.getMetadataValue((0, $d21c5c7a462f3c34$export$a6901bd008617c61));
|
|
5486
5486
|
}
|
|
5487
5487
|
get artist() {
|
|
5488
|
-
return this.
|
|
5488
|
+
return this.getMetadataValue((0, $d21c5c7a462f3c34$export$17d8dfb3db842bf));
|
|
5489
5489
|
}
|
|
5490
5490
|
get composer() {
|
|
5491
|
-
return this.
|
|
5491
|
+
return this.getMetadataValue((0, $d21c5c7a462f3c34$export$98424633dc8c377f));
|
|
5492
5492
|
}
|
|
5493
5493
|
};
|
|
5494
5494
|
var $9047ab737bb447ce$export$2e2bcd8739ae039 = $9047ab737bb447ce$var$MetadataAccessors;
|
|
@@ -5533,10 +5533,10 @@ ${error.stack}`);
|
|
|
5533
5533
|
if (value) this.metadata[key] = value;
|
|
5534
5534
|
else delete this.metadata[key];
|
|
5535
5535
|
}
|
|
5536
|
-
|
|
5536
|
+
getMetadataValue(name) {
|
|
5537
5537
|
return this.get(name);
|
|
5538
5538
|
}
|
|
5539
|
-
|
|
5539
|
+
getSingleMetadataValue(name) {
|
|
5540
5540
|
return this.getSingle(name);
|
|
5541
5541
|
}
|
|
5542
5542
|
/**
|
|
@@ -5839,7 +5839,6 @@ ${error.stack}`);
|
|
|
5839
5839
|
this.warnings = [];
|
|
5840
5840
|
this.song = song;
|
|
5841
5841
|
this.song.lines = this.lines;
|
|
5842
|
-
this.song.metadata = this.metadata;
|
|
5843
5842
|
this.song.warnings = this.warnings;
|
|
5844
5843
|
}
|
|
5845
5844
|
get previousLine() {
|
|
@@ -5855,7 +5854,7 @@ ${error.stack}`);
|
|
|
5855
5854
|
}
|
|
5856
5855
|
this.setCurrentProperties(this.sectionType, this.selector);
|
|
5857
5856
|
this.currentLine.transposeKey = this.transposeKey ?? this.currentKey;
|
|
5858
|
-
this.currentLine.key = this.currentKey || this.
|
|
5857
|
+
this.currentLine.key = this.currentKey || this.song.getMetadata().getSingle((0, $d21c5c7a462f3c34$export$7167c830cefcb6b5));
|
|
5859
5858
|
this.currentLine.lineNumber = this.lines.length - 1;
|
|
5860
5859
|
return this.currentLine;
|
|
5861
5860
|
}
|
|
@@ -5893,8 +5892,7 @@ ${error.stack}`);
|
|
|
5893
5892
|
if (this.currentLine === null) this.addLine();
|
|
5894
5893
|
}
|
|
5895
5894
|
applyTagOnSong(tag) {
|
|
5896
|
-
if (tag.
|
|
5897
|
-
else if (tag.name === (0, $d21c5c7a462f3c34$export$ae60ab9b4739fc3d)) this.transposeKey = tag.value;
|
|
5895
|
+
if (tag.name === (0, $d21c5c7a462f3c34$export$ae60ab9b4739fc3d)) this.transposeKey = tag.value;
|
|
5898
5896
|
else if (tag.name === (0, $d21c5c7a462f3c34$export$b7627374a6424f68)) this.currentKey = tag.value;
|
|
5899
5897
|
else if (tag.isSectionDelimiter()) this.setSectionTypeFromTag(tag);
|
|
5900
5898
|
else if (tag.isInlineFontTag()) this.fontStack.applyTag(tag);
|
|
@@ -5904,9 +5902,6 @@ ${error.stack}`);
|
|
|
5904
5902
|
if (!this.currentLine) throw new Error("Expected this.currentLine to be present");
|
|
5905
5903
|
this.currentLine.addTag(tag);
|
|
5906
5904
|
}
|
|
5907
|
-
setMetadata(name, value) {
|
|
5908
|
-
this.metadata.add(name, value);
|
|
5909
|
-
}
|
|
5910
5905
|
setSectionTypeFromTag(tag) {
|
|
5911
5906
|
const [tagType, sectionType] = (0, $35ced0783ee29c4f$export$2e2bcd8739ae039).interpret(tag.name, tag.value);
|
|
5912
5907
|
if (!sectionType) return;
|
|
@@ -5934,6 +5929,42 @@ ${error.stack}`);
|
|
|
5934
5929
|
}
|
|
5935
5930
|
};
|
|
5936
5931
|
var $69c885ea9d252cfd$export$2e2bcd8739ae039 = $69c885ea9d252cfd$var$SongBuilder;
|
|
5932
|
+
var $feda9c006f56d800$var$SongMapper = class {
|
|
5933
|
+
constructor(song) {
|
|
5934
|
+
this.addedLine = false;
|
|
5935
|
+
this.song = song;
|
|
5936
|
+
this.clonedSong = new (0, $c53141c05fae8382$export$2e2bcd8739ae039)();
|
|
5937
|
+
this.builder = new (0, $69c885ea9d252cfd$export$2e2bcd8739ae039)(this.clonedSong);
|
|
5938
|
+
}
|
|
5939
|
+
mapItems(func) {
|
|
5940
|
+
this.song.lines.forEach((line) => {
|
|
5941
|
+
this.mapLineItems(line, func);
|
|
5942
|
+
});
|
|
5943
|
+
return this.clonedSong;
|
|
5944
|
+
}
|
|
5945
|
+
mapLineItems(line, func) {
|
|
5946
|
+
line.items.forEach((item) => {
|
|
5947
|
+
this.mapItem(func, item);
|
|
5948
|
+
});
|
|
5949
|
+
if (line.isEmpty()) this.ensureLine();
|
|
5950
|
+
this.addedLine = false;
|
|
5951
|
+
}
|
|
5952
|
+
mapItem(func, item) {
|
|
5953
|
+
const changedItem = func(item);
|
|
5954
|
+
if (changedItem === null) return;
|
|
5955
|
+
const isArray = Array.isArray(changedItem);
|
|
5956
|
+
if (!isArray || changedItem.length > 0) this.ensureLine();
|
|
5957
|
+
if (isArray) changedItem.forEach((i) => this.builder.addItem(i));
|
|
5958
|
+
else this.builder.addItem(changedItem);
|
|
5959
|
+
}
|
|
5960
|
+
ensureLine() {
|
|
5961
|
+
if (!this.addedLine) {
|
|
5962
|
+
this.builder.addLine();
|
|
5963
|
+
this.addedLine = true;
|
|
5964
|
+
}
|
|
5965
|
+
}
|
|
5966
|
+
};
|
|
5967
|
+
var $feda9c006f56d800$export$2e2bcd8739ae039 = $feda9c006f56d800$var$SongMapper;
|
|
5937
5968
|
var $e02a17f5a26edf19$var$defaultConstructorOptions = {
|
|
5938
5969
|
capo: 0,
|
|
5939
5970
|
contextKey: null,
|
|
@@ -6029,54 +6060,18 @@ ${error.stack}`);
|
|
|
6029
6060
|
const metadataValueTruthy = metadataValue && metadataValue !== "";
|
|
6030
6061
|
return isNegated ? !metadataValueTruthy : !!metadataValueTruthy;
|
|
6031
6062
|
}
|
|
6032
|
-
var $feda9c006f56d800$var$SongMapper = class {
|
|
6033
|
-
constructor(song) {
|
|
6034
|
-
this.addedLine = false;
|
|
6035
|
-
this.song = song;
|
|
6036
|
-
this.clonedSong = new (0, $c53141c05fae8382$export$2e2bcd8739ae039)();
|
|
6037
|
-
this.builder = new (0, $69c885ea9d252cfd$export$2e2bcd8739ae039)(this.clonedSong);
|
|
6038
|
-
}
|
|
6039
|
-
mapItems(func) {
|
|
6040
|
-
this.song.lines.forEach((line) => {
|
|
6041
|
-
this.mapLineItems(line, func);
|
|
6042
|
-
});
|
|
6043
|
-
return this.clonedSong;
|
|
6044
|
-
}
|
|
6045
|
-
mapLineItems(line, func) {
|
|
6046
|
-
line.items.forEach((item) => {
|
|
6047
|
-
this.mapItem(func, item);
|
|
6048
|
-
});
|
|
6049
|
-
if (line.isEmpty()) this.ensureLine();
|
|
6050
|
-
this.addedLine = false;
|
|
6051
|
-
}
|
|
6052
|
-
mapItem(func, item) {
|
|
6053
|
-
const changedItem = func(item);
|
|
6054
|
-
if (changedItem === null) return;
|
|
6055
|
-
const isArray = Array.isArray(changedItem);
|
|
6056
|
-
if (!isArray || changedItem.length > 0) this.ensureLine();
|
|
6057
|
-
if (isArray) changedItem.forEach((i) => this.builder.addItem(i));
|
|
6058
|
-
else this.builder.addItem(changedItem);
|
|
6059
|
-
}
|
|
6060
|
-
ensureLine() {
|
|
6061
|
-
if (!this.addedLine) {
|
|
6062
|
-
this.builder.addLine();
|
|
6063
|
-
this.addedLine = true;
|
|
6064
|
-
}
|
|
6065
|
-
}
|
|
6066
|
-
};
|
|
6067
|
-
var $feda9c006f56d800$export$2e2bcd8739ae039 = $feda9c006f56d800$var$SongMapper;
|
|
6068
6063
|
var $c53141c05fae8382$var$Song = class _$c53141c05fae8382$var$Song extends (0, $9047ab737bb447ce$export$2e2bcd8739ae039) {
|
|
6069
6064
|
/**
|
|
6070
6065
|
* Creates a new {Song} instance
|
|
6071
6066
|
* @param metadata {Record<string, string | string[]>|Metadata} predefined metadata
|
|
6072
6067
|
*/
|
|
6073
|
-
constructor(metadata =
|
|
6068
|
+
constructor(metadata = null) {
|
|
6074
6069
|
super(), /**
|
|
6075
6070
|
* The {@link Line} items of which the song consists
|
|
6076
6071
|
* @member {Line[]}
|
|
6077
6072
|
*/
|
|
6078
|
-
this.lines = [], this._bodyLines = null, this._bodyParagraphs = null, this.warnings = [];
|
|
6079
|
-
this.
|
|
6073
|
+
this.lines = [], this._bodyLines = null, this._bodyParagraphs = null, this.warnings = [], this._metadata = null;
|
|
6074
|
+
if (metadata) this._metadata = new (0, $5c7afec93ec943b9$export$2e2bcd8739ae039)(metadata);
|
|
6080
6075
|
}
|
|
6081
6076
|
/**
|
|
6082
6077
|
* Returns the song lines, skipping the leading empty lines (empty as in not rendering any content). This is useful
|
|
@@ -6138,18 +6133,17 @@ ${error.stack}`);
|
|
|
6138
6133
|
*/
|
|
6139
6134
|
clone() {
|
|
6140
6135
|
const clone = new _$c53141c05fae8382$var$Song();
|
|
6141
|
-
clone.metadata = this.metadata.clone();
|
|
6142
6136
|
clone.warnings = [
|
|
6143
6137
|
...this.warnings
|
|
6144
6138
|
];
|
|
6145
6139
|
clone.lines = this.lines.map((line) => line.clone());
|
|
6146
6140
|
return clone;
|
|
6147
6141
|
}
|
|
6148
|
-
|
|
6149
|
-
return this.metadata.
|
|
6142
|
+
getMetadataValue(name) {
|
|
6143
|
+
return this.metadata.getMetadataValue(name);
|
|
6150
6144
|
}
|
|
6151
|
-
|
|
6152
|
-
return this.metadata.
|
|
6145
|
+
getSingleMetadataValue(name) {
|
|
6146
|
+
return this.metadata.getSingleMetadataValue(name);
|
|
6153
6147
|
}
|
|
6154
6148
|
/**
|
|
6155
6149
|
* Returns a copy of the song with the key value set to the specified key. It changes:
|
|
@@ -6430,6 +6424,33 @@ Or set the song key before changing key:
|
|
|
6430
6424
|
});
|
|
6431
6425
|
return chordDefinitions;
|
|
6432
6426
|
}
|
|
6427
|
+
/**
|
|
6428
|
+
* The song's metadata. When there is only one value for an entry, the value is a string. Else, the value is
|
|
6429
|
+
* an array containing all unique values for the entry.
|
|
6430
|
+
* @type {Metadata}
|
|
6431
|
+
*/
|
|
6432
|
+
get metadata() {
|
|
6433
|
+
if (!this._metadata) this._metadata = this.getMetadata();
|
|
6434
|
+
return this._metadata;
|
|
6435
|
+
}
|
|
6436
|
+
getMetadata(configuration) {
|
|
6437
|
+
const metadata = new (0, $5c7afec93ec943b9$export$2e2bcd8739ae039)();
|
|
6438
|
+
this.foreachItem((item) => {
|
|
6439
|
+
if (!(item instanceof (0, $7251dad5f4a4c35f$export$2e2bcd8739ae039))) return;
|
|
6440
|
+
const tag = item;
|
|
6441
|
+
if (!tag.isMetaTag()) return;
|
|
6442
|
+
const { selector, isNegated } = tag;
|
|
6443
|
+
if (selector && configuration && !(0, $2ce1086ce25c9ac0$export$efb38dd75b8e2957)({
|
|
6444
|
+
selector,
|
|
6445
|
+
isNegated
|
|
6446
|
+
}, {
|
|
6447
|
+
metadata,
|
|
6448
|
+
configuration
|
|
6449
|
+
})) return;
|
|
6450
|
+
metadata.add(item.name, item.value);
|
|
6451
|
+
});
|
|
6452
|
+
return metadata;
|
|
6453
|
+
}
|
|
6433
6454
|
get chordDefinitions() {
|
|
6434
6455
|
return new (0, $4ff43932a550a629$export$2e2bcd8739ae039)(this.getChordDefinitions());
|
|
6435
6456
|
}
|
|
@@ -23522,7 +23543,7 @@ Or set the song key before changing key:
|
|
|
23522
23543
|
}
|
|
23523
23544
|
};
|
|
23524
23545
|
var $a5a21ced491ea51f$export$2e2bcd8739ae039 = $a5a21ced491ea51f$var$UltimateGuitarParser;
|
|
23525
|
-
var $ae92e002ce14f11a$export$2e2bcd8739ae039 = "12.3.
|
|
23546
|
+
var $ae92e002ce14f11a$export$2e2bcd8739ae039 = "12.3.1";
|
|
23526
23547
|
var $892913528e7f60f9$export$2e2bcd8739ae039 = {
|
|
23527
23548
|
CHORUS: $dce48cb70c4120bb$export$8db6c706fc9142b2,
|
|
23528
23549
|
Chord: $177a605b8569b31c$export$2e2bcd8739ae039,
|