chordsheetjs 6.1.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 +423 -571
  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 +43 -21
  8. package/.husky/pre-commit +0 -5
  9. package/lib/chord.js +0 -496
  10. package/lib/chord_sheet/chord_lyrics_pair.js +0 -80
  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 -207
  17. package/lib/chord_sheet/metadata.js +0 -216
  18. package/lib/chord_sheet/paragraph.js +0 -88
  19. package/lib/chord_sheet/song.js +0 -531
  20. package/lib/chord_sheet/tag.js +0 -359
  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 -56
  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,359 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = exports._KEY = exports.YEAR = exports.TRANSPOSE = exports.TITLE = exports.TIME = exports.TEMPO = exports.SUBTITLE = exports.START_OF_VERSE = exports.START_OF_TAB = exports.START_OF_CHORUS = exports.READ_ONLY_TAGS = exports.NEW_KEY = exports.META_TAGS = exports.LYRICIST = exports.KEY = exports.END_OF_VERSE = exports.END_OF_TAB = exports.END_OF_CHORUS = exports.DURATION = exports.COPYRIGHT = exports.COMPOSER = exports.COMMENT = exports.CAPO = exports.ARTIST = exports.ALBUM = void 0;
7
- exports.isReadonlyTag = isReadonlyTag;
8
-
9
- var _ALIASES;
10
-
11
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
-
13
- 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); } }
14
-
15
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
-
17
- 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; }
18
-
19
- /**
20
- * Album meta directive. See https://www.chordpro.org/chordpro/directives-album/
21
- * @type {string}
22
- */
23
- var ALBUM = 'album';
24
- /**
25
- * Artist meta directive. See https://www.chordpro.org/chordpro/directives-artist/
26
- * @type {string}
27
- */
28
-
29
- exports.ALBUM = ALBUM;
30
- var ARTIST = 'artist';
31
- /**
32
- * Capo meta directive. See https://www.chordpro.org/chordpro/directives-capo/
33
- * @type {string}
34
- */
35
-
36
- exports.ARTIST = ARTIST;
37
- var CAPO = 'capo';
38
- /**
39
- * Comment directive. See https://www.chordpro.org/chordpro/directives-comment/
40
- * @type {string}
41
- */
42
-
43
- exports.CAPO = CAPO;
44
- var COMMENT = 'comment';
45
- /**
46
- * Composer meta directive. See https://www.chordpro.org/chordpro/directives-composer/
47
- * @type {string}
48
- */
49
-
50
- exports.COMMENT = COMMENT;
51
- var COMPOSER = 'composer';
52
- /**
53
- * Copyright meta directive. See https://www.chordpro.org/chordpro/directives-copyright/
54
- * @type {string}
55
- */
56
-
57
- exports.COMPOSER = COMPOSER;
58
- var COPYRIGHT = 'copyright';
59
- /**
60
- * Duration meta directive. See https://www.chordpro.org/chordpro/directives-duration/
61
- * @type {string}
62
- */
63
-
64
- exports.COPYRIGHT = COPYRIGHT;
65
- var DURATION = 'duration';
66
- /**
67
- * End of chorus directive. See https://www.chordpro.org/chordpro/directives-env_chorus/
68
- * @type {string}
69
- */
70
-
71
- exports.DURATION = DURATION;
72
- var END_OF_CHORUS = 'end_of_chorus';
73
- /**
74
- * End of tab directive. See https://www.chordpro.org/chordpro/directives-env_tab/
75
- * @type {string}
76
- */
77
-
78
- exports.END_OF_CHORUS = END_OF_CHORUS;
79
- var END_OF_TAB = 'end_of_tab';
80
- /**
81
- * End of verse directive. See https://www.chordpro.org/chordpro/directives-env_verse/
82
- * @type {string}
83
- */
84
-
85
- exports.END_OF_TAB = END_OF_TAB;
86
- var END_OF_VERSE = 'end_of_verse';
87
- /**
88
- * Key meta directive. See https://www.chordpro.org/chordpro/directives-key/
89
- * @type {string}
90
- */
91
-
92
- exports.END_OF_VERSE = END_OF_VERSE;
93
- var KEY = 'key';
94
- /**
95
- * Key meta directive. See https://www.chordpro.org/chordpro/directives-key/
96
- * @type {string}
97
- */
98
-
99
- exports.KEY = KEY;
100
- var _KEY = '_key';
101
- /**
102
- * Lyricist meta directive. See https://www.chordpro.org/chordpro/directives-lyricist/
103
- * @type {string}
104
- */
105
-
106
- exports._KEY = _KEY;
107
- var LYRICIST = 'lyricist';
108
- /**
109
- * Start of chorus directive. See https://www.chordpro.org/chordpro/directives-env_chorus/
110
- * @type {string}
111
- */
112
-
113
- exports.LYRICIST = LYRICIST;
114
- var START_OF_CHORUS = 'start_of_chorus';
115
- /**
116
- * Start of tab directive. See https://www.chordpro.org/chordpro/directives-env_tab/
117
- * @type {string}
118
- */
119
-
120
- exports.START_OF_CHORUS = START_OF_CHORUS;
121
- var START_OF_TAB = 'start_of_tab';
122
- /**
123
- * Start of verse directive. See https://www.chordpro.org/chordpro/directives-env_verse/
124
- * @type {string}
125
- */
126
-
127
- exports.START_OF_TAB = START_OF_TAB;
128
- var START_OF_VERSE = 'start_of_verse';
129
- /**
130
- * Subtitle meta directive. See https://www.chordpro.org/chordpro/directives-subtitle/
131
- * @type {string}
132
- */
133
-
134
- exports.START_OF_VERSE = START_OF_VERSE;
135
- var SUBTITLE = 'subtitle';
136
- /**
137
- * Tempo meta directive. See https://www.chordpro.org/chordpro/directives-tempo/
138
- * @type {string}
139
- */
140
-
141
- exports.SUBTITLE = SUBTITLE;
142
- var TEMPO = 'tempo';
143
- /**
144
- * Time meta directive. See https://www.chordpro.org/chordpro/directives-time/
145
- * @type {string}
146
- */
147
-
148
- exports.TEMPO = TEMPO;
149
- var TIME = 'time';
150
- /**
151
- * Title meta directive. See https://www.chordpro.org/chordpro/directives-title/
152
- * @type {string}
153
- */
154
-
155
- exports.TIME = TIME;
156
- var TITLE = 'title';
157
- /**
158
- * Transpose meta directive. See: https://www.chordpro.org/chordpro/directives-transpose/
159
- * @type {string}
160
- */
161
-
162
- exports.TITLE = TITLE;
163
- var TRANSPOSE = 'transpose';
164
- /**
165
- * New Key meta directive. See: https://github.com/PraiseCharts/ChordChartJS/issues/53
166
- * @type {string}
167
- */
168
-
169
- exports.TRANSPOSE = TRANSPOSE;
170
- var NEW_KEY = 'new_key';
171
- /**
172
- * Year meta directive. See https://www.chordpro.org/chordpro/directives-year/
173
- * @type {string}
174
- */
175
-
176
- exports.NEW_KEY = NEW_KEY;
177
- var YEAR = 'year';
178
- exports.YEAR = YEAR;
179
- var TITLE_SHORT = 't';
180
- var SUBTITLE_SHORT = 'st';
181
- var COMMENT_SHORT = 'c';
182
- var START_OF_CHORUS_SHORT = 'soc';
183
- var END_OF_CHORUS_SHORT = 'eoc';
184
- var START_OF_TAB_SHORT = 'sot';
185
- var END_OF_TAB_SHORT = 'eot';
186
- var NEW_KEY_SHORT = 'nk';
187
- var RENDERABLE_TAGS = [COMMENT];
188
- var META_TAGS = [ALBUM, ARTIST, CAPO, COMPOSER, COPYRIGHT, DURATION, KEY, LYRICIST, TEMPO, TIME, TITLE, SUBTITLE, YEAR];
189
- exports.META_TAGS = META_TAGS;
190
- var READ_ONLY_TAGS = [_KEY];
191
- exports.READ_ONLY_TAGS = READ_ONLY_TAGS;
192
- var ALIASES = (_ALIASES = {}, _defineProperty(_ALIASES, TITLE_SHORT, TITLE), _defineProperty(_ALIASES, SUBTITLE_SHORT, SUBTITLE), _defineProperty(_ALIASES, COMMENT_SHORT, COMMENT), _defineProperty(_ALIASES, START_OF_CHORUS_SHORT, START_OF_CHORUS), _defineProperty(_ALIASES, END_OF_CHORUS_SHORT, END_OF_CHORUS), _defineProperty(_ALIASES, START_OF_TAB_SHORT, START_OF_TAB), _defineProperty(_ALIASES, END_OF_TAB_SHORT, END_OF_TAB), _defineProperty(_ALIASES, NEW_KEY_SHORT, NEW_KEY), _ALIASES);
193
- var META_TAG_REGEX = /^meta:\s*([^:\s]+)(\s*(.+))?$/;
194
- var TAG_REGEX = /^([^:\s]+)(:?\s*(.+))?$/;
195
- var CUSTOM_META_TAG_NAME_REGEX = /^x_(.+)$/;
196
-
197
- function isReadonlyTag(tagName) {
198
- return READ_ONLY_TAGS.includes(tagName);
199
- }
200
-
201
- var translateTagNameAlias = function translateTagNameAlias(name) {
202
- if (!name) {
203
- return name;
204
- }
205
-
206
- var sanitizedName = name.trim();
207
-
208
- if (sanitizedName in ALIASES) {
209
- return ALIASES[sanitizedName];
210
- }
211
-
212
- return sanitizedName;
213
- };
214
- /**
215
- * Represents a tag/directive. See https://www.chordpro.org/chordpro/chordpro-directives/
216
- */
217
-
218
-
219
- var Tag = /*#__PURE__*/function () {
220
- function Tag(name, value) {
221
- var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
222
- _ref$line = _ref.line,
223
- line = _ref$line === void 0 ? null : _ref$line,
224
- _ref$column = _ref.column,
225
- column = _ref$column === void 0 ? null : _ref$column,
226
- _ref$offset = _ref.offset,
227
- offset = _ref$offset === void 0 ? null : _ref$offset;
228
-
229
- _classCallCheck(this, Tag);
230
-
231
- this.name = name;
232
- this.value = value;
233
- this.line = line;
234
- this.column = column;
235
- this.offset = offset;
236
- }
237
-
238
- _createClass(Tag, [{
239
- key: "name",
240
- get:
241
- /**
242
- * The tag full name. When the original tag used the short name, `name` will return the full name.
243
- * @member
244
- * @type {string}
245
- */
246
- function get() {
247
- return this._name.trim();
248
- }
249
- /**
250
- * The original tag name that was used to construct the tag.
251
- * @member
252
- * @type {string}
253
- */
254
- ,
255
- set: function set(name) {
256
- this._name = translateTagNameAlias(name);
257
- this._originalName = name;
258
- }
259
- }, {
260
- key: "originalName",
261
- get: function get() {
262
- return this._originalName.trim();
263
- }
264
- }, {
265
- key: "value",
266
- get:
267
- /**
268
- * The tag value
269
- * @member
270
- * @type {string|null}
271
- */
272
- function get() {
273
- if (this._value) {
274
- return "".concat(this._value).trim();
275
- }
276
-
277
- return this._value || null;
278
- }
279
- /**
280
- * Checks whether the tag value is a non-empty string.
281
- * @returns {boolean}
282
- */
283
- ,
284
- set: function set(value) {
285
- this._value = value;
286
- }
287
- }, {
288
- key: "hasValue",
289
- value: function hasValue() {
290
- return this.value !== null && this.value.trim().length > 0;
291
- }
292
- /**
293
- * Checks whether the tag is usually rendered inline. It currently only applies to comment tags.
294
- * @returns {boolean}
295
- */
296
-
297
- }, {
298
- key: "isRenderable",
299
- value: function isRenderable() {
300
- return RENDERABLE_TAGS.indexOf(this.name) !== -1;
301
- }
302
- /**
303
- * Checks whether the tag is either a standard meta tag or a custom meta directive (`{x_some_name}`)
304
- * @returns {boolean}
305
- */
306
-
307
- }, {
308
- key: "isMetaTag",
309
- value: function isMetaTag() {
310
- return CUSTOM_META_TAG_NAME_REGEX.test(this.name) || META_TAGS.indexOf(this.name) !== -1;
311
- }
312
- /**
313
- * Returns a clone of the tag.
314
- * @returns {Tag} The cloned tag
315
- */
316
-
317
- }, {
318
- key: "clone",
319
- value: function clone() {
320
- return new Tag(this._originalName, this.value);
321
- }
322
- }, {
323
- key: "toString",
324
- value: function toString() {
325
- return "Tag(name=".concat(this.name, ", value=").concat(this.name, ")");
326
- }
327
- }, {
328
- key: "set",
329
- value: function set(_ref2) {
330
- var value = _ref2.value;
331
- return new Tag(this._originalName, value);
332
- }
333
- }], [{
334
- key: "parse",
335
- value: function parse(tag) {
336
- if (tag instanceof Tag) {
337
- return tag;
338
- }
339
-
340
- return this.parseWithRegex(tag, META_TAG_REGEX) || this.parseWithRegex(tag, TAG_REGEX);
341
- }
342
- }, {
343
- key: "parseWithRegex",
344
- value: function parseWithRegex(tag, regex) {
345
- var matches = tag.match(regex);
346
-
347
- if (matches !== null) {
348
- return new Tag(matches[1], matches[3] || null);
349
- }
350
-
351
- return null;
352
- }
353
- }]);
354
-
355
- return Tag;
356
- }();
357
-
358
- var _default = Tag;
359
- exports["default"] = _default;
@@ -1,278 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _literal = _interopRequireDefault(require("./chord_sheet/chord_pro/literal"));
9
-
10
- var _song = _interopRequireDefault(require("./chord_sheet/song"));
11
-
12
- var _chord_lyrics_pair = _interopRequireDefault(require("./chord_sheet/chord_lyrics_pair"));
13
-
14
- var _tag = _interopRequireDefault(require("./chord_sheet/tag"));
15
-
16
- var _comment = _interopRequireDefault(require("./chord_sheet/comment"));
17
-
18
- var _ternary = _interopRequireDefault(require("./chord_sheet/chord_pro/ternary"));
19
-
20
- var _utilities = require("./utilities");
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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
- var CHORD_SHEET = 'chordSheet';
31
- var CHORD_LYRICS_PAIR = 'chordLyricsPair';
32
- var TAG = 'tag';
33
- var COMMENT = 'comment';
34
- var TERNARY = 'ternary';
35
- var LINE = 'line';
36
- /**
37
- * Serializes a song into een plain object, and deserializes the serialized object back into a {@link Song}
38
- */
39
-
40
- var ChordSheetSerializer = /*#__PURE__*/function () {
41
- function ChordSheetSerializer() {
42
- _classCallCheck(this, ChordSheetSerializer);
43
- }
44
-
45
- _createClass(ChordSheetSerializer, [{
46
- key: "serialize",
47
- value:
48
- /**
49
- * Serializes the chord sheet to a plain object, which can be converted to any format like JSON, XML etc
50
- * Can be deserialized using {@link deserialize}
51
- * @returns object A plain JS object containing all chord sheet data
52
- */
53
- function serialize(song) {
54
- var _this = this;
55
-
56
- return {
57
- type: CHORD_SHEET,
58
- lines: song.lines.map(function (line) {
59
- return _this.serializeLine(line);
60
- })
61
- };
62
- }
63
- }, {
64
- key: "serializeLine",
65
- value: function serializeLine(line) {
66
- var _this2 = this;
67
-
68
- return {
69
- type: LINE,
70
- items: line.items.map(function (item) {
71
- return _this2.serializeItem(item);
72
- })
73
- };
74
- }
75
- }, {
76
- key: "serializeItem",
77
- value: function serializeItem(item) {
78
- if (item instanceof _tag["default"]) {
79
- return this.serializeTag(item);
80
- }
81
-
82
- if (item instanceof _chord_lyrics_pair["default"]) {
83
- return this.serializeChordLyricsPair(item);
84
- }
85
-
86
- if (item instanceof _ternary["default"]) {
87
- return this.serializeTernary(item);
88
- }
89
-
90
- if (item instanceof _literal["default"]) {
91
- return this.serializeLiteral(item);
92
- }
93
-
94
- throw new Error("Don't know how to serialize ".concat(item.constructor.name));
95
- }
96
- }, {
97
- key: "serializeTag",
98
- value: function serializeTag(tag) {
99
- return {
100
- type: TAG,
101
- name: tag.originalName,
102
- value: tag.value
103
- };
104
- }
105
- }, {
106
- key: "serializeChordLyricsPair",
107
- value: function serializeChordLyricsPair(chordLyricsPair) {
108
- return {
109
- type: CHORD_LYRICS_PAIR,
110
- chords: chordLyricsPair.chords,
111
- lyrics: chordLyricsPair.lyrics
112
- };
113
- }
114
- }, {
115
- key: "serializeTernary",
116
- value: function serializeTernary(ternary) {
117
- return {
118
- type: TERNARY,
119
- variable: ternary.variable,
120
- valueTest: ternary.valueTest,
121
- trueExpression: this.serializeExpression(ternary.trueExpression),
122
- falseExpression: this.serializeExpression(ternary.falseExpression)
123
- };
124
- }
125
- }, {
126
- key: "serializeLiteral",
127
- value: function serializeLiteral(literal) {
128
- return literal.string;
129
- }
130
- }, {
131
- key: "serializeExpression",
132
- value: function serializeExpression(expression) {
133
- var _this3 = this;
134
-
135
- return expression === null || expression === void 0 ? void 0 : expression.map(function (part) {
136
- return _this3.serializeItem(part);
137
- });
138
- }
139
- /**
140
- * Deserializes a song that has been serialized using {@link serialize}
141
- * @param {object} serializedSong The serialized song
142
- * @returns {Song} The deserialized song
143
- */
144
-
145
- }, {
146
- key: "deserialize",
147
- value: function deserialize(serializedSong) {
148
- this.parseAstComponent(serializedSong);
149
- this.song.finish();
150
- return this.song;
151
- }
152
- }, {
153
- key: "parseAstComponent",
154
- value: function parseAstComponent(astComponent) {
155
- if (!astComponent) {
156
- return null;
157
- }
158
-
159
- if (typeof astComponent === 'string') {
160
- return new _literal["default"](astComponent);
161
- }
162
-
163
- var type = astComponent.type;
164
-
165
- switch (type) {
166
- case CHORD_SHEET:
167
- return this.parseChordSheet(astComponent);
168
-
169
- case CHORD_LYRICS_PAIR:
170
- return this.parseChordLyricsPair(astComponent);
171
-
172
- case TAG:
173
- return this.parseTag(astComponent);
174
-
175
- case COMMENT:
176
- return this.parseComment(astComponent);
177
-
178
- case TERNARY:
179
- return this.parseTernary(astComponent);
180
-
181
- default:
182
- console.warn("Unhandled AST component \"".concat(type, "\""), astComponent);
183
- }
184
-
185
- return null;
186
- }
187
- }, {
188
- key: "parseChordSheet",
189
- value: function parseChordSheet(astComponent) {
190
- var _this4 = this;
191
-
192
- var lines = astComponent.lines;
193
- this.song = new _song["default"]();
194
- lines.forEach(function (line, index) {
195
- return _this4.parseLine(line, index);
196
- });
197
- }
198
- }, {
199
- key: "parseLine",
200
- value: function parseLine(astComponent) {
201
- var _this5 = this;
202
-
203
- var items = astComponent.items;
204
- this.song.addLine();
205
- items.forEach(function (item) {
206
- var parsedItem = _this5.parseAstComponent(item);
207
-
208
- _this5.song.addItem(parsedItem);
209
- });
210
- }
211
- }, {
212
- key: "parseChordLyricsPair",
213
- value: function parseChordLyricsPair(astComponent) {
214
- var chords = astComponent.chords,
215
- lyrics = astComponent.lyrics;
216
- return new _chord_lyrics_pair["default"](chords, lyrics);
217
- }
218
- }, {
219
- key: "parseTag",
220
- value: function parseTag(astComponent) {
221
- var name = astComponent.name,
222
- value = astComponent.value,
223
- _astComponent$locatio = astComponent.location;
224
- _astComponent$locatio = _astComponent$locatio === void 0 ? {} : _astComponent$locatio;
225
- var offset = _astComponent$locatio.offset,
226
- line = _astComponent$locatio.line,
227
- column = _astComponent$locatio.column;
228
- return new _tag["default"](name, value, {
229
- line: line,
230
- column: column,
231
- offset: offset
232
- });
233
- }
234
- }, {
235
- key: "parseComment",
236
- value: function parseComment(astComponent) {
237
- var comment = astComponent.comment;
238
- return new _comment["default"](comment);
239
- }
240
- }, {
241
- key: "parseTernary",
242
- value: function parseTernary(astComponent) {
243
- var variable = astComponent.variable,
244
- valueTest = astComponent.valueTest,
245
- trueExpression = astComponent.trueExpression,
246
- falseExpression = astComponent.falseExpression,
247
- _astComponent$locatio2 = astComponent.location;
248
- _astComponent$locatio2 = _astComponent$locatio2 === void 0 ? {} : _astComponent$locatio2;
249
- var offset = _astComponent$locatio2.offset,
250
- line = _astComponent$locatio2.line,
251
- column = _astComponent$locatio2.column;
252
- return new _ternary["default"]({
253
- variable: variable,
254
- valueTest: valueTest,
255
- trueExpression: this.parseExpression(trueExpression),
256
- falseExpression: this.parseExpression(falseExpression),
257
- offset: offset,
258
- line: line,
259
- column: column
260
- });
261
- }
262
- }, {
263
- key: "parseExpression",
264
- value: function parseExpression(expression) {
265
- var _this6 = this;
266
-
267
- var parsedParts = (expression || []).map(function (part) {
268
- return _this6.parseAstComponent(part);
269
- });
270
- return (0, _utilities.presence)(parsedParts);
271
- }
272
- }]);
273
-
274
- return ChordSheetSerializer;
275
- }();
276
-
277
- var _default = ChordSheetSerializer;
278
- exports["default"] = _default;
package/lib/constants.js DELETED
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.VERSE = exports.TAB = exports.SYMBOL = exports.ROMAN_NUMERALS = exports.NUMERIC = exports.NUMERAL = exports.NONE = exports.INDETERMINATE = exports.CHORUS = void 0;
7
-
8
- /**
9
- * Used to mark a paragraph as verse
10
- * @constant
11
- * @type {string}
12
- */
13
- var VERSE = 'verse';
14
- /**
15
- * Used to mark a paragraph as chorus
16
- * @constant
17
- * @type {string}
18
- */
19
-
20
- exports.VERSE = VERSE;
21
- var CHORUS = 'chorus';
22
- /**
23
- * Used to mark a paragraph as not containing a line marked with a type
24
- * @constant
25
- * @type {string}
26
- */
27
-
28
- exports.CHORUS = CHORUS;
29
- var NONE = 'none';
30
- /**
31
- * Used to mark a paragraph as containing lines with both verse and chorus type
32
- * @constant
33
- * @type {string}
34
- */
35
-
36
- exports.NONE = NONE;
37
- var INDETERMINATE = 'indeterminate';
38
- /**
39
- * Used to mark a paragraph as tab
40
- * @constant
41
- * @type {string}
42
- */
43
-
44
- exports.INDETERMINATE = INDETERMINATE;
45
- var TAB = 'tab';
46
- exports.TAB = TAB;
47
- var SYMBOL = 'symbol';
48
- exports.SYMBOL = SYMBOL;
49
- var NUMERIC = 'numeric';
50
- exports.NUMERIC = NUMERIC;
51
- var NUMERAL = 'numeral';
52
- exports.NUMERAL = NUMERAL;
53
- var ROMAN_NUMERALS = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII'];
54
- exports.ROMAN_NUMERALS = ROMAN_NUMERALS;