abcjs 6.5.0 → 6.5.2
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/RELEASE.md +26 -0
- package/dist/abcjs-basic-min.js +2 -2
- package/dist/abcjs-basic.js +69 -28
- package/dist/abcjs-basic.js.map +1 -1
- package/dist/abcjs-plugin-min.js +2 -2
- package/package.json +1 -1
- package/src/edit/abc_editarea.js +53 -50
- package/src/edit/abc_editor.js +176 -157
- package/src/parse/transpose-chord.js +1 -1
- package/src/parse/tune-builder.js +3 -3
- package/src/str/output.js +49 -36
- package/src/synth/abc_midi_sequencer.js +2 -1
- package/types/index.d.ts +11 -3
- package/version.js +1 -1
package/dist/abcjs-basic.js
CHANGED
|
@@ -1988,7 +1988,11 @@ try {
|
|
|
1988
1988
|
// if we aren't in a browser, this code will crash, but it is not needed then either.
|
|
1989
1989
|
}
|
|
1990
1990
|
var EditArea = function EditArea(textareaid) {
|
|
1991
|
-
|
|
1991
|
+
this.isEditArea = true;
|
|
1992
|
+
if (typeof textareaid === "string") {
|
|
1993
|
+
this.textarea = document.getElementById(textareaid);
|
|
1994
|
+
if (!this.textarea) this.textarea = document.querySelector(textareaid);
|
|
1995
|
+
} else this.textarea = textareaid;
|
|
1992
1996
|
this.initialText = this.textarea.value;
|
|
1993
1997
|
this.isDragging = false;
|
|
1994
1998
|
};
|
|
@@ -2156,10 +2160,17 @@ var Editor = function Editor(editarea, params) {
|
|
|
2156
2160
|
// Copy all the options that will be passed through
|
|
2157
2161
|
this.abcjsParams = gatherAbcParams(params);
|
|
2158
2162
|
if (params.indicate_changed) this.indicate_changed = true;
|
|
2163
|
+
|
|
2164
|
+
// If a string is passed in then it could either be an element's ID or a selector
|
|
2165
|
+
// If an object is passed in then it could either be an EditArea or a textarea.
|
|
2159
2166
|
if (typeof editarea === "string") {
|
|
2167
|
+
// EditArea handles both the ID and the selector
|
|
2160
2168
|
this.editarea = new EditArea(editarea);
|
|
2161
2169
|
} else {
|
|
2162
|
-
|
|
2170
|
+
// If an edit area was passed in, just use it
|
|
2171
|
+
if (editarea.isEditArea) this.editarea = editarea;else
|
|
2172
|
+
// Hopefully we were passed in a textarea or equivalent.
|
|
2173
|
+
this.editarea = new EditArea(editarea);
|
|
2163
2174
|
}
|
|
2164
2175
|
this.editarea.addSelectionListener(this);
|
|
2165
2176
|
this.editarea.addChangeListener(this);
|
|
@@ -2209,6 +2220,7 @@ var Editor = function Editor(editarea, params) {
|
|
|
2209
2220
|
this.div.parentNode.insertBefore(this.warningsdiv, this.div);
|
|
2210
2221
|
}
|
|
2211
2222
|
this.onchangeCallback = params.onchange;
|
|
2223
|
+
this.redrawCallback = params.redrawCallback;
|
|
2212
2224
|
this.currentAbc = "";
|
|
2213
2225
|
this.tunes = [];
|
|
2214
2226
|
this.bReentry = false;
|
|
@@ -2265,12 +2277,14 @@ Editor.prototype.modelChanged = function () {
|
|
|
2265
2277
|
this.bReentry = true;
|
|
2266
2278
|
try {
|
|
2267
2279
|
this.timerId = null;
|
|
2280
|
+
if (this.redrawCallback) this.redrawCallback(true);
|
|
2268
2281
|
if (this.synth && this.synth.synthControl) this.synth.synthControl.disable(true);
|
|
2269
2282
|
this.tunes = renderAbc(this.div, this.currentAbc, this.abcjsParams);
|
|
2270
2283
|
if (this.tunes.length > 0) {
|
|
2271
2284
|
this.warnings = this.tunes[0].warnings;
|
|
2272
2285
|
}
|
|
2273
2286
|
this.redrawMidi();
|
|
2287
|
+
if (this.redrawCallback) this.redrawCallback(false);
|
|
2274
2288
|
} catch (error) {
|
|
2275
2289
|
console.error("ABCJS error: ", error);
|
|
2276
2290
|
if (!this.warnings) this.warnings = [];
|
|
@@ -2295,6 +2309,9 @@ Editor.prototype.paramChanged = function (engraverParams) {
|
|
|
2295
2309
|
this.currentAbc = "";
|
|
2296
2310
|
this.fireChanged();
|
|
2297
2311
|
};
|
|
2312
|
+
Editor.prototype.getTunes = function () {
|
|
2313
|
+
return this.tunes;
|
|
2314
|
+
};
|
|
2298
2315
|
Editor.prototype.synthParamChanged = function (options) {
|
|
2299
2316
|
if (!this.synth) return;
|
|
2300
2317
|
this.synth.options = {};
|
|
@@ -9249,7 +9266,7 @@ function transposeChordName(chord, steps, preferFlats, freeGCchord) {
|
|
|
9249
9266
|
if (freeGCchord) chord = sharpChordsFree[index];else chord = sharpChords[index];
|
|
9250
9267
|
}
|
|
9251
9268
|
var isDim = extra1 && (extra1.indexOf('dim') >= 0 || extra1.indexOf('°') >= 0);
|
|
9252
|
-
console.log(isDim, chord, extra1)
|
|
9269
|
+
//console.log(isDim, chord, extra1)
|
|
9253
9270
|
// We never want A#dim or D#dim
|
|
9254
9271
|
if (isDim && chord === 'A#') chord = 'Bb';
|
|
9255
9272
|
if (isDim && chord === 'D#') chord = 'Eb';
|
|
@@ -10052,11 +10069,11 @@ function cleanUpSlursInLine(line, staffNum, voiceNum, currSlur) {
|
|
|
10052
10069
|
}
|
|
10053
10070
|
}
|
|
10054
10071
|
function wrapMusicLines(lines, barsperstaff) {
|
|
10055
|
-
for (i = 0; i < lines.length; i++) {
|
|
10072
|
+
for (var i = 0; i < lines.length; i++) {
|
|
10056
10073
|
if (lines[i].staff !== undefined) {
|
|
10057
|
-
for (s = 0; s < lines[i].staff.length; s++) {
|
|
10074
|
+
for (var s = 0; s < lines[i].staff.length; s++) {
|
|
10058
10075
|
var permanentItems = [];
|
|
10059
|
-
for (v = 0; v < lines[i].staff[s].voices.length; v++) {
|
|
10076
|
+
for (var v = 0; v < lines[i].staff[s].voices.length; v++) {
|
|
10060
10077
|
var voice = lines[i].staff[s].voices[v];
|
|
10061
10078
|
var barNumThisLine = 0;
|
|
10062
10079
|
for (var n = 0; n < voice.length; n++) {
|
|
@@ -10777,6 +10794,9 @@ module.exports = {
|
|
|
10777
10794
|
\***************************/
|
|
10778
10795
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
10779
10796
|
|
|
10797
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
10798
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10799
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10780
10800
|
var keyAccidentals = __webpack_require__(/*! ../const/key-accidentals */ "./src/const/key-accidentals.js");
|
|
10781
10801
|
var _require = __webpack_require__(/*! ../const/relative-major */ "./src/const/relative-major.js"),
|
|
10782
10802
|
relativeMajor = _require.relativeMajor,
|
|
@@ -11073,6 +11093,7 @@ var strTranspose;
|
|
|
11073
11093
|
var regNote = /([_^=]*[A-Ga-g][,']*)(\d*\/*\d*)([\>\<\-\)\.\s\\]*)/;
|
|
11074
11094
|
var regOptionalNote = /([_^=]*[A-Ga-g][,']*)?(\d*\/*\d*)?([\>\<\-\)]*)?/;
|
|
11075
11095
|
var regSpace = /(\s*)$/;
|
|
11096
|
+
var regOptionalSpace = /(\s*)/;
|
|
11076
11097
|
|
|
11077
11098
|
// This the relationship of the note to the tonic and an octave. So what is returned is a distance in steps from the tonic and the amount of adjustment from
|
|
11078
11099
|
// a normal scale. That is - in the key of D an F# is two steps from the tonic and no adjustment. A G# is three steps from the tonic and one half-step higher.
|
|
@@ -11101,39 +11122,59 @@ var strTranspose;
|
|
|
11101
11122
|
};
|
|
11102
11123
|
}
|
|
11103
11124
|
function replaceNote(abc, start, end, newPitch, index) {
|
|
11104
|
-
// There may be more than just the note between the start and end - there could be spaces, there could be a chord symbol, there could be a decoration.
|
|
11105
|
-
// This could also be a part of a chord. If so, then the particular note needs to be teased out.
|
|
11106
11125
|
var note = abc.substring(start, end);
|
|
11107
|
-
|
|
11126
|
+
// Try single note first
|
|
11127
|
+
var match = note.match(new RegExp(regNote.source + regSpace.source));
|
|
11108
11128
|
if (match) {
|
|
11109
|
-
// This will match a single note
|
|
11110
11129
|
var noteLen = match[1].length;
|
|
11111
11130
|
var trailingLen = match[2].length + match[3].length + match[4].length;
|
|
11112
11131
|
var leadingLen = end - start - noteLen - trailingLen;
|
|
11113
11132
|
start += leadingLen;
|
|
11114
11133
|
end -= trailingLen;
|
|
11115
11134
|
} else {
|
|
11116
|
-
//
|
|
11135
|
+
// Match chord
|
|
11117
11136
|
var regPreBracket = /([^\[]*)/;
|
|
11118
11137
|
var regOpenBracket = /\[/;
|
|
11119
11138
|
var regCloseBracket = /\-?](\d*\/*\d*)?([\>\<\-\)]*)/;
|
|
11120
|
-
|
|
11139
|
+
var regChord = new RegExp(regPreBracket.source + regOpenBracket.source + "(?:" + regOptionalNote.source + "\\s*){1,8}" + regCloseBracket.source + regSpace.source);
|
|
11140
|
+
match = note.match(regChord);
|
|
11121
11141
|
if (match) {
|
|
11122
|
-
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
|
|
11142
|
+
var beforeChordLen = match[1].length + 1; // text before + '['
|
|
11143
|
+
var chordBody = note.slice(match[1].length + 1, note.lastIndexOf("]"));
|
|
11144
|
+
// Collect notes inside chord
|
|
11145
|
+
var chordNotes = [];
|
|
11146
|
+
var regNoteWithSpace = new RegExp(regOptionalNote.source + "\\s*", "g");
|
|
11147
|
+
var _iterator = _createForOfIteratorHelper(chordBody.matchAll(regNoteWithSpace)),
|
|
11148
|
+
_step;
|
|
11149
|
+
try {
|
|
11150
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
11151
|
+
var m = _step.value;
|
|
11152
|
+
var noteText = m[0].trim();
|
|
11153
|
+
if (noteText !== "") {
|
|
11154
|
+
chordNotes.push({
|
|
11155
|
+
text: noteText,
|
|
11156
|
+
index: m.index
|
|
11157
|
+
});
|
|
11158
|
+
}
|
|
11159
|
+
}
|
|
11160
|
+
} catch (err) {
|
|
11161
|
+
_iterator.e(err);
|
|
11162
|
+
} finally {
|
|
11163
|
+
_iterator.f();
|
|
11130
11164
|
}
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
|
|
11135
|
-
|
|
11136
|
-
|
|
11165
|
+
if (index >= chordNotes.length) {
|
|
11166
|
+
throw new Error("Chord index out of range for chord: " + note);
|
|
11167
|
+
}
|
|
11168
|
+
var chosen = chordNotes[index];
|
|
11169
|
+
// Preserve duration and tie
|
|
11170
|
+
var mDurTie = chosen.text.match(/^(.+?)(\d+\/?\d*)?(-)?$/);
|
|
11171
|
+
var pitchPart = mDurTie ? mDurTie[1] : chosen.text;
|
|
11172
|
+
var durationPart = mDurTie && mDurTie[2] ? mDurTie[2] : "";
|
|
11173
|
+
var tiePart = mDurTie && mDurTie[3] ? mDurTie[3] : "";
|
|
11174
|
+
// Replace note keeping duration and tie
|
|
11175
|
+
newPitch = newPitch + durationPart + tiePart;
|
|
11176
|
+
start += beforeChordLen + chosen.index;
|
|
11177
|
+
end = start + chosen.text.length;
|
|
11137
11178
|
}
|
|
11138
11179
|
}
|
|
11139
11180
|
return {
|
|
@@ -12722,7 +12763,7 @@ var parseCommon = __webpack_require__(/*! ../parse/abc_common */ "./src/parse/ab
|
|
|
12722
12763
|
if (Array.isArray(elem.decoration)) {
|
|
12723
12764
|
volumesPerNotePitch = [];
|
|
12724
12765
|
elem.decoration.forEach(function (d) {
|
|
12725
|
-
volumesPerNotePitch.push(volumes[d].slice(0));
|
|
12766
|
+
if (d in volumes) volumesPerNotePitch.push(volumes[d].slice(0));
|
|
12726
12767
|
});
|
|
12727
12768
|
}
|
|
12728
12769
|
voices[voiceNumber].push({
|
|
@@ -26767,7 +26808,7 @@ module.exports = Svg;
|
|
|
26767
26808
|
\********************/
|
|
26768
26809
|
/***/ (function(module) {
|
|
26769
26810
|
|
|
26770
|
-
var version = '6.5.
|
|
26811
|
+
var version = '6.5.2';
|
|
26771
26812
|
module.exports = version;
|
|
26772
26813
|
|
|
26773
26814
|
/***/ })
|