chordsheetjs 13.2.2 → 14.0.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 CHANGED
@@ -68762,15 +68762,24 @@ AjwCRQJ5AAAAAAABAAAAANpTmfAAAAAA0e+yRgAAAADR77JG
68762
68762
  };
68763
68763
  var $f6d6d454eefadbec$export$2e2bcd8739ae039 = $f6d6d454eefadbec$var$PdfFormatter;
68764
68764
  var $a5a21ced491ea51f$var$VERSE_LINE_REGEX = /^\[(Verse.*)]/i;
68765
- var $a5a21ced491ea51f$var$CHORUS_LINE_REGEX = /^\[(Chorus)]/i;
68765
+ var $a5a21ced491ea51f$var$CHORUS_LINE_REGEX = /^\[(Chorus.*)]/i;
68766
+ var $a5a21ced491ea51f$var$BRIDGE_LINE_REGEX = /^\[(Bridge.*)]/i;
68767
+ var $a5a21ced491ea51f$var$PART_LINE_REGEX = /^\[(Intro|Outro|Instrumental|Interlude|Solo|Pre-Chorus)( \d+)?]/i;
68768
+ var $a5a21ced491ea51f$var$UG_METADATA_REGEX = /^(\w+):\s*(.+)$/;
68766
68769
  var $a5a21ced491ea51f$var$OTHER_METADATA_LINE_REGEX = /^\[([^\]]+)]/;
68770
+ var $a5a21ced491ea51f$var$REPEAT_NOTATION_REGEX = /\s+(x\d+)\s*$/i;
68771
+ var $a5a21ced491ea51f$var$CHORD_LINE_REGEX = /^\s*((([A-G|Do|Re|Mi|Fa|Sol|La|Si])(#|b)?([^/\s]*)(\/([A-G|Do|Re|Mi|Fa|Sol|La|Si])(#|b)?)?)(\s|$)+)+(\s|$)+/;
68767
68772
  var $a5a21ced491ea51f$var$startSectionTags = {
68768
68773
  [(0, $dce48cb70c4120bb$export$4b194284baed1659)]: (0, $d21c5c7a462f3c34$export$deca399f8cd9b7dc),
68769
- [(0, $dce48cb70c4120bb$export$8db6c706fc9142b2)]: (0, $d21c5c7a462f3c34$export$4f5168acae064e01)
68774
+ [(0, $dce48cb70c4120bb$export$8db6c706fc9142b2)]: (0, $d21c5c7a462f3c34$export$4f5168acae064e01),
68775
+ [(0, $dce48cb70c4120bb$export$78d8c50e853acd10)]: (0, $d21c5c7a462f3c34$export$3550cc87694d54e0),
68776
+ [(0, $dce48cb70c4120bb$export$609cc0ea1637d6a0)]: (0, $d21c5c7a462f3c34$export$2b9510a208875fc9)
68770
68777
  };
68771
68778
  var $a5a21ced491ea51f$var$endSectionTags = {
68772
68779
  [(0, $dce48cb70c4120bb$export$4b194284baed1659)]: (0, $d21c5c7a462f3c34$export$640d294ab83f9040),
68773
- [(0, $dce48cb70c4120bb$export$8db6c706fc9142b2)]: (0, $d21c5c7a462f3c34$export$473c1a4819e5180b)
68780
+ [(0, $dce48cb70c4120bb$export$8db6c706fc9142b2)]: (0, $d21c5c7a462f3c34$export$473c1a4819e5180b),
68781
+ [(0, $dce48cb70c4120bb$export$78d8c50e853acd10)]: (0, $d21c5c7a462f3c34$export$1c874e9780385ecd),
68782
+ [(0, $dce48cb70c4120bb$export$609cc0ea1637d6a0)]: (0, $d21c5c7a462f3c34$export$189f12065cceb96a)
68774
68783
  };
68775
68784
  var $a5a21ced491ea51f$var$UltimateGuitarParser = class extends (0, $e136d63bbe28a4e0$export$2e2bcd8739ae039) {
68776
68785
  /**
@@ -68781,11 +68790,111 @@ AjwCRQJ5AAAAAAABAAAAANpTmfAAAAAA0e+yRgAAAADR77JG
68781
68790
  constructor({ preserveWhitespace = true } = {}) {
68782
68791
  super({
68783
68792
  preserveWhitespace
68784
- }, false), this.currentSectionType = null;
68793
+ }, false), this.currentSectionType = null, this.pendingRepeatNotation = null;
68785
68794
  }
68786
68795
  parseLine(line) {
68787
68796
  if (this.isSectionEnd()) this.endSection();
68788
- if (!(this.parseVerseDirective(line) || this.parseChorusDirective(line) || this.parseMetadata(line))) super.parseLine(line);
68797
+ const { cleanLine, repeatNotation } = this.extractRepeatNotation(line);
68798
+ this.pendingRepeatNotation = repeatNotation;
68799
+ if (!(this.parseVerseDirective(cleanLine) || this.parseChorusDirective(cleanLine) || this.parseBridgeDirective(cleanLine) || this.parsePartDirective(cleanLine) || this.parseUGMetadata(cleanLine) || this.parseMetadata(cleanLine))) this.parseRegularLine(cleanLine);
68800
+ }
68801
+ parseRegularLine(line) {
68802
+ this.songLine = this.songBuilder.addLine();
68803
+ if (line.trim().length === 0) this.chordLyricsPair = null;
68804
+ else this.parseNonEmptyLine(line);
68805
+ }
68806
+ parseNonEmptyLine(line) {
68807
+ if (!this.songLine) throw new Error("Expected this.songLine to be present");
68808
+ this.chordLyricsPair = this.songLine.addChordLyricsPair();
68809
+ const isChordLine = $a5a21ced491ea51f$var$CHORD_LINE_REGEX.test(line);
68810
+ if (isChordLine && this.hasNextLine()) this.parseChordLineWithNextLine(line);
68811
+ else if (isChordLine) this.parseChordsOnly(line);
68812
+ else this.chordLyricsPair.lyrics = `${line}`;
68813
+ }
68814
+ parseChordLineWithNextLine(chordsLine) {
68815
+ const nextLine = this.readLine();
68816
+ if (this.isNonLyricsLine(nextLine)) {
68817
+ this.parseChordsOnly(chordsLine);
68818
+ this.unreadLine();
68819
+ } else this.parseLyricsWithChords(chordsLine, nextLine);
68820
+ }
68821
+ unreadLine() {
68822
+ this.currentLine -= 1;
68823
+ }
68824
+ isNonLyricsLine(line) {
68825
+ return $a5a21ced491ea51f$var$VERSE_LINE_REGEX.test(line) || $a5a21ced491ea51f$var$CHORUS_LINE_REGEX.test(line) || $a5a21ced491ea51f$var$BRIDGE_LINE_REGEX.test(line) || $a5a21ced491ea51f$var$PART_LINE_REGEX.test(line) || $a5a21ced491ea51f$var$OTHER_METADATA_LINE_REGEX.test(line) || $a5a21ced491ea51f$var$CHORD_LINE_REGEX.test(line) || line.trim().length === 0;
68826
+ }
68827
+ parseChordsOnly(chordsLine) {
68828
+ this.parseLyricsWithChords(chordsLine, "");
68829
+ this.applyRepeatNotation();
68830
+ }
68831
+ parseLyricsWithChords(chordsLine, lyricsLine) {
68832
+ this.processCharacters(chordsLine, lyricsLine);
68833
+ if (!this.chordLyricsPair) throw new Error("Expected this.chordLyricsPair to be present");
68834
+ this.chordLyricsPair.lyrics += lyricsLine.substring(chordsLine.length);
68835
+ this.chordLyricsPair.chords = this.chordLyricsPair.chords.trim();
68836
+ if (this.chordLyricsPair.lyrics) this.chordLyricsPair.lyrics = this.chordLyricsPair.lyrics.trim();
68837
+ this.applyRepeatNotation();
68838
+ }
68839
+ processCharacters(chordsLine, lyricsLine) {
68840
+ for (let c4 = 0, charCount = chordsLine.length; c4 < charCount; c4 += 1) {
68841
+ const chr = chordsLine[c4];
68842
+ const nextChar = chordsLine[c4 + 1];
68843
+ const isWhiteSpace = /\s/.test(chr);
68844
+ this.addCharacter(chr, nextChar);
68845
+ if (!this.chordLyricsPair) throw new Error("Expected this.chordLyricsPair to be present");
68846
+ this.chordLyricsPair.lyrics += lyricsLine[c4] || "";
68847
+ this.processingText = !isWhiteSpace;
68848
+ }
68849
+ }
68850
+ addCharacter(chr, nextChar) {
68851
+ const isWhiteSpace = /\s/.test(chr);
68852
+ if (!isWhiteSpace) this.ensureChordLyricsPairInitialized();
68853
+ if (!isWhiteSpace || this.shouldAddCharacterToChords(nextChar)) {
68854
+ if (!this.chordLyricsPair) throw new Error("Expected this.chordLyricsPair to be present");
68855
+ this.chordLyricsPair.chords += chr;
68856
+ }
68857
+ }
68858
+ shouldAddCharacterToChords(nextChar) {
68859
+ return !!(nextChar && /\s/.test(nextChar) && this.preserveWhitespace);
68860
+ }
68861
+ ensureChordLyricsPairInitialized() {
68862
+ if (!this.processingText) {
68863
+ if (!this.songLine) throw new Error("Expected this.songLine to be present");
68864
+ this.chordLyricsPair = this.songLine.addChordLyricsPair();
68865
+ this.processingText = true;
68866
+ }
68867
+ }
68868
+ extractRepeatNotation(line) {
68869
+ const match = line.match($a5a21ced491ea51f$var$REPEAT_NOTATION_REGEX);
68870
+ if (match) return {
68871
+ cleanLine: line.replace($a5a21ced491ea51f$var$REPEAT_NOTATION_REGEX, ""),
68872
+ repeatNotation: match[1]
68873
+ };
68874
+ return {
68875
+ cleanLine: line,
68876
+ repeatNotation: null
68877
+ };
68878
+ }
68879
+ applyRepeatNotation() {
68880
+ if (!this.pendingRepeatNotation || !this.songLine) return;
68881
+ const lastItem = this.songLine.items[this.songLine.items.length - 1];
68882
+ if (lastItem && "lyrics" in lastItem) lastItem.lyrics = (lastItem.lyrics || "") + this.pendingRepeatNotation;
68883
+ this.pendingRepeatNotation = null;
68884
+ }
68885
+ parseUGMetadata(line) {
68886
+ const match = line.match($a5a21ced491ea51f$var$UG_METADATA_REGEX);
68887
+ if (!match) return false;
68888
+ const tagName = match[1].toLowerCase();
68889
+ if (!(0, $7251dad5f4a4c35f$export$57ecf0dc09effb3).includes(tagName)) return false;
68890
+ const value = tagName === (0, $d21c5c7a462f3c34$export$866f445d49bad88e) ? this.extractCapoValue(match[2]) : match[2].trim();
68891
+ this.startNewLine();
68892
+ this.songBuilder.addTag(new (0, $7251dad5f4a4c35f$export$2e2bcd8739ae039)(tagName, value));
68893
+ return true;
68894
+ }
68895
+ extractCapoValue(rawValue) {
68896
+ const [, capoNumber] = rawValue.match(/^(\d+)/) || [];
68897
+ return capoNumber || rawValue.trim();
68789
68898
  }
68790
68899
  parseVerseDirective(line) {
68791
68900
  const match = line.match($a5a21ced491ea51f$var$VERSE_LINE_REGEX);
@@ -68803,6 +68912,22 @@ AjwCRQJ5AAAAAAABAAAAANpTmfAAAAAA0e+yRgAAAADR77JG
68803
68912
  this.startSection((0, $dce48cb70c4120bb$export$8db6c706fc9142b2), label);
68804
68913
  return true;
68805
68914
  }
68915
+ parseBridgeDirective(line) {
68916
+ const match = line.match($a5a21ced491ea51f$var$BRIDGE_LINE_REGEX);
68917
+ if (!match) return false;
68918
+ this.startNewLine();
68919
+ const label = match[1];
68920
+ this.startSection((0, $dce48cb70c4120bb$export$78d8c50e853acd10), label);
68921
+ return true;
68922
+ }
68923
+ parsePartDirective(line) {
68924
+ const match = line.match($a5a21ced491ea51f$var$PART_LINE_REGEX);
68925
+ if (!match) return false;
68926
+ this.startNewLine();
68927
+ const label = match[1] + (match[2] || "");
68928
+ this.startSection((0, $dce48cb70c4120bb$export$609cc0ea1637d6a0), label);
68929
+ return true;
68930
+ }
68806
68931
  parseMetadata(line) {
68807
68932
  const match = line.match($a5a21ced491ea51f$var$OTHER_METADATA_LINE_REGEX);
68808
68933
  if (!match) return false;
@@ -68830,7 +68955,11 @@ AjwCRQJ5AAAAAAABAAAAANpTmfAAAAAA0e+yRgAAAADR77JG
68830
68955
  }
68831
68956
  endSection({ addNewLine = true } = {}) {
68832
68957
  if (this.currentSectionType !== null && this.currentSectionType in $a5a21ced491ea51f$var$endSectionTags) {
68833
- this.songBuilder.addTag(new (0, $7251dad5f4a4c35f$export$2e2bcd8739ae039)($a5a21ced491ea51f$var$endSectionTags[this.currentSectionType]));
68958
+ if (this.songLine && this.songLine.isEmpty()) this.songLine.addTag(new (0, $7251dad5f4a4c35f$export$2e2bcd8739ae039)($a5a21ced491ea51f$var$endSectionTags[this.currentSectionType]));
68959
+ else {
68960
+ const endTagLine = this.songBuilder.addLine();
68961
+ endTagLine.addTag(new (0, $7251dad5f4a4c35f$export$2e2bcd8739ae039)($a5a21ced491ea51f$var$endSectionTags[this.currentSectionType]));
68962
+ }
68834
68963
  if (addNewLine) this.startNewLine();
68835
68964
  }
68836
68965
  this.songBuilder.setCurrentProperties((0, $dce48cb70c4120bb$export$c53d0f541b41b88e));
@@ -68841,7 +68970,7 @@ AjwCRQJ5AAAAAAABAAAAANpTmfAAAAAA0e+yRgAAAADR77JG
68841
68970
  }
68842
68971
  };
68843
68972
  var $a5a21ced491ea51f$export$2e2bcd8739ae039 = $a5a21ced491ea51f$var$UltimateGuitarParser;
68844
- var $ae92e002ce14f11a$export$2e2bcd8739ae039 = "13.2.2";
68973
+ var $ae92e002ce14f11a$export$2e2bcd8739ae039 = "14.0.0";
68845
68974
  var $a3816b486f741c00$exports = {};
68846
68975
  var $892913528e7f60f9$export$2e2bcd8739ae039 = {
68847
68976
  CHORUS: $dce48cb70c4120bb$export$8db6c706fc9142b2,