taglib-wasm 0.3.13 → 0.3.15

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.
Files changed (82) hide show
  1. package/README.md +22 -35
  2. package/dist/index.d.ts +10 -10
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +117 -134
  5. package/dist/index.js.map +1 -0
  6. package/dist/src/constants.js +211 -0
  7. package/dist/src/constants.js.map +1 -0
  8. package/dist/src/errors.js +180 -0
  9. package/dist/src/errors.js.map +1 -0
  10. package/dist/src/file-utils.d.ts +2 -2
  11. package/dist/src/file-utils.d.ts.map +1 -1
  12. package/dist/src/file-utils.js +394 -0
  13. package/dist/src/file-utils.js.map +1 -0
  14. package/dist/src/mod.d.ts +4 -4
  15. package/dist/src/mod.d.ts.map +1 -1
  16. package/dist/src/mod.js +7 -0
  17. package/dist/src/mod.js.map +1 -0
  18. package/dist/src/simple.d.ts +4 -4
  19. package/dist/src/simple.d.ts.map +1 -1
  20. package/dist/src/{simple.ts → simple.js} +193 -311
  21. package/dist/src/simple.js.map +1 -0
  22. package/dist/src/taglib.d.ts +3 -3
  23. package/dist/src/taglib.d.ts.map +1 -1
  24. package/dist/src/taglib.js +516 -0
  25. package/dist/src/taglib.js.map +1 -0
  26. package/dist/src/types.d.ts +2 -2
  27. package/dist/src/types.d.ts.map +1 -1
  28. package/dist/src/types.js +239 -0
  29. package/dist/src/types.js.map +1 -0
  30. package/dist/src/utils/file.js +65 -0
  31. package/dist/src/utils/file.js.map +1 -0
  32. package/dist/src/utils/write.js +49 -0
  33. package/dist/src/utils/write.js.map +1 -0
  34. package/dist/src/wasm-workers.d.ts +1 -1
  35. package/dist/src/wasm-workers.d.ts.map +1 -1
  36. package/dist/src/wasm-workers.js +148 -0
  37. package/dist/src/wasm-workers.js.map +1 -0
  38. package/dist/src/wasm.js +6 -0
  39. package/dist/src/wasm.js.map +1 -0
  40. package/dist/src/web-utils.d.ts +2 -2
  41. package/dist/src/web-utils.d.ts.map +1 -1
  42. package/{src/web-utils.ts → dist/src/web-utils.js} +102 -184
  43. package/dist/src/web-utils.js.map +1 -0
  44. package/dist/src/workers.d.ts +2 -2
  45. package/dist/src/workers.d.ts.map +1 -1
  46. package/dist/src/workers.js +389 -0
  47. package/dist/src/workers.js.map +1 -0
  48. package/dist/taglib-wrapper.js +8 -2528
  49. package/package.json +7 -10
  50. package/dist/index.ts +0 -221
  51. package/dist/src/constants.ts +0 -227
  52. package/dist/src/errors.ts +0 -254
  53. package/dist/src/file-utils.ts +0 -483
  54. package/dist/src/file.js +0 -52
  55. package/dist/src/global.d.ts +0 -12
  56. package/dist/src/mod.ts +0 -19
  57. package/dist/src/taglib.ts +0 -961
  58. package/dist/src/types.ts +0 -538
  59. package/dist/src/utils/file.ts +0 -86
  60. package/dist/src/utils/write.ts +0 -66
  61. package/dist/src/wasm-workers.ts +0 -176
  62. package/dist/src/wasm.ts +0 -133
  63. package/dist/src/web-utils.ts +0 -347
  64. package/dist/src/workers.ts +0 -461
  65. package/dist/src/write.js +0 -33
  66. package/index.ts +0 -221
  67. package/lib/taglib/COPYING.LGPL +0 -502
  68. package/lib/taglib/COPYING.MPL +0 -470
  69. package/lib/taglib/README.md +0 -24
  70. package/src/constants.ts +0 -227
  71. package/src/errors.ts +0 -254
  72. package/src/file-utils.ts +0 -483
  73. package/src/global.d.ts +0 -12
  74. package/src/mod.ts +0 -19
  75. package/src/simple.ts +0 -667
  76. package/src/taglib.ts +0 -961
  77. package/src/types.ts +0 -538
  78. package/src/utils/file.ts +0 -86
  79. package/src/utils/write.ts +0 -66
  80. package/src/wasm-workers.ts +0 -176
  81. package/src/wasm.ts +0 -133
  82. package/src/workers.ts +0 -461
package/package.json CHANGED
@@ -1,34 +1,31 @@
1
1
  {
2
2
  "name": "taglib-wasm",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "description": "TagLib for TypeScript platforms: Deno, Node.js, Bun, Electron, browsers, and Cloudflare Workers",
5
- "main": "index.ts",
6
- "types": "index.ts",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "types": "./index.ts",
9
+ "types": "./dist/index.d.ts",
10
10
  "default": "./dist/index.js"
11
11
  },
12
12
  "./workers": {
13
- "types": "./src/workers.ts",
13
+ "types": "./dist/src/workers.d.ts",
14
14
  "default": "./dist/src/workers.js"
15
15
  },
16
16
  "./simple": {
17
- "types": "./src/simple.ts",
17
+ "types": "./dist/src/simple.d.ts",
18
18
  "default": "./dist/src/simple.js"
19
19
  }
20
20
  },
21
21
  "files": [
22
- "index.ts",
23
- "src/**/*",
24
22
  "dist/**/*",
25
- "lib/taglib/COPYING*",
26
23
  "README.md",
27
24
  "LICENSE"
28
25
  ],
29
26
  "scripts": {
30
27
  "build:wasm": "./build/build-wasm.sh",
31
- "build:ts": "tsc && node scripts/build-js.js",
28
+ "build:ts": "tsc",
32
29
  "postbuild": "node scripts/postbuild.js",
33
30
  "build": "npm run build:wasm && npm run build:ts && npm run postbuild",
34
31
  "test": "deno test --allow-read --allow-write tests/",
package/dist/index.ts DELETED
@@ -1,221 +0,0 @@
1
- /**
2
- * @fileoverview Main module exports for taglib-wasm
3
- *
4
- * TagLib v2.1 compiled to WebAssembly with TypeScript bindings
5
- * for universal audio metadata handling across all JavaScript runtimes.
6
- *
7
- * @module taglib-wasm
8
- *
9
- * @example
10
- * ```typescript
11
- * // Using the Core API
12
- * import { TagLib } from "taglib-wasm";
13
- *
14
- * const taglib = await TagLib.initialize();
15
- * const file = await taglib.open(audioBuffer);
16
- * const tag = file.tag();
17
- * console.log(tag.title);
18
- * file.dispose();
19
- * ```
20
- *
21
- * @example
22
- * ```typescript
23
- * // Using the Simple API
24
- * import { readTags, applyTags } from "taglib-wasm/simple";
25
- *
26
- * const tags = await readTags("song.mp3");
27
- * console.log(tags.artist);
28
- *
29
- * const modified = await applyTags("song.mp3", {
30
- * artist: "New Artist",
31
- * album: "New Album"
32
- * });
33
- * ```
34
- */
35
-
36
- /**
37
- * Core API exports for advanced usage with full control.
38
- * @see {@link TagLib} - Main TagLib class
39
- * @see {@link AudioFile} - Audio file interface
40
- * @see {@link createTagLib} - Factory function for creating TagLib instances
41
- */
42
- export {
43
- AudioFileImpl as AudioFile,
44
- createTagLib,
45
- TagLib,
46
- } from "./src/taglib.ts";
47
-
48
- /**
49
- * Error types for proper error handling and debugging.
50
- * @see {@link TagLibError} - Base error class for all TagLib errors
51
- * @see {@link TagLibInitializationError} - Wasm initialization failures
52
- * @see {@link InvalidFormatError} - Invalid or corrupted file format
53
- * @see {@link UnsupportedFormatError} - Valid but unsupported format
54
- * @see {@link FileOperationError} - File read/write/save failures
55
- * @see {@link MetadataError} - Tag reading/writing failures
56
- * @see {@link MemoryError} - Wasm memory allocation issues
57
- * @see {@link EnvironmentError} - Runtime/environment issues
58
- */
59
- export {
60
- EnvironmentError,
61
- FileOperationError,
62
- InvalidFormatError,
63
- isEnvironmentError,
64
- isFileOperationError,
65
- isInvalidFormatError,
66
- isMemoryError,
67
- isMetadataError,
68
- isTagLibError,
69
- isUnsupportedFormatError,
70
- MemoryError,
71
- MetadataError,
72
- SUPPORTED_FORMATS,
73
- TagLibError,
74
- TagLibInitializationError,
75
- UnsupportedFormatError,
76
- } from "./src/errors.ts";
77
-
78
- /**
79
- * Simple API exports for easy tag reading and writing.
80
- * @see {@link readTags} - Read metadata from audio files
81
- * @see {@link applyTags} - Apply metadata changes and return modified buffer
82
- * @see {@link updateTags} - Update metadata and save to disk
83
- * @see {@link writeTags} - Deprecated alias for applyTags
84
- * @see {@link readProperties} - Read audio properties
85
- * @see {@link readPictures} - Read cover art/pictures
86
- * @see {@link applyPictures} - Apply pictures to audio files
87
- * @see {@link getCoverArt} - Get primary cover art data
88
- * @see {@link setCoverArt} - Set primary cover art
89
- */
90
- export {
91
- addPicture,
92
- applyPictures,
93
- applyTags,
94
- clearPictures,
95
- clearTags,
96
- findPictureByType,
97
- getCoverArt,
98
- getFormat,
99
- getPictureMetadata,
100
- isValidAudioFile,
101
- readPictures,
102
- readProperties,
103
- readTags,
104
- replacePictureByType,
105
- setCoverArt,
106
- updateTags
107
- } from "./src/simple.ts";
108
-
109
- /**
110
- * Constants and utilities for tag name validation.
111
- * @see {@link Tags} - Standard tag name constants
112
- * @see {@link FormatMappings} - Format-specific field mappings
113
- * @see {@link isValidTagName} - Validate tag names
114
- * @see {@link getAllTagNames} - Get all valid tag names
115
- */
116
- export {
117
- FormatMappings,
118
- getAllTagNames,
119
- isValidTagName,
120
- Tags,
121
- } from "./src/constants.ts";
122
- /**
123
- * File I/O utilities for cover art operations.
124
- * @see {@link exportCoverArt} - Export cover art to file
125
- * @see {@link importCoverArt} - Import cover art from file
126
- * @see {@link copyCoverArt} - Copy cover art between files
127
- */
128
- export {
129
- copyCoverArt,
130
- exportAllPictures,
131
- exportCoverArt,
132
- exportPictureByType,
133
- findCoverArtFiles,
134
- importCoverArt,
135
- importPictureWithType,
136
- loadPictureFromFile,
137
- savePictureToFile,
138
- } from "./src/file-utils.ts";
139
-
140
- /**
141
- * Web browser utilities for cover art operations.
142
- * @see {@link pictureToDataURL} - Convert picture to data URL
143
- * @see {@link setCoverArtFromCanvas} - Set cover art from HTML canvas
144
- * @see {@link displayPicture} - Display picture in HTML img element
145
- */
146
- export {
147
- canvasToPicture,
148
- createPictureDownloadURL,
149
- createPictureGallery,
150
- dataURLToPicture,
151
- displayPicture,
152
- imageFileToPicture,
153
- pictureToDataURL,
154
- setCoverArtFromCanvas,
155
- } from "./src/web-utils.ts";
156
-
157
- /**
158
- * Type exports for TypeScript users.
159
- * These types define the structure of metadata, audio properties,
160
- * and configuration options used throughout the library.
161
- *
162
- * @see {@link Tag} - Basic metadata structure
163
- * @see {@link ExtendedTag} - Extended metadata with advanced fields
164
- * @see {@link AudioProperties} - Audio technical properties
165
- * @see {@link TagLibConfig} - Configuration options
166
- */
167
- export type {
168
- AudioFormat,
169
- AudioProperties,
170
- ExtendedTag,
171
- FieldMapping,
172
- FileType,
173
- Picture,
174
- PropertyMap,
175
- Tag,
176
- TagLibConfig,
177
- TagName,
178
- } from "./src/types.ts";
179
-
180
- /**
181
- * Enum exports
182
- */
183
- export { PictureType } from "./src/types.ts";
184
-
185
- /**
186
- * Wasm module types for advanced usage.
187
- * @see {@link TagLibModule} - Full TagLib Wasm module interface
188
- * @see {@link WasmModule} - Base Emscripten module interface
189
- */
190
- export type { TagLibModule, WasmModule } from "./src/wasm.ts";
191
-
192
- // Import the type for use in this file
193
- import type { TagLibModule } from "./src/wasm.ts";
194
-
195
- /**
196
- * Load the TagLib Wasm module.
197
- * This function initializes the WebAssembly module and returns
198
- * the loaded module for use with the Core API.
199
- *
200
- * @returns Promise resolving to the initialized TagLib module
201
- *
202
- * @example
203
- * ```typescript
204
- * import { loadTagLibModule, createTagLib } from "taglib-wasm";
205
- *
206
- * // Manual module loading for advanced configuration
207
- * const module = await loadTagLibModule();
208
- * const taglib = await createTagLib(module);
209
- * ```
210
- *
211
- * @note Most users should use `TagLib.initialize()` instead,
212
- * which handles module loading automatically.
213
- */
214
- export async function loadTagLibModule(): Promise<TagLibModule> {
215
- // Now that we're using ES6 modules, we can use dynamic import directly
216
- const { default: createTagLibModule } = await import(
217
- "./build/taglib-wrapper.js"
218
- );
219
- const module = await createTagLibModule();
220
- return module as TagLibModule;
221
- }
@@ -1,227 +0,0 @@
1
- /**
2
- * Standard tag property names used by TagLib.
3
- * These constants provide type-safe access to tag properties with IDE autocomplete.
4
- *
5
- * @example
6
- * ```typescript
7
- * import { Tags } from 'taglib-wasm';
8
- *
9
- * // Read tags
10
- * const title = file.tag.properties.get(Tags.Title);
11
- * const artist = file.tag.properties.get(Tags.Artist);
12
- *
13
- * // Write tags
14
- * file.tag.properties.set(Tags.Album, "Dark Side of the Moon");
15
- * file.tag.properties.set(Tags.Year, "1973");
16
- * ```
17
- */
18
- export const Tags = {
19
- // Basic Properties
20
- /** Track/song title */
21
- Title: "TITLE",
22
- /** Primary performer(s) */
23
- Artist: "ARTIST",
24
- /** Album/collection name */
25
- Album: "ALBUM",
26
- /** Date of recording (year) */
27
- Date: "DATE",
28
- /** Track number on album */
29
- TrackNumber: "TRACKNUMBER",
30
- /** Musical genre */
31
- Genre: "GENRE",
32
- /** Comments/notes */
33
- Comment: "COMMENT",
34
-
35
- // Extended Properties
36
- /** Band/orchestra/ensemble */
37
- AlbumArtist: "ALBUMARTIST",
38
- /** Original composer(s) */
39
- Composer: "COMPOSER",
40
- /** Copyright information */
41
- Copyright: "COPYRIGHT",
42
- /** Encoding software/person */
43
- EncodedBy: "ENCODEDBY",
44
- /** Disc number for multi-disc sets */
45
- DiscNumber: "DISCNUMBER",
46
- /** Beats per minute */
47
- Bpm: "BPM",
48
- /** Lyrics/text writer(s) */
49
- Lyricist: "LYRICIST",
50
- /** Conductor */
51
- Conductor: "CONDUCTOR",
52
- /** Person who remixed */
53
- Remixer: "REMIXEDBY",
54
- /** Language of vocals/lyrics */
55
- Language: "LANGUAGE",
56
- /** Publisher */
57
- Publisher: "PUBLISHER",
58
- /** Mood/atmosphere */
59
- Mood: "MOOD",
60
- /** Media type (CD, vinyl, etc.) */
61
- Media: "MEDIA",
62
- /** Radio station owner */
63
- RadioStationOwner: "RADIOSTATIONOWNER",
64
- /** Producer */
65
- Producer: "PRODUCER",
66
- /** Album subtitle */
67
- Subtitle: "SUBTITLE",
68
- /** Release label */
69
- Label: "LABEL",
70
-
71
- // Sorting Properties
72
- /** Sort name for title */
73
- TitleSort: "TITLESORT",
74
- /** Sort name for artist */
75
- ArtistSort: "ARTISTSORT",
76
- /** Sort name for album artist */
77
- AlbumArtistSort: "ALBUMARTISTSORT",
78
- /** Sort name for album */
79
- AlbumSort: "ALBUMSORT",
80
- /** Sort name for composer */
81
- ComposerSort: "COMPOSERSORT",
82
-
83
- // Identifiers
84
- /** International Standard Recording Code */
85
- Isrc: "ISRC",
86
- /** Amazon Standard Identification Number */
87
- Asin: "ASIN",
88
- /** Catalog number */
89
- CatalogNumber: "CATALOGNUMBER",
90
- /** Barcode (EAN/UPC) */
91
- Barcode: "BARCODE",
92
-
93
- // MusicBrainz Identifiers
94
- /** MusicBrainz Artist ID */
95
- MusicBrainzArtistId: "MUSICBRAINZ_ARTISTID",
96
- /** MusicBrainz Release Artist ID */
97
- MusicBrainzReleaseArtistId: "MUSICBRAINZ_ALBUMARTISTID",
98
- /** MusicBrainz Work ID */
99
- MusicBrainzWorkId: "MUSICBRAINZ_WORKID",
100
- /** MusicBrainz Release ID */
101
- MusicBrainzReleaseId: "MUSICBRAINZ_ALBUMID",
102
- /** MusicBrainz Recording ID */
103
- MusicBrainzRecordingId: "MUSICBRAINZ_TRACKID",
104
- /** MusicBrainz Track ID (deprecated, use RecordingId) */
105
- MusicBrainzTrackId: "MUSICBRAINZ_TRACKID",
106
- /** MusicBrainz Release Group ID */
107
- MusicBrainzReleaseGroupId: "MUSICBRAINZ_RELEASEGROUPID",
108
- /** MusicBrainz Release Track ID */
109
- MusicBrainzReleaseTrackId: "MUSICBRAINZ_RELEASETRACKID",
110
-
111
- // Podcast Properties
112
- /** Podcast identifier */
113
- PodcastId: "PODCASTID",
114
- /** Podcast URL */
115
- PodcastUrl: "PODCASTURL",
116
-
117
- // Grouping and Work
118
- /** Content group/work */
119
- Grouping: "GROUPING",
120
- /** Work name */
121
- Work: "WORK",
122
-
123
- // Additional Metadata
124
- /** Lyrics content */
125
- Lyrics: "LYRICS",
126
- /** Album gain (ReplayGain) */
127
- AlbumGain: "REPLAYGAIN_ALBUM_GAIN",
128
- /** Album peak (ReplayGain) */
129
- AlbumPeak: "REPLAYGAIN_ALBUM_PEAK",
130
- /** Track gain (ReplayGain) */
131
- TrackGain: "REPLAYGAIN_TRACK_GAIN",
132
- /** Track peak (ReplayGain) */
133
- TrackPeak: "REPLAYGAIN_TRACK_PEAK",
134
-
135
- // Special handling
136
- /** Original artist for covers */
137
- OriginalArtist: "ORIGINALARTIST",
138
- /** Original album */
139
- OriginalAlbum: "ORIGINALALBUM",
140
- /** Original release date */
141
- OriginalDate: "ORIGINALDATE",
142
- /** Script/writing system */
143
- Script: "SCRIPT",
144
- /** Involved people list */
145
- InvolvedPeopleList: "INVOLVEDPEOPLELIST",
146
-
147
- // Technical Properties
148
- /** Encoder settings/software */
149
- EncoderSettings: "ENCODERSETTINGS",
150
- /** Source media */
151
- SourceMedia: "SOURCEMEDIA",
152
- } as const;
153
-
154
- /**
155
- * Type representing all valid tag property names
156
- */
157
- export type TagName = typeof Tags[keyof typeof Tags];
158
-
159
- /**
160
- * Type guard to check if a string is a valid tag name
161
- */
162
- export function isValidTagName(name: string): name is TagName {
163
- return Object.values(Tags).includes(name as TagName);
164
- }
165
-
166
- /**
167
- * Get all available tag names as an array
168
- */
169
- export function getAllTagNames(): readonly TagName[] {
170
- return Object.values(Tags);
171
- }
172
-
173
- /**
174
- * Format-specific tag mappings (for reference only - TagLib handles these automatically)
175
- * This shows how standard property names map to format-specific identifiers.
176
- */
177
- export const FormatMappings = {
178
- Title: {
179
- id3v2: "TIT2",
180
- mp4: "©nam",
181
- vorbis: "TITLE",
182
- ape: "Title",
183
- riff: "INAM",
184
- },
185
- Artist: {
186
- id3v2: "TPE1",
187
- mp4: "©ART",
188
- vorbis: "ARTIST",
189
- ape: "Artist",
190
- riff: "IART",
191
- },
192
- Album: {
193
- id3v2: "TALB",
194
- mp4: "©alb",
195
- vorbis: "ALBUM",
196
- ape: "Album",
197
- riff: "IPRD",
198
- },
199
- Date: {
200
- id3v2: "TDRC",
201
- mp4: "©day",
202
- vorbis: "DATE",
203
- ape: "Year",
204
- riff: "ICRD",
205
- },
206
- Genre: {
207
- id3v2: "TCON",
208
- mp4: "©gen",
209
- vorbis: "GENRE",
210
- ape: "Genre",
211
- riff: "IGNR",
212
- },
213
- Comment: {
214
- id3v2: "COMM",
215
- mp4: "©cmt",
216
- vorbis: "COMMENT",
217
- ape: "Comment",
218
- riff: "ICMT",
219
- },
220
- TrackNumber: {
221
- id3v2: "TRCK",
222
- mp4: "trkn",
223
- vorbis: "TRACKNUMBER",
224
- ape: "Track",
225
- riff: "ITRK",
226
- },
227
- } as const;