@onjmin/dtm 0.1.31 → 0.1.33

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/dist/index.d.mts CHANGED
@@ -1219,6 +1219,13 @@ type MmlPlayerOptions = {
1219
1219
  embedUrl?: string;
1220
1220
  /** 利用規約への同意画面の表示をスキップするかどうか */
1221
1221
  skipConsent?: boolean;
1222
+ /**
1223
+ * 「MMLを表示」「MMLコピー」押下時に呼ばれる MML 取得コールバック。
1224
+ * 省略時は mountMmlPlayer に渡した mml をそのまま使う。
1225
+ * DAW と連携する場合は `() => daw.getMML().full` を渡すと
1226
+ * 常に最新の full フォーマット(メタ行・#end; 込み)を返せる。
1227
+ */
1228
+ getMml?: () => string;
1222
1229
  };
1223
1230
  type MmlPlayerInstance = {
1224
1231
  play: () => void;
package/dist/index.d.ts CHANGED
@@ -1219,6 +1219,13 @@ type MmlPlayerOptions = {
1219
1219
  embedUrl?: string;
1220
1220
  /** 利用規約への同意画面の表示をスキップするかどうか */
1221
1221
  skipConsent?: boolean;
1222
+ /**
1223
+ * 「MMLを表示」「MMLコピー」押下時に呼ばれる MML 取得コールバック。
1224
+ * 省略時は mountMmlPlayer に渡した mml をそのまま使う。
1225
+ * DAW と連携する場合は `() => daw.getMML().full` を渡すと
1226
+ * 常に最新の full フォーマット(メタ行・#end; 込み)を返せる。
1227
+ */
1228
+ getMml?: () => string;
1222
1229
  };
1223
1230
  type MmlPlayerInstance = {
1224
1231
  play: () => void;
package/dist/index.js CHANGED
@@ -6703,13 +6703,27 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6703
6703
  showMmlItem.addEventListener("click", (e) => {
6704
6704
  e.stopPropagation();
6705
6705
  toggleMenu(false);
6706
- const modalBody = openInfoModal("MML");
6706
+ const modalBody = openInfoModal("MML\u3092\u8868\u793A");
6707
+ const desc = doc.createElement("p");
6708
+ desc.textContent = "\u3053\u306EMML\u3092\u30B3\u30D4\u30FC\u3057\u3066\u3001\u4ED6\u306E\u30D7\u30EC\u30A4\u30E4\u30FC\u3084\u5171\u6709URL\u306B\u8CBC\u308A\u4ED8\u3051\u3066\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002";
6709
+ desc.style.marginBottom = "8px";
6710
+ modalBody.appendChild(desc);
6711
+ const sourceMml = options.getMml?.() ?? mml;
6712
+ const displayMml = sourceMml.split(";").map((s) => s.trim()).filter((s) => s.length > 0).join(";\n");
6707
6713
  const pre = doc.createElement("pre");
6708
- pre.textContent = mml;
6714
+ pre.textContent = displayMml;
6709
6715
  pre.style.whiteSpace = "pre-wrap";
6710
6716
  pre.style.wordBreak = "break-all";
6717
+ pre.style.cursor = "text";
6718
+ pre.addEventListener("click", () => {
6719
+ const range = doc.createRange();
6720
+ range.selectNodeContents(pre);
6721
+ const sel = doc.defaultView?.getSelection();
6722
+ sel?.removeAllRanges();
6723
+ sel?.addRange(range);
6724
+ });
6711
6725
  modalBody.appendChild(pre);
6712
- appendCopyButton(modalBody, mml);
6726
+ appendCopyButton(modalBody, sourceMml);
6713
6727
  });
6714
6728
  mmlInfoItem.addEventListener("click", (e) => {
6715
6729
  e.stopPropagation();
@@ -6747,7 +6761,7 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6747
6761
  });
6748
6762
  copyMmlItem.addEventListener("click", async (e) => {
6749
6763
  e.stopPropagation();
6750
- const success = await copyToClipboard(doc, mml);
6764
+ const success = await copyToClipboard(doc, options.getMml?.() ?? mml);
6751
6765
  if (success) {
6752
6766
  copyMmlItem.textContent = "\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F\uFF01";
6753
6767
  } else {
@@ -8265,7 +8279,7 @@ var mountDAW = (target, options = {}) => {
8265
8279
  redrawAll();
8266
8280
  };
8267
8281
  const togglePlay = () => {
8268
- if (playbackState === "playing") pause();
8282
+ if (playbackState === "playing") stop();
8269
8283
  else play();
8270
8284
  };
8271
8285
  const updateTransport = () => {
@@ -8791,6 +8805,14 @@ var mountDAW = (target, options = {}) => {
8791
8805
  stop();
8792
8806
  clearAll();
8793
8807
  for (const t of trackStates) t.core.setLoadMode(true);
8808
+ for (const t of trackStates) {
8809
+ t.lyrics = "";
8810
+ t.lyricModel = "";
8811
+ t.vocalVolume = DEFAULT_VOCAL_VOLUME;
8812
+ t.vocalGate = 100;
8813
+ t.vocalPan = 64;
8814
+ t.vocalOctave = 0;
8815
+ }
8794
8816
  const { placements, bpm: parsedBpm } = isAdvanced ? extractMidiPlacementsByTrack(
8795
8817
  midi,
8796
8818
  selectedIndices,
@@ -8818,6 +8840,7 @@ var mountDAW = (target, options = {}) => {
8818
8840
  setDrawOffset(currentOffsetX, currentOffsetY);
8819
8841
  }
8820
8842
  redrawAll();
8843
+ updateTrackPanel();
8821
8844
  updateUndoRedo();
8822
8845
  };
8823
8846
  const exportMIDI2 = () => exportMIDI({
@@ -9116,13 +9139,13 @@ var mountDAW = (target, options = {}) => {
9116
9139
  );
9117
9140
  if (showMidi) wireMidi();
9118
9141
  document.addEventListener("keydown", onKeyDown);
9119
- for (const ta of refs.root.querySelectorAll("textarea, input")) {
9120
- ta.addEventListener("keydown", (e) => {
9121
- const ke = e;
9122
- if ((ke.ctrlKey || ke.metaKey) && ["KeyZ", "KeyY", "KeyV", "KeyC", "KeyX"].includes(ke.code))
9123
- e.stopPropagation();
9124
- });
9125
- }
9142
+ refs.root.addEventListener("keydown", (e) => {
9143
+ const t = e.target;
9144
+ if (t.tagName !== "TEXTAREA" && t.tagName !== "INPUT") return;
9145
+ const ke = e;
9146
+ if ((ke.ctrlKey || ke.metaKey) && ["KeyZ", "KeyY", "KeyV", "KeyC", "KeyX"].includes(ke.code))
9147
+ e.stopPropagation();
9148
+ });
9126
9149
  };
9127
9150
  let pendingMidi = null;
9128
9151
  let detectedTracks = [];
package/dist/index.mjs CHANGED
@@ -6592,13 +6592,27 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6592
6592
  showMmlItem.addEventListener("click", (e) => {
6593
6593
  e.stopPropagation();
6594
6594
  toggleMenu(false);
6595
- const modalBody = openInfoModal("MML");
6595
+ const modalBody = openInfoModal("MML\u3092\u8868\u793A");
6596
+ const desc = doc.createElement("p");
6597
+ desc.textContent = "\u3053\u306EMML\u3092\u30B3\u30D4\u30FC\u3057\u3066\u3001\u4ED6\u306E\u30D7\u30EC\u30A4\u30E4\u30FC\u3084\u5171\u6709URL\u306B\u8CBC\u308A\u4ED8\u3051\u3066\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002";
6598
+ desc.style.marginBottom = "8px";
6599
+ modalBody.appendChild(desc);
6600
+ const sourceMml = options.getMml?.() ?? mml;
6601
+ const displayMml = sourceMml.split(";").map((s) => s.trim()).filter((s) => s.length > 0).join(";\n");
6596
6602
  const pre = doc.createElement("pre");
6597
- pre.textContent = mml;
6603
+ pre.textContent = displayMml;
6598
6604
  pre.style.whiteSpace = "pre-wrap";
6599
6605
  pre.style.wordBreak = "break-all";
6606
+ pre.style.cursor = "text";
6607
+ pre.addEventListener("click", () => {
6608
+ const range = doc.createRange();
6609
+ range.selectNodeContents(pre);
6610
+ const sel = doc.defaultView?.getSelection();
6611
+ sel?.removeAllRanges();
6612
+ sel?.addRange(range);
6613
+ });
6600
6614
  modalBody.appendChild(pre);
6601
- appendCopyButton(modalBody, mml);
6615
+ appendCopyButton(modalBody, sourceMml);
6602
6616
  });
6603
6617
  mmlInfoItem.addEventListener("click", (e) => {
6604
6618
  e.stopPropagation();
@@ -6636,7 +6650,7 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6636
6650
  });
6637
6651
  copyMmlItem.addEventListener("click", async (e) => {
6638
6652
  e.stopPropagation();
6639
- const success = await copyToClipboard(doc, mml);
6653
+ const success = await copyToClipboard(doc, options.getMml?.() ?? mml);
6640
6654
  if (success) {
6641
6655
  copyMmlItem.textContent = "\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F\uFF01";
6642
6656
  } else {
@@ -8154,7 +8168,7 @@ var mountDAW = (target, options = {}) => {
8154
8168
  redrawAll();
8155
8169
  };
8156
8170
  const togglePlay = () => {
8157
- if (playbackState === "playing") pause();
8171
+ if (playbackState === "playing") stop();
8158
8172
  else play();
8159
8173
  };
8160
8174
  const updateTransport = () => {
@@ -8680,6 +8694,14 @@ var mountDAW = (target, options = {}) => {
8680
8694
  stop();
8681
8695
  clearAll();
8682
8696
  for (const t of trackStates) t.core.setLoadMode(true);
8697
+ for (const t of trackStates) {
8698
+ t.lyrics = "";
8699
+ t.lyricModel = "";
8700
+ t.vocalVolume = DEFAULT_VOCAL_VOLUME;
8701
+ t.vocalGate = 100;
8702
+ t.vocalPan = 64;
8703
+ t.vocalOctave = 0;
8704
+ }
8683
8705
  const { placements, bpm: parsedBpm } = isAdvanced ? extractMidiPlacementsByTrack(
8684
8706
  midi,
8685
8707
  selectedIndices,
@@ -8707,6 +8729,7 @@ var mountDAW = (target, options = {}) => {
8707
8729
  setDrawOffset(currentOffsetX, currentOffsetY);
8708
8730
  }
8709
8731
  redrawAll();
8732
+ updateTrackPanel();
8710
8733
  updateUndoRedo();
8711
8734
  };
8712
8735
  const exportMIDI2 = () => exportMIDI({
@@ -9005,13 +9028,13 @@ var mountDAW = (target, options = {}) => {
9005
9028
  );
9006
9029
  if (showMidi) wireMidi();
9007
9030
  document.addEventListener("keydown", onKeyDown);
9008
- for (const ta of refs.root.querySelectorAll("textarea, input")) {
9009
- ta.addEventListener("keydown", (e) => {
9010
- const ke = e;
9011
- if ((ke.ctrlKey || ke.metaKey) && ["KeyZ", "KeyY", "KeyV", "KeyC", "KeyX"].includes(ke.code))
9012
- e.stopPropagation();
9013
- });
9014
- }
9031
+ refs.root.addEventListener("keydown", (e) => {
9032
+ const t = e.target;
9033
+ if (t.tagName !== "TEXTAREA" && t.tagName !== "INPUT") return;
9034
+ const ke = e;
9035
+ if ((ke.ctrlKey || ke.metaKey) && ["KeyZ", "KeyY", "KeyV", "KeyC", "KeyX"].includes(ke.code))
9036
+ e.stopPropagation();
9037
+ });
9015
9038
  };
9016
9039
  let pendingMidi = null;
9017
9040
  let detectedTracks = [];
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "onjmin",
3
3
  "license": "MIT",
4
4
  "name": "@onjmin/dtm",
5
- "version": "0.1.31",
5
+ "version": "0.1.33",
6
6
  "description": "MMLを中間言語に用いた、モバイルファーストなDAW / ピアノロール打ち込みコンポーネント",
7
7
  "homepage": "https://onjmin.github.io/dtm",
8
8
  "repository": {