chordsheetjs 6.0.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +477 -539
  2. package/lib/bundle.js +15353 -0
  3. package/lib/index.js +6253 -216
  4. package/lib/index.js.map +1 -0
  5. package/lib/main.d.ts +1062 -0
  6. package/lib/main.d.ts.map +1 -0
  7. package/package.json +50 -23
  8. package/d7b54993c4ea66c07a35bd36690482ab620f836e.patch +0 -105
  9. package/lib/chord.js +0 -496
  10. package/lib/chord_sheet/chord_lyrics_pair.js +0 -75
  11. package/lib/chord_sheet/chord_pro/composite.js +0 -54
  12. package/lib/chord_sheet/chord_pro/evaluation_error.js +0 -58
  13. package/lib/chord_sheet/chord_pro/literal.js +0 -42
  14. package/lib/chord_sheet/chord_pro/ternary.js +0 -126
  15. package/lib/chord_sheet/comment.js +0 -55
  16. package/lib/chord_sheet/line.js +0 -185
  17. package/lib/chord_sheet/metadata.js +0 -202
  18. package/lib/chord_sheet/paragraph.js +0 -88
  19. package/lib/chord_sheet/song.js +0 -353
  20. package/lib/chord_sheet/tag.js +0 -345
  21. package/lib/chord_sheet_serializer.js +0 -278
  22. package/lib/constants.js +0 -54
  23. package/lib/formatter/chord_pro_formatter.js +0 -184
  24. package/lib/formatter/html_div_formatter.js +0 -130
  25. package/lib/formatter/html_formatter.js +0 -44
  26. package/lib/formatter/html_table_formatter.js +0 -154
  27. package/lib/formatter/templates/html_div_formatter.js +0 -544
  28. package/lib/formatter/templates/html_table_formatter.js +0 -731
  29. package/lib/formatter/text_formatter.js +0 -184
  30. package/lib/helpers.js +0 -32
  31. package/lib/key.js +0 -386
  32. package/lib/normalize_mappings/enharmonic-normalize.js +0 -124
  33. package/lib/normalize_mappings/generate-suffix-normalize-mapping.js +0 -36
  34. package/lib/normalize_mappings/suffix-normalize-mapping.js +0 -914
  35. package/lib/note.js +0 -264
  36. package/lib/parser/chord_pro_parser.js +0 -64
  37. package/lib/parser/chord_pro_peg_parser.js +0 -2069
  38. package/lib/parser/chord_sheet_parser.js +0 -175
  39. package/lib/parser/parser_warning.js +0 -62
  40. package/lib/parser/ultimate_guitar_parser.js +0 -154
  41. package/lib/template_helpers.js +0 -98
  42. package/lib/utilities.js +0 -110
@@ -1,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;
@@ -1,184 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _tag = _interopRequireDefault(require("../chord_sheet/tag"));
9
-
10
- var _chord_lyrics_pair = _interopRequireDefault(require("../chord_sheet/chord_lyrics_pair"));
11
-
12
- var _ternary = _interopRequireDefault(require("../chord_sheet/chord_pro/ternary"));
13
-
14
- var _literal = _interopRequireDefault(require("../chord_sheet/chord_pro/literal"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
-
18
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
-
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
-
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
-
24
- var NEW_LINE = '\n';
25
- /**
26
- * Formats a song into a ChordPro chord sheet
27
- */
28
-
29
- var ChordProFormatter = /*#__PURE__*/function () {
30
- /**
31
- * Instantiate
32
- * @param {Object} options options
33
- * @param {boolean} options.evaluate Whether or not to evaluate meta expressions. For more info about meta
34
- * expression, see: https://bit.ly/2SC9c2u
35
- */
36
- function ChordProFormatter() {
37
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
38
- _ref$evaluate = _ref.evaluate,
39
- evaluate = _ref$evaluate === void 0 ? false : _ref$evaluate;
40
-
41
- _classCallCheck(this, ChordProFormatter);
42
-
43
- this.evaluate = evaluate === true;
44
- }
45
- /**
46
- * Formats a song into a ChordPro chord sheet.
47
- * @param {Song} song The song to be formatted
48
- * @returns {string} The ChordPro string
49
- */
50
-
51
-
52
- _createClass(ChordProFormatter, [{
53
- key: "format",
54
- value: function format(song) {
55
- var _this = this;
56
-
57
- var lines = song.lines,
58
- metadata = song.metadata;
59
- return lines.map(function (line) {
60
- return _this.formatLine(line, metadata);
61
- }).join(NEW_LINE);
62
- }
63
- }, {
64
- key: "formatLine",
65
- value: function formatLine(line, metadata) {
66
- var _this2 = this;
67
-
68
- return line.items.map(function (item) {
69
- return _this2.formatItem(item, metadata);
70
- }).join('');
71
- }
72
- }, {
73
- key: "formatItem",
74
- value: function formatItem(item, metadata) {
75
- if (item instanceof _tag["default"]) {
76
- return this.formatTag(item);
77
- }
78
-
79
- if (item instanceof _chord_lyrics_pair["default"]) {
80
- return this.formatChordLyricsPair(item);
81
- }
82
-
83
- if (typeof item.evaluate === 'function') {
84
- return this.formatOrEvaluateItem(item, metadata);
85
- }
86
-
87
- throw new Error("Don't know how to format a ".concat(item.constructor.name));
88
- }
89
- }, {
90
- key: "formatOrEvaluateItem",
91
- value: function formatOrEvaluateItem(item, metadata) {
92
- if (this.evaluate) {
93
- return item.evaluate(metadata);
94
- }
95
-
96
- if (item instanceof _ternary["default"]) {
97
- return this.formatTernary(item);
98
- }
99
-
100
- if (item instanceof _literal["default"]) {
101
- return item.evaluate();
102
- }
103
-
104
- throw new Error("Don't know how to format a ".concat(item.constructor.name));
105
- }
106
- }, {
107
- key: "formatTernary",
108
- value: function formatTernary(ternary) {
109
- var variable = ternary.variable,
110
- valueTest = ternary.valueTest,
111
- trueExpression = ternary.trueExpression,
112
- falseExpression = ternary.falseExpression;
113
- return ['%{', variable || '', this.formatValueTest(valueTest), this.formatExpressionRange(trueExpression), this.formatExpressionRange(falseExpression), '}'].join('');
114
- }
115
- }, {
116
- key: "formatValueTest",
117
- value: function formatValueTest(valueTest) {
118
- if (!valueTest) {
119
- return '';
120
- }
121
-
122
- return "=".concat(valueTest);
123
- }
124
- }, {
125
- key: "formatExpressionRange",
126
- value: function formatExpressionRange(expressionRange) {
127
- var _this3 = this;
128
-
129
- if (!expressionRange) {
130
- return '';
131
- }
132
-
133
- return "|".concat(expressionRange.map(function (expression) {
134
- return _this3.formatExpression(expression);
135
- }).join(''));
136
- }
137
- }, {
138
- key: "formatExpression",
139
- value: function formatExpression(expression) {
140
- if (expression instanceof _ternary["default"]) {
141
- return this.formatTernary(expression);
142
- }
143
-
144
- if (expression instanceof _literal["default"]) {
145
- return expression.string;
146
- }
147
-
148
- return '';
149
- }
150
- }, {
151
- key: "formatTag",
152
- value: function formatTag(tag) {
153
- if (tag.hasValue()) {
154
- return "{".concat(tag.originalName, ": ").concat(tag.value, "}");
155
- }
156
-
157
- return "{".concat(tag.originalName, "}");
158
- }
159
- }, {
160
- key: "formatChordLyricsPair",
161
- value: function formatChordLyricsPair(chordLyricsPair) {
162
- return [this.formatChordLyricsPairChords(chordLyricsPair), this.formatChordLyricsPairLyrics(chordLyricsPair)].join('');
163
- }
164
- }, {
165
- key: "formatChordLyricsPairChords",
166
- value: function formatChordLyricsPairChords(chordLyricsPair) {
167
- if (chordLyricsPair.chords) {
168
- return "[".concat(chordLyricsPair.chords, "]");
169
- }
170
-
171
- return '';
172
- }
173
- }, {
174
- key: "formatChordLyricsPairLyrics",
175
- value: function formatChordLyricsPairLyrics(chordLyricsPair) {
176
- return chordLyricsPair.lyrics || '';
177
- }
178
- }]);
179
-
180
- return ChordProFormatter;
181
- }();
182
-
183
- var _default = ChordProFormatter;
184
- exports["default"] = _default;
@@ -1,130 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _handlebars = _interopRequireDefault(require("handlebars"));
11
-
12
- require("../template_helpers");
13
-
14
- var _html_formatter = _interopRequireDefault(require("./html_formatter"));
15
-
16
- require("./templates/html_div_formatter");
17
-
18
- var _utilities = require("../utilities");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
-
22
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23
-
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
-
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
-
28
- 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); }
29
-
30
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
31
-
32
- 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); }; }
33
-
34
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
35
-
36
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
37
-
38
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
39
-
40
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
41
-
42
- var template = _handlebars["default"].templates.html_div_formatter;
43
- var defaultCss = {
44
- '.chord:not(:last-child)': {
45
- paddingRight: '10px'
46
- },
47
- '.paragraph': {
48
- marginBottom: '1em'
49
- },
50
- '.row': {
51
- display: 'flex'
52
- },
53
- '.chord:after': {
54
- content: '\'\\200b\''
55
- },
56
- '.lyrics:after': {
57
- content: '\'\\200b\''
58
- }
59
- };
60
- /**
61
- * Formats a song into HTML. It uses DIVs to align lyrics with chords, which makes it useful for responsive web pages.
62
- */
63
-
64
- var HtmlDivFormatter = /*#__PURE__*/function (_HtmlFormatter) {
65
- _inherits(HtmlDivFormatter, _HtmlFormatter);
66
-
67
- var _super = _createSuper(HtmlDivFormatter);
68
-
69
- function HtmlDivFormatter() {
70
- _classCallCheck(this, HtmlDivFormatter);
71
-
72
- return _super.apply(this, arguments);
73
- }
74
-
75
- _createClass(HtmlDivFormatter, [{
76
- key: "format",
77
- value:
78
- /**
79
- * Formats a song into HTML.
80
- * @param {Song} song The song to be formatted
81
- * @returns {string} The HTML string
82
- */
83
- function format(song) {
84
- return this.formatWithTemplate(song, template);
85
- }
86
- /**
87
- * Generates basic CSS, optionally scoped within the provided selector, to use with output generated by
88
- * {@link HtmlDivFormatter}
89
- *
90
- * For example, execute cssString('.chordSheetViewer') will result in CSS like:
91
- *
92
- * .chordSheetViewer .paragraph {
93
- * margin-bottom: 1em;
94
- * }
95
- *
96
- * @param scope the CSS scope to use, for example `.chordSheetViewer`
97
- * @returns {string} the CSS string
98
- */
99
-
100
- }], [{
101
- key: "cssString",
102
- value: function cssString() {
103
- var scope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
104
- return (0, _utilities.scopeCss)(defaultCss, scope);
105
- }
106
- /**
107
- * Basic CSS, in object style à la useStyles, to use with output generated by {@link HtmlDivFormatter}
108
- *
109
- * Example:
110
- *
111
- * '.paragraph': {
112
- * marginBottom: '1em'
113
- * }
114
- *
115
- * For a CSS string see {@link cssString}
116
- * @return {Object.<string, Object.<string, string>>} the CSS object
117
- */
118
-
119
- }, {
120
- key: "cssObject",
121
- value: function cssObject() {
122
- return defaultCss;
123
- }
124
- }]);
125
-
126
- return HtmlDivFormatter;
127
- }(_html_formatter["default"]);
128
-
129
- var _default = HtmlDivFormatter;
130
- exports["default"] = _default;
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
-
10
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11
-
12
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
-
14
- /**
15
- * Acts as a base class for HTML formatters, taking care of whitelisting prototype property access.
16
- */
17
- var HtmlFormatter = /*#__PURE__*/function () {
18
- function HtmlFormatter() {
19
- _classCallCheck(this, HtmlFormatter);
20
- }
21
-
22
- _createClass(HtmlFormatter, [{
23
- key: "formatWithTemplate",
24
- value: function formatWithTemplate(song, template) {
25
- return template({
26
- song: song
27
- }, {
28
- allowedProtoProperties: {
29
- bodyLines: true,
30
- bodyParagraphs: true,
31
- subtitle: true,
32
- title: true,
33
- value: true,
34
- key: true
35
- }
36
- });
37
- }
38
- }]);
39
-
40
- return HtmlFormatter;
41
- }();
42
-
43
- var _default = HtmlFormatter;
44
- exports["default"] = _default;