taglib-wasm 0.5.2 → 0.9.0
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/README.md +90 -41
- package/dist/index.d.ts +42 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -0
- package/dist/src/constants/basic-properties.d.ts +105 -0
- package/dist/src/constants/basic-properties.d.ts.map +1 -0
- package/dist/src/constants/basic-properties.js +90 -0
- package/dist/src/constants/complex-properties.d.ts +166 -0
- package/dist/src/constants/complex-properties.d.ts.map +1 -0
- package/dist/src/constants/complex-properties.js +45 -0
- package/dist/src/constants/format-mappings.d.ts +56 -0
- package/dist/src/constants/format-mappings.d.ts.map +1 -0
- package/dist/src/constants/format-mappings.js +54 -0
- package/dist/src/constants/general-extended-properties.d.ts +233 -0
- package/dist/src/constants/general-extended-properties.d.ts.map +1 -0
- package/dist/src/constants/general-extended-properties.js +220 -0
- package/dist/src/constants/index.d.ts +10 -0
- package/dist/src/constants/index.d.ts.map +1 -0
- package/dist/src/constants/index.js +5 -0
- package/dist/src/constants/legacy-tags.d.ts +79 -0
- package/dist/src/constants/legacy-tags.d.ts.map +1 -0
- package/dist/src/constants/legacy-tags.js +80 -0
- package/dist/src/constants/properties.d.ts +512 -0
- package/dist/src/constants/properties.d.ts.map +1 -0
- package/dist/src/constants/properties.js +11 -0
- package/dist/src/constants/property-types.d.ts +18 -0
- package/dist/src/constants/property-types.d.ts.map +1 -0
- package/dist/src/constants/property-types.js +0 -0
- package/dist/src/constants/specialized-properties.d.ts +161 -0
- package/dist/src/constants/specialized-properties.d.ts.map +1 -0
- package/dist/src/constants/specialized-properties.js +130 -0
- package/dist/src/constants/utilities.d.ts +26 -0
- package/dist/src/constants/utilities.d.ts.map +1 -0
- package/dist/src/constants/utilities.js +25 -0
- package/dist/src/constants.d.ts +4 -1142
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +1 -582
- package/dist/src/deno-compile-loader.d.ts +2 -1
- package/dist/src/deno-compile-loader.d.ts.map +1 -1
- package/dist/src/deno-compile-loader.js +1 -1
- package/dist/src/deno-compile-support.d.ts +1 -1
- package/dist/src/deno-compile-support.d.ts.map +1 -1
- package/dist/src/deno-compile-support.js +2 -2
- package/dist/src/deno-compile.d.ts +6 -6
- package/dist/src/deno-compile.d.ts.map +1 -1
- package/dist/src/deno-compile.js +9 -6
- package/dist/src/file-utils.d.ts.map +1 -1
- package/dist/src/file-utils.js +71 -77
- package/dist/src/folder-api.d.ts +4 -3
- package/dist/src/folder-api.d.ts.map +1 -1
- package/dist/src/folder-api.js +163 -117
- package/dist/src/mod.d.ts +1 -1
- package/dist/src/mod.d.ts.map +1 -1
- package/dist/src/mod.js +2 -0
- package/dist/src/msgpack/decoder.d.ts +57 -0
- package/dist/src/msgpack/decoder.d.ts.map +1 -0
- package/dist/src/msgpack/decoder.js +190 -0
- package/dist/src/msgpack/encoder.d.ts +70 -0
- package/dist/src/msgpack/encoder.d.ts.map +1 -0
- package/dist/src/msgpack/encoder.js +219 -0
- package/dist/src/msgpack/index.d.ts +133 -0
- package/dist/src/msgpack/index.d.ts.map +1 -0
- package/dist/src/msgpack/index.js +249 -0
- package/dist/src/msgpack/types.d.ts +247 -0
- package/dist/src/msgpack/types.d.ts.map +1 -0
- package/dist/src/msgpack/types.js +19 -0
- package/dist/src/runtime/detector.d.ts +64 -0
- package/dist/src/runtime/detector.d.ts.map +1 -0
- package/dist/src/runtime/detector.js +137 -0
- package/dist/src/runtime/loader-types.d.ts +27 -0
- package/dist/src/runtime/loader-types.d.ts.map +1 -0
- package/dist/src/runtime/loader-types.js +0 -0
- package/dist/src/runtime/unified-loader.d.ts +75 -0
- package/dist/src/runtime/unified-loader.d.ts.map +1 -0
- package/dist/src/runtime/unified-loader.js +202 -0
- package/dist/src/runtime/wasi-adapter.d.ts +41 -0
- package/dist/src/runtime/wasi-adapter.d.ts.map +1 -0
- package/dist/src/runtime/wasi-adapter.js +454 -0
- package/dist/src/runtime/wasi-loader.d.ts +102 -0
- package/dist/src/runtime/wasi-loader.d.ts.map +1 -0
- package/dist/src/runtime/wasi-loader.js +231 -0
- package/dist/src/runtime/wasi-memory.d.ts +105 -0
- package/dist/src/runtime/wasi-memory.d.ts.map +1 -0
- package/dist/src/runtime/wasi-memory.js +184 -0
- package/dist/src/runtime/wasmer-sdk-loader.d.ts +69 -0
- package/dist/src/runtime/wasmer-sdk-loader.d.ts.map +1 -0
- package/dist/src/runtime/wasmer-sdk-loader.js +312 -0
- package/dist/src/runtime/wasmer-types.d.js +0 -0
- package/dist/src/simple.d.ts +3 -3
- package/dist/src/simple.d.ts.map +1 -1
- package/dist/src/taglib.d.ts +48 -8
- package/dist/src/taglib.d.ts.map +1 -1
- package/dist/src/taglib.js +63 -18
- package/dist/src/types.d.ts +4 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/file.d.ts.map +1 -1
- package/dist/src/utils/file.js +39 -32
- package/dist/src/utils/rating.d.ts +114 -0
- package/dist/src/utils/rating.d.ts.map +1 -0
- package/dist/src/utils/rating.js +63 -0
- package/dist/src/utils/write.d.ts.map +1 -1
- package/dist/src/utils/write.js +11 -2
- package/dist/src/wasm-workers.d.ts +1 -0
- package/dist/src/wasm-workers.d.ts.map +1 -1
- package/dist/src/wasm-workers.js +34 -24
- package/dist/src/wasm.d.ts +51 -0
- package/dist/src/wasm.d.ts.map +1 -1
- package/dist/src/web-utils.d.ts.map +1 -1
- package/dist/src/web-utils.js +18 -7
- package/dist/src/worker-pool.d.ts +22 -3
- package/dist/src/worker-pool.d.ts.map +1 -1
- package/dist/src/worker-pool.js +59 -12
- package/dist/src/workers.d.ts +4 -4
- package/dist/src/workers.d.ts.map +1 -1
- package/dist/src/workers.js +79 -50
- package/dist/taglib-web.wasm +0 -0
- package/dist/taglib-wrapper.js +2 -14
- package/package.json +15 -7
- package/dist/taglib.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# TagLib-Wasm
|
|
2
2
|
|
|
3
3
|
[](https://github.com/CharlesWiltgen/taglib-wasm/actions/workflows/test.yml)
|
|
4
|
-
[](https://www.npmjs.com/package/taglib-wasm)
|
|
5
5
|
[](https://www.npmjs.com/package/taglib-wasm)
|
|
6
6
|
[](https://github.com/CharlesWiltgen/taglib-wasm/blob/main/LICENSE)
|
|
7
7
|
<br>[](https://www.typescriptlang.org/)
|
|
@@ -29,24 +29,26 @@ TagLib-Wasm stands on the shoulders of giants, including
|
|
|
29
29
|
[Wasm](https://webassembly.org/) ([WebAssembly](https://webassembly.org/)).
|
|
30
30
|
TagLib itself is legendary, and a core dependency of many music apps.
|
|
31
31
|
|
|
32
|
-
##
|
|
32
|
+
## Features
|
|
33
33
|
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
34
|
+
- **Blazing fast performance** – Batch processing delivers 10-20x speedup for
|
|
35
|
+
multiple files
|
|
36
|
+
- **Full audio format support** – Supports all audio formats supported by TagLib
|
|
37
|
+
- **TypeScript first** – Complete type definitions and modern API
|
|
38
|
+
- **Wide TS/JS runtime support** – Deno, Node.js, Bun, Electron, Cloudflare
|
|
38
39
|
Workers, and browsers
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
-
|
|
40
|
+
- **Format abstraction** – Handles container format details automagically when
|
|
41
|
+
possible
|
|
42
|
+
- **Zero dependencies** – Self-contained Wasm bundle
|
|
43
|
+
- **Automatic runtime optimization** – Uses WASI for Deno/Node.js, Emscripten
|
|
44
|
+
for browsers
|
|
45
|
+
- **Production ready** – Growing test suite helps ensure safety and reliability
|
|
46
|
+
- **Two API styles** – Use the "Simple" API (3 functions), or the full "Core"
|
|
45
47
|
API for more advanced applications
|
|
46
|
-
-
|
|
47
|
-
|
|
48
|
+
- **Batch folder operations** – Scan directories, process multiple files, find
|
|
49
|
+
duplicates, and export metadata catalogs
|
|
48
50
|
|
|
49
|
-
##
|
|
51
|
+
## Installation
|
|
50
52
|
|
|
51
53
|
### Deno
|
|
52
54
|
|
|
@@ -118,7 +120,7 @@ const wasmBinary = await Deno.readFile(
|
|
|
118
120
|
const taglib = await TagLib.initialize({ wasmBinary });
|
|
119
121
|
```
|
|
120
122
|
|
|
121
|
-
##
|
|
123
|
+
## Quick Start
|
|
122
124
|
|
|
123
125
|
### Simple API
|
|
124
126
|
|
|
@@ -143,6 +145,25 @@ await updateTags("song.mp3", {
|
|
|
143
145
|
});
|
|
144
146
|
```
|
|
145
147
|
|
|
148
|
+
### High-Performance Batch Processing
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { readMetadataBatch, readTagsBatch } from "taglib-wasm/simple";
|
|
152
|
+
|
|
153
|
+
// Process multiple files in parallel - dramatically faster!
|
|
154
|
+
const files = ["track01.mp3", "track02.mp3", /* ... */ "track20.mp3"];
|
|
155
|
+
|
|
156
|
+
// Read just tags (18x faster than sequential)
|
|
157
|
+
const tags = await readTagsBatch(files, { concurrency: 8 });
|
|
158
|
+
|
|
159
|
+
// Read complete metadata including cover art detection (15x faster)
|
|
160
|
+
const metadata = await readMetadataBatch(files, { concurrency: 8 });
|
|
161
|
+
|
|
162
|
+
// Real-world performance:
|
|
163
|
+
// Sequential: ~100 seconds for 20 files
|
|
164
|
+
// Batch: ~5 seconds for 20 files (20x speedup!)
|
|
165
|
+
```
|
|
166
|
+
|
|
146
167
|
### Full API
|
|
147
168
|
|
|
148
169
|
The Full API might be a better choice for apps and utilities focused on advanced
|
|
@@ -216,6 +237,30 @@ const modifiedBuffer = await setCoverArt("song.mp3", imageData, "image/jpeg");
|
|
|
216
237
|
// Save modifiedBuffer to file if needed
|
|
217
238
|
```
|
|
218
239
|
|
|
240
|
+
### Working with Ratings
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import { RatingUtils, TagLib } from "taglib-wasm";
|
|
244
|
+
|
|
245
|
+
const taglib = await TagLib.initialize();
|
|
246
|
+
const file = await taglib.open("song.mp3");
|
|
247
|
+
|
|
248
|
+
// Read rating (normalized 0.0-1.0)
|
|
249
|
+
const rating = file.getRating();
|
|
250
|
+
if (rating !== undefined) {
|
|
251
|
+
console.log(`Rating: ${RatingUtils.toStars(rating)} stars`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Set rating (4 out of 5 stars)
|
|
255
|
+
file.setRating(0.8);
|
|
256
|
+
file.save();
|
|
257
|
+
|
|
258
|
+
file.dispose();
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
See the [Track Ratings Guide](https://charleswiltgen.github.io/taglib-wasm/guide/ratings.html)
|
|
262
|
+
for RatingUtils API and cross-format conversion details.
|
|
263
|
+
|
|
219
264
|
### Container Format and Codec Detection
|
|
220
265
|
|
|
221
266
|
```typescript
|
|
@@ -247,9 +292,9 @@ Supported formats:
|
|
|
247
292
|
- **WAV** – Container for PCM (uncompressed) audio
|
|
248
293
|
- **AIFF** – Container for PCM (uncompressed) audio
|
|
249
294
|
|
|
250
|
-
##
|
|
295
|
+
## Documentation
|
|
251
296
|
|
|
252
|
-
**[
|
|
297
|
+
**[View Full Documentation](https://charleswiltgen.github.io/taglib-wasm/)**
|
|
253
298
|
|
|
254
299
|
### Getting Started
|
|
255
300
|
|
|
@@ -260,8 +305,11 @@ Supported formats:
|
|
|
260
305
|
### Guides
|
|
261
306
|
|
|
262
307
|
- [API Reference](https://charleswiltgen.github.io/taglib-wasm/api/)
|
|
308
|
+
- [Performance Guide](https://charleswiltgen.github.io/taglib-wasm/concepts/performance.html)
|
|
309
|
+
- [Album Processing Guide](https://charleswiltgen.github.io/taglib-wasm/guide/album-processing.html) - Process entire albums in seconds
|
|
263
310
|
- [Platform Examples](https://charleswiltgen.github.io/taglib-wasm/guide/platform-examples.html)
|
|
264
311
|
- [Working with Cover Art](https://charleswiltgen.github.io/taglib-wasm/guide/cover-art.html)
|
|
312
|
+
- [Track Ratings](https://charleswiltgen.github.io/taglib-wasm/guide/ratings.html)
|
|
265
313
|
- [Cloudflare Workers Setup](https://charleswiltgen.github.io/taglib-wasm/guide/workers-setup.html)
|
|
266
314
|
- [Error Handling](https://charleswiltgen.github.io/taglib-wasm/concepts/error-handling.html)
|
|
267
315
|
|
|
@@ -271,19 +319,19 @@ Supported formats:
|
|
|
271
319
|
- [Future Improvements](https://charleswiltgen.github.io/taglib-wasm/development/improvements.html)
|
|
272
320
|
- [Contributing](CONTRIBUTING.md)
|
|
273
321
|
|
|
274
|
-
##
|
|
322
|
+
## Supported Formats
|
|
275
323
|
|
|
276
324
|
`taglib-wasm` is designed to support all formats supported by TagLib:
|
|
277
325
|
|
|
278
|
-
-
|
|
279
|
-
-
|
|
280
|
-
-
|
|
281
|
-
-
|
|
282
|
-
-
|
|
283
|
-
-
|
|
326
|
+
- **.mp3** – ID3v2 and ID3v1 tags
|
|
327
|
+
- **.m4a/.mp4** – MPEG-4/AAC metadata for AAC and Apple Lossless audio
|
|
328
|
+
- **.flac** – Vorbis comments and audio properties
|
|
329
|
+
- **.ogg** – Ogg Vorbis format with full metadata support
|
|
330
|
+
- **.wav** – INFO chunk metadata
|
|
331
|
+
- **Additional formats** – Opus, APE, MPC, WavPack, TrueAudio, AIFF, WMA, and
|
|
284
332
|
more
|
|
285
333
|
|
|
286
|
-
##
|
|
334
|
+
## Key Features
|
|
287
335
|
|
|
288
336
|
### Extended Metadata Support
|
|
289
337
|
|
|
@@ -311,7 +359,7 @@ file.setProperty(Tags.TrackPeak, "0.987654");
|
|
|
311
359
|
|
|
312
360
|
[View all supported tag constants →](https://charleswiltgen.github.io/taglib-wasm/api/tag-name-constants.html)
|
|
313
361
|
|
|
314
|
-
##
|
|
362
|
+
## Performance and Best Practices
|
|
315
363
|
|
|
316
364
|
### Batch Processing for Multiple Files
|
|
317
365
|
|
|
@@ -386,7 +434,7 @@ const taglib = await TagLib.initialize({ wasmBinary });
|
|
|
386
434
|
|
|
387
435
|
[View complete performance guide →](https://charleswiltgen.github.io/taglib-wasm/concepts/performance.html)
|
|
388
436
|
|
|
389
|
-
##
|
|
437
|
+
## Development
|
|
390
438
|
|
|
391
439
|
### Build from Source
|
|
392
440
|
|
|
@@ -407,20 +455,20 @@ npm test
|
|
|
407
455
|
|
|
408
456
|
[View full development guide →](CONTRIBUTING.md)
|
|
409
457
|
|
|
410
|
-
##
|
|
458
|
+
## Runtime Compatibility
|
|
411
459
|
|
|
412
460
|
`taglib-wasm` works across all major JavaScript runtimes:
|
|
413
461
|
|
|
414
|
-
| Runtime | Status
|
|
415
|
-
| ---------------------- |
|
|
416
|
-
| **Deno** |
|
|
417
|
-
| **Node.js** |
|
|
418
|
-
| **Bun** |
|
|
419
|
-
| **Browser** |
|
|
420
|
-
| **Cloudflare Workers** |
|
|
421
|
-
| **Electron** |
|
|
462
|
+
| Runtime | Status | Installation | Notes |
|
|
463
|
+
| ---------------------- | ------ | ------------------------- | ------------------------- |
|
|
464
|
+
| **Deno** | Full | `npm:taglib-wasm` | Native TypeScript |
|
|
465
|
+
| **Node.js** | Full | `npm install taglib-wasm` | TypeScript via tsx |
|
|
466
|
+
| **Bun** | Full | `bun add taglib-wasm` | Native TypeScript |
|
|
467
|
+
| **Browser** | Full | Via bundler | Full API support |
|
|
468
|
+
| **Cloudflare Workers** | Full | `taglib-wasm/workers` | Memory-optimized build |
|
|
469
|
+
| **Electron** | Full | `npm install taglib-wasm` | Main & renderer processes |
|
|
422
470
|
|
|
423
|
-
##
|
|
471
|
+
## Known Limitations
|
|
424
472
|
|
|
425
473
|
- **Memory Usage** – Entire file must be loaded into memory (may be an issue for
|
|
426
474
|
very large files)
|
|
@@ -429,12 +477,12 @@ npm test
|
|
|
429
477
|
- **Cloudflare Workers** – Limited to 128MB memory per request; files larger
|
|
430
478
|
than ~100MB may fail
|
|
431
479
|
|
|
432
|
-
##
|
|
480
|
+
## Contributing
|
|
433
481
|
|
|
434
482
|
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md)
|
|
435
483
|
for details on our code of conduct and the process for submitting pull requests.
|
|
436
484
|
|
|
437
|
-
##
|
|
485
|
+
## License
|
|
438
486
|
|
|
439
487
|
This project uses dual licensing:
|
|
440
488
|
|
|
@@ -452,7 +500,8 @@ means:
|
|
|
452
500
|
|
|
453
501
|
For details, see [lib/taglib/COPYING.LGPL](lib/taglib/COPYING.LGPL)
|
|
454
502
|
|
|
455
|
-
##
|
|
503
|
+
## Acknowledgments
|
|
456
504
|
|
|
457
505
|
- [TagLib](https://taglib.org/) – Excellent audio metadata library
|
|
458
506
|
- [Emscripten](https://emscripten.org/) – WebAssembly compilation toolchain
|
|
507
|
+
- [WASI](https://wasi.dev/) – WebAssembly System Interface for server-side runtimes
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
* @see {@link createTagLib} - Factory function for creating TagLib instances
|
|
40
40
|
*/
|
|
41
41
|
export { AudioFileImpl as AudioFile, createTagLib, TagLib, } from "./src/taglib.ts";
|
|
42
|
+
export type { AudioFile as AudioFileInterface } from "./src/taglib.ts";
|
|
42
43
|
/**
|
|
43
44
|
* Error types for proper error handling and debugging.
|
|
44
45
|
* @see {@link TagLibError} - Base error class for all TagLib errors
|
|
@@ -81,6 +82,7 @@ export { addPicture, applyPictures, applyTags, type BatchOptions, type BatchResu
|
|
|
81
82
|
* @see {@link FormatMappings} - Format-specific field mappings (deprecated)
|
|
82
83
|
*/
|
|
83
84
|
export { FormatMappings, getAllProperties, getAllPropertyKeys, getAllTagNames, getPropertiesByFormat, getPropertyMetadata, isValidProperty, isValidTagName, PROPERTIES, Tags, } from "./src/constants.ts";
|
|
85
|
+
export type { PropertyMetadata } from "./src/constants/property-types.ts";
|
|
84
86
|
/**
|
|
85
87
|
* File I/O utilities for cover art operations.
|
|
86
88
|
* @see {@link exportCoverArt} - Export cover art to file
|
|
@@ -95,7 +97,7 @@ export { copyCoverArt, exportAllPictures, exportCoverArt, exportPictureByType, f
|
|
|
95
97
|
* @see {@link findDuplicates} - Find duplicate files based on metadata
|
|
96
98
|
* @see {@link exportFolderMetadata} - Export folder metadata to JSON
|
|
97
99
|
*/
|
|
98
|
-
export { type AudioFileMetadata, exportFolderMetadata, findDuplicates, type FolderScanOptions, type FolderScanResult, scanFolder, updateFolderTags, } from "./src/folder-api.ts";
|
|
100
|
+
export { type AudioDynamics, type AudioFileMetadata, exportFolderMetadata, findDuplicates, type FolderScanOptions, type FolderScanResult, scanFolder, updateFolderTags, } from "./src/folder-api.ts";
|
|
99
101
|
/**
|
|
100
102
|
* Web browser utilities for cover art operations.
|
|
101
103
|
* @see {@link pictureToDataURL} - Convert picture to data URL
|
|
@@ -114,20 +116,42 @@ export { canvasToPicture, createPictureDownloadURL, createPictureGallery, dataUR
|
|
|
114
116
|
* @see {@link PropertyKey} - Type-safe property keys with autocomplete
|
|
115
117
|
* @see {@link PropertyValue} - Type-safe property values
|
|
116
118
|
*/
|
|
117
|
-
export type { AudioFormat, AudioProperties, ExtendedTag, FieldMapping, FileType, Picture, PropertyMap, Tag, TagName, } from "./src/types.ts";
|
|
119
|
+
export type { AudioFileInput, AudioFormat, AudioProperties, ExtendedTag, FieldMapping, FileType, Picture, PropertyMap, Tag, TagName, } from "./src/types.ts";
|
|
118
120
|
export type { PropertyKey, PropertyValue } from "./src/constants.ts";
|
|
119
121
|
/**
|
|
120
122
|
* Type and constant exports
|
|
121
123
|
*/
|
|
122
124
|
export type { PictureType } from "./src/types.ts";
|
|
123
125
|
export { PICTURE_TYPE_NAMES, PICTURE_TYPE_VALUES } from "./src/types.ts";
|
|
126
|
+
/**
|
|
127
|
+
* Complex property types and constants for structured metadata.
|
|
128
|
+
* @see {@link COMPLEX_PROPERTIES} - Rich metadata object with format mappings
|
|
129
|
+
* @see {@link COMPLEX_PROPERTY_KEY} - Simple key map for daily use
|
|
130
|
+
* @see {@link Rating} - Track rating metadata (normalized 0.0-1.0)
|
|
131
|
+
* @see {@link UnsyncedLyrics} - Unsynchronized lyrics text
|
|
132
|
+
* @see {@link ComplexPropertyValueMap} - Type map for generic methods
|
|
133
|
+
*/
|
|
134
|
+
export { COMPLEX_PROPERTIES, COMPLEX_PROPERTY_KEY, } from "./src/constants/complex-properties.ts";
|
|
135
|
+
export type { ComplexPropertyKey, ComplexPropertyKeyMap, ComplexPropertyValueMap, Rating, UnsyncedLyrics, VariantMap, } from "./src/constants/complex-properties.ts";
|
|
136
|
+
/**
|
|
137
|
+
* Rating conversion utilities for cross-format compatibility.
|
|
138
|
+
* @see {@link RatingUtils} - Namespace with all rating utilities
|
|
139
|
+
* @see {@link toNormalized} - POPM (0-255) to normalized (0.0-1.0)
|
|
140
|
+
* @see {@link fromNormalized} - Normalized to POPM
|
|
141
|
+
* @see {@link toStars} - Normalized to star rating
|
|
142
|
+
* @see {@link fromStars} - Star rating to normalized
|
|
143
|
+
* @see {@link toPopm} - Normalized to standard POPM value
|
|
144
|
+
* @see {@link fromPopm} - Standard POPM to normalized
|
|
145
|
+
*/
|
|
146
|
+
export { clamp as clampRating, fromNormalized, fromPercent, fromPopm, fromStars, isValid as isValidRating, RatingUtils, toNormalized, toPercent, toPopm, toStars, } from "./src/utils/rating.ts";
|
|
124
147
|
/**
|
|
125
148
|
* Worker pool exports for parallel processing.
|
|
126
149
|
* @see {@link TagLibWorkerPool} - Worker pool for parallel file processing
|
|
127
|
-
* @see {@link
|
|
150
|
+
* @see {@link createWorkerPool} - Create and initialize a worker pool
|
|
151
|
+
* @see {@link getGlobalWorkerPool} - Get/create global worker pool instance (deprecated)
|
|
128
152
|
* @see {@link terminateGlobalWorkerPool} - Terminate global worker pool
|
|
129
153
|
*/
|
|
130
|
-
export { getGlobalWorkerPool, TagLibWorkerPool, terminateGlobalWorkerPool, } from "./src/worker-pool.ts";
|
|
154
|
+
export { createWorkerPool, getGlobalWorkerPool, TagLibWorkerPool, terminateGlobalWorkerPool, } from "./src/worker-pool.ts";
|
|
131
155
|
export type { BatchOperation, WorkerPoolOptions, WorkerTask, } from "./src/worker-pool.ts";
|
|
132
156
|
/**
|
|
133
157
|
* Wasm module types for advanced usage.
|
|
@@ -139,34 +163,34 @@ import type { TagLibModule } from "./src/wasm.ts";
|
|
|
139
163
|
/**
|
|
140
164
|
* Configuration options for loading the TagLib WASM module
|
|
141
165
|
*/
|
|
142
|
-
export
|
|
143
|
-
|
|
144
|
-
* Optional pre-loaded WASM binary data.
|
|
145
|
-
* If provided, this will be used instead of fetching from network.
|
|
146
|
-
*/
|
|
147
|
-
wasmBinary?: ArrayBuffer | Uint8Array;
|
|
148
|
-
/**
|
|
149
|
-
* Optional custom URL or path for the WASM file.
|
|
150
|
-
* This is passed to the locateFile function.
|
|
151
|
-
*/
|
|
152
|
-
wasmUrl?: string;
|
|
153
|
-
}
|
|
166
|
+
export type { LoadTagLibOptions } from "./src/runtime/loader-types.ts";
|
|
167
|
+
import type { LoadTagLibOptions } from "./src/runtime/loader-types.ts";
|
|
154
168
|
/**
|
|
155
169
|
* Load the TagLib Wasm module.
|
|
156
170
|
* This function initializes the WebAssembly module and returns
|
|
157
171
|
* the loaded module for use with the Full API.
|
|
158
172
|
*
|
|
159
|
-
*
|
|
173
|
+
* Automatically selects the optimal implementation:
|
|
174
|
+
* - WASI for Deno/Node.js (faster filesystem access, MessagePack serialization)
|
|
175
|
+
* - Emscripten for browsers (universal compatibility)
|
|
176
|
+
*
|
|
177
|
+
* @param options - Optional configuration for module initialization
|
|
160
178
|
* @returns Promise resolving to the initialized TagLib module
|
|
161
179
|
*
|
|
162
180
|
* @example
|
|
163
181
|
* ```typescript
|
|
164
182
|
* import { loadTagLibModule, createTagLib } from "taglib-wasm";
|
|
165
183
|
*
|
|
166
|
-
* //
|
|
184
|
+
* // Auto-select optimal implementation
|
|
167
185
|
* const module = await loadTagLibModule();
|
|
168
186
|
* const taglib = await createTagLib(module);
|
|
169
187
|
*
|
|
188
|
+
* // Force Emscripten mode
|
|
189
|
+
* const module = await loadTagLibModule({ legacyMode: true });
|
|
190
|
+
*
|
|
191
|
+
* // Force WASI mode (Deno/Node.js only)
|
|
192
|
+
* const module = await loadTagLibModule({ forceWasmType: "wasi" });
|
|
193
|
+
*
|
|
170
194
|
* // With custom WASM binary
|
|
171
195
|
* const wasmData = await fetch("taglib.wasm").then(r => r.arrayBuffer());
|
|
172
196
|
* const module = await loadTagLibModule({ wasmBinary: wasmData });
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH;;;;;GAKG;AACH,OAAO,EACL,aAAa,IAAI,SAAS,EAC1B,YAAY,EACZ,MAAM,GACP,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
CHANGED
|
@@ -85,11 +85,49 @@ import {
|
|
|
85
85
|
} from "./src/web-utils.js";
|
|
86
86
|
import { PICTURE_TYPE_NAMES, PICTURE_TYPE_VALUES } from "./src/types.js";
|
|
87
87
|
import {
|
|
88
|
+
COMPLEX_PROPERTIES,
|
|
89
|
+
COMPLEX_PROPERTY_KEY
|
|
90
|
+
} from "./src/constants/complex-properties.js";
|
|
91
|
+
import {
|
|
92
|
+
clamp,
|
|
93
|
+
fromNormalized,
|
|
94
|
+
fromPercent,
|
|
95
|
+
fromPopm,
|
|
96
|
+
fromStars,
|
|
97
|
+
isValid,
|
|
98
|
+
RatingUtils,
|
|
99
|
+
toNormalized,
|
|
100
|
+
toPercent,
|
|
101
|
+
toPopm,
|
|
102
|
+
toStars
|
|
103
|
+
} from "./src/utils/rating.js";
|
|
104
|
+
import {
|
|
105
|
+
createWorkerPool,
|
|
88
106
|
getGlobalWorkerPool,
|
|
89
107
|
TagLibWorkerPool,
|
|
90
108
|
terminateGlobalWorkerPool
|
|
91
109
|
} from "./src/worker-pool.js";
|
|
92
110
|
async function loadTagLibModule(options) {
|
|
111
|
+
if (options?.legacyMode) {
|
|
112
|
+
return loadLegacyTagLibModule(options);
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const { loadUnifiedTagLibModule } = await import("./src/runtime/unified-loader.js");
|
|
116
|
+
return await loadUnifiedTagLibModule({
|
|
117
|
+
wasmBinary: options?.wasmBinary,
|
|
118
|
+
wasmUrl: options?.wasmUrl,
|
|
119
|
+
// These options exist in the v2 loader
|
|
120
|
+
debug: false,
|
|
121
|
+
useInlineWasm: false
|
|
122
|
+
});
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.warn(
|
|
125
|
+
`[TagLib] Unified loader failed, falling back to legacy mode: ${error}`
|
|
126
|
+
);
|
|
127
|
+
return loadLegacyTagLibModule(options || {});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function loadLegacyTagLibModule(options) {
|
|
93
131
|
let createTagLibModule;
|
|
94
132
|
try {
|
|
95
133
|
const module2 = await import("./taglib-wrapper.js");
|
|
@@ -121,6 +159,8 @@ async function loadTagLibModule(options) {
|
|
|
121
159
|
}
|
|
122
160
|
export {
|
|
123
161
|
AudioFileImpl as AudioFile,
|
|
162
|
+
COMPLEX_PROPERTIES,
|
|
163
|
+
COMPLEX_PROPERTY_KEY,
|
|
124
164
|
EnvironmentError,
|
|
125
165
|
FileOperationError,
|
|
126
166
|
FormatMappings,
|
|
@@ -130,6 +170,7 @@ export {
|
|
|
130
170
|
PICTURE_TYPE_NAMES,
|
|
131
171
|
PICTURE_TYPE_VALUES,
|
|
132
172
|
PROPERTIES,
|
|
173
|
+
RatingUtils,
|
|
133
174
|
SUPPORTED_FORMATS,
|
|
134
175
|
TagLib,
|
|
135
176
|
TagLibError,
|
|
@@ -141,12 +182,14 @@ export {
|
|
|
141
182
|
applyPictures,
|
|
142
183
|
applyTags,
|
|
143
184
|
canvasToPicture,
|
|
185
|
+
clamp as clampRating,
|
|
144
186
|
clearPictures,
|
|
145
187
|
clearTags,
|
|
146
188
|
copyCoverArt,
|
|
147
189
|
createPictureDownloadURL,
|
|
148
190
|
createPictureGallery,
|
|
149
191
|
createTagLib,
|
|
192
|
+
createWorkerPool,
|
|
150
193
|
dataURLToPicture,
|
|
151
194
|
displayPicture,
|
|
152
195
|
exportAllPictures,
|
|
@@ -156,6 +199,10 @@ export {
|
|
|
156
199
|
findCoverArtFiles,
|
|
157
200
|
findDuplicates,
|
|
158
201
|
findPictureByType,
|
|
202
|
+
fromNormalized,
|
|
203
|
+
fromPercent,
|
|
204
|
+
fromPopm,
|
|
205
|
+
fromStars,
|
|
159
206
|
getAllProperties,
|
|
160
207
|
getAllPropertyKeys,
|
|
161
208
|
getAllTagNames,
|
|
@@ -177,6 +224,7 @@ export {
|
|
|
177
224
|
isUnsupportedFormatError,
|
|
178
225
|
isValidAudioFile,
|
|
179
226
|
isValidProperty,
|
|
227
|
+
isValid as isValidRating,
|
|
180
228
|
isValidTagName,
|
|
181
229
|
loadPictureFromFile,
|
|
182
230
|
loadTagLibModule,
|
|
@@ -194,6 +242,10 @@ export {
|
|
|
194
242
|
setCoverArtFromCanvas,
|
|
195
243
|
setWorkerPoolMode,
|
|
196
244
|
terminateGlobalWorkerPool,
|
|
245
|
+
toNormalized,
|
|
246
|
+
toPercent,
|
|
247
|
+
toPopm,
|
|
248
|
+
toStars,
|
|
197
249
|
updateFolderTags,
|
|
198
250
|
updateTags
|
|
199
251
|
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Basic audio metadata properties supported across all common formats.
|
|
3
|
+
* These are the core tags that most audio files should have.
|
|
4
|
+
*/
|
|
5
|
+
export declare const BASIC_PROPERTIES: {
|
|
6
|
+
readonly TITLE: {
|
|
7
|
+
readonly key: "TITLE";
|
|
8
|
+
readonly description: "The title of the track";
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly supportedFormats: readonly ["ID3v2", "MP4", "Vorbis", "WAV"];
|
|
11
|
+
readonly mappings: {
|
|
12
|
+
readonly id3v2: {
|
|
13
|
+
readonly frame: "TIT2";
|
|
14
|
+
};
|
|
15
|
+
readonly vorbis: "TITLE";
|
|
16
|
+
readonly mp4: "©nam";
|
|
17
|
+
readonly wav: "INAM";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
readonly ARTIST: {
|
|
21
|
+
readonly key: "ARTIST";
|
|
22
|
+
readonly description: "The primary performer(s) of the track";
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly supportedFormats: readonly ["ID3v2", "MP4", "Vorbis", "WAV"];
|
|
25
|
+
readonly mappings: {
|
|
26
|
+
readonly id3v2: {
|
|
27
|
+
readonly frame: "TPE1";
|
|
28
|
+
};
|
|
29
|
+
readonly vorbis: "ARTIST";
|
|
30
|
+
readonly mp4: "©ART";
|
|
31
|
+
readonly wav: "IART";
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
readonly ALBUM: {
|
|
35
|
+
readonly key: "ALBUM";
|
|
36
|
+
readonly description: "The album/collection name";
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
readonly supportedFormats: readonly ["ID3v2", "MP4", "Vorbis", "WAV"];
|
|
39
|
+
readonly mappings: {
|
|
40
|
+
readonly id3v2: {
|
|
41
|
+
readonly frame: "TALB";
|
|
42
|
+
};
|
|
43
|
+
readonly vorbis: "ALBUM";
|
|
44
|
+
readonly mp4: "©alb";
|
|
45
|
+
readonly wav: "IPRD";
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
readonly DATE: {
|
|
49
|
+
readonly key: "DATE";
|
|
50
|
+
readonly description: "The date of recording (typically year)";
|
|
51
|
+
readonly type: "string";
|
|
52
|
+
readonly supportedFormats: readonly ["ID3v2", "MP4", "Vorbis", "WAV"];
|
|
53
|
+
readonly mappings: {
|
|
54
|
+
readonly id3v2: {
|
|
55
|
+
readonly frame: "TDRC";
|
|
56
|
+
};
|
|
57
|
+
readonly vorbis: "DATE";
|
|
58
|
+
readonly mp4: "©day";
|
|
59
|
+
readonly wav: "ICRD";
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
readonly TRACKNUMBER: {
|
|
63
|
+
readonly key: "TRACKNUMBER";
|
|
64
|
+
readonly description: "The track number within the album";
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
readonly supportedFormats: readonly ["ID3v2", "MP4", "Vorbis", "WAV"];
|
|
67
|
+
readonly mappings: {
|
|
68
|
+
readonly id3v2: {
|
|
69
|
+
readonly frame: "TRCK";
|
|
70
|
+
};
|
|
71
|
+
readonly vorbis: "TRACKNUMBER";
|
|
72
|
+
readonly mp4: "trkn";
|
|
73
|
+
readonly wav: "ITRK";
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
readonly GENRE: {
|
|
77
|
+
readonly key: "GENRE";
|
|
78
|
+
readonly description: "The musical genre";
|
|
79
|
+
readonly type: "string";
|
|
80
|
+
readonly supportedFormats: readonly ["ID3v2", "MP4", "Vorbis", "WAV"];
|
|
81
|
+
readonly mappings: {
|
|
82
|
+
readonly id3v2: {
|
|
83
|
+
readonly frame: "TCON";
|
|
84
|
+
};
|
|
85
|
+
readonly vorbis: "GENRE";
|
|
86
|
+
readonly mp4: "©gen";
|
|
87
|
+
readonly wav: "IGNR";
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
readonly COMMENT: {
|
|
91
|
+
readonly key: "COMMENT";
|
|
92
|
+
readonly description: "Comments or notes about the track";
|
|
93
|
+
readonly type: "string";
|
|
94
|
+
readonly supportedFormats: readonly ["ID3v2", "MP4", "Vorbis", "WAV"];
|
|
95
|
+
readonly mappings: {
|
|
96
|
+
readonly id3v2: {
|
|
97
|
+
readonly frame: "COMM";
|
|
98
|
+
};
|
|
99
|
+
readonly vorbis: "COMMENT";
|
|
100
|
+
readonly mp4: "©cmt";
|
|
101
|
+
readonly wav: "ICMT";
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=basic-properties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic-properties.d.ts","sourceRoot":"","sources":["../../../src/constants/basic-properties.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFnB,CAAC"}
|