@onjmin/dtm 0.1.26 → 0.1.27

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.js CHANGED
@@ -2717,7 +2717,7 @@ var createKoeVoice = async (ctx, destination, options) => {
2717
2717
  return model;
2718
2718
  };
2719
2719
  var PREWARM_NOTES = 3;
2720
- var STREAM_LOOKAHEAD_SEC = 1.5;
2720
+ var STREAM_LOOKAHEAD_SEC = 6;
2721
2721
  var STREAM_POLL_MS = 100;
2722
2722
  var FALLBACK_MODEL = "klatt";
2723
2723
  var createSingingVoices = (ctx, destination, options = {}) => {
@@ -2781,7 +2781,7 @@ var createSingingVoices = (ctx, destination, options = {}) => {
2781
2781
  if (!m?.renderToCache) continue;
2782
2782
  let n = 0;
2783
2783
  forEachSungNote(track, (note, prevVowel) => {
2784
- if (n >= count && note.startSec >= 3) return;
2784
+ if (n >= count && note.startSec >= STREAM_LOOKAHEAD_SEC) return;
2785
2785
  n++;
2786
2786
  promises.push(
2787
2787
  m.renderToCache?.(
@@ -6824,9 +6824,9 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6824
6824
  }
6825
6825
  target.appendChild(root);
6826
6826
  let consentOverlayEl = null;
6827
- const checkConsentAndShow = () => {
6827
+ const checkConsentAndShow = (onAgree) => {
6828
6828
  try {
6829
- if (options.skipConsent) return;
6829
+ if (options.skipConsent) return false;
6830
6830
  const unagreed = termsModels.filter((model) => {
6831
6831
  if (agreedModelsInSession.has(model)) return false;
6832
6832
  try {
@@ -6840,7 +6840,7 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6840
6840
  return true;
6841
6841
  }
6842
6842
  });
6843
- if (unagreed.length === 0) return;
6843
+ if (unagreed.length === 0) return false;
6844
6844
  const consentOverlay = doc.createElement("div");
6845
6845
  consentOverlay.className = "dtm-consent-overlay";
6846
6846
  const modal = doc.createElement("div");
@@ -6883,17 +6883,19 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6883
6883
  }
6884
6884
  consentOverlay.remove();
6885
6885
  consentOverlayEl = null;
6886
+ if (onAgree) onAgree();
6886
6887
  };
6887
6888
  footer.appendChild(btn);
6888
6889
  modal.append(header, body2, footer);
6889
6890
  consentOverlay.appendChild(modal);
6890
6891
  doc.body.appendChild(consentOverlay);
6891
6892
  consentOverlayEl = consentOverlay;
6893
+ return true;
6892
6894
  } catch (err2) {
6893
6895
  console.error("[dtm-player] Error in checkConsentAndShow:", err2);
6896
+ return false;
6894
6897
  }
6895
6898
  };
6896
- checkConsentAndShow();
6897
6899
  const autoScroll = (lane, el) => {
6898
6900
  if (el.offsetWidth === 0 || lane.clientWidth === 0) return;
6899
6901
  const elementCenter = el.offsetLeft + el.offsetWidth / 2;
@@ -7026,6 +7028,7 @@ var mountMmlPlayer = (target, mml, options = {}) => {
7026
7028
  };
7027
7029
  const play = () => {
7028
7030
  if (playing || trackIndices.length === 0) return;
7031
+ if (checkConsentAndShow(() => play())) return;
7029
7032
  if (activePlayer && activePlayer !== instance) activePlayer.stop();
7030
7033
  activePlayer = instance;
7031
7034
  setPlayingUI(true);
package/dist/index.mjs CHANGED
@@ -2609,7 +2609,7 @@ var createKoeVoice = async (ctx, destination, options) => {
2609
2609
  return model;
2610
2610
  };
2611
2611
  var PREWARM_NOTES = 3;
2612
- var STREAM_LOOKAHEAD_SEC = 1.5;
2612
+ var STREAM_LOOKAHEAD_SEC = 6;
2613
2613
  var STREAM_POLL_MS = 100;
2614
2614
  var FALLBACK_MODEL = "klatt";
2615
2615
  var createSingingVoices = (ctx, destination, options = {}) => {
@@ -2673,7 +2673,7 @@ var createSingingVoices = (ctx, destination, options = {}) => {
2673
2673
  if (!m?.renderToCache) continue;
2674
2674
  let n = 0;
2675
2675
  forEachSungNote(track, (note, prevVowel) => {
2676
- if (n >= count && note.startSec >= 3) return;
2676
+ if (n >= count && note.startSec >= STREAM_LOOKAHEAD_SEC) return;
2677
2677
  n++;
2678
2678
  promises.push(
2679
2679
  m.renderToCache?.(
@@ -6716,9 +6716,9 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6716
6716
  }
6717
6717
  target.appendChild(root);
6718
6718
  let consentOverlayEl = null;
6719
- const checkConsentAndShow = () => {
6719
+ const checkConsentAndShow = (onAgree) => {
6720
6720
  try {
6721
- if (options.skipConsent) return;
6721
+ if (options.skipConsent) return false;
6722
6722
  const unagreed = termsModels.filter((model) => {
6723
6723
  if (agreedModelsInSession.has(model)) return false;
6724
6724
  try {
@@ -6732,7 +6732,7 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6732
6732
  return true;
6733
6733
  }
6734
6734
  });
6735
- if (unagreed.length === 0) return;
6735
+ if (unagreed.length === 0) return false;
6736
6736
  const consentOverlay = doc.createElement("div");
6737
6737
  consentOverlay.className = "dtm-consent-overlay";
6738
6738
  const modal = doc.createElement("div");
@@ -6775,17 +6775,19 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6775
6775
  }
6776
6776
  consentOverlay.remove();
6777
6777
  consentOverlayEl = null;
6778
+ if (onAgree) onAgree();
6778
6779
  };
6779
6780
  footer.appendChild(btn);
6780
6781
  modal.append(header, body2, footer);
6781
6782
  consentOverlay.appendChild(modal);
6782
6783
  doc.body.appendChild(consentOverlay);
6783
6784
  consentOverlayEl = consentOverlay;
6785
+ return true;
6784
6786
  } catch (err2) {
6785
6787
  console.error("[dtm-player] Error in checkConsentAndShow:", err2);
6788
+ return false;
6786
6789
  }
6787
6790
  };
6788
- checkConsentAndShow();
6789
6791
  const autoScroll = (lane, el) => {
6790
6792
  if (el.offsetWidth === 0 || lane.clientWidth === 0) return;
6791
6793
  const elementCenter = el.offsetLeft + el.offsetWidth / 2;
@@ -6918,6 +6920,7 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6918
6920
  };
6919
6921
  const play = () => {
6920
6922
  if (playing || trackIndices.length === 0) return;
6923
+ if (checkConsentAndShow(() => play())) return;
6921
6924
  if (activePlayer && activePlayer !== instance) activePlayer.stop();
6922
6925
  activePlayer = instance;
6923
6926
  setPlayingUI(true);
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.26",
5
+ "version": "0.1.27",
6
6
  "description": "MMLを中間言語に用いた、モバイルファーストなDAW / ピアノロール打ち込みコンポーネント",
7
7
  "homepage": "https://onjmin.github.io/dtm",
8
8
  "repository": {