chordsheetjs 5.0.0 → 5.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/d7b54993c4ea66c07a35bd36690482ab620f836e.patch +105 -0
- package/lib/chord.js +118 -13
- package/lib/chord_sheet/chord_lyrics_pair.js +1 -1
- package/lib/chord_sheet/chord_pro/composite.js +1 -1
- package/lib/chord_sheet/chord_pro/evaluation_error.js +7 -3
- package/lib/chord_sheet/chord_pro/literal.js +1 -1
- package/lib/chord_sheet/chord_pro/ternary.js +1 -1
- package/lib/chord_sheet/comment.js +1 -1
- package/lib/chord_sheet/line.js +1 -1
- package/lib/chord_sheet/metadata.js +1 -1
- package/lib/chord_sheet/paragraph.js +1 -1
- package/lib/chord_sheet/song.js +9 -5
- package/lib/chord_sheet/tag.js +10 -3
- package/lib/chord_sheet_serializer.js +1 -1
- package/lib/constants.js +6 -2
- package/lib/formatter/chord_pro_formatter.js +1 -1
- package/lib/formatter/html_div_formatter.js +4 -4
- package/lib/formatter/html_formatter.js +3 -2
- package/lib/formatter/html_table_formatter.js +4 -4
- package/lib/formatter/templates/html_div_formatter.js +31 -32
- package/lib/formatter/templates/html_table_formatter.js +7 -6
- package/lib/formatter/text_formatter.js +25 -17
- package/lib/helpers.js +32 -0
- package/lib/index.js +1 -1
- package/lib/key.js +103 -32
- package/lib/note.js +154 -27
- package/lib/parser/chord_pro_parser.js +1 -1
- package/lib/parser/chord_pro_peg_parser.js +22 -13
- package/lib/parser/chord_sheet_parser.js +1 -1
- package/lib/parser/parser_warning.js +1 -1
- package/lib/parser/ultimate_guitar_parser.js +3 -3
- package/lib/{handlebars_helpers.js → template_helpers.js} +21 -2
- package/lib/utilities.js +3 -17
- package/package.json +5 -4
package/lib/key.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
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
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -15,15 +15,15 @@ var _MODIFIER_TRANSPOSITI;
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
17
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
19
|
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
21
|
|
|
22
22
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
23
|
|
|
24
24
|
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); } }
|
|
25
25
|
|
|
26
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
26
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
27
27
|
|
|
28
28
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
29
29
|
|
|
@@ -31,9 +31,9 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
|
|
|
31
31
|
|
|
32
32
|
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
33
33
|
|
|
34
|
-
function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re,
|
|
34
|
+
function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, void 0, groups); }; var _super = RegExp.prototype, _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype); } function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { return groups[name] = result[g[name]], groups; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); return result && (result.groups = buildGroups(result, this)), result; }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if ("string" == typeof substitution) { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { return "$" + groups[name]; })); } if ("function" == typeof substitution) { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; return "object" != _typeof(args[args.length - 1]) && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args); }); } return _super[Symbol.replace].call(this, str, substitution); }, _wrapRegExp.apply(this, arguments); }
|
|
35
35
|
|
|
36
|
-
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
36
|
+
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); }
|
|
37
37
|
|
|
38
38
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
39
39
|
|
|
@@ -53,7 +53,12 @@ var numericKeyRegex = /*#__PURE__*/_wrapRegExp(/^(#|b)?([1-7])$/, {
|
|
|
53
53
|
note: 2
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
var
|
|
56
|
+
var numeralKeyRegex = /*#__PURE__*/_wrapRegExp(/^(#|b)?(I{1,3}|IV|VI{0,2}|i{1,3}|iv|vi{0,2})$/, {
|
|
57
|
+
modifier: 1,
|
|
58
|
+
note: 2
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
var regexes = [symbolKeyRegex, numericKeyRegex, numeralKeyRegex];
|
|
57
62
|
|
|
58
63
|
var _set = /*#__PURE__*/new WeakSet();
|
|
59
64
|
|
|
@@ -67,29 +72,33 @@ var Key = /*#__PURE__*/function () {
|
|
|
67
72
|
|
|
68
73
|
_classPrivateMethodInitSpec(this, _set);
|
|
69
74
|
|
|
70
|
-
this.note = note instanceof _note["default"] ? note :
|
|
75
|
+
this.note = note instanceof _note["default"] ? note : _note["default"].parse(note);
|
|
71
76
|
this.modifier = modifier || null;
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
_createClass(Key, [{
|
|
75
|
-
key: "
|
|
76
|
-
value: function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
key: "distanceTo",
|
|
81
|
+
value: function distanceTo(otherKey) {
|
|
82
|
+
var otherKeyObj = Key.wrap(otherKey);
|
|
83
|
+
var key = this.useModifier(otherKeyObj.modifier);
|
|
84
|
+
var delta = 0;
|
|
85
|
+
|
|
86
|
+
while (!key.equals(otherKeyObj) && delta < 20) {
|
|
87
|
+
key = key.transposeUp().useModifier(otherKeyObj.modifier);
|
|
88
|
+
delta += 1;
|
|
84
89
|
}
|
|
85
90
|
|
|
86
|
-
|
|
87
|
-
return key.transpose(transposeDistance).normalize().useModifier(key.modifier);
|
|
91
|
+
return delta;
|
|
88
92
|
}
|
|
89
93
|
}, {
|
|
90
|
-
key: "
|
|
91
|
-
value: function
|
|
92
|
-
return this.
|
|
94
|
+
key: "isMinor",
|
|
95
|
+
value: function isMinor() {
|
|
96
|
+
return this.note.isMinor();
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
key: "clone",
|
|
100
|
+
value: function clone() {
|
|
101
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {});
|
|
93
102
|
}
|
|
94
103
|
}, {
|
|
95
104
|
key: "is",
|
|
@@ -106,6 +115,33 @@ var Key = /*#__PURE__*/function () {
|
|
|
106
115
|
value: function isChordSymbol() {
|
|
107
116
|
return this.is(_constants.SYMBOL);
|
|
108
117
|
}
|
|
118
|
+
}, {
|
|
119
|
+
key: "isNumeral",
|
|
120
|
+
value: function isNumeral() {
|
|
121
|
+
return this.is(_constants.NUMERAL);
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "equals",
|
|
125
|
+
value: function equals(_ref2) {
|
|
126
|
+
var note = _ref2.note,
|
|
127
|
+
modifier = _ref2.modifier;
|
|
128
|
+
return this.note.equals(note) && this.modifier === modifier;
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
131
|
+
key: "toChordSymbol",
|
|
132
|
+
value: function toChordSymbol(key) {
|
|
133
|
+
if (this.is(_constants.SYMBOL)) {
|
|
134
|
+
return this.clone();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
var transposeDistance = this.note.getTransposeDistance() + (MODIFIER_TRANSPOSITION[this.modifier] || 0);
|
|
138
|
+
return key.transpose(transposeDistance).normalize().useModifier(key.modifier);
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "toChordSymbolString",
|
|
142
|
+
value: function toChordSymbolString(key) {
|
|
143
|
+
return this.toChordSymbol(key).toString();
|
|
144
|
+
}
|
|
109
145
|
}, {
|
|
110
146
|
key: "toNumeric",
|
|
111
147
|
value: function toNumeric(key) {
|
|
@@ -113,6 +149,12 @@ var Key = /*#__PURE__*/function () {
|
|
|
113
149
|
return this.clone();
|
|
114
150
|
}
|
|
115
151
|
|
|
152
|
+
if (this.isNumeral()) {
|
|
153
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
154
|
+
note: this.note.toNumeric()
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
116
158
|
var numericKey = new Key({
|
|
117
159
|
note: 1
|
|
118
160
|
});
|
|
@@ -126,26 +168,50 @@ var Key = /*#__PURE__*/function () {
|
|
|
126
168
|
|
|
127
169
|
return numericKey;
|
|
128
170
|
}
|
|
129
|
-
}, {
|
|
130
|
-
key: "equals",
|
|
131
|
-
value: function equals(_ref2) {
|
|
132
|
-
var note = _ref2.note,
|
|
133
|
-
modifier = _ref2.modifier;
|
|
134
|
-
return this.note.equals(note) && this.modifier === modifier;
|
|
135
|
-
}
|
|
136
171
|
}, {
|
|
137
172
|
key: "toNumericString",
|
|
138
173
|
value: function toNumericString(key) {
|
|
139
174
|
return this.toNumeric(key).toString();
|
|
140
175
|
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "toNumeral",
|
|
178
|
+
value: function toNumeral(key) {
|
|
179
|
+
if (this.isNumeral()) {
|
|
180
|
+
return this.clone();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (this.isNumeric()) {
|
|
184
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
185
|
+
note: this.note.toNumeral()
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
var numeralKey = new Key({
|
|
190
|
+
note: 'I'
|
|
191
|
+
});
|
|
192
|
+
var symbolKey = key.clone();
|
|
193
|
+
var reference = this.clone().normalize().useModifier(key.modifier);
|
|
194
|
+
|
|
195
|
+
while (!symbolKey.equals(reference)) {
|
|
196
|
+
numeralKey = numeralKey.transposeUp().useModifier(key.modifier);
|
|
197
|
+
symbolKey = symbolKey.transposeUp().normalize().useModifier(key.modifier);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return numeralKey;
|
|
201
|
+
}
|
|
202
|
+
}, {
|
|
203
|
+
key: "toNumeralString",
|
|
204
|
+
value: function toNumeralString(key) {
|
|
205
|
+
return this.toNumeral(key).toString();
|
|
206
|
+
}
|
|
141
207
|
}, {
|
|
142
208
|
key: "toString",
|
|
143
209
|
value: function toString() {
|
|
144
|
-
if (this.
|
|
145
|
-
return "".concat(this.modifier || '')
|
|
210
|
+
if (this.isChordSymbol()) {
|
|
211
|
+
return "".concat(this.note).concat(this.modifier || '');
|
|
146
212
|
}
|
|
147
213
|
|
|
148
|
-
return "".concat(this.
|
|
214
|
+
return "".concat(this.modifier || '').concat(this.note);
|
|
149
215
|
}
|
|
150
216
|
}, {
|
|
151
217
|
key: "transpose",
|
|
@@ -276,6 +342,11 @@ var Key = /*#__PURE__*/function () {
|
|
|
276
342
|
|
|
277
343
|
return this.parse(keyStringOrObject);
|
|
278
344
|
}
|
|
345
|
+
}, {
|
|
346
|
+
key: "distance",
|
|
347
|
+
value: function distance(oneKey, otherKey) {
|
|
348
|
+
return this.wrap(oneKey).distanceTo(otherKey);
|
|
349
|
+
}
|
|
279
350
|
}]);
|
|
280
351
|
|
|
281
352
|
return Key;
|
package/lib/note.js
CHANGED
|
@@ -7,11 +7,23 @@ exports["default"] = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _constants = require("./constants");
|
|
9
9
|
|
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
+
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
10
16
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
17
|
|
|
12
18
|
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); } }
|
|
13
19
|
|
|
14
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
20
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
+
|
|
22
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
23
|
+
|
|
24
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
25
|
+
|
|
26
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
15
27
|
|
|
16
28
|
var A = 'A'.charCodeAt(0);
|
|
17
29
|
var G = 'G'.charCodeAt(0);
|
|
@@ -33,30 +45,84 @@ function clamp(note, min, max) {
|
|
|
33
45
|
return newNote;
|
|
34
46
|
}
|
|
35
47
|
|
|
48
|
+
function numeralToNumber(numeral) {
|
|
49
|
+
for (var i = 0, count = _constants.ROMAN_NUMERALS.length; i < count; i += 1) {
|
|
50
|
+
var romanNumeral = _constants.ROMAN_NUMERALS[i];
|
|
51
|
+
|
|
52
|
+
if (romanNumeral === numeral || romanNumeral.toLowerCase() === numeral) {
|
|
53
|
+
return i + 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function numberToNumeral(number) {
|
|
61
|
+
return _constants.ROMAN_NUMERALS[number - 1];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var _set = /*#__PURE__*/new WeakSet();
|
|
65
|
+
|
|
36
66
|
var Note = /*#__PURE__*/function () {
|
|
37
|
-
function Note(
|
|
67
|
+
function Note(_ref) {
|
|
68
|
+
var note = _ref.note,
|
|
69
|
+
type = _ref.type,
|
|
70
|
+
_ref$minor = _ref.minor,
|
|
71
|
+
minor = _ref$minor === void 0 ? false : _ref$minor;
|
|
72
|
+
|
|
38
73
|
_classCallCheck(this, Note);
|
|
39
74
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this.type = _constants.NUMERIC;
|
|
46
|
-
} else {
|
|
47
|
-
throw new Error("Invalid note ".concat(note));
|
|
48
|
-
}
|
|
75
|
+
_classPrivateMethodInitSpec(this, _set);
|
|
76
|
+
|
|
77
|
+
this._note = note;
|
|
78
|
+
this.type = type;
|
|
79
|
+
this.minor = minor;
|
|
49
80
|
}
|
|
50
81
|
|
|
51
82
|
_createClass(Note, [{
|
|
83
|
+
key: "toNumeral",
|
|
84
|
+
value: function toNumeral() {
|
|
85
|
+
if (this.isNumeral()) {
|
|
86
|
+
return this.clone();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (this.isNumeric()) {
|
|
90
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
91
|
+
type: _constants.NUMERAL
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
throw new Error("Converting a ".concat(this.type, " note to numeral is not supported"));
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "toNumeric",
|
|
99
|
+
value: function toNumeric() {
|
|
100
|
+
if (this.isNumeric()) {
|
|
101
|
+
return this.clone();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (this.isNumeral()) {
|
|
105
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
106
|
+
type: _constants.NUMERIC
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
throw new Error("Converting a ".concat(this.type, " note to numeric is not supported"));
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
key: "isMinor",
|
|
114
|
+
value: function isMinor() {
|
|
115
|
+
return this.minor;
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
52
118
|
key: "equals",
|
|
53
119
|
value: function equals(otherNote) {
|
|
54
|
-
return this.
|
|
120
|
+
return this._note === otherNote._note && this.type === otherNote.type && this.minor === otherNote.minor;
|
|
55
121
|
}
|
|
56
122
|
}, {
|
|
57
123
|
key: "clone",
|
|
58
124
|
value: function clone() {
|
|
59
|
-
return
|
|
125
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {});
|
|
60
126
|
}
|
|
61
127
|
}, {
|
|
62
128
|
key: "up",
|
|
@@ -75,7 +141,7 @@ var Note = /*#__PURE__*/function () {
|
|
|
75
141
|
options[_key] = arguments[_key];
|
|
76
142
|
}
|
|
77
143
|
|
|
78
|
-
return options.includes(this.
|
|
144
|
+
return options.includes(this._note);
|
|
79
145
|
}
|
|
80
146
|
}, {
|
|
81
147
|
key: "isNumeric",
|
|
@@ -87,6 +153,11 @@ var Note = /*#__PURE__*/function () {
|
|
|
87
153
|
value: function isChordSymbol() {
|
|
88
154
|
return this.is(_constants.SYMBOL);
|
|
89
155
|
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "isNumeral",
|
|
158
|
+
value: function isNumeral() {
|
|
159
|
+
return this.is(_constants.NUMERAL);
|
|
160
|
+
}
|
|
90
161
|
}, {
|
|
91
162
|
key: "is",
|
|
92
163
|
value: function is(noteType) {
|
|
@@ -95,38 +166,94 @@ var Note = /*#__PURE__*/function () {
|
|
|
95
166
|
}, {
|
|
96
167
|
key: "getTransposeDistance",
|
|
97
168
|
value: function getTransposeDistance() {
|
|
98
|
-
return TRANSPOSE_DISTANCE[this.
|
|
169
|
+
return TRANSPOSE_DISTANCE[this._note];
|
|
99
170
|
}
|
|
100
171
|
}, {
|
|
101
172
|
key: "change",
|
|
102
173
|
value: function change(delta) {
|
|
103
|
-
if (this.
|
|
104
|
-
var
|
|
174
|
+
if (this.isChordSymbol()) {
|
|
175
|
+
var charCode;
|
|
176
|
+
charCode = keyToCharCode(this._note);
|
|
177
|
+
charCode += delta;
|
|
178
|
+
charCode = clamp(charCode, A, G);
|
|
179
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
180
|
+
note: String.fromCharCode(charCode)
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
var newNote = clamp(this._note + delta, 1, 7);
|
|
185
|
+
|
|
186
|
+
if (newNote < 1) {
|
|
187
|
+
newNote += 7;
|
|
188
|
+
} else if (newNote > 7) {
|
|
189
|
+
newNote -= 7;
|
|
190
|
+
}
|
|
105
191
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
192
|
+
return _classPrivateMethodGet(this, _set, _set2).call(this, {
|
|
193
|
+
note: newNote
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}, {
|
|
197
|
+
key: "note",
|
|
198
|
+
get: function get() {
|
|
199
|
+
if (this.isNumeral()) {
|
|
200
|
+
var numeral = numberToNumeral(this._note);
|
|
201
|
+
|
|
202
|
+
if (this.isMinor()) {
|
|
203
|
+
return numeral.toLowerCase();
|
|
110
204
|
}
|
|
111
205
|
|
|
112
|
-
return
|
|
206
|
+
return numeral;
|
|
113
207
|
}
|
|
114
208
|
|
|
115
|
-
|
|
116
|
-
charCode = keyToCharCode(this.note);
|
|
117
|
-
charCode += delta;
|
|
118
|
-
charCode = clamp(charCode, A, G);
|
|
119
|
-
return new Note(String.fromCharCode(charCode));
|
|
209
|
+
return this._note;
|
|
120
210
|
}
|
|
121
211
|
}, {
|
|
122
212
|
key: "toString",
|
|
123
213
|
value: function toString() {
|
|
124
214
|
return "".concat(this.note);
|
|
125
215
|
}
|
|
216
|
+
}], [{
|
|
217
|
+
key: "parse",
|
|
218
|
+
value: function parse(note) {
|
|
219
|
+
if (/^[A-Ga-g]$/.test(note)) {
|
|
220
|
+
return new Note({
|
|
221
|
+
note: note.toUpperCase(),
|
|
222
|
+
type: _constants.SYMBOL
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (/^[1-7]$/.test(note)) {
|
|
227
|
+
return new Note({
|
|
228
|
+
note: parseInt(note, 10),
|
|
229
|
+
type: _constants.NUMERIC
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
var romanNumeralValue = numeralToNumber(note);
|
|
234
|
+
|
|
235
|
+
if (romanNumeralValue) {
|
|
236
|
+
return new Note({
|
|
237
|
+
note: romanNumeralValue,
|
|
238
|
+
type: _constants.NUMERAL,
|
|
239
|
+
minor: note.toLowerCase() === note
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
throw new Error("Invalid note ".concat(note));
|
|
244
|
+
}
|
|
126
245
|
}]);
|
|
127
246
|
|
|
128
247
|
return Note;
|
|
129
248
|
}();
|
|
130
249
|
|
|
250
|
+
function _set2(attributes) {
|
|
251
|
+
return new this.constructor(_objectSpread({
|
|
252
|
+
note: this._note,
|
|
253
|
+
type: this.type,
|
|
254
|
+
minor: this.minor
|
|
255
|
+
}, attributes));
|
|
256
|
+
}
|
|
257
|
+
|
|
131
258
|
var _default = Note;
|
|
132
259
|
exports["default"] = _default;
|
|
@@ -15,7 +15,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
15
15
|
|
|
16
16
|
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); } }
|
|
17
17
|
|
|
18
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
18
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Parses a ChordPro chord sheet
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
9
|
|
|
10
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
11
|
|
|
12
12
|
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; }
|
|
13
13
|
|
|
@@ -529,7 +529,7 @@ function peg$parse(input, options) {
|
|
|
529
529
|
}
|
|
530
530
|
|
|
531
531
|
function peg$parseLine() {
|
|
532
|
-
var s0, s1, s2, s3, s4;
|
|
532
|
+
var s0, s1, s2, s3, s4, s5, s6;
|
|
533
533
|
s0 = peg$currPos;
|
|
534
534
|
s1 = peg$parseLyrics();
|
|
535
535
|
|
|
@@ -561,9 +561,22 @@ function peg$parse(input, options) {
|
|
|
561
561
|
}
|
|
562
562
|
|
|
563
563
|
if (s4 !== peg$FAILED) {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
564
|
+
s5 = [];
|
|
565
|
+
s6 = peg$parseSpace();
|
|
566
|
+
|
|
567
|
+
while (s6 !== peg$FAILED) {
|
|
568
|
+
s5.push(s6);
|
|
569
|
+
s6 = peg$parseSpace();
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
if (s5 !== peg$FAILED) {
|
|
573
|
+
peg$savedPos = s0;
|
|
574
|
+
s1 = peg$c2(s1, s2, s3, s4);
|
|
575
|
+
s0 = s1;
|
|
576
|
+
} else {
|
|
577
|
+
peg$currPos = s0;
|
|
578
|
+
s0 = peg$FAILED;
|
|
579
|
+
}
|
|
567
580
|
} else {
|
|
568
581
|
peg$currPos = s0;
|
|
569
582
|
s0 = peg$FAILED;
|
|
@@ -1714,13 +1727,9 @@ function peg$parse(input, options) {
|
|
|
1714
1727
|
s0 = [];
|
|
1715
1728
|
s1 = peg$parseTagValueChar();
|
|
1716
1729
|
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
s1 = peg$parseTagValueChar();
|
|
1721
|
-
}
|
|
1722
|
-
} else {
|
|
1723
|
-
s0 = peg$FAILED;
|
|
1730
|
+
while (s1 !== peg$FAILED) {
|
|
1731
|
+
s0.push(s1);
|
|
1732
|
+
s1 = peg$parseTagValueChar();
|
|
1724
1733
|
}
|
|
1725
1734
|
|
|
1726
1735
|
return s0;
|
|
@@ -13,7 +13,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
13
13
|
|
|
14
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
15
|
|
|
16
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
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
17
|
|
|
18
18
|
var WHITE_SPACE = /\s/;
|
|
19
19
|
var CHORD_LINE_REGEX = /^\s*((([A-G])(#|b)?([^/\s]*)(\/([A-G])(#|b)?)?)(\s|$)+)+(\s|$)+/;
|
|
@@ -9,7 +9,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
9
9
|
|
|
10
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
11
|
|
|
12
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
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
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Represents a parser warning, currently only used by ChordProParser.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
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
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -25,13 +25,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
25
25
|
|
|
26
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
27
|
|
|
28
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
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
29
|
|
|
30
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
31
|
|
|
32
32
|
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
33
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
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
35
|
|
|
36
36
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
37
|
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hasTextContents = void 0;
|
|
7
|
+
|
|
3
8
|
var _handlebars = _interopRequireDefault(require("handlebars"));
|
|
4
9
|
|
|
5
10
|
var _chord_lyrics_pair = _interopRequireDefault(require("./chord_sheet/chord_lyrics_pair"));
|
|
@@ -8,6 +13,8 @@ var _tag = _interopRequireDefault(require("./chord_sheet/tag"));
|
|
|
8
13
|
|
|
9
14
|
var _constants = require("./constants");
|
|
10
15
|
|
|
16
|
+
var _helpers = require("./helpers");
|
|
17
|
+
|
|
11
18
|
var _utilities = require("./utilities");
|
|
12
19
|
|
|
13
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -17,6 +24,16 @@ var lineHasContents = function lineHasContents(line) {
|
|
|
17
24
|
return item.isRenderable();
|
|
18
25
|
});
|
|
19
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;
|
|
20
37
|
|
|
21
38
|
_handlebars["default"].registerHelper('isChordLyricsPair', function (item) {
|
|
22
39
|
return item instanceof _chord_lyrics_pair["default"];
|
|
@@ -40,7 +57,7 @@ _handlebars["default"].registerHelper('shouldRenderLine', function (line, option
|
|
|
40
57
|
|
|
41
58
|
_handlebars["default"].registerHelper('hasChordContents', _utilities.hasChordContents);
|
|
42
59
|
|
|
43
|
-
_handlebars["default"].registerHelper('hasTextContents',
|
|
60
|
+
_handlebars["default"].registerHelper('hasTextContents', hasTextContents);
|
|
44
61
|
|
|
45
62
|
_handlebars["default"].registerHelper('lineHasContents', lineHasContents);
|
|
46
63
|
|
|
@@ -76,4 +93,6 @@ _handlebars["default"].registerHelper('evaluate', function (item, metadata) {
|
|
|
76
93
|
}
|
|
77
94
|
|
|
78
95
|
return item.evaluate(metadata);
|
|
79
|
-
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
_handlebars["default"].registerHelper('renderChord', _helpers.renderChord);
|