@dsebastien/music-notation 0.13.0 → 0.14.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.
@@ -44,6 +44,7 @@ function html(doc, tag, cls, text) {
44
44
  }
45
45
  var NAME_PREFIX = `mn-name-${Math.random().toString(36).slice(2, 8)}-`;
46
46
  var names = 0;
47
+ var uniqueId = () => `${NAME_PREFIX}${++names}`;
47
48
  function svgRoot(doc, width, height, cls, label) {
48
49
  const id = `${NAME_PREFIX}${++names}`;
49
50
  const title = svg(doc, "title", { class: "mn-name", id });
@@ -9253,6 +9254,109 @@ var RENDERERS = {
9253
9254
  circle: renderCircleBlock
9254
9255
  };
9255
9256
 
9257
+ // src/playback/bar-parts.ts
9258
+ var ICONS = {
9259
+ play: "M4 2.5v11l9-5.5z",
9260
+ stop: "M4 4h8v8H4z",
9261
+ all: "M1.5 2.5v11l6.5-5.5zM8 2.5v11l6.5-5.5z",
9262
+ loop: "M3 8a5 5 0 0 1 8.5-3.5L13 6V2.5M13 8a5 5 0 0 1-8.5 3.5L3 10v3.5",
9263
+ count: "M5.5 14h5L9 2.5H7zM8 11.5l4.5-7",
9264
+ click: "M3 5v6M8 5v6M13 5v6"
9265
+ };
9266
+ var STROKED = new Set(["loop", "count", "click"]);
9267
+ function icon(doc, name) {
9268
+ const root = svg(doc, "svg", {
9269
+ class: `mn-play-icon mn-play-icon-${name}${STROKED.has(name) ? " mn-play-icon-line" : ""}`,
9270
+ viewBox: "0 0 16 16",
9271
+ width: 12,
9272
+ height: 12,
9273
+ "aria-hidden": "true"
9274
+ });
9275
+ root.appendChild(svg(doc, "path", { d: ICONS[name] }));
9276
+ return root;
9277
+ }
9278
+ function playBar(doc, cls, label) {
9279
+ const bar = html(doc, "div", `mn-play mn-play-static ${cls}`);
9280
+ bar.addEventListener("mousedown", (event) => event.stopPropagation());
9281
+ bar.setAttribute("role", "group");
9282
+ bar.setAttribute("aria-label", label);
9283
+ return bar;
9284
+ }
9285
+ function iconButton(doc, cls, label, name) {
9286
+ const button = html(doc, "button", cls);
9287
+ button.type = "button";
9288
+ button.appendChild(icon(doc, name));
9289
+ button.title = label;
9290
+ button.setAttribute("aria-label", label);
9291
+ return button;
9292
+ }
9293
+ function pressedButton(doc, cls, label, name, on, set) {
9294
+ const button = iconButton(doc, cls, label, name);
9295
+ const show = () => {
9296
+ button.setAttribute("aria-pressed", String(on));
9297
+ button.classList.toggle("mn-on", on);
9298
+ };
9299
+ button.addEventListener("click", () => {
9300
+ on = !on;
9301
+ set(on);
9302
+ show();
9303
+ });
9304
+ show();
9305
+ return button;
9306
+ }
9307
+ function valueSlider(doc, label, unit, min, max, value, set, hint) {
9308
+ const field = html(doc, "label", "mn-play-field");
9309
+ const input = html(doc, "input");
9310
+ input.type = "range";
9311
+ input.min = String(min);
9312
+ input.max = String(max);
9313
+ input.setAttribute("aria-label", label);
9314
+ if (hint)
9315
+ input.setAttribute("aria-description", hint);
9316
+ const text = html(doc, "span", "mn-play-value");
9317
+ text.setAttribute("aria-hidden", "true");
9318
+ const show = (n) => {
9319
+ input.value = String(n);
9320
+ const written = `${n} ${unit}`;
9321
+ text.textContent = written;
9322
+ input.setAttribute("aria-valuetext", written);
9323
+ field.title = `${label}: ${written}${hint ? ` (${hint})` : ""}`;
9324
+ };
9325
+ input.addEventListener("input", () => {
9326
+ const n = Number(input.value);
9327
+ set(n);
9328
+ show(n);
9329
+ });
9330
+ show(value);
9331
+ field.append(input, text);
9332
+ return { field, input, show };
9333
+ }
9334
+ function choice(doc, cls, label, values, chosen, names, set) {
9335
+ const el = html(doc, "select", cls);
9336
+ el.setAttribute("aria-label", label);
9337
+ el.title = label;
9338
+ for (const value of values) {
9339
+ const option = html(doc, "option", undefined, names[value]);
9340
+ option.value = value;
9341
+ option.selected = value === chosen;
9342
+ el.appendChild(option);
9343
+ }
9344
+ el.addEventListener("change", () => set(el.value));
9345
+ return el;
9346
+ }
9347
+ var DEFAULT_VOLUME = 0.8;
9348
+ function volumeOf(volume) {
9349
+ let value = volume;
9350
+ if (typeof volume === "function") {
9351
+ try {
9352
+ value = volume();
9353
+ } catch {
9354
+ value = undefined;
9355
+ }
9356
+ }
9357
+ return typeof value === "number" && Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : DEFAULT_VOLUME;
9358
+ }
9359
+
9256
9360
  // src/playback/app-bar.ts
9257
9361
  var NONE = { tempoChanged() {}, free() {} };
9258
9362
  function handToApp(options, bar, info) {
@@ -9363,7 +9467,6 @@ function barPlayer(wrap, win, options) {
9363
9467
  }
9364
9468
  };
9365
9469
  }
9366
- var COUNT_IN = "M5.5 14h5L9 2.5H7zM8 11.5l4.5-7";
9367
9470
  function strumBarFor(doc, win, drawing, options) {
9368
9471
  const score = scoreFromDrawing(drawing);
9369
9472
  if (!score)
@@ -9382,13 +9485,10 @@ function strumBarFor(doc, win, drawing, options) {
9382
9485
  });
9383
9486
  }
9384
9487
  function timedBarFor(doc, win, drawing, options, piece) {
9385
- const wrap = html(doc, "div", `mn-playable ${piece.cls}`);
9488
+ const wrap = html(doc, "div", `mn-timed ${piece.cls}`);
9386
9489
  drawing.parentNode?.insertBefore(wrap, drawing);
9387
9490
  wrap.appendChild(drawing);
9388
- const bar = html(doc, "div", "mn-play");
9389
- bar.addEventListener("mousedown", (event) => event.stopPropagation());
9390
- bar.setAttribute("role", "group");
9391
- bar.setAttribute("aria-label", piece.label);
9491
+ const bar = playBar(doc, "mn-timed-bar", piece.label);
9392
9492
  wrap.appendChild(bar);
9393
9493
  const tempo = Number(drawing.getAttribute("data-mn-tempo"));
9394
9494
  const compound = piece.compound;
@@ -9398,7 +9498,7 @@ function timedBarFor(doc, win, drawing, options, piece) {
9398
9498
  loop: false,
9399
9499
  click: piece.click ?? false,
9400
9500
  sound: options.sound ?? "guitar",
9401
- volume: clamp(options.volume, 0, 1, 0.8)
9501
+ volume: volumeOf(options.volume)
9402
9502
  };
9403
9503
  let playing = null;
9404
9504
  const toggle = html(doc, "button", "mn-play-toggle");
@@ -9419,7 +9519,11 @@ function timedBarFor(doc, win, drawing, options, piece) {
9419
9519
  if (!wrap.isConnected)
9420
9520
  return;
9421
9521
  const here = wrap.ownerDocument.defaultView ?? win;
9422
- playing = runPasses(piece.make, player, () => ({ ...settings, loop: settings.loop && wrap.isConnected }), here, () => {
9522
+ playing = runPasses(piece.make, player, () => ({
9523
+ ...settings,
9524
+ volume: volumeOf(options.volume),
9525
+ loop: settings.loop && wrap.isConnected
9526
+ }), here, () => {
9423
9527
  playing = null;
9424
9528
  show();
9425
9529
  }, (strums, current) => {
@@ -9437,85 +9541,18 @@ function timedBarFor(doc, win, drawing, options, piece) {
9437
9541
  toggle.addEventListener("click", () => playing ? stop() : start());
9438
9542
  show();
9439
9543
  bar.appendChild(toggle);
9440
- const pressed = (cls, label, mark, set, start = false) => {
9441
- const button = html(doc, "button", cls);
9442
- button.type = "button";
9443
- button.appendChild(mark);
9444
- button.title = label;
9445
- button.setAttribute("aria-label", label);
9446
- button.setAttribute("aria-pressed", String(start));
9447
- button.classList.toggle("mn-on", start);
9448
- let on = start;
9449
- button.addEventListener("click", () => {
9450
- on = !on;
9451
- set(on);
9452
- button.setAttribute("aria-pressed", String(on));
9453
- button.classList.toggle("mn-on", on);
9454
- });
9455
- bar.appendChild(button);
9456
- };
9457
- pressed("mn-play-loop", "Loop", icon(doc, "loop"), (on) => settings.loop = on);
9458
- const metronome = svg(doc, "svg", {
9459
- class: "mn-play-icon mn-play-icon-loop",
9460
- viewBox: "0 0 16 16",
9461
- width: 12,
9462
- height: 12,
9463
- "aria-hidden": "true"
9464
- });
9465
- metronome.appendChild(svg(doc, "path", { d: COUNT_IN }));
9466
- pressed("mn-play-count", "Count-in", metronome, (on) => settings.countIn = on);
9467
- if (piece.click !== undefined) {
9468
- const beats = svg(doc, "svg", {
9469
- class: "mn-play-icon mn-play-icon-loop",
9470
- viewBox: "0 0 16 16",
9471
- width: 12,
9472
- height: 12,
9473
- "aria-hidden": "true"
9474
- });
9475
- beats.appendChild(svg(doc, "path", { d: "M3 5v6M8 5v6M13 5v6" }));
9476
- pressed("mn-play-click", "Click", beats, (on) => settings.click = on, piece.click);
9477
- }
9478
- const slider = (label, min, max, value, set, mark) => {
9479
- const field = html(doc, "label", "mn-play-field");
9480
- field.title = `${label}: ${value}`;
9481
- const tag = html(doc, "span", "mn-play-label");
9482
- tag.setAttribute("aria-hidden", "true");
9483
- tag.append(mark);
9484
- const input = html(doc, "input");
9485
- input.type = "range";
9486
- input.min = String(min);
9487
- input.max = String(max);
9488
- input.value = String(value);
9489
- input.setAttribute("aria-label", label);
9490
- input.addEventListener("input", () => {
9491
- set(Number(input.value));
9492
- field.title = `${label}: ${input.value}`;
9493
- });
9494
- field.append(tag, input);
9495
- bar.appendChild(field);
9496
- };
9497
- slider("Tempo (BPM)", 20, 240, settings.bpm, (n) => {
9544
+ bar.append(pressedButton(doc, "mn-play-loop", "Loop", "loop", false, (on) => settings.loop = on), pressedButton(doc, "mn-play-count", "Count-in", "count", false, (on) => {
9545
+ settings.countIn = on;
9546
+ }));
9547
+ if (piece.click !== undefined)
9548
+ bar.appendChild(pressedButton(doc, "mn-play-click", "Click", "click", piece.click, (on) => {
9549
+ settings.click = on;
9550
+ }));
9551
+ bar.appendChild(valueSlider(doc, "Tempo (BPM)", "BPM", 20, 240, settings.bpm, (n) => {
9498
9552
  settings.bpm = tempoOf(n);
9499
9553
  app.tempoChanged(settings.bpm);
9500
- }, compound ? "♩." : "♩");
9501
- slider("Volume", 0, 100, Math.round(settings.volume * 100), (n) => settings.volume = n / 100, icon(doc, "volume"));
9502
- const sound = html(doc, "select", "mn-play-sound");
9503
- sound.setAttribute("aria-label", "Sound");
9504
- for (const value of ["guitar", "piano"]) {
9505
- const option = html(doc, "option", undefined, value === "guitar" ? "Guitar" : "Piano");
9506
- option.value = value;
9507
- option.selected = value === settings.sound;
9508
- sound.appendChild(option);
9509
- }
9510
- sound.addEventListener("change", () => {
9511
- settings.sound = sound.value === "piano" ? "piano" : "guitar";
9512
- });
9513
- bar.appendChild(sound);
9514
- wrap.addEventListener("pointerdown", (event) => {
9515
- if (event.pointerType !== "touch" || bar.contains(event.target))
9516
- return;
9517
- wrap.classList.toggle("mn-play-open");
9518
- });
9554
+ }, compound ? "counts dotted quarters" : undefined).field);
9555
+ bar.appendChild(choice(doc, "mn-play-sound", "Sound", ["guitar", "piano"], settings.sound, { guitar: "Guitar", piano: "Piano" }, (value) => settings.sound = value === "piano" ? "piano" : "guitar"));
9519
9556
  const app = handToApp(options, bar, {
9520
9557
  kind: piece.kind,
9521
9558
  drawing,
@@ -9529,8 +9566,6 @@ function timedBarFor(doc, win, drawing, options, piece) {
9529
9566
  }
9530
9567
 
9531
9568
  // src/playback/progression-bar.ts
9532
- var COUNT_IN2 = "M5.5 14h5L9 2.5H7zM8 11.5l4.5-7";
9533
- var CLICK4 = "M3 5v6M8 5v6M13 5v6";
9534
9569
  var pitchesOf2 = (text) => (text ?? "").split(" ").filter(Boolean).map(Number).filter((n) => Number.isFinite(n));
9535
9570
  function barsFromDrawing(drawing) {
9536
9571
  const byBar = new Map;
@@ -9581,7 +9616,7 @@ var STRUM_LABELS = {
9581
9616
  arpeggio: "Arpeggio",
9582
9617
  pattern: "Pattern"
9583
9618
  };
9584
- function progressionBarFor(doc, win, drawing, options) {
9619
+ function progressionBarFor(doc, win, drawing, options, diagrams = null) {
9585
9620
  const { bars, marks } = barsFromDrawing(drawing);
9586
9621
  if (!bars.length)
9587
9622
  return () => {};
@@ -9604,15 +9639,12 @@ function progressionBarFor(doc, win, drawing, options) {
9604
9639
  loop: false,
9605
9640
  click: true,
9606
9641
  sound: options.sound ?? (piano ? "piano" : "guitar"),
9607
- volume: clamp(options.volume, 0, 1, 0.8)
9642
+ volume: volumeOf(options.volume)
9608
9643
  };
9609
9644
  let strum = pattern ? "pattern" : written.strum;
9610
9645
  let playing = null;
9611
- const bar = html(doc, "div", "mn-play mn-play-static mn-progression-play");
9612
- bar.addEventListener("mousedown", (event) => event.stopPropagation());
9613
- bar.setAttribute("role", "group");
9614
- bar.setAttribute("aria-label", "Play the chords in time");
9615
- drawing.insertBefore(bar, drawing.firstChild);
9646
+ const bar = playBar(doc, "mn-progression-play", "Play the chords in time");
9647
+ drawing.appendChild(bar);
9616
9648
  const toggle = html(doc, "button", "mn-play-toggle");
9617
9649
  toggle.type = "button";
9618
9650
  const show = () => {
@@ -9625,17 +9657,30 @@ function progressionBarFor(doc, win, drawing, options) {
9625
9657
  playing = null;
9626
9658
  show();
9627
9659
  };
9660
+ if (diagrams) {
9661
+ diagrams.onPlay = stop;
9662
+ diagrams.stopOthers = () => {
9663
+ const was = playing !== null;
9664
+ stop();
9665
+ return was;
9666
+ };
9667
+ }
9628
9668
  const start = () => {
9629
9669
  stop();
9630
9670
  if (!drawing.isConnected)
9631
9671
  return;
9672
+ diagrams?.stop();
9632
9673
  const here = drawing.ownerDocument.defaultView ?? win;
9633
9674
  playing = runProgression(bars, {
9634
9675
  beatsPerBar,
9635
9676
  beatUnit,
9636
9677
  strum: strum === "pattern" ? "beats" : strum,
9637
9678
  pattern: strum === "pattern" ? pattern : null
9638
- }, () => barPlayer(drawing, win, options), () => ({ ...settings, loop: settings.loop && drawing.isConnected }), here, () => {
9679
+ }, () => barPlayer(drawing, win, options), () => ({
9680
+ ...settings,
9681
+ volume: volumeOf(options.volume),
9682
+ loop: settings.loop && drawing.isConnected
9683
+ }), here, () => {
9639
9684
  playing = null;
9640
9685
  show();
9641
9686
  }, (timings, current) => followNotes(here, drawing, timings.map((t) => marks[t.slot] ?? []), timings.map((t) => ({ midi: 0, time: t.time, duration: t.duration })), current.reportsStart === true ? Infinity : START_WAIT));
@@ -9644,85 +9689,26 @@ function progressionBarFor(doc, win, drawing, options) {
9644
9689
  toggle.addEventListener("click", () => playing ? stop() : start());
9645
9690
  show();
9646
9691
  bar.appendChild(toggle);
9647
- const mark = (path) => {
9648
- const el = svg(doc, "svg", {
9649
- class: "mn-play-icon mn-play-icon-loop",
9650
- viewBox: "0 0 16 16",
9651
- width: 12,
9652
- height: 12,
9653
- "aria-hidden": "true"
9654
- });
9655
- el.appendChild(svg(doc, "path", { d: path }));
9656
- return el;
9657
- };
9658
- const pressed = (cls, label, glyph, on, set) => {
9659
- const button = html(doc, "button", cls);
9660
- button.type = "button";
9661
- button.appendChild(glyph);
9662
- button.title = label;
9663
- button.setAttribute("aria-label", label);
9664
- const show = () => {
9665
- button.setAttribute("aria-pressed", String(on));
9666
- button.classList.toggle("mn-on", on);
9667
- };
9668
- button.addEventListener("click", () => {
9669
- on = !on;
9670
- set(on);
9671
- show();
9672
- });
9673
- show();
9674
- bar.appendChild(button);
9675
- };
9676
- pressed("mn-play-loop", "Loop", icon(doc, "loop"), false, (on) => settings.loop = on);
9677
- pressed("mn-play-count", "Count-in", mark(COUNT_IN2), false, (on) => settings.countIn = on);
9678
- pressed("mn-play-click", "Click", mark(CLICK4), true, (on) => settings.click = on);
9679
- const slider = (label, min, max, value, set, glyph) => {
9680
- const field = html(doc, "label", "mn-play-field");
9681
- field.title = `${label}: ${value}`;
9682
- const tag = html(doc, "span", "mn-play-label");
9683
- tag.setAttribute("aria-hidden", "true");
9684
- tag.append(glyph);
9685
- const input = html(doc, "input");
9686
- input.type = "range";
9687
- input.min = String(min);
9688
- input.max = String(max);
9689
- input.value = String(value);
9690
- input.setAttribute("aria-label", label);
9691
- input.addEventListener("input", () => {
9692
- set(Number(input.value));
9693
- field.title = `${label}: ${input.value}`;
9694
- });
9695
- field.append(tag, input);
9696
- bar.appendChild(field);
9697
- };
9698
- slider("Tempo (BPM)", 20, 240, settings.bpm, (n) => {
9692
+ bar.append(pressedButton(doc, "mn-play-loop", "Loop", "loop", false, (on) => settings.loop = on), pressedButton(doc, "mn-play-count", "Count-in", "count", false, (on) => {
9693
+ settings.countIn = on;
9694
+ }), pressedButton(doc, "mn-play-click", "Click", "click", true, (on) => settings.click = on));
9695
+ bar.appendChild(valueSlider(doc, "Tempo (BPM)", "BPM", 20, 240, settings.bpm, (n) => {
9699
9696
  settings.bpm = tempoOf(n);
9700
9697
  app.tempoChanged(settings.bpm);
9701
- }, compound ? "♩." : "♩");
9702
- slider("Volume", 0, 100, Math.round(settings.volume * 100), (n) => settings.volume = n / 100, icon(doc, "volume"));
9703
- const select = (cls, label, values, chosen, names, set) => {
9704
- const el = html(doc, "select", cls);
9705
- el.setAttribute("aria-label", label);
9706
- el.title = label;
9707
- for (const value of values) {
9708
- const option = html(doc, "option", undefined, names[value]);
9709
- option.value = value;
9710
- option.selected = value === chosen;
9711
- el.appendChild(option);
9712
- }
9713
- el.addEventListener("change", () => set(el.value));
9714
- bar.appendChild(el);
9715
- };
9698
+ }, compound ? "counts dotted quarters" : undefined).field);
9716
9699
  const strums = [
9717
9700
  ...pattern ? ["pattern"] : [],
9718
9701
  ...PROGRESSION_STRUMS
9719
9702
  ];
9720
- select("mn-play-strum", "Strum", strums, strum, STRUM_LABELS, (value) => {
9703
+ bar.appendChild(choice(doc, "mn-play-strum", "Strum", strums, strum, STRUM_LABELS, (value) => {
9721
9704
  strum = value;
9722
9705
  if (playing)
9723
9706
  start();
9724
- });
9725
- select("mn-play-sound", "Sound", ["guitar", "piano"], settings.sound, { guitar: "Guitar", piano: "Piano" }, (value) => settings.sound = value === "piano" ? "piano" : "guitar");
9707
+ }));
9708
+ bar.appendChild(choice(doc, "mn-play-sound", "Sound", ["guitar", "piano"], settings.sound, { guitar: "Guitar", piano: "Piano" }, (value) => {
9709
+ settings.sound = value === "piano" ? "piano" : "guitar";
9710
+ diagrams?.setSound(settings.sound);
9711
+ }));
9726
9712
  const app = handToApp(options, bar, {
9727
9713
  kind: drawing.classList.contains("mn-chart") ? "chart" : "progression",
9728
9714
  drawing,
@@ -9731,6 +9717,10 @@ function progressionBarFor(doc, win, drawing, options) {
9731
9717
  });
9732
9718
  return () => {
9733
9719
  stop();
9720
+ if (diagrams?.onPlay === stop) {
9721
+ diagrams.onPlay = null;
9722
+ diagrams.stopOthers = null;
9723
+ }
9734
9724
  app.free();
9735
9725
  };
9736
9726
  }
@@ -9793,6 +9783,396 @@ function pickingBarFor(doc, win, drawing, options) {
9793
9783
  });
9794
9784
  }
9795
9785
 
9786
+ // src/playback/block-bar.ts
9787
+ function nameOf2(diagram) {
9788
+ const title = diagram.querySelector(".mn-title")?.textContent?.trim();
9789
+ return title || accessibleName(diagram) || "Diagram";
9790
+ }
9791
+ function noteAt(node) {
9792
+ const el = node;
9793
+ if (typeof el?.closest !== "function")
9794
+ return null;
9795
+ return el.closest("[data-midi]") ?? el.closest(".mn-mark")?.querySelector("[data-midi]") ?? null;
9796
+ }
9797
+ function diagramGroup(doc, win, diagrams, options, how) {
9798
+ const items = diagrams.map(({ diagram, data }) => {
9799
+ const wrap = html(doc, "div", "mn-playable");
9800
+ diagram.parentNode?.insertBefore(wrap, diagram);
9801
+ wrap.appendChild(diagram);
9802
+ const figure = wrap.parentElement;
9803
+ const caption = figure?.classList.contains("mn-captioned") ? [...figure.children].find((c) => c.classList.contains("mn-fingering")) : undefined;
9804
+ return {
9805
+ diagram,
9806
+ data,
9807
+ wrap,
9808
+ shown: diagram,
9809
+ other: undefined,
9810
+ caption,
9811
+ name: nameOf2(diagram),
9812
+ spoken: accessibleName(diagram) ?? nameOf2(diagram)
9813
+ };
9814
+ });
9815
+ const counts = new Map;
9816
+ for (const item of items)
9817
+ counts.set(item.name, (counts.get(item.name) ?? 0) + 1);
9818
+ items.forEach((item, i) => {
9819
+ if ((counts.get(item.name) ?? 0) <= 1)
9820
+ return;
9821
+ const place = ` (${i + 1} of ${items.length})`;
9822
+ item.name += place;
9823
+ item.spoken += place;
9824
+ });
9825
+ const strums = strumsOf(options.strum);
9826
+ const settings = {
9827
+ chosen: options.sound ?? null,
9828
+ bpm: clamp(options.bpm, 20, 240, DEFAULT_SEQUENCE.bpm),
9829
+ loop: false
9830
+ };
9831
+ let selected = items[0];
9832
+ let playing = null;
9833
+ let playingItem = null;
9834
+ let lights = null;
9835
+ let inTurn = false;
9836
+ let pause = null;
9837
+ let ui = null;
9838
+ let alive = true;
9839
+ let run = 0;
9840
+ const self = {
9841
+ stop: () => stop(),
9842
+ setSound: (sound) => setSound(sound),
9843
+ onPlay: null,
9844
+ stopOthers: null,
9845
+ destroy() {
9846
+ stop();
9847
+ alive = false;
9848
+ }
9849
+ };
9850
+ const soundOf = (item) => settings.chosen ?? item.data.sound;
9851
+ const connected = () => items.some((item) => item.wrap.isConnected);
9852
+ const changed = () => ui?.changed();
9853
+ const clearPause = () => {
9854
+ if (pause)
9855
+ pause.win.clearTimeout(pause.id);
9856
+ pause = null;
9857
+ };
9858
+ const later = (item, ms, then) => {
9859
+ clearPause();
9860
+ const here = item.wrap.ownerDocument.defaultView ?? win;
9861
+ pause = {
9862
+ win: here,
9863
+ id: here.setTimeout(() => {
9864
+ pause = null;
9865
+ then();
9866
+ }, ms)
9867
+ };
9868
+ };
9869
+ const ended = (mine, then) => () => queueMicrotask(() => {
9870
+ if (mine === run)
9871
+ then();
9872
+ });
9873
+ const stop = () => {
9874
+ clearPause();
9875
+ inTurn = false;
9876
+ run++;
9877
+ playing?.stop();
9878
+ playing = null;
9879
+ playingItem = null;
9880
+ lights?.stop();
9881
+ lights = null;
9882
+ changed();
9883
+ };
9884
+ const play = (item, events, onEnd, targets) => {
9885
+ const here = item.wrap.ownerDocument.defaultView ?? win;
9886
+ const run = (player) => {
9887
+ lights?.stop();
9888
+ const follower = followNotes(here, item.shown, targets, events, startsReported(player) ? Infinity : START_WAIT);
9889
+ lights = follower;
9890
+ const onStart = () => {
9891
+ sawStart(player);
9892
+ follower.heard();
9893
+ };
9894
+ try {
9895
+ return player.play(events, {
9896
+ sound: soundOf(item),
9897
+ volume: volumeOf(options.volume),
9898
+ onEnd,
9899
+ onStart
9900
+ });
9901
+ } catch (error) {
9902
+ follower.stop();
9903
+ throw error;
9904
+ }
9905
+ };
9906
+ try {
9907
+ return run(playerFor(here, options));
9908
+ } catch {
9909
+ return run(lightFor(here));
9910
+ }
9911
+ };
9912
+ const select = (item) => {
9913
+ selected = item;
9914
+ if (how.bar && items.length > 1)
9915
+ for (const each of items) {
9916
+ each.wrap.classList.toggle("mn-selected", each === item);
9917
+ if (each === item)
9918
+ each.wrap.setAttribute("aria-current", "true");
9919
+ else
9920
+ each.wrap.removeAttribute("aria-current");
9921
+ }
9922
+ changed();
9923
+ };
9924
+ const start = (item, turn) => {
9925
+ clearPause();
9926
+ run++;
9927
+ playing?.stop();
9928
+ playing = null;
9929
+ lights?.stop();
9930
+ lights = null;
9931
+ inTurn = turn !== null;
9932
+ if (!alive || !item.wrap.isConnected)
9933
+ return stop();
9934
+ self.onPlay?.();
9935
+ const shown = item.shown;
9936
+ const pitches = shown === item.diagram ? item.data.pitches : dataOf(shown)?.pitches ?? item.data.pitches;
9937
+ const tones = tonesOf(shown);
9938
+ const sound = soundOf(item);
9939
+ const events = sequenceOf(item.data.kind, pitches, {
9940
+ sound,
9941
+ bpm: settings.bpm,
9942
+ strum: strums[sound],
9943
+ root: shown === item.diagram ? item.data.root : rootOf2(shown),
9944
+ ...tones ? { tones } : {},
9945
+ ...shown.getAttribute("data-mn-order") === "written" ? { ordered: true } : {}
9946
+ });
9947
+ playingItem = item;
9948
+ const mine = ++run;
9949
+ playing = play(item, events, ended(mine, () => {
9950
+ playing = null;
9951
+ playingItem = null;
9952
+ if (inTurn && turn !== null)
9953
+ later(item, 60000 / settings.bpm, () => next(turn + 1));
9954
+ else if (settings.loop && item.wrap.isConnected && alive)
9955
+ later(item, 0, () => start(item, null));
9956
+ else
9957
+ changed();
9958
+ }), noteTargets(shown, events, item.data.kind));
9959
+ changed();
9960
+ };
9961
+ const next = (index) => {
9962
+ if (!inTurn || !alive)
9963
+ return;
9964
+ if (!connected())
9965
+ return stop();
9966
+ if (index >= items.length) {
9967
+ if (!settings.loop)
9968
+ return stop();
9969
+ index = 0;
9970
+ }
9971
+ const item = items[index];
9972
+ select(item);
9973
+ start(item, index);
9974
+ };
9975
+ const playAll = () => {
9976
+ stop();
9977
+ inTurn = true;
9978
+ next(0);
9979
+ };
9980
+ const playNote = (item, target) => {
9981
+ const midi = Number(target.getAttribute("data-midi"));
9982
+ if (!alive || !Number.isFinite(midi))
9983
+ return;
9984
+ stop();
9985
+ select(item);
9986
+ self.onPlay?.();
9987
+ const strum = (target.getAttribute("data-mn-strum") ?? "").split(" ").filter(Boolean).map(Number).filter((n) => Number.isFinite(n));
9988
+ const sound = soundOf(item);
9989
+ const events = strum.length ? sequenceOf("chord", strum, { sound, bpm: settings.bpm, strum: strums[sound] }) : [{ midi, time: 0, duration: 1.5 }];
9990
+ const mine = ++run;
9991
+ playing = play(item, events, ended(mine, () => {
9992
+ playing = null;
9993
+ changed();
9994
+ }), events.map(() => [target]));
9995
+ changed();
9996
+ };
9997
+ const press = (item) => {
9998
+ if (!alive)
9999
+ return;
10000
+ if (playingItem === item || inTurn && selected === item)
10001
+ return stop();
10002
+ select(item);
10003
+ start(item, null);
10004
+ };
10005
+ const drawFor = (item) => {
10006
+ if (!how.bar)
10007
+ return;
10008
+ if (item.diagram.getAttribute("data-mn-redraw") === "no")
10009
+ return;
10010
+ const sound = soundOf(item);
10011
+ if (sound !== item.data.sound)
10012
+ item.other ??= redrawFor(doc, item.diagram, item.data, options.hand);
10013
+ const next = sound === item.data.sound ? item.diagram : item.other ?? item.diagram;
10014
+ if (next !== item.shown && item.shown.parentNode === item.wrap) {
10015
+ item.wrap.replaceChild(next, item.shown);
10016
+ item.shown = next;
10017
+ }
10018
+ if (item.caption)
10019
+ item.caption.hidden = item.shown !== item.diagram;
10020
+ };
10021
+ const setSound = (sound) => {
10022
+ stop();
10023
+ settings.chosen = sound;
10024
+ for (const item of items)
10025
+ drawFor(item);
10026
+ changed();
10027
+ };
10028
+ for (const item of items) {
10029
+ const { wrap } = item;
10030
+ wrap.tabIndex = 0;
10031
+ wrap.setAttribute("role", "button");
10032
+ const label = html(doc, "span", "mn-playable-name", `Play ${item.spoken}`);
10033
+ label.id = uniqueId();
10034
+ label.hidden = true;
10035
+ wrap.prepend(label);
10036
+ wrap.setAttribute("aria-labelledby", label.id);
10037
+ wrap.addEventListener("mousedown", (event) => event.stopPropagation());
10038
+ wrap.addEventListener("click", (event) => {
10039
+ const note = noteAt(event.target);
10040
+ if (note && item.shown.contains(note))
10041
+ playNote(item, note);
10042
+ else
10043
+ press(item);
10044
+ });
10045
+ wrap.addEventListener("keydown", (event) => {
10046
+ if (event.target !== wrap)
10047
+ return;
10048
+ if (event.key === " " || event.key === "Enter") {
10049
+ event.preventDefault();
10050
+ press(item);
10051
+ } else if (event.key === "Escape") {
10052
+ const here = playing !== null || inTurn;
10053
+ const others = self.stopOthers?.() ?? false;
10054
+ if (here)
10055
+ stop();
10056
+ if (here || others)
10057
+ event.preventDefault();
10058
+ }
10059
+ });
10060
+ }
10061
+ for (const item of items)
10062
+ drawFor(item);
10063
+ select(selected);
10064
+ const api = {
10065
+ get selected() {
10066
+ return selected;
10067
+ },
10068
+ get busy() {
10069
+ return playing !== null || inTurn || pause !== null;
10070
+ },
10071
+ get inTurn() {
10072
+ return inTurn;
10073
+ },
10074
+ get sound() {
10075
+ return soundOf(selected);
10076
+ },
10077
+ get bpm() {
10078
+ return settings.bpm;
10079
+ },
10080
+ set bpm(n) {
10081
+ settings.bpm = n;
10082
+ },
10083
+ strumOf: (sound) => strums[sound],
10084
+ setStrum(sound, n) {
10085
+ strums[sound] = n;
10086
+ },
10087
+ get loop() {
10088
+ return settings.loop;
10089
+ },
10090
+ set loop(on) {
10091
+ settings.loop = on;
10092
+ },
10093
+ playSelected: () => start(selected, null),
10094
+ playAll,
10095
+ stop
10096
+ };
10097
+ return {
10098
+ group: self,
10099
+ items,
10100
+ api,
10101
+ bind: (given) => {
10102
+ ui = given;
10103
+ changed();
10104
+ }
10105
+ };
10106
+ }
10107
+ function placeBar(block, last, bar) {
10108
+ if (last.parentElement?.classList.contains("mn-exercise-block")) {
10109
+ last.after(bar);
10110
+ return;
10111
+ }
10112
+ let node = last;
10113
+ while (node.parentElement && node.parentElement !== block)
10114
+ node = node.parentElement;
10115
+ if (node.parentElement === block)
10116
+ node.after(bar);
10117
+ else
10118
+ block.appendChild(bar);
10119
+ }
10120
+ function blockBarFor(doc, win, block, diagrams, options) {
10121
+ const {
10122
+ group,
10123
+ items,
10124
+ api: made,
10125
+ bind
10126
+ } = diagramGroup(doc, win, diagrams, options, {
10127
+ bar: true
10128
+ });
10129
+ const several = items.length > 1;
10130
+ const bar = playBar(doc, "mn-block-bar", "Playback");
10131
+ placeBar(block, items[items.length - 1].wrap, bar);
10132
+ const toggle = html(doc, "button", "mn-play-toggle");
10133
+ toggle.type = "button";
10134
+ toggle.addEventListener("click", () => made.busy ? made.stop() : made.playSelected());
10135
+ bar.appendChild(toggle);
10136
+ if (several) {
10137
+ const all = iconButton(doc, "mn-play-all", "Play all in turn", "all");
10138
+ all.addEventListener("click", () => made.inTurn ? made.stop() : made.playAll());
10139
+ bar.appendChild(all);
10140
+ }
10141
+ const name = several ? html(doc, "span", "mn-play-name") : null;
10142
+ if (name)
10143
+ bar.appendChild(name);
10144
+ bar.appendChild(pressedButton(doc, "mn-play-loop", "Loop", "loop", false, (on) => made.loop = on));
10145
+ const tempo = items.some((i) => i.data.kind === "scale" && i.data.pitches.length > 1) ? valueSlider(doc, "Tempo (BPM)", "BPM", 20, 240, made.bpm, (n) => made.bpm = n) : null;
10146
+ const strum = items.some((i) => i.data.kind === "chord" && i.data.pitches.length > 1) ? valueSlider(doc, "Strum (ms between strings)", "ms", 0, 200, made.strumOf(made.sound), (n) => made.setStrum(made.sound, n)) : null;
10147
+ if (tempo)
10148
+ bar.appendChild(tempo.field);
10149
+ if (strum)
10150
+ bar.appendChild(strum.field);
10151
+ const sound = choice(doc, "mn-play-sound", "Sound", ["guitar", "piano"], made.sound, { guitar: "Guitar", piano: "Piano" }, (value) => group.setSound(value === "piano" ? "piano" : "guitar"));
10152
+ bar.appendChild(sound);
10153
+ bind({
10154
+ changed() {
10155
+ const busy = made.busy;
10156
+ toggle.replaceChildren(icon(doc, busy ? "stop" : "play"));
10157
+ toggle.setAttribute("aria-label", busy ? "Stop" : "Play");
10158
+ toggle.title = busy ? "Stop" : "Play";
10159
+ const item = made.selected;
10160
+ if (name)
10161
+ name.textContent = item.name;
10162
+ bar.setAttribute("aria-label", `Play ${item.spoken}`);
10163
+ const several = item.data.pitches.length > 1;
10164
+ if (tempo)
10165
+ tempo.field.hidden = !(several && item.data.kind === "scale");
10166
+ if (strum) {
10167
+ strum.field.hidden = !(several && item.data.kind === "chord");
10168
+ strum.show(made.strumOf(made.sound));
10169
+ }
10170
+ sound.value = made.sound;
10171
+ }
10172
+ });
10173
+ return () => group.destroy();
10174
+ }
10175
+
9796
10176
  // src/playback/controls.ts
9797
10177
  var clamp = (n, lo, hi, fallback) => n === undefined || !Number.isFinite(n) ? fallback : Math.min(hi, Math.max(lo, n));
9798
10178
  function strumsOf(strum) {
@@ -9802,23 +10182,6 @@ function strumsOf(strum) {
9802
10182
  piano: clamp(given.piano, 0, 200, DEFAULT_STRUM.piano)
9803
10183
  };
9804
10184
  }
9805
- var ICONS = {
9806
- play: "M4 2.5v11l9-5.5z",
9807
- stop: "M4 4h8v8H4z",
9808
- loop: "M3 8a5 5 0 0 1 8.5-3.5L13 6V2.5M13 8a5 5 0 0 1-8.5 3.5L3 10v3.5",
9809
- volume: "M2 6h3l4-3v10l-4-3H2zM11 5.5a3.5 3.5 0 0 1 0 5"
9810
- };
9811
- function icon(doc, name) {
9812
- const root = svg(doc, "svg", {
9813
- class: `mn-play-icon mn-play-icon-${name}`,
9814
- viewBox: "0 0 16 16",
9815
- width: 12,
9816
- height: 12,
9817
- "aria-hidden": "true"
9818
- });
9819
- root.appendChild(svg(doc, "path", { d: ICONS[name] }));
9820
- return root;
9821
- }
9822
10185
  var players = new WeakMap;
9823
10186
  function lightFor(win) {
9824
10187
  let player = players.get(win);
@@ -9946,211 +10309,35 @@ function attachPlayback(el, options = {}) {
9946
10309
  if (!win)
9947
10310
  return () => {};
9948
10311
  const stops = [];
10312
+ for (const pattern of [...el.querySelectorAll("svg[data-mn-strum]")])
10313
+ stops.push(strumBarFor(doc, win, pattern, options));
10314
+ for (const pattern of [...el.querySelectorAll("svg[data-mn-picking]")])
10315
+ stops.push(pickingBarFor(doc, win, pattern, options));
10316
+ const timed = [...el.querySelectorAll("[data-mn-progression-play]")];
10317
+ const byBlock = new Map;
10318
+ const byDrawing = new Map;
9949
10319
  for (const diagram of [...el.querySelectorAll("svg[data-mn-pitches]")]) {
9950
10320
  const data = dataOf(diagram);
9951
10321
  if (!data)
9952
10322
  continue;
9953
- stops.push(barFor(doc, win, diagram, data, options));
10323
+ const drawing = timed.find((t) => t.contains(diagram));
10324
+ const key = drawing ?? diagram.closest(".mn-block") ?? el;
10325
+ const map = drawing ? byDrawing : byBlock;
10326
+ map.set(key, [...map.get(key) ?? [], { diagram, data }]);
10327
+ }
10328
+ for (const [block, diagrams] of byBlock)
10329
+ stops.push(blockBarFor(doc, win, block, diagrams, options));
10330
+ for (const drawing of timed) {
10331
+ const diagrams = byDrawing.get(drawing);
10332
+ const group = diagrams?.length ? diagramGroup(doc, win, diagrams, options, { bar: false }).group : null;
10333
+ const bar = progressionBarFor(doc, win, drawing, options, group);
10334
+ stops.push(() => {
10335
+ bar();
10336
+ group?.destroy();
10337
+ });
9954
10338
  }
9955
- for (const pattern of [...el.querySelectorAll("svg[data-mn-strum]")])
9956
- stops.push(strumBarFor(doc, win, pattern, options));
9957
- for (const pattern of [...el.querySelectorAll("svg[data-mn-picking]")])
9958
- stops.push(pickingBarFor(doc, win, pattern, options));
9959
- for (const drawing of [...el.querySelectorAll("[data-mn-progression-play]")])
9960
- stops.push(progressionBarFor(doc, win, drawing, options));
9961
10339
  return () => stops.forEach((stop) => stop());
9962
10340
  }
9963
- function barFor(doc, win, diagram, data, options) {
9964
- const wrap = html(doc, "div", "mn-playable");
9965
- diagram.parentNode?.insertBefore(wrap, diagram);
9966
- wrap.appendChild(diagram);
9967
- const bar = html(doc, "div", "mn-play");
9968
- bar.addEventListener("mousedown", (event) => event.stopPropagation());
9969
- bar.setAttribute("role", "group");
9970
- const name = accessibleName(diagram);
9971
- bar.setAttribute("aria-label", name ? `Play ${name}` : "Playback");
9972
- wrap.appendChild(bar);
9973
- const firstSound = options.sound ?? data.sound;
9974
- const strums = strumsOf(options.strum);
9975
- const settings = {
9976
- sound: firstSound,
9977
- volume: clamp(options.volume, 0, 1, 0.8),
9978
- bpm: clamp(options.bpm, 20, 240, DEFAULT_SEQUENCE.bpm),
9979
- strum: strums[firstSound],
9980
- loop: false
9981
- };
9982
- let playing = null;
9983
- let lights = null;
9984
- let shown = diagram;
9985
- const pitchesShown = () => shown === diagram ? data.pitches : dataOf(shown)?.pitches ?? data.pitches;
9986
- const rootShown = () => shown === diagram ? data.root : rootOf2(shown);
9987
- const toggle = html(doc, "button", "mn-play-toggle");
9988
- toggle.type = "button";
9989
- const show = () => {
9990
- toggle.replaceChildren(icon(doc, playing ? "stop" : "play"));
9991
- toggle.setAttribute("aria-label", playing ? "Stop" : "Play");
9992
- toggle.title = playing ? "Stop" : "Play";
9993
- };
9994
- const stop = () => {
9995
- playing?.stop();
9996
- playing = null;
9997
- lights?.stop();
9998
- lights = null;
9999
- show();
10000
- };
10001
- const play = (events, onEnd, targets) => {
10002
- const here = wrap.ownerDocument.defaultView ?? win;
10003
- const run = (player) => {
10004
- lights?.stop();
10005
- const follower = followNotes(here, shown, targets, events, startsReported(player) ? Infinity : START_WAIT);
10006
- lights = follower;
10007
- const onStart = () => {
10008
- sawStart(player);
10009
- follower.heard();
10010
- };
10011
- try {
10012
- return player.play(events, {
10013
- sound: settings.sound,
10014
- volume: settings.volume,
10015
- onEnd,
10016
- onStart
10017
- });
10018
- } catch (error) {
10019
- follower.stop();
10020
- throw error;
10021
- }
10022
- };
10023
- try {
10024
- return run(playerFor(here, options));
10025
- } catch {
10026
- return run(lightFor(here));
10027
- }
10028
- };
10029
- const start = () => {
10030
- stop();
10031
- if (!wrap.isConnected)
10032
- return;
10033
- const tones = tonesOf(shown);
10034
- const events = sequenceOf(data.kind, pitchesShown(), {
10035
- ...settings,
10036
- root: rootShown(),
10037
- ...tones ? { tones } : {},
10038
- ...shown.getAttribute("data-mn-order") === "written" ? { ordered: true } : {}
10039
- });
10040
- playing = play(events, () => {
10041
- playing = null;
10042
- if (settings.loop && wrap.isConnected)
10043
- start();
10044
- else
10045
- show();
10046
- }, noteTargets(shown, events, data.kind));
10047
- show();
10048
- };
10049
- toggle.addEventListener("click", () => playing ? stop() : start());
10050
- show();
10051
- bar.appendChild(toggle);
10052
- const loop = html(doc, "button", "mn-play-loop");
10053
- loop.type = "button";
10054
- loop.appendChild(icon(doc, "loop"));
10055
- loop.title = "Loop";
10056
- loop.setAttribute("aria-label", "Loop");
10057
- loop.setAttribute("aria-pressed", "false");
10058
- loop.addEventListener("click", () => {
10059
- settings.loop = !settings.loop;
10060
- loop.setAttribute("aria-pressed", String(settings.loop));
10061
- loop.classList.toggle("mn-on", settings.loop);
10062
- });
10063
- bar.appendChild(loop);
10064
- const slider = (label, min, max, value, set, mark) => {
10065
- const field = html(doc, "label", "mn-play-field");
10066
- field.title = `${label}: ${value}`;
10067
- const tag = html(doc, "span", "mn-play-label");
10068
- tag.setAttribute("aria-hidden", "true");
10069
- tag.append(mark);
10070
- const input = html(doc, "input");
10071
- input.type = "range";
10072
- input.min = String(min);
10073
- input.max = String(max);
10074
- input.value = String(value);
10075
- input.setAttribute("aria-label", label);
10076
- input.addEventListener("input", () => {
10077
- set(Number(input.value));
10078
- field.title = `${label}: ${input.value}`;
10079
- });
10080
- field.append(tag, input);
10081
- bar.appendChild(field);
10082
- return (n) => {
10083
- input.value = String(n);
10084
- field.title = `${label}: ${n}`;
10085
- };
10086
- };
10087
- let showStrum = null;
10088
- if (data.pitches.length > 1) {
10089
- if (data.kind === "scale")
10090
- slider("Tempo (BPM)", 20, 240, settings.bpm, (n) => settings.bpm = n, "♩");
10091
- else
10092
- showStrum = slider("Strum (ms between strings)", 0, 200, settings.strum, (n) => {
10093
- settings.strum = n;
10094
- strums[settings.sound] = n;
10095
- }, "≋");
10096
- }
10097
- slider("Volume", 0, 100, Math.round(settings.volume * 100), (n) => settings.volume = n / 100, icon(doc, "volume"));
10098
- const sound = html(doc, "select", "mn-play-sound");
10099
- sound.setAttribute("aria-label", "Sound");
10100
- for (const value of ["guitar", "piano"]) {
10101
- const option = html(doc, "option", undefined, value === "guitar" ? "Guitar" : "Piano");
10102
- option.value = value;
10103
- option.selected = value === settings.sound;
10104
- sound.appendChild(option);
10105
- }
10106
- let other;
10107
- const redraws = diagram.getAttribute("data-mn-redraw") !== "no";
10108
- const figure = wrap.parentElement;
10109
- const caption = figure?.classList.contains("mn-captioned") ? [...figure.children].find((c) => c.classList.contains("mn-fingering")) : undefined;
10110
- const drawFor = () => {
10111
- if (!redraws)
10112
- return;
10113
- if (settings.sound !== data.sound)
10114
- other ??= redrawFor(doc, diagram, data, options.hand);
10115
- const next = settings.sound === data.sound ? diagram : other ?? diagram;
10116
- if (next !== shown && shown.parentNode === wrap) {
10117
- wrap.replaceChild(next, shown);
10118
- shown = next;
10119
- }
10120
- if (caption)
10121
- caption.hidden = shown !== diagram;
10122
- };
10123
- sound.addEventListener("change", () => {
10124
- stop();
10125
- settings.sound = sound.value === "piano" ? "piano" : "guitar";
10126
- settings.strum = strums[settings.sound];
10127
- showStrum?.(settings.strum);
10128
- drawFor();
10129
- });
10130
- drawFor();
10131
- bar.appendChild(sound);
10132
- wrap.addEventListener("click", (event) => {
10133
- const node = event.target;
10134
- const target = typeof node?.closest === "function" ? node.closest("[data-midi]") ?? node.closest(".mn-mark")?.querySelector("[data-midi]") ?? null : null;
10135
- const midi = Number(target?.getAttribute("data-midi"));
10136
- if (!target || !Number.isFinite(midi))
10137
- return;
10138
- stop();
10139
- const strum = (target.getAttribute("data-mn-strum") ?? "").split(" ").filter(Boolean).map(Number).filter((n) => Number.isFinite(n));
10140
- const events = strum.length ? sequenceOf("chord", strum, settings) : [{ midi, time: 0, duration: 1.5 }];
10141
- playing = play(events, () => {
10142
- playing = null;
10143
- show();
10144
- }, events.map(() => [target]));
10145
- show();
10146
- });
10147
- wrap.addEventListener("pointerdown", (event) => {
10148
- if (event.pointerType !== "touch" || bar.contains(event.target))
10149
- return;
10150
- wrap.classList.toggle("mn-play-open");
10151
- });
10152
- return stop;
10153
- }
10154
10341
 
10155
10342
  // src/blocks/properties.ts
10156
10343
  var DEFAULT_PROPERTY_NAMES = {
@@ -11310,5 +11497,5 @@ export {
11310
11497
  renderAll
11311
11498
  };
11312
11499
 
11313
- //# debugId=A62ED8A359C490EB64756E2164756E21
11500
+ //# debugId=E4744F393E5C5B7564756E2164756E21
11314
11501
  //# sourceMappingURL=index.js.map