@dsebastien/music-notation 0.21.0 → 0.21.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/README.md +1 -1
- package/dist/blocks/properties.d.ts +4 -0
- package/dist/index.js +23 -5
- package/dist/index.js.map +5 -5
- package/dist/music-notation.publish.min.js +28 -28
- package/dist/music-notation.tab.min.js +1 -1
- package/dist/playback/follow.d.ts +6 -0
- package/dist/publish/index.js +23 -5
- package/dist/publish/index.js.map +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -191,7 +191,7 @@ Add this to your site's `publish.js`. It loads the bundle only on pages that hav
|
|
|
191
191
|
|
|
192
192
|
```js
|
|
193
193
|
;(() => {
|
|
194
|
-
const VERSION = '0.
|
|
194
|
+
const VERSION = '0.21.1'
|
|
195
195
|
const CDN = `https://cdn.jsdelivr.net/npm/@dsebastien/music-notation@${VERSION}/dist`
|
|
196
196
|
const selector = (languages) => languages.map((l) => `pre > code.language-${l}`).join(', ')
|
|
197
197
|
const BLOCKS = selector([
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/** Property names, as Music Practice and the Obsidian Starter Kit write them by default. */
|
|
2
2
|
export interface PropertyNames {
|
|
3
3
|
chordSymbol: string;
|
|
4
|
+
/** The chord's root ("A", "C#"), read with the quality when the note has no chord symbol (#132). */
|
|
5
|
+
chordRoot: string;
|
|
6
|
+
/** The chord's quality ("Minor 7", "5 (Power)"), read with the root (#132). */
|
|
7
|
+
chordQuality: string;
|
|
4
8
|
frets: string;
|
|
5
9
|
fingers: string;
|
|
6
10
|
/** First fret shown (guitar); 0 or empty means computed. */
|
package/dist/index.js
CHANGED
|
@@ -4502,6 +4502,12 @@ function lightPlayer(win, random = Math.random) {
|
|
|
4502
4502
|
|
|
4503
4503
|
// src/playback/follow.ts
|
|
4504
4504
|
var PLAYING_CLASS = "mn-playing";
|
|
4505
|
+
function raise(el) {
|
|
4506
|
+
const group = el.closest("[data-mn-raise]");
|
|
4507
|
+
const parent = group?.parentNode;
|
|
4508
|
+
if (group && parent && parent.lastChild !== group)
|
|
4509
|
+
parent.appendChild(group);
|
|
4510
|
+
}
|
|
4505
4511
|
var START_WAIT = 300;
|
|
4506
4512
|
var reporting = new WeakSet;
|
|
4507
4513
|
function startsReported(player) {
|
|
@@ -4614,6 +4620,7 @@ function followNotes(win, drawing, targets, events, wait = START_WAIT) {
|
|
|
4614
4620
|
if (!lit.has(el)) {
|
|
4615
4621
|
el.classList.add(PLAYING_CLASS);
|
|
4616
4622
|
lit.add(el);
|
|
4623
|
+
raise(el);
|
|
4617
4624
|
}
|
|
4618
4625
|
if (next === Infinity)
|
|
4619
4626
|
return end();
|
|
@@ -11262,7 +11269,9 @@ function renderCircle(doc, options = {}) {
|
|
|
11262
11269
|
const title = svg(doc, "title");
|
|
11263
11270
|
title.textContent = chord ? `${chord.numeral}: ${name}` : name.replace("/", " or ");
|
|
11264
11271
|
cell.appendChild(title);
|
|
11265
|
-
g
|
|
11272
|
+
const slot = svg(doc, "g", { class: "mn-circle-slot", "data-mn-raise": "" });
|
|
11273
|
+
slot.appendChild(cell);
|
|
11274
|
+
g.appendChild(slot);
|
|
11266
11275
|
const mid = (outer + inner) / 2;
|
|
11267
11276
|
const solid = mark === " mn-circle-tonic" || mark === " mn-circle-neighbour";
|
|
11268
11277
|
const textClass = `mn-circle-label mn-circle-label-${ring}${solid ? " mn-circle-on" : ""}`;
|
|
@@ -11273,7 +11282,7 @@ function renderCircle(doc, options = {}) {
|
|
|
11273
11282
|
lines.forEach((line, i) => {
|
|
11274
11283
|
const [x, y] = point(mid, position * 30, top);
|
|
11275
11284
|
const isNumeral = chord !== undefined && i === lines.length - 1;
|
|
11276
|
-
|
|
11285
|
+
slot.appendChild(svgText(doc, line, {
|
|
11277
11286
|
class: isNumeral ? `${textClass} mn-circle-numeral` : textClass,
|
|
11278
11287
|
x,
|
|
11279
11288
|
y: y + 4 + (i - (lines.length - 1) / 2) * step,
|
|
@@ -12360,6 +12369,8 @@ var RENDERERS = {
|
|
|
12360
12369
|
// src/blocks/properties.ts
|
|
12361
12370
|
var DEFAULT_PROPERTY_NAMES = {
|
|
12362
12371
|
chordSymbol: "chord_symbol",
|
|
12372
|
+
chordRoot: "chord_root",
|
|
12373
|
+
chordQuality: "chord_quality",
|
|
12363
12374
|
frets: "frets",
|
|
12364
12375
|
fingers: "fingers",
|
|
12365
12376
|
position: "position",
|
|
@@ -12427,9 +12438,16 @@ function cagedShape(value) {
|
|
|
12427
12438
|
return m ? m[1].toUpperCase() : null;
|
|
12428
12439
|
}
|
|
12429
12440
|
function chordOf2(properties, names) {
|
|
12430
|
-
const value = first(properties[names.chordSymbol]);
|
|
12441
|
+
const value = first(properties[names.chordSymbol]) || rootAndQuality(properties, names);
|
|
12431
12442
|
return value ? readChord(value)?.symbol ?? null : null;
|
|
12432
12443
|
}
|
|
12444
|
+
function rootAndQuality(properties, names) {
|
|
12445
|
+
const root = first(properties[names.chordRoot]);
|
|
12446
|
+
if (!root)
|
|
12447
|
+
return "";
|
|
12448
|
+
const quality = first(properties[names.chordQuality]).replace(/\([^)]*\)/g, "").trim();
|
|
12449
|
+
return quality ? `${root} ${quality}` : root;
|
|
12450
|
+
}
|
|
12433
12451
|
function arpeggioSource(language, properties, names, instrument) {
|
|
12434
12452
|
const kind = kindOf(properties, names);
|
|
12435
12453
|
const guitar = instrument !== "piano";
|
|
@@ -12496,7 +12514,7 @@ function blockFromProperties(language, properties, options = {}) {
|
|
|
12496
12514
|
if (language === "picking")
|
|
12497
12515
|
return pickingSource(properties, names);
|
|
12498
12516
|
if (language === "chord") {
|
|
12499
|
-
const symbol = get(names.chordSymbol);
|
|
12517
|
+
const symbol = get(names.chordSymbol) ?? chordOf2(properties, names) ?? undefined;
|
|
12500
12518
|
if (symbol)
|
|
12501
12519
|
lines.push(`symbol: ${symbol}`);
|
|
12502
12520
|
if (instrument === "piano") {
|
|
@@ -16426,5 +16444,5 @@ export {
|
|
|
16426
16444
|
withTonicizations
|
|
16427
16445
|
};
|
|
16428
16446
|
|
|
16429
|
-
//# debugId=
|
|
16447
|
+
//# debugId=0445A74304ED6A3164756E2164756E21
|
|
16430
16448
|
//# sourceMappingURL=index.js.map
|