Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos and add TypeScript declaration file #89

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,14 @@ See [#42](https://github.com/egoroof/browser-id3-writer/issues/42).
| 3 | Cover (front) |
| 4 | Cover (back) |
| 5 | Leaflet page |
| 6 | Media (e.g. lable side of CD) |
| 6 | Media (e.g. label side of CD) |
| 7 | Lead artist/lead performer/soloist |
| 8 | Artist/performer |
| 9 | Conductor |
| 10 | Band/Orchestra |
| 11 | Composer |
| 12 | Lyricist/text writer |
| 13 | Recording Location |
| 13 | Recording location |
| 14 | During recording |
| 15 | During performance |
| 16 | Movie/video screen capture |
Expand Down
241 changes: 241 additions & 0 deletions browser-id3-writer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
// Hexidecimal values used to maintain consistency with the ID3v2.3
// documentation. Refer to /tools/id3v2.3.0.txt.
declare module 'browser-id3-writer' {
export const enum SynchronizedLyricsType {
Other = 0x00,
Lyrics = 0x01,

/**
* Text transcription
*/
TextTranscription = 0x02,

/**
* Movement/part name (e.g. "Adagio")
*/
MovementPartName = 0x03,

/**
* Events (e.g. "Don Quijote enters the stage")
*/
Events = 0x04,

/**
* Chord (e.g. "Bb F Fsus")
*/
Chord = 0x05,

/**
* Trivia/'pop up' information
*/
Trivia = 0x06,
}

export const enum SynchronizedLyricsTimestampFormat {
/**
* Absolute time, 32 bit sized, using MPEG frames as unit
*/
Frames = 0x01,

/**
* Absolute time, 32 bit sized, using milliseconds as unit
*/
Milliseconds = 0x02,
}

export const enum ImageType {
Other = 0x00,
/**
* 32x32 pixels 'file icon' (PNG only)
*/
Icon = 0x01,

/**
* Other file icon
*/
OtherIcon = 0x02,

/**
* Cover (front)
*/
CoverFront = 0x03,

/**
* Cover (back)
*/
CoverBack = 0x04,

/**
* Leaflet page
*/
Leaflet = 0x05,

/**
* Media (e.g. label side of CD)
*/
Media = 0x06,

/**
* Lead artist/lead performer/soloist
*/
LeadArtist = 0x07,

/**
* Artist/performer
*/
Artist = 0x08,

Conductor = 0x09,

/**
* Band/Orchestra
*/
Band = 0x0a,

Composer = 0x0b,

/**
* Lyricist/text writer
*/
Lyricist = 0x0c,

/**
* Recording location
*/
RecordingLocation = 0x0d,

/**
* During recording
*/
DuringRecording = 0x0e,

/**
* During performance
*/
DuringPerformance = 0x0f,

/**
* Movie/video screen capture
*/
MovieScreenCapture = 0x10,

/**
* A brightly coloured fish
*/
BrightColouredFish = 0x11,

Illustration = 0x12,

/**
* Band/artist logotype
*/
BandLogotype = 0x13,

/**
* Publisher/Studio logotype
*/
PublisherLogotype = 0x14,
}

export class ID3Writer {
constructor(buffer: ArrayBufferLike);

setFrame(id: 'TBPM' | 'TLEN' | 'TYER', value: number): this;

setFrame(
id:
| 'TALB'
| 'TCOP'
| 'TDAT'
| 'TEXT'
| 'TIT1'
| 'TIT2'
| 'TIT3'
| 'TKEY'
| 'TLAN'
| 'TMED'
| 'TPE2'
| 'TPE3'
| 'TPE4'
| 'TPOS'
| 'TPUB'
| 'TRCK'
| 'TSRC',
value: string,
): this;

setFrame(id: 'TCOM' | 'TCON' | 'TPE1', value: readonly string[]): this;

setFrame(
id: 'USLT',
value: {
readonly description: string;
readonly language?: string;
readonly lyrics: string;
},
): this;

setFrame(
id: 'APIC',
value: {
readonly description: string;
readonly data: ArrayBufferLike;
readonly type: ImageType;
readonly useUnicodeEncoding?: boolean;
},
): this;

setFrame(
id: 'TXXX',
value: {
readonly description: string;
readonly value: string;
},
): this;

setFrame(
id: 'WCOM' | 'WCOP' | 'WOAF' | 'WOAR' | 'WOAS' | 'WORS' | 'WPAY' | 'WPUB',
value: string,
): this;

setFrame(
id: 'COMM',
value: {
readonly language?: string;
readonly description: string;
readonly text: string;
},
): this;

setFrame(
id: 'PRIV',
value: {
readonly id: string;
readonly data: ArrayBufferLike;
},
): this;

setFrame(id: 'IPLS', value: readonly (readonly [string, string])[]): this;

setFrame(
id: 'SYLT',
value: {
readonly type: SynchronizedLyricsType;
readonly text: readonly (readonly [string, number])[];
readonly timestampFormat: SynchronizedLyricsTimestampFormat;
readonly language?: string;
readonly description?: string;
},
): this;

removeTag(): void;

addTag(): ArrayBuffer;

getBlob(): Blob;

getURL(): string;

revokeURL(): void;
}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "6.0.0",
"description": "JavaScript library for writing ID3 tag to MP3 files in browsers and Node.js",
"main": "dist/browser-id3-writer.mjs",
"types": "./browser-id3-writer.d.ts",
"scripts": {
"lint": "eslint src tools test --ext js,mjs",
"build": "npm run build:bundle && npm run build:compress && node tools/distSize.mjs",
Expand Down Expand Up @@ -34,6 +35,7 @@
"files": [
"LICENSE.md",
"README.md",
"browser-id3-writer.d.ts",
"dist/browser-id3-writer.mjs"
],
"license": "MIT",
Expand Down