chordsheetjs 4.9.0 → 5.1.3
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 +164 -138
- package/lib/chord.js +341 -35
- 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 +4 -4
- package/lib/chord_sheet/paragraph.js +1 -1
- package/lib/chord_sheet/song.js +17 -5
- package/lib/chord_sheet/tag.js +29 -6
- package/lib/chord_sheet_serializer.js +1 -1
- package/lib/constants.js +14 -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 +33 -10
- package/lib/key.js +311 -0
- package/lib/note.js +132 -0
- package/lib/parser/chord_pro_parser.js +1 -1
- package/lib/parser/chord_pro_peg_parser.js +2 -2
- package/lib/parser/chord_sheet_parser.js +1 -1
- package/lib/parser/parser_warning.js +1 -1
- package/lib/parser/ultimate_guitar_parser.js +4 -4
- package/lib/{handlebars_helpers.js → template_helpers.js} +21 -2
- package/lib/utilities.js +22 -23
- package/package.json +7 -6
- package/lib/chord_helpers.js +0 -222
- package/lib/chord_symbol.js +0 -139
- package/lib/numeric_chord.js +0 -138
- package/lib/parse_chord.js +0 -74
- package/lib/to_chord_symbol.js +0 -93
package/lib/chord.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports["default"] = void 0;
|
|
9
|
+
exports.parseChord = parseChord;
|
|
10
|
+
|
|
11
|
+
var _utilities = require("./utilities");
|
|
12
|
+
|
|
13
|
+
var _key = _interopRequireDefault(require("./key"));
|
|
7
14
|
|
|
8
|
-
|
|
15
|
+
var _constants = require("./constants");
|
|
9
16
|
|
|
10
|
-
function
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
18
|
+
|
|
19
|
+
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; }
|
|
20
|
+
|
|
21
|
+
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
22
|
|
|
12
23
|
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
24
|
|
|
@@ -15,64 +26,359 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
15
26
|
|
|
16
27
|
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
28
|
|
|
18
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
29
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
30
|
+
|
|
31
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
32
|
+
|
|
33
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
34
|
+
|
|
35
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
36
|
+
|
|
37
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
38
|
+
|
|
39
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
40
|
+
|
|
41
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
42
|
+
|
|
43
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
19
44
|
|
|
45
|
+
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); }
|
|
46
|
+
|
|
47
|
+
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); }
|
|
48
|
+
|
|
49
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
50
|
+
|
|
51
|
+
var MAJOR_SCALE = [null, 'M', 'm', 'm', 'M', 'M', 'm', 'dim'];
|
|
52
|
+
|
|
53
|
+
function normalizeSuffix(suffix) {
|
|
54
|
+
if (suffix === 'M') {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return suffix;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function chordSuffix(noteNumber, suffix) {
|
|
62
|
+
if ((0, _utilities.isEmptyString)(suffix)) {
|
|
63
|
+
var defaultSuffix = MAJOR_SCALE[noteNumber];
|
|
64
|
+
return normalizeSuffix(defaultSuffix);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return normalizeSuffix(suffix);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var chordRegex = /*#__PURE__*/_wrapRegExp(/^([A-G])(#|b)?((?:(?![\t-\r \/\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])[\s\S])*)(\/([A-G])(#|b)?)?$/i, {
|
|
71
|
+
base: 1,
|
|
72
|
+
modifier: 2,
|
|
73
|
+
suffix: 3,
|
|
74
|
+
bassBase: 5,
|
|
75
|
+
bassModifier: 6
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
var numericChordRegex = /*#__PURE__*/_wrapRegExp(/^(#|b)?([1-7])((?:(?![\t-\r \/\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])[\s\S])*)(\/(#|b)?([0-7]))?$/, {
|
|
79
|
+
modifier: 1,
|
|
80
|
+
base: 2,
|
|
81
|
+
suffix: 3,
|
|
82
|
+
bassModifier: 5,
|
|
83
|
+
bassBase: 6
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
var regexes = [numericChordRegex, chordRegex];
|
|
20
87
|
/**
|
|
21
|
-
*
|
|
88
|
+
* Represents a Chord, consisting of a root, suffix (quality) and bass
|
|
22
89
|
*/
|
|
90
|
+
|
|
91
|
+
var _rootNote = /*#__PURE__*/new WeakMap();
|
|
92
|
+
|
|
93
|
+
var _process = /*#__PURE__*/new WeakSet();
|
|
94
|
+
|
|
95
|
+
var _is = /*#__PURE__*/new WeakSet();
|
|
96
|
+
|
|
23
97
|
var Chord = /*#__PURE__*/function () {
|
|
24
98
|
function Chord(_ref) {
|
|
25
|
-
var base = _ref.base,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
99
|
+
var _ref$base = _ref.base,
|
|
100
|
+
base = _ref$base === void 0 ? null : _ref$base,
|
|
101
|
+
_ref$modifier = _ref.modifier,
|
|
102
|
+
modifier = _ref$modifier === void 0 ? null : _ref$modifier,
|
|
103
|
+
_ref$suffix = _ref.suffix,
|
|
104
|
+
suffix = _ref$suffix === void 0 ? null : _ref$suffix,
|
|
105
|
+
_ref$bassBase = _ref.bassBase,
|
|
106
|
+
bassBase = _ref$bassBase === void 0 ? null : _ref$bassBase,
|
|
107
|
+
_ref$bassModifier = _ref.bassModifier,
|
|
108
|
+
bassModifier = _ref$bassModifier === void 0 ? null : _ref$bassModifier,
|
|
109
|
+
_ref$root = _ref.root,
|
|
110
|
+
root = _ref$root === void 0 ? null : _ref$root,
|
|
111
|
+
_ref$bass = _ref.bass,
|
|
112
|
+
bass = _ref$bass === void 0 ? null : _ref$bass;
|
|
30
113
|
|
|
31
114
|
_classCallCheck(this, Chord);
|
|
32
115
|
|
|
33
|
-
this
|
|
34
|
-
|
|
35
|
-
this
|
|
36
|
-
this.bassBase = bassBase || null;
|
|
37
|
-
this.bassModifier = bassModifier || null;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Returns a deep copy of the chord
|
|
41
|
-
* @returns {Chord}
|
|
42
|
-
*/
|
|
116
|
+
_classPrivateMethodInitSpec(this, _is);
|
|
117
|
+
|
|
118
|
+
_classPrivateMethodInitSpec(this, _process);
|
|
43
119
|
|
|
120
|
+
_classPrivateFieldInitSpec(this, _rootNote, {
|
|
121
|
+
get: _get_rootNote,
|
|
122
|
+
set: void 0
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
this.root = root || new _key["default"]({
|
|
126
|
+
note: base,
|
|
127
|
+
modifier: modifier
|
|
128
|
+
});
|
|
129
|
+
this.suffix = (0, _utilities.presence)(suffix);
|
|
130
|
+
this.bass = bass || (bassBase ? new _key["default"]({
|
|
131
|
+
note: bassBase,
|
|
132
|
+
modifier: bassModifier
|
|
133
|
+
}) : null);
|
|
134
|
+
}
|
|
44
135
|
|
|
45
136
|
_createClass(Chord, [{
|
|
46
137
|
key: "clone",
|
|
47
|
-
value:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
138
|
+
value:
|
|
139
|
+
/**
|
|
140
|
+
* Returns a deep copy of the chord
|
|
141
|
+
* @returns {Chord}
|
|
142
|
+
*/
|
|
143
|
+
function clone() {
|
|
144
|
+
return this.set({});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Converts the chord to a chord symbol, using the supplied key as a reference.
|
|
148
|
+
* For example, a numeric chord `#4` with reference key `E` will return the chord symbol `A#`.
|
|
149
|
+
* When the chord is already a chord symbol, it will return a clone of the object.
|
|
150
|
+
* @param {Key|string} key the reference key
|
|
151
|
+
* @returns {Chord} the chord symbol
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
}, {
|
|
155
|
+
key: "toChordSymbol",
|
|
156
|
+
value: function toChordSymbol(key) {
|
|
157
|
+
var _this$bass;
|
|
158
|
+
|
|
159
|
+
if (this.isChordSymbol()) {
|
|
160
|
+
return this.clone();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
var keyObj = _key["default"].wrap(key);
|
|
164
|
+
|
|
165
|
+
return new Chord({
|
|
166
|
+
suffix: chordSuffix(_classPrivateFieldGet(this, _rootNote), this.suffix),
|
|
167
|
+
root: this.root.toChordSymbol(keyObj),
|
|
168
|
+
bass: (_this$bass = this.bass) === null || _this$bass === void 0 ? void 0 : _this$bass.toChordSymbol(keyObj)
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Converts the chord to a chord symbol string, using the supplied key as a reference.
|
|
173
|
+
* For example, a numeric chord `#4` with reference key `E` will return the chord symbol `A#`.
|
|
174
|
+
* When the chord is already a chord symbol, it will return a string version of the chord.
|
|
175
|
+
* @param {Key|string} key the reference key
|
|
176
|
+
* @returns {string} the chord symbol string
|
|
177
|
+
* @see {toChordSymbol}
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
}, {
|
|
181
|
+
key: "toChordSymbolString",
|
|
182
|
+
value: function toChordSymbolString(key) {
|
|
183
|
+
return this.toChordSymbol(key).toString();
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Determines whether the chord is a chord symbol
|
|
187
|
+
* @returns {boolean}
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
}, {
|
|
191
|
+
key: "isChordSymbol",
|
|
192
|
+
value: function isChordSymbol() {
|
|
193
|
+
return _classPrivateMethodGet(this, _is, _is2).call(this, _constants.SYMBOL);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Converts the chord to a numeric chord, using the supplied kye as a reference.
|
|
197
|
+
* For example, a chord symbol A# with reference key E will return the numeric chord #4.
|
|
198
|
+
* @param {Key|string} key the reference key
|
|
199
|
+
* @returns {Chord} the numeric chord
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
}, {
|
|
203
|
+
key: "toNumeric",
|
|
204
|
+
value: function toNumeric(key) {
|
|
205
|
+
var _this$bass2;
|
|
206
|
+
|
|
207
|
+
if (this.isNumeric()) {
|
|
208
|
+
return this.clone();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
var keyObj = _key["default"].wrap(key);
|
|
212
|
+
|
|
213
|
+
return new Chord({
|
|
214
|
+
suffix: chordSuffix(_classPrivateFieldGet(this, _rootNote), this.suffix),
|
|
215
|
+
root: this.root.toNumeric(keyObj),
|
|
216
|
+
bass: (_this$bass2 = this.bass) === null || _this$bass2 === void 0 ? void 0 : _this$bass2.toNumeric(keyObj)
|
|
59
217
|
});
|
|
60
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Determines whether the chord is numeric
|
|
221
|
+
* @returns {boolean}
|
|
222
|
+
*/
|
|
223
|
+
|
|
224
|
+
}, {
|
|
225
|
+
key: "isNumeric",
|
|
226
|
+
value: function isNumeric() {
|
|
227
|
+
return _classPrivateMethodGet(this, _is, _is2).call(this, _constants.NUMERIC);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Converts the chord to a numeric chord string, using the supplied kye as a reference.
|
|
231
|
+
* For example, a chord symbol A# with reference key E will return the numeric chord #4.
|
|
232
|
+
* @param {Key|string} key the reference key
|
|
233
|
+
* @returns {string} the numeric chord string
|
|
234
|
+
* @see {toNumeric}
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
}, {
|
|
238
|
+
key: "toNumericString",
|
|
239
|
+
value: function toNumericString(key) {
|
|
240
|
+
return this.toNumeric(key).toString();
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Converts the chord to a string, eg `Esus4/G#` or `1sus4/#3`
|
|
244
|
+
* @returns {string} the chord string
|
|
245
|
+
*/
|
|
246
|
+
|
|
247
|
+
}, {
|
|
248
|
+
key: "toString",
|
|
249
|
+
value: function toString() {
|
|
250
|
+
var chordString = this.root.toString() + (this.suffix || '');
|
|
251
|
+
|
|
252
|
+
if (this.bass) {
|
|
253
|
+
return "".concat(chordString, "/").concat(this.bass.toString());
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return chordString;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Normalizes the chord:
|
|
260
|
+
* - Fb becomes E
|
|
261
|
+
* - Cb becomes B
|
|
262
|
+
* - B# becomes C
|
|
263
|
+
* - E# becomes F
|
|
264
|
+
* - 4b becomes 3
|
|
265
|
+
* - 1b becomes 7
|
|
266
|
+
* - 7# becomes 1
|
|
267
|
+
* - 3# becomes 4
|
|
268
|
+
*
|
|
269
|
+
* If the chord is already normalized, this will return a copy.
|
|
270
|
+
* @returns {Chord} the normalized chord
|
|
271
|
+
*/
|
|
272
|
+
|
|
273
|
+
}, {
|
|
274
|
+
key: "normalize",
|
|
275
|
+
value: function normalize() {
|
|
276
|
+
return _classPrivateMethodGet(this, _process, _process2).call(this, 'normalize');
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Switches to the specified modifier
|
|
280
|
+
* @param newModifier the modifier to use: `'#'` or `'b'`
|
|
281
|
+
* @returns {Chord} the new, changed chord
|
|
282
|
+
*/
|
|
283
|
+
|
|
284
|
+
}, {
|
|
285
|
+
key: "useModifier",
|
|
286
|
+
value: function useModifier(newModifier) {
|
|
287
|
+
return _classPrivateMethodGet(this, _process, _process2).call(this, 'useModifier', newModifier);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Transposes the chord up by 1 semitone. Eg. A becomes A#, Eb becomes E
|
|
291
|
+
* @returns {Chord} the new, transposed chord
|
|
292
|
+
*/
|
|
293
|
+
|
|
294
|
+
}, {
|
|
295
|
+
key: "transposeUp",
|
|
296
|
+
value: function transposeUp() {
|
|
297
|
+
return _classPrivateMethodGet(this, _process, _process2).call(this, 'transposeUp');
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Transposes the chord down by 1 semitone. Eg. A# becomes A, E becomes Eb
|
|
301
|
+
* @returns {Chord} the new, transposed chord
|
|
302
|
+
*/
|
|
303
|
+
|
|
304
|
+
}, {
|
|
305
|
+
key: "transposeDown",
|
|
306
|
+
value: function transposeDown() {
|
|
307
|
+
return _classPrivateMethodGet(this, _process, _process2).call(this, 'transposeDown');
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Transposes the chord by the specified number of semitones
|
|
311
|
+
* @param delta de number of semitones
|
|
312
|
+
* @returns {Chord} the new, transposed chord
|
|
313
|
+
*/
|
|
314
|
+
|
|
315
|
+
}, {
|
|
316
|
+
key: "transpose",
|
|
317
|
+
value: function transpose(delta) {
|
|
318
|
+
return _classPrivateMethodGet(this, _process, _process2).call(this, 'transpose', delta);
|
|
319
|
+
}
|
|
61
320
|
}, {
|
|
62
321
|
key: "set",
|
|
63
322
|
value: function set(properties) {
|
|
323
|
+
var _this$bass3;
|
|
324
|
+
|
|
64
325
|
return new this.constructor(_objectSpread({
|
|
65
|
-
|
|
66
|
-
modifier: this.modifier,
|
|
326
|
+
root: this.root.clone(),
|
|
67
327
|
suffix: this.suffix,
|
|
68
|
-
|
|
69
|
-
bassModifier: this.bassModifier
|
|
328
|
+
bass: (_this$bass3 = this.bass) === null || _this$bass3 === void 0 ? void 0 : _this$bass3.clone()
|
|
70
329
|
}, properties));
|
|
71
330
|
}
|
|
331
|
+
}], [{
|
|
332
|
+
key: "parse",
|
|
333
|
+
value:
|
|
334
|
+
/**
|
|
335
|
+
* Tries to parse a chord string into a chord
|
|
336
|
+
* @param chordString the chord string, eg `Esus4/G#` or `1sus4/#3`
|
|
337
|
+
* @returns {null|Chord}
|
|
338
|
+
*/
|
|
339
|
+
function parse(chordString) {
|
|
340
|
+
for (var i = 0, count = regexes.length; i < count; i += 1) {
|
|
341
|
+
var match = chordString.match(regexes[i]);
|
|
342
|
+
|
|
343
|
+
if (match) {
|
|
344
|
+
return new Chord(match.groups);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
72
350
|
}]);
|
|
73
351
|
|
|
74
352
|
return Chord;
|
|
75
353
|
}();
|
|
354
|
+
/**
|
|
355
|
+
* Tries to parse a chord string into a chord
|
|
356
|
+
* @param chordString the chord string, eg Esus4/G# or 1sus4/#3
|
|
357
|
+
* @deprecated Please use {@link Chord.parse} instead
|
|
358
|
+
* @returns {null|Chord}
|
|
359
|
+
*/
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
function _get_rootNote() {
|
|
363
|
+
return this.root.note.note;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function _process2(func) {
|
|
367
|
+
var arg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
368
|
+
return this.set({
|
|
369
|
+
root: this.root[func](arg),
|
|
370
|
+
bass: this.bass ? this.bass[func](arg) : null
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function _is2(type) {
|
|
375
|
+
return this.root.is(type) && (!this.bass || this.bass.is(type));
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function parseChord(chordString) {
|
|
379
|
+
(0, _utilities.deprecate)('parseChord() is deprecated, please use Chord.parse() instead');
|
|
380
|
+
return Chord.parse(chordString);
|
|
381
|
+
}
|
|
76
382
|
|
|
77
383
|
var _default = Chord;
|
|
78
384
|
exports["default"] = _default;
|
|
@@ -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 chord with the corresponding (partial) lyrics
|
|
@@ -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
|
var Composite = /*#__PURE__*/function () {
|
|
15
15
|
function Composite(expressions) {
|
|
@@ -1,15 +1,19 @@
|
|
|
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
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
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
|
+
|
|
10
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
15
|
|
|
12
|
-
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); }
|
|
16
|
+
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); }
|
|
13
17
|
|
|
14
18
|
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); }; }
|
|
15
19
|
|
|
@@ -47,7 +51,7 @@ var EvaluationError = /*#__PURE__*/function (_Error) {
|
|
|
47
51
|
return _this;
|
|
48
52
|
}
|
|
49
53
|
|
|
50
|
-
return EvaluationError;
|
|
54
|
+
return _createClass(EvaluationError);
|
|
51
55
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
52
56
|
|
|
53
57
|
var _default = EvaluationError;
|
|
@@ -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
|
var Literal = /*#__PURE__*/function () {
|
|
15
15
|
function Literal(expression) {
|
|
@@ -17,7 +17,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
17
17
|
|
|
18
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); } }
|
|
19
19
|
|
|
20
|
-
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
21
|
|
|
22
22
|
var Ternary = /*#__PURE__*/function () {
|
|
23
23
|
function Ternary() {
|
|
@@ -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 comment. See https://www.chordpro.org/chordpro/chordpro-file-format-specification/#overview
|
package/lib/chord_sheet/line.js
CHANGED
|
@@ -19,7 +19,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
19
19
|
|
|
20
20
|
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); } }
|
|
21
21
|
|
|
22
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
22
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Represents a line in a chord sheet, consisting of items of type ChordLyricsPair or Tag
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
|
|
8
|
-
var _parse_chord = _interopRequireDefault(require("../parse_chord"));
|
|
9
|
-
|
|
10
8
|
var _tag = require("./tag");
|
|
11
9
|
|
|
10
|
+
var _chord = _interopRequireDefault(require("../chord"));
|
|
11
|
+
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
13
|
|
|
14
14
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
@@ -35,7 +35,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
35
35
|
|
|
36
36
|
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); } }
|
|
37
37
|
|
|
38
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
38
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
39
39
|
|
|
40
40
|
function appendValue(array, key, value) {
|
|
41
41
|
if (!array.includes(value)) {
|
|
@@ -188,7 +188,7 @@ var Metadata = /*#__PURE__*/function () {
|
|
|
188
188
|
var key = this.get(_tag.KEY);
|
|
189
189
|
|
|
190
190
|
if (capo && key) {
|
|
191
|
-
return
|
|
191
|
+
return _chord["default"].parse(key).transpose(parseInt(capo, 10)).toString();
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
return undefined;
|
|
@@ -23,7 +23,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
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
|
/**
|
|
29
29
|
* Represents a paragraph of lines in a chord sheet
|
package/lib/chord_sheet/song.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
|
|
@@ -9,17 +9,17 @@ exports["default"] = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _line = _interopRequireDefault(require("./line"));
|
|
11
11
|
|
|
12
|
-
var _tag = _interopRequireWildcard(require("./tag"));
|
|
13
|
-
|
|
14
12
|
var _paragraph = _interopRequireDefault(require("./paragraph"));
|
|
15
13
|
|
|
16
14
|
var _utilities = require("../utilities");
|
|
17
15
|
|
|
18
16
|
var _metadata = _interopRequireDefault(require("./metadata"));
|
|
19
17
|
|
|
18
|
+
var _parser_warning = _interopRequireDefault(require("../parser/parser_warning"));
|
|
19
|
+
|
|
20
20
|
var _constants = require("../constants");
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _tag = _interopRequireWildcard(require("./tag"));
|
|
23
23
|
|
|
24
24
|
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); }
|
|
25
25
|
|
|
@@ -43,7 +43,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
43
43
|
|
|
44
44
|
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); } }
|
|
45
45
|
|
|
46
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
46
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Represents a song in a chord sheet. Currently a chord sheet can only have one song.
|
|
@@ -82,6 +82,7 @@ var Song = /*#__PURE__*/function () {
|
|
|
82
82
|
this.currentParagraph = null;
|
|
83
83
|
this.warnings = [];
|
|
84
84
|
this.sectionType = _constants.NONE;
|
|
85
|
+
this.currentKey = null;
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
_createClass(Song, [{
|
|
@@ -150,6 +151,7 @@ var Song = /*#__PURE__*/function () {
|
|
|
150
151
|
this.flushLine();
|
|
151
152
|
this.currentLine = (0, _utilities.pushNew)(this.lines, _line["default"]);
|
|
152
153
|
this.setCurrentLineType(this.sectionType);
|
|
154
|
+
this.currentLine.key = this.currentKey;
|
|
153
155
|
return this.currentLine;
|
|
154
156
|
}
|
|
155
157
|
}, {
|
|
@@ -208,6 +210,8 @@ var Song = /*#__PURE__*/function () {
|
|
|
208
210
|
|
|
209
211
|
if (tag.isMetaTag()) {
|
|
210
212
|
this.setMetaData(tag.name, tag.value);
|
|
213
|
+
} else if (tag.name === _tag.TRANSPOSE) {
|
|
214
|
+
this.currentKey = tag.value;
|
|
211
215
|
} else {
|
|
212
216
|
this.setSectionTypeFromTag(tag);
|
|
213
217
|
}
|
|
@@ -228,6 +232,14 @@ var Song = /*#__PURE__*/function () {
|
|
|
228
232
|
this.endSection(_constants.CHORUS, tag);
|
|
229
233
|
break;
|
|
230
234
|
|
|
235
|
+
case _tag.START_OF_TAB:
|
|
236
|
+
this.startSection(_constants.TAB, tag);
|
|
237
|
+
break;
|
|
238
|
+
|
|
239
|
+
case _tag.END_OF_TAB:
|
|
240
|
+
this.endSection(_constants.TAB, tag);
|
|
241
|
+
break;
|
|
242
|
+
|
|
231
243
|
case _tag.START_OF_VERSE:
|
|
232
244
|
this.startSection(_constants.VERSE, tag);
|
|
233
245
|
break;
|