From 620e6c4bd63cbf92f08b9b5b6e178a9d0b11cdfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9is=20Bazin?= Date: Mon, 17 Jan 2022 16:38:36 +0100 Subject: [PATCH 1/2] :memo: Add types --- dist/types/audiokeys.d.ts | 26 ++++++++++++++++++++++++++ package.json | 1 + src/AudioKeys.js | 3 ++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 dist/types/audiokeys.d.ts diff --git a/dist/types/audiokeys.d.ts b/dist/types/audiokeys.d.ts new file mode 100644 index 0000000..8f89ad5 --- /dev/null +++ b/dist/types/audiokeys.d.ts @@ -0,0 +1,26 @@ +type AudioKeysOptions = { + polyphony: number + rows: 1 | 2 + priority: 'last' | 'first' | 'highest' | 'lowest' + rootNote: number + octaveControls: boolean + velocityControls: boolean +} + +interface AudioKeysNoteData { + velocity: number // the velocity, between 0 and 127 + keyCode: number // the keyboard key pressed or released + note: number + frequency: number + isActive: boolean +} + +declare module 'audiokeys' { + export default class AudioKeysDefault { + constructor(options: Partial) + up(callback: (note: AudioKeysNoteData) => void): void + down(callback: (note: AudioKeysNoteData) => void): void + clear: () => void + } + export class AudioKeys extends AudioKeysDefault {} +} diff --git a/package.json b/package.json index 5f910c5..4a9e640 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "type" : "git", "url" : "https://github.com/kylestetz/AudioKeys.git" }, + "types": "dist/types/audiokeys.d.ts", "keywords": [ "web audio", "audio", diff --git a/src/AudioKeys.js b/src/AudioKeys.js index 0cef530..349836c 100644 --- a/src/AudioKeys.js +++ b/src/AudioKeys.js @@ -63,4 +63,5 @@ AudioKeys.prototype._specialKeyMap = special._specialKeyMap; // Browserify will take care of making this a global // in a browser environment without a build system. -module.exports = AudioKeys; \ No newline at end of file +module.exports = AudioKeys; +module.exports.AudioKeys = AudioKeys; From 2155767bfe4cd99d942629c87941a0c47e9750a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9is=20Bazin?= <9104039+tbazin@users.noreply.github.com> Date: Wed, 9 Aug 2023 08:00:23 +0200 Subject: [PATCH 2/2] fix: make options optional in constructor --- dist/types/audiokeys.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/types/audiokeys.d.ts b/dist/types/audiokeys.d.ts index 8f89ad5..cbce07b 100644 --- a/dist/types/audiokeys.d.ts +++ b/dist/types/audiokeys.d.ts @@ -17,7 +17,7 @@ interface AudioKeysNoteData { declare module 'audiokeys' { export default class AudioKeysDefault { - constructor(options: Partial) + constructor(options?: Partial) up(callback: (note: AudioKeysNoteData) => void): void down(callback: (note: AudioKeysNoteData) => void): void clear: () => void