diff --git a/.gitignore b/.gitignore index 8452bb5..5bfa031 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ npm-debug.log node_modules build +browser/types index.html index.js yarn.lock diff --git a/package.json b/package.json index 0d76419..b0bbf28 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "3.1.0", "description": "A library providing an API for generating MIDI files.", "main": "build/index.js", - "types": "types.d.ts", + "types": "build/types/main.d.ts", "dependencies": { "@tonaljs/midi": "^4.9.0" }, diff --git a/tsconfig.json b/tsconfig.json index 0b4cec9..ba14d0c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,7 @@ { "compilerOptions": { - "lib": ["esnext", "dom"] + "lib": ["esnext", "dom"], + "declaration": true, + "declarationDir": "./types" } } diff --git a/types.d.ts b/types.d.ts deleted file mode 100644 index 90ad4d4..0000000 --- a/types.d.ts +++ /dev/null @@ -1,113 +0,0 @@ -declare module "midi-writer-js" { - type BaseDuration = "1" | "2" | "4" | "8" | "16" | "32" | "64"; - type TickDuration = `T${number}`; - type DottedDuration = `d${BaseDuration}`; - type DoubleDottedDuration = `dd${BaseDuration}`; - type TripletDuration = `${BaseDuration}t`; - type Duration = - | BaseDuration - | TickDuration - | DottedDuration - | DoubleDottedDuration - | TripletDuration; - type PitchModifier = "#" | "b" | ""; - type BasePitch = "A" | "B" | "C" | "D" | "E" | "F" | "G"; - type Pitch = `${BasePitch}${PitchModifier}${number}`; - - type Options = Omit & - (Pick | Pick); - - class Event {} - class NoteEvent extends Event { - /** - * Each pitch can be a string or valid MIDI note code. Format for string - * is C#4. Pro tip: You can use the output from tonal functions to build - * scales, chords, intervals, etc. in this parameter. - */ - pitch: Pitch | Pitch[]; - /** - * How long the note should sound. - * - 1 : whole - * - 2 : half - * - d2 : dotted half - * - dd2 : double dotted half - * - 4 : quarter - * - 4t : quarter triplet - * - d4 : dotted quarter - * - dd4 : double dotted quarter - * - 8 : eighth - * - 8t : eighth triplet - * - d8 : dotted eighth - * - dd8 : double dotted eighth - * - 16 : sixteenth - * - 16t : sixteenth triplet - * - 32 : thirty-second - * - 64 : sixty-fourth - * - Tn : where n is an explicit number of ticks (T128 = 1 beat) - * - * If an array of durations is passed then the sum of the durations will be used. - */ - duration: Duration | Duration[]; - /** - * Grace note to be applied to note event. Takes same value format as pitch - */ - grace?: Pitch | Pitch[]; - /** - * If true then array of pitches will be played sequentially as opposed to simulatanously. - * Default: false - */ - sequential?: boolean; - /** - * How loud the note should sound, values 1-100. Default: 50 - */ - velocity?: number; - /** - * How many times this event should be repeated. Default: 1 - */ - repeat?: number; - /** - * MIDI channel to use. Default: 1 - */ - channel?: number; - /** - * How long to wait before sounding note (rest). Takes same values as duration. - */ - wait?: Duration | Duration[]; - /** - * Specific tick where this event should be played. If this parameter is supplied - * then wait is disregarded if also supplied. - */ - startTick?: number; - - constructor(options: Options); - } - class ProgramChangeEvent { - constructor(options?: Partial<{ instrument: number }>); - } - class Track { - addEvent( - event: EventType | EventType[], - mapFunction?: (index: number, event: EventType) => Partial - ): void; - setTempo(tempo: number, tick: number): void; - addText(text: string): void; - addCopyright(text: string): void; - addTrackName(text: string): void; - addInstrumentName(text: string): void; - addMarker(text: string): void; - addCuePoint(text: string): void; - addLyric(text: string): void; - setTimeSignature(numerator: number, denominator: number): void; - } - class Writer { - constructor(track: Track | Track[]); - buildFile(): Uint8Array; - base64(): string; - dataUri(): string; - saveMIDI(filename: string): void; - /** - * file stream (cli) - */ - stdout(): void; - } -}