fix pattern checks for minified code

This commit is contained in:
Felix Roos 2022-03-25 22:32:42 +01:00
parent ef75590853
commit 9458faf5b0
7 changed files with 1359 additions and 22 deletions

View file

@ -1,13 +1,11 @@
import { isNote } from 'tone';
import _WebMidi from 'webmidi';
import { Pattern as _Pattern } from '@strudel/core/strudel.mjs';
import { Pattern, isPattern } from '@strudel/core/strudel.mjs';
import { Tone } from '@strudel/tone';
// if you use WebMidi from outside of this package, make sure to import that instance:
export const WebMidi = _WebMidi;
const Pattern = _Pattern;
export function enableWebMidi() {
return new Promise((resolve, reject) => {
if (WebMidi.enabled) {
@ -28,7 +26,7 @@ const outputByName = (name) => WebMidi.getOutputByName(name);
// Pattern.prototype.midi = function (output: string | number, channel = 1) {
Pattern.prototype.midi = function (output, channel = 1) {
if (output?.constructor?.name === 'Pattern') {
if (isPattern(output?.constructor?.name)) {
throw new Error(
`.midi does not accept Pattern input. Make sure to pass device name with single quotes. Example: .midi('${
WebMidi.outputs?.[0]?.name || 'IAC Driver Bus 1'