chordsheetjs 6.0.0 → 6.2.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.
Files changed (42) hide show
  1. package/README.md +477 -539
  2. package/lib/bundle.js +15353 -0
  3. package/lib/index.js +6253 -216
  4. package/lib/index.js.map +1 -0
  5. package/lib/main.d.ts +1062 -0
  6. package/lib/main.d.ts.map +1 -0
  7. package/package.json +50 -23
  8. package/d7b54993c4ea66c07a35bd36690482ab620f836e.patch +0 -105
  9. package/lib/chord.js +0 -496
  10. package/lib/chord_sheet/chord_lyrics_pair.js +0 -75
  11. package/lib/chord_sheet/chord_pro/composite.js +0 -54
  12. package/lib/chord_sheet/chord_pro/evaluation_error.js +0 -58
  13. package/lib/chord_sheet/chord_pro/literal.js +0 -42
  14. package/lib/chord_sheet/chord_pro/ternary.js +0 -126
  15. package/lib/chord_sheet/comment.js +0 -55
  16. package/lib/chord_sheet/line.js +0 -185
  17. package/lib/chord_sheet/metadata.js +0 -202
  18. package/lib/chord_sheet/paragraph.js +0 -88
  19. package/lib/chord_sheet/song.js +0 -353
  20. package/lib/chord_sheet/tag.js +0 -345
  21. package/lib/chord_sheet_serializer.js +0 -278
  22. package/lib/constants.js +0 -54
  23. package/lib/formatter/chord_pro_formatter.js +0 -184
  24. package/lib/formatter/html_div_formatter.js +0 -130
  25. package/lib/formatter/html_formatter.js +0 -44
  26. package/lib/formatter/html_table_formatter.js +0 -154
  27. package/lib/formatter/templates/html_div_formatter.js +0 -544
  28. package/lib/formatter/templates/html_table_formatter.js +0 -731
  29. package/lib/formatter/text_formatter.js +0 -184
  30. package/lib/helpers.js +0 -32
  31. package/lib/key.js +0 -386
  32. package/lib/normalize_mappings/enharmonic-normalize.js +0 -124
  33. package/lib/normalize_mappings/generate-suffix-normalize-mapping.js +0 -36
  34. package/lib/normalize_mappings/suffix-normalize-mapping.js +0 -914
  35. package/lib/note.js +0 -264
  36. package/lib/parser/chord_pro_parser.js +0 -64
  37. package/lib/parser/chord_pro_peg_parser.js +0 -2069
  38. package/lib/parser/chord_sheet_parser.js +0 -175
  39. package/lib/parser/parser_warning.js +0 -62
  40. package/lib/parser/ultimate_guitar_parser.js +0 -154
  41. package/lib/template_helpers.js +0 -98
  42. package/lib/utilities.js +0 -110
@@ -1,175 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _song = _interopRequireDefault(require("../chord_sheet/song"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
-
12
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13
-
14
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
15
-
16
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
-
18
- var WHITE_SPACE = /\s/;
19
- var CHORD_LINE_REGEX = /^\s*((([A-G])(#|b)?([^/\s]*)(\/([A-G])(#|b)?)?)(\s|$)+)+(\s|$)+/;
20
- /**
21
- * Parses a normal chord sheet
22
- */
23
-
24
- var ChordSheetParser = /*#__PURE__*/function () {
25
- /**
26
- * Instantiate a chord sheet parser
27
- * @param {Object} options options
28
- * @param {boolean} options.preserveWhitespace whether to preserve trailing whitespace for chords
29
- */
30
- function ChordSheetParser() {
31
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
32
- _ref$preserveWhitespa = _ref.preserveWhitespace,
33
- preserveWhitespace = _ref$preserveWhitespa === void 0 ? true : _ref$preserveWhitespa;
34
-
35
- _classCallCheck(this, ChordSheetParser);
36
-
37
- this.preserveWhitespace = preserveWhitespace === true;
38
- }
39
- /**
40
- * Parses a chord sheet into a song
41
- * @param {string} chordSheet The ChordPro chord sheet
42
- * @param {Object} options Optional parser options
43
- * @param {Song} options.song The {@link Song} to store the song data in
44
- * @returns {Song} The parsed song
45
- */
46
-
47
-
48
- _createClass(ChordSheetParser, [{
49
- key: "parse",
50
- value: function parse(chordSheet) {
51
- var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
52
- _ref2$song = _ref2.song,
53
- song = _ref2$song === void 0 ? null : _ref2$song;
54
-
55
- this.initialize(chordSheet, {
56
- song: song
57
- });
58
-
59
- while (this.hasNextLine()) {
60
- var line = this.readLine();
61
- this.parseLine(line);
62
- }
63
-
64
- this.endOfSong();
65
- this.song.finish();
66
- return this.song;
67
- }
68
- }, {
69
- key: "endOfSong",
70
- value: function endOfSong() {}
71
- }, {
72
- key: "parseLine",
73
- value: function parseLine(line) {
74
- this.songLine = this.song.addLine();
75
-
76
- if (line.trim().length === 0) {
77
- this.chordLyricsPair = null;
78
- } else {
79
- this.parseNonEmptyLine(line);
80
- }
81
- }
82
- }, {
83
- key: "parseNonEmptyLine",
84
- value: function parseNonEmptyLine(line) {
85
- this.chordLyricsPair = this.songLine.addChordLyricsPair();
86
-
87
- if (CHORD_LINE_REGEX.test(line) && this.hasNextLine()) {
88
- var nextLine = this.readLine();
89
- this.parseLyricsWithChords(line, nextLine);
90
- } else {
91
- this.chordLyricsPair.lyrics = "".concat(line);
92
- }
93
- }
94
- }, {
95
- key: "initialize",
96
- value: function initialize(document) {
97
- var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
98
- _ref3$song = _ref3.song,
99
- song = _ref3$song === void 0 ? null : _ref3$song;
100
-
101
- this.song = song || new _song["default"]();
102
- this.lines = document.split('\n');
103
- this.currentLine = 0;
104
- this.lineCount = this.lines.length;
105
- this.processingText = true;
106
- }
107
- }, {
108
- key: "readLine",
109
- value: function readLine() {
110
- var line = this.lines[this.currentLine];
111
- this.currentLine += 1;
112
- return line;
113
- }
114
- }, {
115
- key: "hasNextLine",
116
- value: function hasNextLine() {
117
- return this.currentLine < this.lineCount;
118
- }
119
- }, {
120
- key: "parseLyricsWithChords",
121
- value: function parseLyricsWithChords(chordsLine, lyricsLine) {
122
- this.processCharacters(chordsLine, lyricsLine);
123
- this.chordLyricsPair.lyrics += lyricsLine.substring(chordsLine.length);
124
- this.chordLyricsPair.chords = this.chordLyricsPair.chords.trim();
125
- this.chordLyricsPair.lyrics = this.chordLyricsPair.lyrics.trim();
126
-
127
- if (!lyricsLine.trim().length) {
128
- this.songLine = this.song.addLine();
129
- }
130
- }
131
- }, {
132
- key: "processCharacters",
133
- value: function processCharacters(chordsLine, lyricsLine) {
134
- for (var c = 0, charCount = chordsLine.length; c < charCount; c += 1) {
135
- var chr = chordsLine[c];
136
- var nextChar = chordsLine[c + 1];
137
- var isWhiteSpace = WHITE_SPACE.test(chr);
138
- this.addCharacter(chr, nextChar);
139
- this.chordLyricsPair.lyrics += lyricsLine[c] || '';
140
- this.processingText = !isWhiteSpace;
141
- }
142
- }
143
- }, {
144
- key: "addCharacter",
145
- value: function addCharacter(chr, nextChar) {
146
- var isWhiteSpace = WHITE_SPACE.test(chr);
147
-
148
- if (!isWhiteSpace) {
149
- this.ensureChordLyricsPairInitialized();
150
- }
151
-
152
- if (!isWhiteSpace || this.shouldAddCharacterToChords(nextChar)) {
153
- this.chordLyricsPair.chords += chr;
154
- }
155
- }
156
- }, {
157
- key: "shouldAddCharacterToChords",
158
- value: function shouldAddCharacterToChords(nextChar) {
159
- return nextChar && WHITE_SPACE.test(nextChar) && this.preserveWhitespace;
160
- }
161
- }, {
162
- key: "ensureChordLyricsPairInitialized",
163
- value: function ensureChordLyricsPairInitialized() {
164
- if (!this.processingText) {
165
- this.chordLyricsPair = this.songLine.addChordLyricsPair();
166
- this.processingText = true;
167
- }
168
- }
169
- }]);
170
-
171
- return ChordSheetParser;
172
- }();
173
-
174
- var _default = ChordSheetParser;
175
- exports["default"] = _default;
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
-
10
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11
-
12
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
-
14
- /**
15
- * Represents a parser warning, currently only used by ChordProParser.
16
- */
17
- var ParserWarning = /*#__PURE__*/function () {
18
- /**
19
- * @hideconstructor
20
- */
21
- function ParserWarning(message, lineNumber, column) {
22
- _classCallCheck(this, ParserWarning);
23
-
24
- /**
25
- * The warning message
26
- * @member
27
- * @type {string}
28
- */
29
- this.message = message;
30
- /**
31
- * The chord sheet line number on which the warning occurred
32
- * @member
33
- * @type {number}
34
- */
35
-
36
- this.lineNumber = lineNumber;
37
- /**
38
- * The chord sheet column on which the warning occurred
39
- * @member
40
- * @type {number}
41
- */
42
-
43
- this.column = column;
44
- }
45
- /**
46
- * Returns a stringified version of the warning
47
- * @returns {string} The string warning
48
- */
49
-
50
-
51
- _createClass(ParserWarning, [{
52
- key: "toString",
53
- value: function toString() {
54
- return "Warning: ".concat(this.message, " on line ").concat(this.lineNumber, " column ").concat(this.column);
55
- }
56
- }]);
57
-
58
- return ParserWarning;
59
- }();
60
-
61
- var _default = ParserWarning;
62
- exports["default"] = _default;
@@ -1,154 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _constants = require("../constants");
11
-
12
- var _tag = _interopRequireWildcard(require("../chord_sheet/tag"));
13
-
14
- var _chord_sheet_parser = _interopRequireDefault(require("./chord_sheet_parser"));
15
-
16
- var _startSectionTags, _endSectionTags;
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
-
20
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
-
22
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
-
24
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
-
26
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
27
-
28
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
29
-
30
- function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
31
-
32
- function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
33
-
34
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
35
-
36
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
37
-
38
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
39
-
40
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
41
-
42
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
43
-
44
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
45
-
46
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
47
-
48
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
49
-
50
- var VERSE_LINE_REGEX = /^\[Verse.*]/;
51
- var CHORUS_LINE_REGEX = /^\[Chorus]/;
52
- var OTHER_METADATA_LINE_REGEX = /^\[([^\]]+)]/;
53
- var startSectionTags = (_startSectionTags = {}, _defineProperty(_startSectionTags, _constants.VERSE, _tag.START_OF_VERSE), _defineProperty(_startSectionTags, _constants.CHORUS, _tag.START_OF_CHORUS), _startSectionTags);
54
- var endSectionTags = (_endSectionTags = {}, _defineProperty(_endSectionTags, _constants.VERSE, _tag.END_OF_VERSE), _defineProperty(_endSectionTags, _constants.CHORUS, _tag.END_OF_CHORUS), _endSectionTags);
55
- /**
56
- * Parses an Ultimate Guitar chord sheet with metadata
57
- * Inherits from {@link ChordSheetParser}
58
- */
59
-
60
- var UltimateGuitarParser = /*#__PURE__*/function (_ChordSheetParser) {
61
- _inherits(UltimateGuitarParser, _ChordSheetParser);
62
-
63
- var _super = _createSuper(UltimateGuitarParser);
64
-
65
- function UltimateGuitarParser() {
66
- _classCallCheck(this, UltimateGuitarParser);
67
-
68
- return _super.apply(this, arguments);
69
- }
70
-
71
- _createClass(UltimateGuitarParser, [{
72
- key: "parseLine",
73
- value: function parseLine(line) {
74
- if (this.isSectionEnd()) {
75
- this.endSection();
76
- }
77
-
78
- if (VERSE_LINE_REGEX.test(line)) {
79
- this.startNewLine();
80
- this.startSection(_constants.VERSE);
81
- } else if (CHORUS_LINE_REGEX.test(line)) {
82
- this.startNewLine();
83
- this.startSection(_constants.CHORUS);
84
- } else if (OTHER_METADATA_LINE_REGEX.test(line)) {
85
- this.startNewLine();
86
- this.endSection();
87
- var comment = line.match(OTHER_METADATA_LINE_REGEX)[1];
88
- this.songLine.addTag(new _tag["default"](_tag.COMMENT, comment));
89
- } else {
90
- _get(_getPrototypeOf(UltimateGuitarParser.prototype), "parseLine", this).call(this, line);
91
- }
92
- }
93
- }, {
94
- key: "isSectionEnd",
95
- value: function isSectionEnd() {
96
- return this.songLine && this.songLine.isEmpty() && this.song.previousLine && !this.song.previousLine.isEmpty();
97
- }
98
- }, {
99
- key: "endOfSong",
100
- value: function endOfSong() {
101
- _get(_getPrototypeOf(UltimateGuitarParser.prototype), "endOfSong", this).call(this);
102
-
103
- if (this.currentSectionType in endSectionTags) {
104
- this.startNewLine();
105
- }
106
-
107
- this.endSection({
108
- addNewLine: false
109
- });
110
- }
111
- }, {
112
- key: "startSection",
113
- value: function startSection(sectionType) {
114
- if (this.currentSectionType) {
115
- this.endSection();
116
- }
117
-
118
- this.currentSectionType = sectionType;
119
- this.song.setCurrentLineType(sectionType);
120
-
121
- if (sectionType in startSectionTags) {
122
- this.song.addTag(new _tag["default"](startSectionTags[sectionType]));
123
- }
124
- }
125
- }, {
126
- key: "endSection",
127
- value: function endSection() {
128
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
129
- _ref$addNewLine = _ref.addNewLine,
130
- addNewLine = _ref$addNewLine === void 0 ? true : _ref$addNewLine;
131
-
132
- if (this.currentSectionType in endSectionTags) {
133
- this.song.addTag(new _tag["default"](endSectionTags[this.currentSectionType]));
134
-
135
- if (addNewLine) {
136
- this.startNewLine();
137
- }
138
- }
139
-
140
- this.song.setCurrentLineType(_constants.NONE);
141
- this.currentSectionType = null;
142
- }
143
- }, {
144
- key: "startNewLine",
145
- value: function startNewLine() {
146
- this.songLine = this.song.addLine();
147
- }
148
- }]);
149
-
150
- return UltimateGuitarParser;
151
- }(_chord_sheet_parser["default"]);
152
-
153
- var _default = UltimateGuitarParser;
154
- exports["default"] = _default;
@@ -1,98 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.hasTextContents = void 0;
7
-
8
- var _handlebars = _interopRequireDefault(require("handlebars"));
9
-
10
- var _chord_lyrics_pair = _interopRequireDefault(require("./chord_sheet/chord_lyrics_pair"));
11
-
12
- var _tag = _interopRequireDefault(require("./chord_sheet/tag"));
13
-
14
- var _constants = require("./constants");
15
-
16
- var _helpers = require("./helpers");
17
-
18
- var _utilities = require("./utilities");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
-
22
- var lineHasContents = function lineHasContents(line) {
23
- return line.items.some(function (item) {
24
- return item.isRenderable();
25
- });
26
- };
27
- /* eslint import/prefer-default-export: 0 */
28
-
29
-
30
- var hasTextContents = function hasTextContents(line) {
31
- return line.items.some(function (item) {
32
- return item instanceof _chord_lyrics_pair["default"] && item.lyrics || item instanceof _tag["default"] && item.isRenderable() || (0, _utilities.isEvaluatable)(item);
33
- });
34
- };
35
-
36
- exports.hasTextContents = hasTextContents;
37
-
38
- _handlebars["default"].registerHelper('isChordLyricsPair', function (item) {
39
- return item instanceof _chord_lyrics_pair["default"];
40
- });
41
-
42
- _handlebars["default"].registerHelper('isTag', function (item) {
43
- return item instanceof _tag["default"];
44
- });
45
-
46
- _handlebars["default"].registerHelper('isComment', function (item) {
47
- return item.name === 'comment';
48
- });
49
-
50
- _handlebars["default"].registerHelper('shouldRenderLine', function (line, options) {
51
- if (options.data.root.renderBlankLines) {
52
- return true;
53
- }
54
-
55
- return lineHasContents(line);
56
- });
57
-
58
- _handlebars["default"].registerHelper('hasChordContents', _utilities.hasChordContents);
59
-
60
- _handlebars["default"].registerHelper('hasTextContents', hasTextContents);
61
-
62
- _handlebars["default"].registerHelper('lineHasContents', lineHasContents);
63
-
64
- _handlebars["default"].registerHelper('lineClasses', function (line) {
65
- var classes = ['row'];
66
-
67
- if (!lineHasContents(line)) {
68
- classes.push('empty-line');
69
- }
70
-
71
- return classes.join(' ');
72
- });
73
-
74
- _handlebars["default"].registerHelper('toUpperCase', function (line) {
75
- return line.toUpperCase();
76
- });
77
-
78
- _handlebars["default"].registerHelper('paragraphClasses', function (paragraph) {
79
- var classes = ['paragraph'];
80
-
81
- if (paragraph.type !== _constants.INDETERMINATE && paragraph.type !== _constants.NONE) {
82
- classes.push(paragraph.type);
83
- }
84
-
85
- return classes.join(' ');
86
- });
87
-
88
- _handlebars["default"].registerHelper('isEvaluatable', _utilities.isEvaluatable);
89
-
90
- _handlebars["default"].registerHelper('evaluate', function (item, metadata) {
91
- if (!metadata) {
92
- throw new Error('cannot evaluate, metadata is null');
93
- }
94
-
95
- return item.evaluate(metadata);
96
- });
97
-
98
- _handlebars["default"].registerHelper('renderChord', _helpers.renderChord);
package/lib/utilities.js DELETED
@@ -1,110 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.deprecate = deprecate;
7
- exports.hasChordContents = void 0;
8
- exports.isEmptyString = isEmptyString;
9
- exports.pushNew = exports.presence = exports.padLeft = exports.isPresent = exports.isEvaluatable = void 0;
10
- exports.scopeCss = scopeCss;
11
-
12
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
13
-
14
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
15
-
16
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
-
18
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
19
-
20
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
21
-
22
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
23
-
24
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
-
26
- var pushNew = function pushNew(collection, Klass) {
27
- var newObject = new Klass();
28
- collection.push(newObject);
29
- return newObject;
30
- };
31
-
32
- exports.pushNew = pushNew;
33
-
34
- var hasChordContents = function hasChordContents(line) {
35
- return line.items.some(function (item) {
36
- return !!item.chords;
37
- });
38
- };
39
-
40
- exports.hasChordContents = hasChordContents;
41
-
42
- var isEvaluatable = function isEvaluatable(item) {
43
- return typeof item.evaluate === 'function';
44
- };
45
-
46
- exports.isEvaluatable = isEvaluatable;
47
-
48
- var padLeft = function padLeft(str, length) {
49
- var paddedString = str;
50
-
51
- for (var l = str.length; l < length; l += 1, paddedString += ' ') {
52
- ;
53
- }
54
-
55
- return paddedString;
56
- };
57
-
58
- exports.padLeft = padLeft;
59
-
60
- var isPresent = function isPresent(object) {
61
- return object && object.length > 0;
62
- };
63
-
64
- exports.isPresent = isPresent;
65
-
66
- var presence = function presence(object) {
67
- return isPresent(object) ? object : null;
68
- };
69
-
70
- exports.presence = presence;
71
-
72
- function dasherize(string) {
73
- return string.replace(/[A-Z]/g, function (match) {
74
- return "-".concat(match.toLowerCase());
75
- });
76
- }
77
-
78
- function scopeCss(css, scope) {
79
- return Object.entries(css).map(function (_ref) {
80
- var _ref2 = _slicedToArray(_ref, 2),
81
- selector = _ref2[0],
82
- styles = _ref2[1];
83
-
84
- var rules = Object.entries(styles).map(function (_ref3) {
85
- var _ref4 = _slicedToArray(_ref3, 2),
86
- property = _ref4[0],
87
- value = _ref4[1];
88
-
89
- return "".concat(dasherize(property), ": ").concat(value, ";");
90
- }).join('\n ');
91
- var scopedSelector = "".concat(scope, " ").concat(selector).trim();
92
- return "\n".concat(scopedSelector, " {\n ").concat(rules, "\n}").substring(1);
93
- }).join('\n\n');
94
- }
95
-
96
- function deprecate(message) {
97
- try {
98
- throw new Error("DEPRECATION: ".concat(message));
99
- } catch (e) {
100
- if ((typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && typeof process.emitWarning === 'function') {
101
- process.emitWarning("".concat(message, "\n").concat(e.stack));
102
- } else {
103
- console.warn("".concat(message, "\n").concat(e.stack));
104
- }
105
- }
106
- }
107
-
108
- function isEmptyString(string) {
109
- return string === null || string === undefined || string === '';
110
- }