@onjmin/dtm 0.1.73 → 0.1.75

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
@@ -271,7 +271,7 @@ async function buildNameToKeyMapping() {
271
271
  }
272
272
  var GM_INSTRUMENT_NAMES = FONT_NAME_SURIKOV.trim().split("\n").map((line) => line.slice(line.indexOf(" ") + 1));
273
273
 
274
- // node_modules/.pnpm/@onjmin+chord-parser@1.0.2/node_modules/@onjmin/chord-parser/dist/index.mjs
274
+ // node_modules/.pnpm/@onjmin+chord-parser@1.0.4/node_modules/@onjmin/chord-parser/dist/index.mjs
275
275
  var SHARP_NAMES = [
276
276
  "C",
277
277
  "C#",
@@ -480,8 +480,11 @@ var parsePitch = (input, output) => {
480
480
  const pitch = pitchMatcher.parse(input);
481
481
  if (pitch === null) err(input, "Not found pitch");
482
482
  output.pitch = pitch;
483
- const half = parseHalf(input, true);
484
- if (half !== null) output.pitch += half;
483
+ for (let i = 0; i < 2; i++) {
484
+ const half = parseHalf(input, true);
485
+ if (half === null) break;
486
+ output.pitch += half;
487
+ }
485
488
  return parseBase(input, output);
486
489
  };
487
490
  var MAJOR = [0, 4, 7];
@@ -6981,7 +6984,7 @@ var parseToneMeta = (chords) => {
6981
6984
  return m ? m[1].toLowerCase() : null;
6982
6985
  };
6983
6986
  var parseMetronomeMeta = (chords) => {
6984
- return /^#\s*metronome(?:\s*=\s*on)?\s*$/im.test(chords);
6987
+ return !/^#\s*metronome\s*=\s*off\s*$/im.test(chords);
6985
6988
  };
6986
6989
  var _nameToKeyCache = null;
6987
6990
  var getNameToKey = async () => {
@@ -7917,6 +7920,7 @@ var mountChordPlayer = (target, chords, options = {}) => {
7917
7920
  currentPlaySec = playOffsetSec;
7918
7921
  ownCtx ??= options.audioContext ? null : new AudioContext();
7919
7922
  const ctx = options.audioContext ?? ownCtx;
7923
+ const resumePromise = ctx.state === "suspended" ? ctx.resume() : Promise.resolve();
7920
7924
  const cutGain = ctx.createGain();
7921
7925
  cutGain.connect(ctx.destination);
7922
7926
  activeCut = { gain: cutGain, ctx };
@@ -7928,18 +7932,15 @@ var mountChordPlayer = (target, chords, options = {}) => {
7928
7932
  setProgress(totalSec > 0 ? playOffsetSec / totalSec : 0);
7929
7933
  playInternal(startIdx, ctx, cutGain);
7930
7934
  };
7931
- if (activeGmName && !_wafCache.has(activeGmName)) {
7932
- const myAbortId = ++loadAbortId;
7933
- setLoadingUI(true);
7934
- loadWafFont(ctx, activeGmName).then(() => {
7935
- if (loadAbortId !== myAbortId) return;
7936
- setLoadingUI(false);
7937
- startPlayback();
7938
- });
7939
- } else {
7935
+ const myAbortId = ++loadAbortId;
7936
+ setLoadingUI(true);
7937
+ const wafPromise = activeGmName && !_wafCache.has(activeGmName) ? loadWafFont(ctx, activeGmName) : Promise.resolve(null);
7938
+ Promise.all([resumePromise, wafPromise]).then(() => {
7939
+ if (loadAbortId !== myAbortId) return;
7940
+ setLoadingUI(false);
7940
7941
  startPlayback();
7941
- }
7942
- preloadInstruments();
7942
+ preloadInstruments();
7943
+ });
7943
7944
  };
7944
7945
  const seekTo = (idx) => {
7945
7946
  if (isLoading) {
package/dist/index.mjs CHANGED
@@ -148,7 +148,7 @@ async function buildNameToKeyMapping() {
148
148
  }
149
149
  var GM_INSTRUMENT_NAMES = FONT_NAME_SURIKOV.trim().split("\n").map((line) => line.slice(line.indexOf(" ") + 1));
150
150
 
151
- // node_modules/.pnpm/@onjmin+chord-parser@1.0.2/node_modules/@onjmin/chord-parser/dist/index.mjs
151
+ // node_modules/.pnpm/@onjmin+chord-parser@1.0.4/node_modules/@onjmin/chord-parser/dist/index.mjs
152
152
  var SHARP_NAMES = [
153
153
  "C",
154
154
  "C#",
@@ -357,8 +357,11 @@ var parsePitch = (input, output) => {
357
357
  const pitch = pitchMatcher.parse(input);
358
358
  if (pitch === null) err(input, "Not found pitch");
359
359
  output.pitch = pitch;
360
- const half = parseHalf(input, true);
361
- if (half !== null) output.pitch += half;
360
+ for (let i = 0; i < 2; i++) {
361
+ const half = parseHalf(input, true);
362
+ if (half === null) break;
363
+ output.pitch += half;
364
+ }
362
365
  return parseBase(input, output);
363
366
  };
364
367
  var MAJOR = [0, 4, 7];
@@ -6858,7 +6861,7 @@ var parseToneMeta = (chords) => {
6858
6861
  return m ? m[1].toLowerCase() : null;
6859
6862
  };
6860
6863
  var parseMetronomeMeta = (chords) => {
6861
- return /^#\s*metronome(?:\s*=\s*on)?\s*$/im.test(chords);
6864
+ return !/^#\s*metronome\s*=\s*off\s*$/im.test(chords);
6862
6865
  };
6863
6866
  var _nameToKeyCache = null;
6864
6867
  var getNameToKey = async () => {
@@ -7794,6 +7797,7 @@ var mountChordPlayer = (target, chords, options = {}) => {
7794
7797
  currentPlaySec = playOffsetSec;
7795
7798
  ownCtx ??= options.audioContext ? null : new AudioContext();
7796
7799
  const ctx = options.audioContext ?? ownCtx;
7800
+ const resumePromise = ctx.state === "suspended" ? ctx.resume() : Promise.resolve();
7797
7801
  const cutGain = ctx.createGain();
7798
7802
  cutGain.connect(ctx.destination);
7799
7803
  activeCut = { gain: cutGain, ctx };
@@ -7805,18 +7809,15 @@ var mountChordPlayer = (target, chords, options = {}) => {
7805
7809
  setProgress(totalSec > 0 ? playOffsetSec / totalSec : 0);
7806
7810
  playInternal(startIdx, ctx, cutGain);
7807
7811
  };
7808
- if (activeGmName && !_wafCache.has(activeGmName)) {
7809
- const myAbortId = ++loadAbortId;
7810
- setLoadingUI(true);
7811
- loadWafFont(ctx, activeGmName).then(() => {
7812
- if (loadAbortId !== myAbortId) return;
7813
- setLoadingUI(false);
7814
- startPlayback();
7815
- });
7816
- } else {
7812
+ const myAbortId = ++loadAbortId;
7813
+ setLoadingUI(true);
7814
+ const wafPromise = activeGmName && !_wafCache.has(activeGmName) ? loadWafFont(ctx, activeGmName) : Promise.resolve(null);
7815
+ Promise.all([resumePromise, wafPromise]).then(() => {
7816
+ if (loadAbortId !== myAbortId) return;
7817
+ setLoadingUI(false);
7817
7818
  startPlayback();
7818
- }
7819
- preloadInstruments();
7819
+ preloadInstruments();
7820
+ });
7820
7821
  };
7821
7822
  const seekTo = (idx) => {
7822
7823
  if (isLoading) {
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.73",
5
+ "version": "0.1.75",
6
6
  "description": "MMLを中間言語に用いた、モバイルファーストなDAW / ピアノロール打ち込みコンポーネント",
7
7
  "homepage": "https://onjmin.github.io/dtm",
8
8
  "repository": {
@@ -54,7 +54,7 @@
54
54
  "typescript": "5.8.3"
55
55
  },
56
56
  "dependencies": {
57
- "@onjmin/chord-parser": "1.0.2",
57
+ "@onjmin/chord-parser": "1.0.4",
58
58
  "@onjmin/koe": "1.0.4",
59
59
  "midi-json-parser": "8.1.74"
60
60
  },