taglib-wasm 0.3.24 β†’ 0.3.26

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 (2) hide show
  1. package/README.md +337 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,337 @@
1
+ # TagLib-Wasm
2
+
3
+ [![Tests](https://github.com/CharlesWiltgen/taglib-wasm/actions/workflows/test.yml/badge.svg)](https://github.com/CharlesWiltgen/taglib-wasm/actions/workflows/test.yml)
4
+ [![npm version](https://img.shields.io/npm/v/taglib-wasm.svg?logo=nodedotjs&logoColor=f5f5f5)](https://www.npmjs.com/package/taglib-wasm)
5
+ [![npm downloads](https://img.shields.io/npm/dm/taglib-wasm.svg)](https://www.npmjs.com/package/taglib-wasm)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/CharlesWiltgen/taglib-wasm/blob/main/LICENSE)
7
+ <br>[![Built with](https://img.shields.io/badge/TypeScript-5-3178c6.svg?logo=typescript&logoColor=f5f5f5)](https://www.typescriptlang.org/)
8
+ [![Built with Emscripten](https://img.shields.io/badge/Built%20with-Emscripten-4B9BFF.svg)](https://emscripten.org/)
9
+ [![Built with WebAssembly](https://img.shields.io/badge/Built%20with-WebAssembly-654ff0.svg?logo=webassembly&logoColor=white)](https://webassembly.org/)
10
+ [![Built with TagLib](https://img.shields.io/badge/Built%20with-TagLib-brightgreen.svg)](https://taglib.org/)
11
+ <br>[![Deno](https://img.shields.io/badge/Deno-000000?logo=deno&logoColor=white)](https://deno.land/)
12
+ [![Node.js](https://img.shields.io/badge/Node.js-339933?logo=nodedotjs&logoColor=white)](https://nodejs.org/)
13
+ [![Bun](https://img.shields.io/badge/Bun-000000?logo=bun&logoColor=white)](https://bun.sh/)
14
+ [![Cloudflare Workers](https://img.shields.io/badge/Cloudflare%20Workers-F38020?logo=cloudflare&logoColor=white)](https://workers.cloudflare.com/)
15
+ [![Electron](https://img.shields.io/badge/Electron-47848F?logo=electron&logoColor=white)](https://www.electronjs.org/)
16
+ [![Browsers](https://img.shields.io/badge/Browsers-E34C26?logo=html5&logoColor=white)](https://html.spec.whatwg.org/multipage/)
17
+
18
+ TagLib-Wasm is the **universal tagging library for TypeScript/JavaScript**
19
+ (TS|JS) platforms: **Deno**, **Node.js**, **Bun**, **Cloudflare Workers**,
20
+ **Electron**, and **browsers**.
21
+
22
+ This project exists because the TS|JS ecosystem had no battle-tested audio
23
+ tagging library that supports reading and writing music metadata to all popular
24
+ audio formats. It aspires to be a universal solution for all TS|JS-capable
25
+ platforms β€” Deno, Node.js, Bun, Electron, Cloudflare Workers, and browsers.
26
+
27
+ TagLib-Wasm stands on the shoulders of giants, including
28
+ [TagLib](https://taglib.org/) itself, [Emscripten](https://emscripten.org/), and
29
+ [Wasm](https://webassembly.org/) ([WebAssembly](https://webassembly.org/)).
30
+ TagLib itself is legendary, and a core dependency of many music apps.
31
+
32
+ ## 🎯 Features
33
+
34
+ - **βœ… Full audio format support** – Supports all audio formats supported by
35
+ TagLib
36
+ - **βœ… TypeScript first** – Complete type definitions and modern API
37
+ - **βœ… Wide TS/JS runtime support** – Deno, Node.js, Bun, Electron, Cloudflare
38
+ Workers, and browsers
39
+ - **βœ… Format abstraction** – Handles container format details automagically
40
+ when possible
41
+ - **βœ… Zero dependencies** – Self-contained Wasm bundle
42
+ - **βœ… Production ready** – Growing test suite helps ensure safety and
43
+ reliability
44
+ - **βœ… Two API styles** – Use the β€œSimple” API (3 functions), or the full β€œCore”
45
+ API for more advanced applications
46
+
47
+ ## πŸ“¦ Installation
48
+
49
+ ### Deno
50
+
51
+ ```typescript
52
+ import { TagLib } from "@charlesw/taglib-wasm";
53
+ ```
54
+
55
+ ### Node.js
56
+
57
+ ```bash
58
+ npm install taglib-wasm
59
+ ```
60
+
61
+ > **Note:** Requires Node.js v22.6.0 or higher. If you want to use the
62
+ > TypeScript version with Node.js, see the
63
+ > [installation guide](https://charleswiltgen.github.io/taglib-wasm/guide/installation.html).
64
+
65
+ ### Bun
66
+
67
+ ```bash
68
+ bun add taglib-wasm
69
+ ```
70
+
71
+ ### Electron
72
+
73
+ ```bash
74
+ npm install taglib-wasm
75
+ ```
76
+
77
+ Works in both main and renderer processes:
78
+
79
+ ```typescript
80
+ // Main process
81
+ import { TagLib } from "taglib-wasm";
82
+
83
+ // Renderer process (with nodeIntegration: true)
84
+ const { TagLib } = require("taglib-wasm");
85
+ ```
86
+
87
+ ### Deno Compiled Binaries (Offline Support)
88
+
89
+ For Deno compiled binaries that need to work offline, you can embed the WASM file:
90
+
91
+ ```typescript
92
+ // 1. Prepare your build by copying the WASM file
93
+ import { prepareWasmForEmbedding } from "@charlesw/taglib-wasm";
94
+ await prepareWasmForEmbedding("./taglib.wasm");
95
+
96
+ // 2. In your application, use the helper for automatic handling
97
+ import { initializeForDenoCompile } from "@charlesw/taglib-wasm";
98
+ const taglib = await initializeForDenoCompile();
99
+
100
+ // 3. Compile with the embedded WASM
101
+ // deno compile --allow-read --include taglib.wasm myapp.ts
102
+ ```
103
+
104
+ For manual control:
105
+
106
+ ```typescript
107
+ // Load embedded WASM in compiled binaries
108
+ const wasmBinary = await Deno.readFile(new URL("./taglib.wasm", import.meta.url));
109
+ const taglib = await TagLib.initialize({ wasmBinary });
110
+ ```
111
+
112
+ ## πŸš€ Quick Start
113
+
114
+ ### Simple API
115
+
116
+ ```typescript
117
+ import { applyTags, readTags, updateTags } from "taglib-wasm/simple";
118
+
119
+ // Read tags - just one function call!
120
+ const tags = await readTags("song.mp3");
121
+ console.log(tags.title, tags.artist, tags.album);
122
+
123
+ // Apply tags and get modified buffer (in-memory)
124
+ const modifiedBuffer = await applyTags("song.mp3", {
125
+ title: "New Title",
126
+ artist: "New Artist",
127
+ album: "New Album",
128
+ });
129
+
130
+ // Or update tags on disk (requires file path)
131
+ await updateTags("song.mp3", {
132
+ title: "New Title",
133
+ artist: "New Artist",
134
+ });
135
+ ```
136
+
137
+ ### Core API
138
+
139
+ The full Core API might be a better choice for apps and utilities focused on
140
+ advanced metadata management.
141
+
142
+ ```typescript
143
+ import { TagLib } from "taglib-wasm";
144
+
145
+ // Initialize taglib-wasm
146
+ const taglib = await TagLib.initialize();
147
+
148
+ // Load audio file
149
+ const file = await taglib.open("song.mp3");
150
+
151
+ // Read and update metadata
152
+ const tag = file.tag();
153
+ tag.setTitle("New Title");
154
+ tag.setArtist("New Artist");
155
+
156
+ // Save changes
157
+ file.save();
158
+
159
+ // Clean up
160
+ file.dispose();
161
+ ```
162
+
163
+ ### Working with Cover Art
164
+
165
+ ```typescript
166
+ import { getCoverArt, setCoverArt } from "taglib-wasm/simple";
167
+
168
+ // Extract cover art
169
+ const coverData = await getCoverArt("song.mp3");
170
+ if (coverData) {
171
+ await Deno.writeFile("cover.jpg", coverData);
172
+ }
173
+
174
+ // Set new cover art
175
+ const imageData = await Deno.readFile("new-cover.jpg");
176
+ const modifiedBuffer = await setCoverArt("song.mp3", imageData, "image/jpeg");
177
+ // Save modifiedBuffer to file if needed
178
+ ```
179
+
180
+ ### Codec Detection and Audio Properties
181
+
182
+ ```typescript
183
+ import { readProperties } from "taglib-wasm/simple";
184
+
185
+ // Get detailed audio properties including codec info
186
+ const props = await readProperties("song.m4a");
187
+
188
+ console.log(props.codec); // "AAC" or "ALAC"
189
+ console.log(props.isLossless); // false for AAC, true for ALAC
190
+ console.log(props.bitsPerSample); // 16 for most formats
191
+ console.log(props.bitrate); // 256 (kbps)
192
+ console.log(props.sampleRate); // 44100 (Hz)
193
+ console.log(props.length); // 180 (duration in seconds)
194
+ ```
195
+
196
+ Supported codec detection:
197
+
198
+ - **MP3** – Returns "MP3" (lossy)
199
+ - **M4A/MP4** – Distinguishes between "AAC" (lossy) and "ALAC" (lossless)
200
+ - **FLAC** – Returns "FLAC" (lossless)
201
+ - **OGG** – Returns "Vorbis" (lossy) or "Opus" (lossy)
202
+ - **WAV** – Returns "PCM" (uncompressed)
203
+
204
+ ## πŸ“š Documentation
205
+
206
+ **[πŸ“– View Full Documentation](https://charleswiltgen.github.io/taglib-wasm/)**
207
+
208
+ ### Getting Started
209
+
210
+ - [Installation Guide](https://charleswiltgen.github.io/taglib-wasm/guide/installation.html)
211
+ - [Quick Start Tutorial](https://charleswiltgen.github.io/taglib-wasm/guide/quick-start.html)
212
+ - [All Examples](https://charleswiltgen.github.io/taglib-wasm/guide/examples.html)
213
+
214
+ ### Guides
215
+
216
+ - [API Reference](https://charleswiltgen.github.io/taglib-wasm/API.html)
217
+ - [Platform Examples](https://charleswiltgen.github.io/taglib-wasm/guide/platform-examples.html)
218
+ - [Working with Cover Art](https://charleswiltgen.github.io/taglib-wasm/guide/cover-art.html)
219
+ - [Cloudflare Workers Setup](https://charleswiltgen.github.io/taglib-wasm/guide/workers-setup.html)
220
+ - [Error Handling](https://charleswiltgen.github.io/taglib-wasm/Error-Handling.html)
221
+
222
+ ### Development
223
+
224
+ - [Testing Guide](https://charleswiltgen.github.io/taglib-wasm/development/testing.html)
225
+ - [Future Improvements](https://charleswiltgen.github.io/taglib-wasm/development/improvements.html)
226
+ - [Contributing](https://charleswiltgen.github.io/taglib-wasm/CONTRIBUTING.html)
227
+
228
+ ## πŸ“‹ Supported Formats
229
+
230
+ `taglib-wasm` is designed to support all formats supported by TagLib:
231
+
232
+ - βœ… **.mp3** – ID3v2 and ID3v1 tags
233
+ - βœ… **.m4a/.mp4** – MPEG-4/AAC metadata for AAC and Apple Lossless audio
234
+ - βœ… **.flac** – Vorbis comments and audio properties
235
+ - βœ… **.ogg** – Ogg Vorbis format with full metadata support
236
+ - βœ… **.wav** – INFO chunk metadata
237
+ - βœ… **Additional formats** – Opus, APE, MPC, WavPack, TrueAudio, AIFF, WMA, and
238
+ more
239
+
240
+ ## 🎯 Key Features
241
+
242
+ ### Extended Metadata Support
243
+
244
+ Beyond basic tags, taglib-wasm supports extended metadata:
245
+
246
+ ```typescript
247
+ import { Tags } from "taglib-wasm";
248
+
249
+ // AcoustID fingerprints
250
+ file.setProperty(
251
+ Tags.AcoustidFingerprint,
252
+ "AQADtMmybfGO8NCNEESLnzHyXNOHeHnG...",
253
+ );
254
+
255
+ // MusicBrainz IDs
256
+ file.setProperty(
257
+ Tags.MusicBrainzTrackId,
258
+ "f4d1b6b8-8c1e-4d9a-9f2a-1234567890ab",
259
+ );
260
+
261
+ // ReplayGain volume normalization
262
+ file.setProperty(Tags.TrackGain, "-6.54 dB");
263
+ file.setProperty(Tags.TrackPeak, "0.987654");
264
+ ```
265
+
266
+ [View all supported tag constants β†’](https://charleswiltgen.github.io/taglib-wasm/Tag-Name-Constants.html)
267
+
268
+ ## πŸ—οΈ Development
269
+
270
+ ### Build from Source
271
+
272
+ ```bash
273
+ # Prerequisites: Emscripten SDK
274
+ # Install via: https://emscripten.org/docs/getting_started/downloads.html
275
+
276
+ # Clone and build
277
+ git clone https://github.com/CharlesWiltgen/taglib-wasm.git
278
+ cd taglib-wasm
279
+
280
+ # Build Wasm module
281
+ npm run build:wasm
282
+
283
+ # Run tests
284
+ npm test
285
+ ```
286
+
287
+ [View full development guide β†’](CONTRIBUTING.md)
288
+
289
+ ## 🌐 Runtime Compatibility
290
+
291
+ `taglib-wasm` works across all major JavaScript runtimes:
292
+
293
+ | Runtime | Status | Installation | Notes |
294
+ | ---------------------- | ------- | ------------------------- | ------------------------- |
295
+ | **Deno** | βœ… Full | `npm:taglib-wasm` | Native TypeScript |
296
+ | **Node.js** | βœ… Full | `npm install taglib-wasm` | TypeScript via tsx |
297
+ | **Bun** | βœ… Full | `bun add taglib-wasm` | Native TypeScript |
298
+ | **Browser** | βœ… Full | Via bundler | Full API support |
299
+ | **Cloudflare Workers** | βœ… Full | `taglib-wasm/workers` | Memory-optimized build |
300
+ | **Electron** | βœ… Full | `npm install taglib-wasm` | Main & renderer processes |
301
+
302
+ ## 🚧 Known Limitations
303
+
304
+ - **Memory Usage** – Entire file must be loaded into memory (may be an issue for
305
+ very large files)
306
+ - **Concurrent Access** – Not thread-safe (JavaScript single-threaded nature
307
+ mitigates this)
308
+ - **Cloudflare Workers** – Limited to 128MB memory per request; files larger
309
+ than ~100MB may fail
310
+
311
+ ## 🀝 Contributing
312
+
313
+ Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md)
314
+ for details on our code of conduct and the process for submitting pull requests.
315
+
316
+ ## πŸ“„ License
317
+
318
+ This project uses dual licensing:
319
+
320
+ - **TypeScript/JavaScript code** – MIT License (see [LICENSE](LICENSE))
321
+ - **WebAssembly binary (taglib.wasm)** – LGPL-2.1-or-later (inherited from
322
+ TagLib)
323
+
324
+ The TagLib library is dual-licensed under LGPL/MPL. When compiled to
325
+ WebAssembly, the resulting binary must comply with LGPL requirements. This
326
+ means:
327
+
328
+ - You can use taglib-wasm in commercial projects
329
+ - If you modify the TagLib C++ code, you must share those changes
330
+ - You must provide a way for users to relink with a modified TagLib
331
+
332
+ For details, see [lib/taglib/COPYING.LGPL](lib/taglib/COPYING.LGPL)
333
+
334
+ ## πŸ™ Acknowledgments
335
+
336
+ - [TagLib](https://taglib.org/) – Excellent audio metadata library
337
+ - [Emscripten](https://emscripten.org/) – WebAssembly compilation toolchain
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taglib-wasm",
3
- "version": "0.3.24",
3
+ "version": "0.3.26",
4
4
  "description": "TagLib for TypeScript platforms: Deno, Node.js, Bun, Electron, browsers, and Cloudflare Workers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",