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 1 commit
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
242 changes: 242 additions & 0 deletions browser-id3-writer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
declare module 'browser-id3-writer' {
export const enum SynchronizedLyricsType {
Other = 0,
Lyrics = 1,

/**
* Text transcription
*/
TextTranscription = 2,

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

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

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

/**
* Trivia/'pop up' information
*/
Trivia = 6,
}

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,
}

// id3.org uses hex values for these. I'm keeping them as hex for consistency
// with the documentation.
altearius marked this conversation as resolved.
Show resolved Hide resolved
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 mimeType: string;
altearius marked this conversation as resolved.
Show resolved Hide resolved
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: URL | string,
altearius marked this conversation as resolved.
Show resolved Hide resolved
): 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(): URL;
altearius marked this conversation as resolved.
Show resolved Hide resolved

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