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.
Files changed (119) hide show
  1. package/README.md +90 -41
  2. package/dist/index.d.ts +42 -18
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +52 -0
  5. package/dist/src/constants/basic-properties.d.ts +105 -0
  6. package/dist/src/constants/basic-properties.d.ts.map +1 -0
  7. package/dist/src/constants/basic-properties.js +90 -0
  8. package/dist/src/constants/complex-properties.d.ts +166 -0
  9. package/dist/src/constants/complex-properties.d.ts.map +1 -0
  10. package/dist/src/constants/complex-properties.js +45 -0
  11. package/dist/src/constants/format-mappings.d.ts +56 -0
  12. package/dist/src/constants/format-mappings.d.ts.map +1 -0
  13. package/dist/src/constants/format-mappings.js +54 -0
  14. package/dist/src/constants/general-extended-properties.d.ts +233 -0
  15. package/dist/src/constants/general-extended-properties.d.ts.map +1 -0
  16. package/dist/src/constants/general-extended-properties.js +220 -0
  17. package/dist/src/constants/index.d.ts +10 -0
  18. package/dist/src/constants/index.d.ts.map +1 -0
  19. package/dist/src/constants/index.js +5 -0
  20. package/dist/src/constants/legacy-tags.d.ts +79 -0
  21. package/dist/src/constants/legacy-tags.d.ts.map +1 -0
  22. package/dist/src/constants/legacy-tags.js +80 -0
  23. package/dist/src/constants/properties.d.ts +512 -0
  24. package/dist/src/constants/properties.d.ts.map +1 -0
  25. package/dist/src/constants/properties.js +11 -0
  26. package/dist/src/constants/property-types.d.ts +18 -0
  27. package/dist/src/constants/property-types.d.ts.map +1 -0
  28. package/dist/src/constants/property-types.js +0 -0
  29. package/dist/src/constants/specialized-properties.d.ts +161 -0
  30. package/dist/src/constants/specialized-properties.d.ts.map +1 -0
  31. package/dist/src/constants/specialized-properties.js +130 -0
  32. package/dist/src/constants/utilities.d.ts +26 -0
  33. package/dist/src/constants/utilities.d.ts.map +1 -0
  34. package/dist/src/constants/utilities.js +25 -0
  35. package/dist/src/constants.d.ts +4 -1142
  36. package/dist/src/constants.d.ts.map +1 -1
  37. package/dist/src/constants.js +1 -582
  38. package/dist/src/deno-compile-loader.d.ts +2 -1
  39. package/dist/src/deno-compile-loader.d.ts.map +1 -1
  40. package/dist/src/deno-compile-loader.js +1 -1
  41. package/dist/src/deno-compile-support.d.ts +1 -1
  42. package/dist/src/deno-compile-support.d.ts.map +1 -1
  43. package/dist/src/deno-compile-support.js +2 -2
  44. package/dist/src/deno-compile.d.ts +6 -6
  45. package/dist/src/deno-compile.d.ts.map +1 -1
  46. package/dist/src/deno-compile.js +9 -6
  47. package/dist/src/file-utils.d.ts.map +1 -1
  48. package/dist/src/file-utils.js +71 -77
  49. package/dist/src/folder-api.d.ts +4 -3
  50. package/dist/src/folder-api.d.ts.map +1 -1
  51. package/dist/src/folder-api.js +163 -117
  52. package/dist/src/mod.d.ts +1 -1
  53. package/dist/src/mod.d.ts.map +1 -1
  54. package/dist/src/mod.js +2 -0
  55. package/dist/src/msgpack/decoder.d.ts +57 -0
  56. package/dist/src/msgpack/decoder.d.ts.map +1 -0
  57. package/dist/src/msgpack/decoder.js +190 -0
  58. package/dist/src/msgpack/encoder.d.ts +70 -0
  59. package/dist/src/msgpack/encoder.d.ts.map +1 -0
  60. package/dist/src/msgpack/encoder.js +219 -0
  61. package/dist/src/msgpack/index.d.ts +133 -0
  62. package/dist/src/msgpack/index.d.ts.map +1 -0
  63. package/dist/src/msgpack/index.js +249 -0
  64. package/dist/src/msgpack/types.d.ts +247 -0
  65. package/dist/src/msgpack/types.d.ts.map +1 -0
  66. package/dist/src/msgpack/types.js +19 -0
  67. package/dist/src/runtime/detector.d.ts +64 -0
  68. package/dist/src/runtime/detector.d.ts.map +1 -0
  69. package/dist/src/runtime/detector.js +137 -0
  70. package/dist/src/runtime/loader-types.d.ts +27 -0
  71. package/dist/src/runtime/loader-types.d.ts.map +1 -0
  72. package/dist/src/runtime/loader-types.js +0 -0
  73. package/dist/src/runtime/unified-loader.d.ts +75 -0
  74. package/dist/src/runtime/unified-loader.d.ts.map +1 -0
  75. package/dist/src/runtime/unified-loader.js +202 -0
  76. package/dist/src/runtime/wasi-adapter.d.ts +41 -0
  77. package/dist/src/runtime/wasi-adapter.d.ts.map +1 -0
  78. package/dist/src/runtime/wasi-adapter.js +454 -0
  79. package/dist/src/runtime/wasi-loader.d.ts +102 -0
  80. package/dist/src/runtime/wasi-loader.d.ts.map +1 -0
  81. package/dist/src/runtime/wasi-loader.js +231 -0
  82. package/dist/src/runtime/wasi-memory.d.ts +105 -0
  83. package/dist/src/runtime/wasi-memory.d.ts.map +1 -0
  84. package/dist/src/runtime/wasi-memory.js +184 -0
  85. package/dist/src/runtime/wasmer-sdk-loader.d.ts +69 -0
  86. package/dist/src/runtime/wasmer-sdk-loader.d.ts.map +1 -0
  87. package/dist/src/runtime/wasmer-sdk-loader.js +312 -0
  88. package/dist/src/runtime/wasmer-types.d.js +0 -0
  89. package/dist/src/simple.d.ts +3 -3
  90. package/dist/src/simple.d.ts.map +1 -1
  91. package/dist/src/taglib.d.ts +48 -8
  92. package/dist/src/taglib.d.ts.map +1 -1
  93. package/dist/src/taglib.js +63 -18
  94. package/dist/src/types.d.ts +4 -0
  95. package/dist/src/types.d.ts.map +1 -1
  96. package/dist/src/utils/file.d.ts.map +1 -1
  97. package/dist/src/utils/file.js +39 -32
  98. package/dist/src/utils/rating.d.ts +114 -0
  99. package/dist/src/utils/rating.d.ts.map +1 -0
  100. package/dist/src/utils/rating.js +63 -0
  101. package/dist/src/utils/write.d.ts.map +1 -1
  102. package/dist/src/utils/write.js +11 -2
  103. package/dist/src/wasm-workers.d.ts +1 -0
  104. package/dist/src/wasm-workers.d.ts.map +1 -1
  105. package/dist/src/wasm-workers.js +34 -24
  106. package/dist/src/wasm.d.ts +51 -0
  107. package/dist/src/wasm.d.ts.map +1 -1
  108. package/dist/src/web-utils.d.ts.map +1 -1
  109. package/dist/src/web-utils.js +18 -7
  110. package/dist/src/worker-pool.d.ts +22 -3
  111. package/dist/src/worker-pool.d.ts.map +1 -1
  112. package/dist/src/worker-pool.js +59 -12
  113. package/dist/src/workers.d.ts +4 -4
  114. package/dist/src/workers.d.ts.map +1 -1
  115. package/dist/src/workers.js +79 -50
  116. package/dist/taglib-web.wasm +0 -0
  117. package/dist/taglib-wrapper.js +2 -14
  118. package/package.json +15 -7
  119. package/dist/taglib.wasm +0 -0
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # TagLib-Wasm
2
2
 
3
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)
4
+ [![npm version](https://img.shields.io/npm/v/taglib-wasm.svg)](https://www.npmjs.com/package/taglib-wasm)
5
5
  [![npm downloads](https://img.shields.io/npm/dm/taglib-wasm.svg)](https://www.npmjs.com/package/taglib-wasm)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/CharlesWiltgen/taglib-wasm/blob/main/LICENSE)
7
7
  <br>[![Built with](https://img.shields.io/badge/TypeScript-5-3178c6.svg?logo=typescript&logoColor=f5f5f5)](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
- ## 🎯 Features
32
+ ## Features
33
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
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
- - **✅ 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”
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
- - **✅ Batch folder operations** – Scan directories, process multiple files,
47
- find duplicates, and export metadata catalogs
48
+ - **Batch folder operations** – Scan directories, process multiple files, find
49
+ duplicates, and export metadata catalogs
48
50
 
49
- ## 📦 Installation
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
- ## 🚀 Quick Start
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
- ## 📚 Documentation
295
+ ## Documentation
251
296
 
252
- **[📖 View Full Documentation](https://charleswiltgen.github.io/taglib-wasm/)**
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
- ## 📋 Supported Formats
322
+ ## Supported Formats
275
323
 
276
324
  `taglib-wasm` is designed to support all formats supported by TagLib:
277
325
 
278
- - **.mp3** – ID3v2 and ID3v1 tags
279
- - **.m4a/.mp4** – MPEG-4/AAC metadata for AAC and Apple Lossless audio
280
- - **.flac** – Vorbis comments and audio properties
281
- - **.ogg** – Ogg Vorbis format with full metadata support
282
- - **.wav** – INFO chunk metadata
283
- - **Additional formats** – Opus, APE, MPC, WavPack, TrueAudio, AIFF, WMA, and
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
- ## 🎯 Key Features
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
- ## Performance & Best Practices
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
- ## 🏗️ Development
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
- ## 🌐 Runtime Compatibility
458
+ ## Runtime Compatibility
411
459
 
412
460
  `taglib-wasm` works across all major JavaScript runtimes:
413
461
 
414
- | Runtime | Status | Installation | Notes |
415
- | ---------------------- | ------- | ------------------------- | ------------------------- |
416
- | **Deno** | Full | `npm:taglib-wasm` | Native TypeScript |
417
- | **Node.js** | Full | `npm install taglib-wasm` | TypeScript via tsx |
418
- | **Bun** | Full | `bun add taglib-wasm` | Native TypeScript |
419
- | **Browser** | Full | Via bundler | Full API support |
420
- | **Cloudflare Workers** | Full | `taglib-wasm/workers` | Memory-optimized build |
421
- | **Electron** | Full | `npm install taglib-wasm` | Main & renderer processes |
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
- ## 🚧 Known Limitations
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
- ## 🤝 Contributing
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
- ## 📄 License
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
- ## 🙏 Acknowledgments
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 getGlobalWorkerPool} - Get/create global worker pool instance
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 interface LoadTagLibOptions {
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
- * @param config - Optional configuration for module initialization
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
- * // Manual module loading for advanced configuration
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 });
@@ -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;AAEzB;;;;;;;;;;GAUG;AACH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,aAAa,EACb,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,UAAU,EACV,aAAa,EACb,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,WA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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"}