taglib-wasm 0.3.2 → 0.3.3
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 +37 -20
- package/build/taglib.js +2401 -8
- package/index.ts +95 -5
- package/package.json +1 -1
- package/src/constants.ts +106 -106
- package/src/mod.ts +6 -6
- package/src/simple.ts +105 -70
- package/src/taglib.ts +246 -70
- package/src/types.ts +161 -17
- package/src/wasm-workers.ts +8 -8
- package/src/wasm.ts +21 -12
- package/src/workers.ts +111 -31
package/README.md
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# TagLib-Wasm
|
|
2
|
+
|
|
3
|
+
> TagLib for TypeScript platforms: Deno, Node.js, Bun, browsers, and Cloudflare
|
|
4
|
+
> Workers
|
|
2
5
|
|
|
3
6
|
This is the Wasm version of [**TagLib**](https://taglib.org/), the most robust,
|
|
4
7
|
de-facto standard for reading and editing metadata tags (Title, Album, Artist,
|
|
@@ -34,7 +37,7 @@ platform-specific dependencies whenever possible.
|
|
|
34
37
|
TagLib
|
|
35
38
|
- **✅ Format abstraction** – `taglib-wasm` deals with how tags are read
|
|
36
39
|
from/written to in different file formats
|
|
37
|
-
- **✅ Zero dependencies** – Self-contained
|
|
40
|
+
- **✅ Zero dependencies** – Self-contained Wasm bundle
|
|
38
41
|
- **✅ Memory efficient** – In-memory processing without filesystem access
|
|
39
42
|
- **✅ Production ready** – Growing test suite helps ensure safety and
|
|
40
43
|
reliability
|
|
@@ -163,18 +166,19 @@ const musicBrainzId = properties[Tags.MusicBrainzArtistId]?.[0];
|
|
|
163
166
|
file.setProperties({
|
|
164
167
|
[Tags.Title]: ["My Song"],
|
|
165
168
|
[Tags.AlbumArtist]: ["Various Artists"],
|
|
166
|
-
[Tags.Bpm]: ["128"]
|
|
169
|
+
[Tags.Bpm]: ["128"],
|
|
167
170
|
});
|
|
168
171
|
|
|
169
172
|
// All constants provide IDE autocomplete
|
|
170
|
-
Tags.Title
|
|
171
|
-
Tags.Artist
|
|
172
|
-
Tags.AlbumArtist
|
|
173
|
-
Tags.TrackGain
|
|
173
|
+
Tags.Title; // → "TITLE"
|
|
174
|
+
Tags.Artist; // → "ARTIST"
|
|
175
|
+
Tags.AlbumArtist; // → "ALBUMARTIST"
|
|
176
|
+
Tags.TrackGain; // → "REPLAYGAIN_TRACK_GAIN"
|
|
174
177
|
// ... and many more
|
|
175
178
|
```
|
|
176
179
|
|
|
177
|
-
See [Tag Name Constants](docs/Tag-Name-Constants.md) for the complete list of
|
|
180
|
+
See [Tag Name Constants](docs/Tag-Name-Constants.md) for the complete list of
|
|
181
|
+
available tags and format-specific mappings.
|
|
178
182
|
|
|
179
183
|
## Platform examples
|
|
180
184
|
|
|
@@ -404,7 +408,10 @@ and custom metadata.
|
|
|
404
408
|
import { Tags } from "taglib-wasm";
|
|
405
409
|
|
|
406
410
|
// Using PropertyMap API to set extended metadata with tag constants
|
|
407
|
-
file.setProperty(
|
|
411
|
+
file.setProperty(
|
|
412
|
+
Tags.AcoustidFingerprint,
|
|
413
|
+
"AQADtMmybfGO8NCNEESLnzHyXNOHeHnG...",
|
|
414
|
+
);
|
|
408
415
|
file.setProperty(Tags.AcoustidId, "e7359e88-f1f7-41ed-b9f6-16e58e906997");
|
|
409
416
|
|
|
410
417
|
// Or using string property names
|
|
@@ -419,8 +426,14 @@ file.save(); // Don't forget to save!
|
|
|
419
426
|
|
|
420
427
|
```typescript
|
|
421
428
|
// MusicBrainz metadata using PropertyMap with tag constants
|
|
422
|
-
file.setProperty(
|
|
423
|
-
|
|
429
|
+
file.setProperty(
|
|
430
|
+
Tags.MusicBrainzTrackId,
|
|
431
|
+
"f4d1b6b8-8c1e-4d9a-9f2a-1234567890ab",
|
|
432
|
+
);
|
|
433
|
+
file.setProperty(
|
|
434
|
+
Tags.MusicBrainzAlbumId,
|
|
435
|
+
"a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
|
436
|
+
);
|
|
424
437
|
file.setProperty(
|
|
425
438
|
Tags.MusicBrainzArtistId,
|
|
426
439
|
"12345678-90ab-cdef-1234-567890abcdef",
|
|
@@ -471,7 +484,7 @@ file.setProperty(Tags.Composer, "Composer Name");
|
|
|
471
484
|
git clone <repository>
|
|
472
485
|
cd taglib-wasm
|
|
473
486
|
|
|
474
|
-
# Build
|
|
487
|
+
# Build Wasm module
|
|
475
488
|
deno task build:wasm
|
|
476
489
|
|
|
477
490
|
# Run tests
|
|
@@ -485,7 +498,7 @@ src/
|
|
|
485
498
|
├── mod.ts # Main module exports
|
|
486
499
|
├── taglib.ts # Core TagLib and AudioFile classes
|
|
487
500
|
├── types.ts # TypeScript type definitions
|
|
488
|
-
└── wasm.ts #
|
|
501
|
+
└── wasm.ts # Wasm module interface and utilities
|
|
489
502
|
|
|
490
503
|
build/
|
|
491
504
|
├── build-wasm.sh # Complete build script with C++ wrapper
|
|
@@ -526,11 +539,11 @@ npm test
|
|
|
526
539
|
|
|
527
540
|
### Key architecture decisions
|
|
528
541
|
|
|
529
|
-
1. **Memory Management**: Uses Emscripten's `allocate()` for reliable JS↔
|
|
542
|
+
1. **Memory Management**: Uses Emscripten's `allocate()` for reliable JS↔Wasm
|
|
530
543
|
data transfer
|
|
531
544
|
2. **Buffer-Based Processing**: `TagLib::ByteVectorStream` enables in-memory
|
|
532
545
|
file processing
|
|
533
|
-
3. **C++ Wrapper**: Custom C functions bridge TagLib's C++ API to
|
|
546
|
+
3. **C++ Wrapper**: Custom C functions bridge TagLib's C++ API to Wasm exports
|
|
534
547
|
4. **Type Safety**: Complete TypeScript definitions for all audio formats and
|
|
535
548
|
metadata
|
|
536
549
|
|
|
@@ -541,7 +554,7 @@ npm test
|
|
|
541
554
|
- **ID-based Object Management**: C++ objects managed via integer IDs for memory
|
|
542
555
|
safety
|
|
543
556
|
- **Emscripten allocate()**: Ensures proper memory synchronization between JS
|
|
544
|
-
and
|
|
557
|
+
and Wasm
|
|
545
558
|
- **UTF-8 String Handling**: Proper encoding for international metadata
|
|
546
559
|
|
|
547
560
|
## 📚 API Reference
|
|
@@ -621,10 +634,14 @@ type PropertyMap = { [key: string]: string[] };
|
|
|
621
634
|
|
|
622
635
|
## 📖 Additional Documentation
|
|
623
636
|
|
|
624
|
-
- [**Tag Name Constants**](docs/Tag-Name-Constants.md) - Comprehensive reference
|
|
625
|
-
|
|
626
|
-
- [**
|
|
627
|
-
|
|
637
|
+
- [**Tag Name Constants**](docs/Tag-Name-Constants.md) - Comprehensive reference
|
|
638
|
+
for standard tag names and cross-format mapping
|
|
639
|
+
- [**Automatic Tag Mapping**](docs/Automatic-Tag-Mapping.md) - How taglib-wasm
|
|
640
|
+
handles format-specific tag differences
|
|
641
|
+
- [**Implementation Details**](docs/Implementation.md) - Technical details about
|
|
642
|
+
the Wasm implementation
|
|
643
|
+
- [**Runtime Compatibility**](docs/Runtime-Compatibility.md) - Platform-specific
|
|
644
|
+
setup and considerations
|
|
628
645
|
|
|
629
646
|
## 🌐 Runtime Compatibility
|
|
630
647
|
|