diff --git a/README.md b/README.md index 448e3dd..32b0de9 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,10 @@ const options: DeviceOptions = { deviceNumber: 0 // Choose device from listMIDIDevices() } -await MIDIPlugin.openDevice(options) +await MIDI.openDevice(options) -MIDIPlugin.addListener('MIDIEventReceived', +MIDI.addListener('MIDIEventReceived', (message: MidiMessage) => console.log(message)); interface MidiMessage { diff --git a/example/src/app/home/home.page.ts b/example/src/app/home/home.page.ts index b56bd6d..7931742 100644 --- a/example/src/app/home/home.page.ts +++ b/example/src/app/home/home.page.ts @@ -1,5 +1,5 @@ import {ChangeDetectorRef, Component} from '@angular/core'; -import {MidiMessage, DeviceOptions, MIDIPlugin} from 'capacitor-midi'; +import {MidiMessage, DeviceOptions, MIDI} from 'capacitor-midi'; @Component({ selector: 'app-home', @@ -12,19 +12,19 @@ export class HomePage { opened = false; constructor(private cd: ChangeDetectorRef) { - MIDIPlugin.listMIDIDevices() + MIDI.listMIDIDevices() .then(devices => { this.devices = devices.value; }); - MIDIPlugin.addListener('MIDIEventReceived', (message: MidiMessage) => { + MIDI.addListener('MIDIEventReceived', (message: MidiMessage) => { this.messages.push(message); cd.detectChanges(); }); } updateDevices(): void { - MIDIPlugin.listMIDIDevices() + MIDI.listMIDIDevices() .then(devices => { this.devices = devices.value; }); @@ -34,7 +34,7 @@ export class HomePage { const deviceOptions: DeviceOptions = { deviceNumber: deviceNumber }; - MIDIPlugin.openDevice(deviceOptions).then(r => { + MIDI.openDevice(deviceOptions).then(r => { this.clearMessages(); }); } diff --git a/package.json b/package.json index e6d5db3..e7cf84a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "capacitor-midi", - "version": "0.0.3", + "version": "0.0.4", "description": "Grants access to midi devices via native libraries or WebMIDI.", "main": "dist/plugin.cjs.js", "module": "dist/esm/index.js", @@ -38,7 +38,7 @@ "eslint": "eslint . --ext ts", "prettier": "prettier \"**/*.{css,html,ts,js,java}\"", "swiftlint": "node-swiftlint", - "docgen": "docgen --api MIDIPluginPlugin --output-readme README.md --output-json dist/docs.json", + "docgen": "docgen --api MIDIPlugin --output-readme README.md --output-json dist/docs.json", "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js", "clean": "rimraf ./dist", "watch": "tsc --watch", diff --git a/src/definitions.ts b/src/definitions.ts index 19d4d74..f6c49e6 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -1,6 +1,6 @@ import type {ListenerCallback, PluginListenerHandle} from "@capacitor/core"; -export interface MIDIPluginPlugin{ +export interface MIDIPlugin { listMIDIDevices(): Promise<{ value: string[] }> openDevice(options: DeviceOptions): Promise diff --git a/src/index.ts b/src/index.ts index d041b47..4f1a327 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,10 @@ import { registerPlugin } from '@capacitor/core'; -import type { MIDIPluginPlugin } from './definitions'; +import type { MIDIPlugin } from './definitions'; -const MIDIPlugin = registerPlugin('MIDIPlugin', { +const MIDI = registerPlugin('MIDIPlugin', { web: () => import('./web').then(m => new m.MIDIPluginWeb()), }); export * from './definitions'; -export { MIDIPlugin }; +export { MIDI }; diff --git a/src/web.ts b/src/web.ts index c9160e3..83b893a 100644 --- a/src/web.ts +++ b/src/web.ts @@ -1,9 +1,9 @@ import {WebPlugin} from '@capacitor/core'; import {WebMIDIHandler} from "./WebMIDIHandler"; -import type {DeviceOptions, MIDIPluginPlugin} from './definitions'; +import type {DeviceOptions, MIDIPlugin} from './definitions'; -export class MIDIPluginWeb extends WebPlugin implements MIDIPluginPlugin { +export class MIDIPluginWeb extends WebPlugin implements MIDIPlugin { async listMIDIDevices(): Promise<{ value: string[] }> { const wmh = WebMIDIHandler.instance; await wmh.initWebMidi()