taglib-wasm 0.3.3 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +293 -0
- package/NOTICE +34 -0
- package/README.md +122 -511
- package/dist/index.d.ts +132 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +137 -0
- package/dist/index.ts +220 -0
- package/dist/src/constants.d.ts +201 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.ts +227 -0
- package/dist/src/errors.d.ts +89 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.ts +237 -0
- package/dist/src/file-utils.d.ts +205 -0
- package/dist/src/file-utils.d.ts.map +1 -0
- package/dist/src/file-utils.ts +467 -0
- package/dist/src/file.js +47 -0
- package/dist/src/global.d.ts +10 -0
- package/dist/src/mod.d.ts +9 -0
- package/dist/src/mod.d.ts.map +1 -0
- package/dist/src/mod.ts +19 -0
- package/dist/src/simple.d.ts +347 -0
- package/dist/src/simple.d.ts.map +1 -0
- package/dist/src/simple.ts +659 -0
- package/dist/src/taglib.d.ts +502 -0
- package/dist/src/taglib.d.ts.map +1 -0
- package/dist/src/taglib.ts +959 -0
- package/dist/src/types.d.ts +323 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.ts +538 -0
- package/dist/src/utils/file.d.ts +15 -0
- package/dist/src/utils/file.d.ts.map +1 -0
- package/dist/src/utils/file.ts +82 -0
- package/dist/src/utils/write.d.ts +15 -0
- package/dist/src/utils/write.d.ts.map +1 -0
- package/dist/src/utils/write.ts +61 -0
- package/dist/src/wasm-workers.d.ts +33 -0
- package/dist/src/wasm-workers.d.ts.map +1 -0
- package/dist/src/wasm-workers.ts +176 -0
- package/dist/src/wasm.d.ts +97 -0
- package/dist/src/wasm.d.ts.map +1 -0
- package/dist/src/wasm.ts +133 -0
- package/dist/src/web-utils.d.ts +180 -0
- package/dist/src/web-utils.d.ts.map +1 -0
- package/dist/src/web-utils.ts +347 -0
- package/dist/src/workers.d.ts +219 -0
- package/dist/src/workers.d.ts.map +1 -0
- package/dist/src/workers.ts +465 -0
- package/dist/src/write.js +33 -0
- package/dist/taglib-wrapper.d.ts +5 -0
- package/dist/taglib-wrapper.js +14 -0
- package/dist/taglib.wasm +0 -0
- package/index.ts +100 -7
- package/package.json +40 -16
- package/src/errors.ts +237 -0
- package/src/file-utils.ts +467 -0
- package/src/global.d.ts +10 -0
- package/src/simple.ts +399 -84
- package/src/taglib.ts +522 -28
- package/src/types.ts +1 -1
- package/src/utils/file.ts +82 -0
- package/src/utils/write.ts +61 -0
- package/src/wasm-workers.ts +13 -4
- package/src/wasm.ts +1 -1
- package/src/web-utils.ts +347 -0
- package/src/workers.ts +32 -13
- package/build/taglib.js +0 -2407
- package/build/taglib.wasm +0 -0
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import type { TagLibModule, WasmModule } from "./wasm.ts";
|
|
2
|
+
import type { AudioProperties, FileType, PropertyMap, Tag as BasicTag, Picture } from "./types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Extended Tag interface with read/write capabilities for audio metadata.
|
|
5
|
+
* Extends the basic Tag interface with setter methods for modifying metadata.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const file = await taglib.open("song.mp3");
|
|
10
|
+
* const tag = file.tag();
|
|
11
|
+
*
|
|
12
|
+
* // Read metadata
|
|
13
|
+
* console.log(tag.title);
|
|
14
|
+
*
|
|
15
|
+
* // Write metadata
|
|
16
|
+
* tag.setTitle("New Title");
|
|
17
|
+
* tag.setArtist("New Artist");
|
|
18
|
+
* file.save();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export interface Tag extends BasicTag {
|
|
22
|
+
/** Set the track title */
|
|
23
|
+
setTitle(value: string): void;
|
|
24
|
+
/** Set the artist name */
|
|
25
|
+
setArtist(value: string): void;
|
|
26
|
+
/** Set the album name */
|
|
27
|
+
setAlbum(value: string): void;
|
|
28
|
+
/** Set the comment */
|
|
29
|
+
setComment(value: string): void;
|
|
30
|
+
/** Set the genre */
|
|
31
|
+
setGenre(value: string): void;
|
|
32
|
+
/** Set the release year */
|
|
33
|
+
setYear(value: number): void;
|
|
34
|
+
/** Set the track number */
|
|
35
|
+
setTrack(value: number): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Represents an audio file with metadata and audio properties.
|
|
39
|
+
* Provides methods for reading and writing metadata, accessing audio properties,
|
|
40
|
+
* and managing format-specific features.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const file = await taglib.open("song.mp3");
|
|
45
|
+
*
|
|
46
|
+
* // Check if valid
|
|
47
|
+
* if (!file.isValid()) {
|
|
48
|
+
* throw new Error("Invalid audio file");
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* // Read metadata
|
|
52
|
+
* const tag = file.tag();
|
|
53
|
+
* const props = file.audioProperties();
|
|
54
|
+
*
|
|
55
|
+
* // Modify and save
|
|
56
|
+
* tag.setTitle("New Title");
|
|
57
|
+
* file.save();
|
|
58
|
+
*
|
|
59
|
+
* // Get modified buffer
|
|
60
|
+
* const modifiedBuffer = file.getFileBuffer();
|
|
61
|
+
*
|
|
62
|
+
* // Clean up
|
|
63
|
+
* file.dispose();
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export interface AudioFile {
|
|
67
|
+
/**
|
|
68
|
+
* Get the audio file format.
|
|
69
|
+
* @returns The detected file type (e.g., "MP3", "FLAC", "MP4")
|
|
70
|
+
*/
|
|
71
|
+
getFormat(): FileType;
|
|
72
|
+
/**
|
|
73
|
+
* Get the tag object for reading/writing basic metadata.
|
|
74
|
+
* @returns Tag object with getters and setters for metadata fields
|
|
75
|
+
* @throws {Error} If unable to get tag from file
|
|
76
|
+
*/
|
|
77
|
+
tag(): Tag;
|
|
78
|
+
/**
|
|
79
|
+
* Get audio properties (duration, bitrate, sample rate, etc.).
|
|
80
|
+
* @returns Audio properties or null if unavailable
|
|
81
|
+
*/
|
|
82
|
+
audioProperties(): AudioProperties | null;
|
|
83
|
+
/**
|
|
84
|
+
* Get all metadata properties as a key-value map.
|
|
85
|
+
* Includes both standard and format-specific properties.
|
|
86
|
+
* @returns PropertyMap with all available metadata
|
|
87
|
+
*/
|
|
88
|
+
properties(): PropertyMap;
|
|
89
|
+
/**
|
|
90
|
+
* Set multiple properties at once from a PropertyMap.
|
|
91
|
+
* @param properties - Map of property names to values
|
|
92
|
+
*/
|
|
93
|
+
setProperties(properties: PropertyMap): void;
|
|
94
|
+
/**
|
|
95
|
+
* Get a single property value by key.
|
|
96
|
+
* @param key - Property name (e.g., "ALBUMARTIST", "ACOUSTID_ID")
|
|
97
|
+
* @returns Property value or undefined if not found
|
|
98
|
+
*/
|
|
99
|
+
getProperty(key: string): string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Set a single property value.
|
|
102
|
+
* @param key - Property name
|
|
103
|
+
* @param value - Property value
|
|
104
|
+
*/
|
|
105
|
+
setProperty(key: string, value: string): void;
|
|
106
|
+
/**
|
|
107
|
+
* Check if this is an MP4/M4A file.
|
|
108
|
+
* @returns true if the file is MP4/M4A format
|
|
109
|
+
*/
|
|
110
|
+
isMP4(): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Get an MP4-specific metadata item.
|
|
113
|
+
* @param key - MP4 atom name (e.g., "----:com.apple.iTunes:iTunNORM")
|
|
114
|
+
* @returns Item value or undefined if not found
|
|
115
|
+
* @throws {Error} If not an MP4 file
|
|
116
|
+
*/
|
|
117
|
+
getMP4Item(key: string): string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Set an MP4-specific metadata item.
|
|
120
|
+
* @param key - MP4 atom name
|
|
121
|
+
* @param value - Item value
|
|
122
|
+
* @throws {Error} If not an MP4 file
|
|
123
|
+
*/
|
|
124
|
+
setMP4Item(key: string, value: string): void;
|
|
125
|
+
/**
|
|
126
|
+
* Remove an MP4-specific metadata item.
|
|
127
|
+
* @param key - MP4 atom name to remove
|
|
128
|
+
* @throws {Error} If not an MP4 file
|
|
129
|
+
*/
|
|
130
|
+
removeMP4Item(key: string): void;
|
|
131
|
+
/**
|
|
132
|
+
* Save all changes to the in-memory buffer.
|
|
133
|
+
* Note: This does not write to disk, but updates the internal buffer.
|
|
134
|
+
* Use getFileBuffer() to retrieve the modified data.
|
|
135
|
+
* @returns true if save was successful
|
|
136
|
+
*/
|
|
137
|
+
save(): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Get the current file data as a buffer, including any modifications.
|
|
140
|
+
* Call this after save() to get the updated file data.
|
|
141
|
+
* @returns Uint8Array containing the complete file data
|
|
142
|
+
*/
|
|
143
|
+
getFileBuffer(): Uint8Array;
|
|
144
|
+
/**
|
|
145
|
+
* Save all changes to a file on disk.
|
|
146
|
+
* This first saves changes to the in-memory buffer, then writes to the specified path.
|
|
147
|
+
* @param path - Optional file path. If not provided, saves to the original path (if opened from a file).
|
|
148
|
+
* @throws {Error} If no path is available or write fails
|
|
149
|
+
*/
|
|
150
|
+
saveToFile(path?: string): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* Check if the file was loaded successfully and is valid.
|
|
153
|
+
* @returns true if the file is valid and can be processed
|
|
154
|
+
*/
|
|
155
|
+
isValid(): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Get all pictures/cover art from the audio file.
|
|
158
|
+
* @returns Array of Picture objects
|
|
159
|
+
*/
|
|
160
|
+
getPictures(): Picture[];
|
|
161
|
+
/**
|
|
162
|
+
* Set pictures/cover art in the audio file (replaces all existing).
|
|
163
|
+
* @param pictures - Array of Picture objects to set
|
|
164
|
+
*/
|
|
165
|
+
setPictures(pictures: Picture[]): void;
|
|
166
|
+
/**
|
|
167
|
+
* Add a single picture to the audio file.
|
|
168
|
+
* @param picture - Picture object to add
|
|
169
|
+
*/
|
|
170
|
+
addPicture(picture: Picture): void;
|
|
171
|
+
/**
|
|
172
|
+
* Remove all pictures from the audio file.
|
|
173
|
+
*/
|
|
174
|
+
removePictures(): void;
|
|
175
|
+
/**
|
|
176
|
+
* Release all resources associated with this file.
|
|
177
|
+
* Always call this when done to prevent memory leaks.
|
|
178
|
+
*/
|
|
179
|
+
dispose(): void;
|
|
180
|
+
/**
|
|
181
|
+
* Get MusicBrainz Track ID.
|
|
182
|
+
* @returns MusicBrainz Track ID or undefined if not set
|
|
183
|
+
*/
|
|
184
|
+
getMusicBrainzTrackId(): string | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Set MusicBrainz Track ID.
|
|
187
|
+
* @param id - MusicBrainz Track ID (UUID format)
|
|
188
|
+
*/
|
|
189
|
+
setMusicBrainzTrackId(id: string): void;
|
|
190
|
+
/**
|
|
191
|
+
* Get MusicBrainz Release ID.
|
|
192
|
+
* @returns MusicBrainz Release ID or undefined if not set
|
|
193
|
+
*/
|
|
194
|
+
getMusicBrainzReleaseId(): string | undefined;
|
|
195
|
+
/**
|
|
196
|
+
* Set MusicBrainz Release ID.
|
|
197
|
+
* @param id - MusicBrainz Release ID (UUID format)
|
|
198
|
+
*/
|
|
199
|
+
setMusicBrainzReleaseId(id: string): void;
|
|
200
|
+
/**
|
|
201
|
+
* Get MusicBrainz Artist ID.
|
|
202
|
+
* @returns MusicBrainz Artist ID or undefined if not set
|
|
203
|
+
*/
|
|
204
|
+
getMusicBrainzArtistId(): string | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* Set MusicBrainz Artist ID.
|
|
207
|
+
* @param id - MusicBrainz Artist ID (UUID format)
|
|
208
|
+
*/
|
|
209
|
+
setMusicBrainzArtistId(id: string): void;
|
|
210
|
+
/**
|
|
211
|
+
* Get AcoustID fingerprint.
|
|
212
|
+
* @returns AcoustID fingerprint or undefined if not set
|
|
213
|
+
*/
|
|
214
|
+
getAcoustIdFingerprint(): string | undefined;
|
|
215
|
+
/**
|
|
216
|
+
* Set AcoustID fingerprint.
|
|
217
|
+
* @param fingerprint - AcoustID fingerprint
|
|
218
|
+
*/
|
|
219
|
+
setAcoustIdFingerprint(fingerprint: string): void;
|
|
220
|
+
/**
|
|
221
|
+
* Get AcoustID ID.
|
|
222
|
+
* @returns AcoustID ID or undefined if not set
|
|
223
|
+
*/
|
|
224
|
+
getAcoustIdId(): string | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Set AcoustID ID.
|
|
227
|
+
* @param id - AcoustID ID
|
|
228
|
+
*/
|
|
229
|
+
setAcoustIdId(id: string): void;
|
|
230
|
+
/**
|
|
231
|
+
* Get ReplayGain track gain.
|
|
232
|
+
* @returns ReplayGain track gain (e.g., "-6.54 dB") or undefined
|
|
233
|
+
*/
|
|
234
|
+
getReplayGainTrackGain(): string | undefined;
|
|
235
|
+
/**
|
|
236
|
+
* Set ReplayGain track gain.
|
|
237
|
+
* @param gain - ReplayGain track gain (e.g., "-6.54 dB")
|
|
238
|
+
*/
|
|
239
|
+
setReplayGainTrackGain(gain: string): void;
|
|
240
|
+
/**
|
|
241
|
+
* Get ReplayGain track peak.
|
|
242
|
+
* @returns ReplayGain track peak (0.0-1.0) or undefined
|
|
243
|
+
*/
|
|
244
|
+
getReplayGainTrackPeak(): string | undefined;
|
|
245
|
+
/**
|
|
246
|
+
* Set ReplayGain track peak.
|
|
247
|
+
* @param peak - ReplayGain track peak (0.0-1.0)
|
|
248
|
+
*/
|
|
249
|
+
setReplayGainTrackPeak(peak: string): void;
|
|
250
|
+
/**
|
|
251
|
+
* Get ReplayGain album gain.
|
|
252
|
+
* @returns ReplayGain album gain (e.g., "-7.89 dB") or undefined
|
|
253
|
+
*/
|
|
254
|
+
getReplayGainAlbumGain(): string | undefined;
|
|
255
|
+
/**
|
|
256
|
+
* Set ReplayGain album gain.
|
|
257
|
+
* @param gain - ReplayGain album gain (e.g., "-7.89 dB")
|
|
258
|
+
*/
|
|
259
|
+
setReplayGainAlbumGain(gain: string): void;
|
|
260
|
+
/**
|
|
261
|
+
* Get ReplayGain album peak.
|
|
262
|
+
* @returns ReplayGain album peak (0.0-1.0) or undefined
|
|
263
|
+
*/
|
|
264
|
+
getReplayGainAlbumPeak(): string | undefined;
|
|
265
|
+
/**
|
|
266
|
+
* Set ReplayGain album peak.
|
|
267
|
+
* @param peak - ReplayGain album peak (0.0-1.0)
|
|
268
|
+
*/
|
|
269
|
+
setReplayGainAlbumPeak(peak: string): void;
|
|
270
|
+
/**
|
|
271
|
+
* Get Apple Sound Check normalization data.
|
|
272
|
+
* @returns Apple Sound Check data (iTunNORM) or undefined
|
|
273
|
+
*/
|
|
274
|
+
getAppleSoundCheck(): string | undefined;
|
|
275
|
+
/**
|
|
276
|
+
* Set Apple Sound Check normalization data.
|
|
277
|
+
* @param data - Apple Sound Check data (iTunNORM format)
|
|
278
|
+
*/
|
|
279
|
+
setAppleSoundCheck(data: string): void;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Implementation of AudioFile interface using Embind API.
|
|
283
|
+
* Wraps the native TagLib C++ FileHandle object.
|
|
284
|
+
*
|
|
285
|
+
* @internal This class is not meant to be instantiated directly.
|
|
286
|
+
* Use TagLib.open() to create instances.
|
|
287
|
+
*/
|
|
288
|
+
export declare class AudioFileImpl implements AudioFile {
|
|
289
|
+
private module;
|
|
290
|
+
private fileHandle;
|
|
291
|
+
private cachedTag;
|
|
292
|
+
private cachedAudioProperties;
|
|
293
|
+
private sourcePath?;
|
|
294
|
+
constructor(module: TagLibModule, fileHandle: any, sourcePath?: string);
|
|
295
|
+
/** @inheritdoc */
|
|
296
|
+
getFormat(): FileType;
|
|
297
|
+
/** @inheritdoc */
|
|
298
|
+
tag(): Tag;
|
|
299
|
+
/** @inheritdoc */
|
|
300
|
+
audioProperties(): AudioProperties | null;
|
|
301
|
+
/** @inheritdoc */
|
|
302
|
+
properties(): PropertyMap;
|
|
303
|
+
/** @inheritdoc */
|
|
304
|
+
setProperties(properties: PropertyMap): void;
|
|
305
|
+
/** @inheritdoc */
|
|
306
|
+
getProperty(key: string): string | undefined;
|
|
307
|
+
/** @inheritdoc */
|
|
308
|
+
setProperty(key: string, value: string): void;
|
|
309
|
+
/** @inheritdoc */
|
|
310
|
+
isMP4(): boolean;
|
|
311
|
+
/** @inheritdoc */
|
|
312
|
+
getMP4Item(key: string): string | undefined;
|
|
313
|
+
/** @inheritdoc */
|
|
314
|
+
setMP4Item(key: string, value: string): void;
|
|
315
|
+
/** @inheritdoc */
|
|
316
|
+
removeMP4Item(key: string): void;
|
|
317
|
+
/** @inheritdoc */
|
|
318
|
+
save(): boolean;
|
|
319
|
+
/** @inheritdoc */
|
|
320
|
+
getFileBuffer(): Uint8Array;
|
|
321
|
+
/** @inheritdoc */
|
|
322
|
+
saveToFile(path?: string): Promise<void>;
|
|
323
|
+
/** @inheritdoc */
|
|
324
|
+
isValid(): boolean;
|
|
325
|
+
/** @inheritdoc */
|
|
326
|
+
getPictures(): Picture[];
|
|
327
|
+
/** @inheritdoc */
|
|
328
|
+
setPictures(pictures: Picture[]): void;
|
|
329
|
+
/** @inheritdoc */
|
|
330
|
+
addPicture(picture: Picture): void;
|
|
331
|
+
/** @inheritdoc */
|
|
332
|
+
removePictures(): void;
|
|
333
|
+
/** @inheritdoc */
|
|
334
|
+
dispose(): void;
|
|
335
|
+
/** @inheritdoc */
|
|
336
|
+
getMusicBrainzTrackId(): string | undefined;
|
|
337
|
+
/** @inheritdoc */
|
|
338
|
+
setMusicBrainzTrackId(id: string): void;
|
|
339
|
+
/** @inheritdoc */
|
|
340
|
+
getMusicBrainzReleaseId(): string | undefined;
|
|
341
|
+
/** @inheritdoc */
|
|
342
|
+
setMusicBrainzReleaseId(id: string): void;
|
|
343
|
+
/** @inheritdoc */
|
|
344
|
+
getMusicBrainzArtistId(): string | undefined;
|
|
345
|
+
/** @inheritdoc */
|
|
346
|
+
setMusicBrainzArtistId(id: string): void;
|
|
347
|
+
/** @inheritdoc */
|
|
348
|
+
getAcoustIdFingerprint(): string | undefined;
|
|
349
|
+
/** @inheritdoc */
|
|
350
|
+
setAcoustIdFingerprint(fingerprint: string): void;
|
|
351
|
+
/** @inheritdoc */
|
|
352
|
+
getAcoustIdId(): string | undefined;
|
|
353
|
+
/** @inheritdoc */
|
|
354
|
+
setAcoustIdId(id: string): void;
|
|
355
|
+
/** @inheritdoc */
|
|
356
|
+
getReplayGainTrackGain(): string | undefined;
|
|
357
|
+
/** @inheritdoc */
|
|
358
|
+
setReplayGainTrackGain(gain: string): void;
|
|
359
|
+
/** @inheritdoc */
|
|
360
|
+
getReplayGainTrackPeak(): string | undefined;
|
|
361
|
+
/** @inheritdoc */
|
|
362
|
+
setReplayGainTrackPeak(peak: string): void;
|
|
363
|
+
/** @inheritdoc */
|
|
364
|
+
getReplayGainAlbumGain(): string | undefined;
|
|
365
|
+
/** @inheritdoc */
|
|
366
|
+
setReplayGainAlbumGain(gain: string): void;
|
|
367
|
+
/** @inheritdoc */
|
|
368
|
+
getReplayGainAlbumPeak(): string | undefined;
|
|
369
|
+
/** @inheritdoc */
|
|
370
|
+
setReplayGainAlbumPeak(peak: string): void;
|
|
371
|
+
/** @inheritdoc */
|
|
372
|
+
getAppleSoundCheck(): string | undefined;
|
|
373
|
+
/** @inheritdoc */
|
|
374
|
+
setAppleSoundCheck(data: string): void;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Main TagLib interface for audio metadata operations.
|
|
378
|
+
* Provides methods to open audio files and access TagLib functionality.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* // Option 1: Auto-initialize
|
|
383
|
+
* const taglib = await TagLib.initialize();
|
|
384
|
+
*
|
|
385
|
+
* // Option 2: Manual initialization
|
|
386
|
+
* import { loadTagLibModule } from "taglib-wasm";
|
|
387
|
+
* const module = await loadTagLibModule();
|
|
388
|
+
* const taglib = new TagLib(module);
|
|
389
|
+
*
|
|
390
|
+
* // Open and process a file
|
|
391
|
+
* const file = await taglib.open("song.mp3");
|
|
392
|
+
* const tag = file.tag();
|
|
393
|
+
* console.log(`Title: ${tag.title}`);
|
|
394
|
+
* file.dispose();
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
export declare class TagLib {
|
|
398
|
+
private module;
|
|
399
|
+
constructor(module: WasmModule);
|
|
400
|
+
/**
|
|
401
|
+
* Initialize TagLib with default configuration.
|
|
402
|
+
* This is the recommended way to create a TagLib instance.
|
|
403
|
+
*
|
|
404
|
+
* @returns Promise resolving to initialized TagLib instance
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* const taglib = await TagLib.initialize();
|
|
409
|
+
* const file = await taglib.open("song.mp3");
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
412
|
+
static initialize(): Promise<TagLib>;
|
|
413
|
+
/**
|
|
414
|
+
* Open an audio file from various sources.
|
|
415
|
+
* Automatically detects the file format based on content.
|
|
416
|
+
*
|
|
417
|
+
* @param input - File path (string), ArrayBuffer, Uint8Array, or File object
|
|
418
|
+
* @returns Promise resolving to AudioFile instance
|
|
419
|
+
* @throws {Error} If the file format is invalid or unsupported
|
|
420
|
+
* @throws {Error} If the module is not properly initialized
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```typescript
|
|
424
|
+
* // From file path
|
|
425
|
+
* const file = await taglib.open("song.mp3");
|
|
426
|
+
*
|
|
427
|
+
* // From ArrayBuffer
|
|
428
|
+
* const file = await taglib.open(arrayBuffer);
|
|
429
|
+
*
|
|
430
|
+
* // From Uint8Array
|
|
431
|
+
* const file = await taglib.open(uint8Array);
|
|
432
|
+
*
|
|
433
|
+
* // From File object (browser)
|
|
434
|
+
* const file = await taglib.open(fileObject);
|
|
435
|
+
*
|
|
436
|
+
* // Remember to dispose when done
|
|
437
|
+
* file.dispose();
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
open(input: string | ArrayBuffer | Uint8Array | File): Promise<AudioFile>;
|
|
441
|
+
/**
|
|
442
|
+
* Update tags in a file and save changes to disk in one operation.
|
|
443
|
+
* This is a convenience method that opens, modifies, saves, and closes the file.
|
|
444
|
+
*
|
|
445
|
+
* @param path - File path to update
|
|
446
|
+
* @param tags - Object containing tags to update
|
|
447
|
+
* @throws {Error} If file operations fail
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* ```typescript
|
|
451
|
+
* await taglib.updateFile("song.mp3", {
|
|
452
|
+
* title: "New Title",
|
|
453
|
+
* artist: "New Artist"
|
|
454
|
+
* });
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
updateFile(path: string, tags: Partial<BasicTag>): Promise<void>;
|
|
458
|
+
/**
|
|
459
|
+
* Copy a file with new tags.
|
|
460
|
+
* Opens the source file, applies new tags, and saves to a new location.
|
|
461
|
+
*
|
|
462
|
+
* @param sourcePath - Source file path
|
|
463
|
+
* @param destPath - Destination file path
|
|
464
|
+
* @param tags - Object containing tags to apply
|
|
465
|
+
* @throws {Error} If file operations fail
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
* ```typescript
|
|
469
|
+
* await taglib.copyWithTags("original.mp3", "copy.mp3", {
|
|
470
|
+
* title: "Copy of Song",
|
|
471
|
+
* comment: "This is a copy"
|
|
472
|
+
* });
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
copyWithTags(sourcePath: string, destPath: string, tags: Partial<BasicTag>): Promise<void>;
|
|
476
|
+
/**
|
|
477
|
+
* Get the TagLib version.
|
|
478
|
+
* @returns Version string (e.g., "2.1.0")
|
|
479
|
+
*/
|
|
480
|
+
version(): string;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Create a TagLib instance from a pre-loaded Wasm module.
|
|
484
|
+
* For advanced users who need custom module configuration.
|
|
485
|
+
*
|
|
486
|
+
* @param module - Pre-loaded Wasm module from loadTagLibModule()
|
|
487
|
+
* @returns Promise resolving to TagLib instance
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* ```typescript
|
|
491
|
+
* import { loadTagLibModule, createTagLib } from "taglib-wasm";
|
|
492
|
+
*
|
|
493
|
+
* const module = await loadTagLibModule();
|
|
494
|
+
* const taglib = await createTagLib(module);
|
|
495
|
+
* ```
|
|
496
|
+
*/
|
|
497
|
+
export declare function createTagLib(module: WasmModule): Promise<TagLib>;
|
|
498
|
+
/**
|
|
499
|
+
* Re-export error types for convenient error handling
|
|
500
|
+
*/
|
|
501
|
+
export { EnvironmentError, FileOperationError, InvalidFormatError, isEnvironmentError, isFileOperationError, isInvalidFormatError, isMemoryError, isMetadataError, isTagLibError, isUnsupportedFormatError, MemoryError, MetadataError, SUPPORTED_FORMATS, TagLibError, TagLibErrorCode, TagLibInitializationError, UnsupportedFormatError, } from "./errors.ts";
|
|
502
|
+
//# sourceMappingURL=taglib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taglib.d.ts","sourceRoot":"","sources":["../../src/taglib.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,QAAQ,EACR,WAAW,EACX,GAAG,IAAI,QAAQ,EACf,OAAO,EACR,MAAM,YAAY,CAAC;AAUpB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,GAAI,SAAQ,QAAQ;IACnC,0BAA0B;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,0BAA0B;IAC1B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,yBAAyB;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,sBAAsB;IACtB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,oBAAoB;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,2BAA2B;IAC3B,OAAO,CAAC,KAAK,EAAE,MAAM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