taglib-wasm 1.4.3 → 1.5.1
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 -1
- package/dist/index.browser.js +228 -80
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/simple.browser.js +171 -18
- package/dist/src/constants/complex-properties.d.ts +19 -0
- package/dist/src/constants/complex-properties.d.ts.map +1 -1
- package/dist/src/msgpack/encoder.d.ts.map +1 -1
- package/dist/src/msgpack/encoder.js +1 -0
- package/dist/src/runtime/detector.d.ts +2 -0
- package/dist/src/runtime/detector.d.ts.map +1 -1
- package/dist/src/runtime/detector.js +1 -0
- package/dist/src/runtime/loader-types.d.ts +5 -2
- package/dist/src/runtime/loader-types.d.ts.map +1 -1
- package/dist/src/runtime/module-loader.d.ts +3 -2
- package/dist/src/runtime/module-loader.d.ts.map +1 -1
- package/dist/src/runtime/module-loader.js +12 -0
- package/dist/src/runtime/unified-loader/loader.d.ts.map +1 -1
- package/dist/src/runtime/unified-loader/loader.js +7 -0
- package/dist/src/runtime/unified-loader/module-loading.d.ts +2 -0
- package/dist/src/runtime/unified-loader/module-loading.d.ts.map +1 -1
- package/dist/src/runtime/unified-loader/module-loading.js +19 -8
- package/dist/src/runtime/unified-loader/module-selection.d.ts.map +1 -1
- package/dist/src/runtime/unified-loader/module-selection.js +3 -0
- package/dist/src/runtime/unified-loader/types.d.ts +4 -1
- package/dist/src/runtime/unified-loader/types.d.ts.map +1 -1
- package/dist/src/runtime/wasi-adapter/file-handle.d.ts +5 -1
- package/dist/src/runtime/wasi-adapter/file-handle.d.ts.map +1 -1
- package/dist/src/runtime/wasi-adapter/file-handle.js +34 -0
- package/dist/src/runtime/wasi-adapter/wasm-io.d.ts +2 -0
- package/dist/src/runtime/wasi-adapter/wasm-io.d.ts.map +1 -1
- package/dist/src/runtime/wasi-adapter/wasm-io.js +56 -1
- package/dist/src/runtime/wasi-host-loader.d.ts.map +1 -1
- package/dist/src/runtime/wasi-host-loader.js +3 -1
- package/dist/src/runtime/wasmer-sdk-loader/types.d.ts +1 -0
- package/dist/src/runtime/wasmer-sdk-loader/types.d.ts.map +1 -1
- package/dist/src/taglib/audio-file-impl.d.ts +8 -2
- package/dist/src/taglib/audio-file-impl.d.ts.map +1 -1
- package/dist/src/taglib/audio-file-impl.js +55 -17
- package/dist/src/taglib/audio-file-interface.d.ts +24 -4
- package/dist/src/taglib/audio-file-interface.d.ts.map +1 -1
- package/dist/src/taglib/embind-adapter.d.ts.map +1 -1
- package/dist/src/taglib/embind-adapter.js +12 -0
- package/dist/src/taglib/extra-state-registry.d.ts.map +1 -1
- package/dist/src/taglib/extra-state-registry.js +10 -0
- package/dist/src/taglib/id3v2-frames.d.ts +12 -0
- package/dist/src/taglib/id3v2-frames.d.ts.map +1 -0
- package/dist/src/taglib/id3v2-frames.js +42 -0
- package/dist/src/taglib/taglib-class.d.ts.map +1 -1
- package/dist/src/taglib/taglib-class.js +2 -1
- package/dist/src/types/metadata-mappings.d.ts +1 -1
- package/dist/src/types/metadata-mappings.d.ts.map +1 -1
- package/dist/src/types/tags.d.ts +2 -0
- package/dist/src/types/tags.d.ts.map +1 -1
- package/dist/src/utils/node-fs.d.ts +27 -0
- package/dist/src/utils/node-fs.d.ts.map +1 -0
- package/dist/src/utils/node-fs.js +21 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/wasm.d.ts +20 -0
- package/dist/src/wasm.d.ts.map +1 -1
- package/dist/taglib-wasi.wasm +0 -0
- package/dist/taglib-web.wasm +0 -0
- package/dist/taglib-wrapper.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,6 +114,10 @@ const wasmBinary = await Deno.readFile(
|
|
|
114
114
|
const taglib = await TagLib.initialize({ wasmBinary });
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
+
Supplying `wasmBinary` selects the Emscripten backend (the bytes above are
|
|
118
|
+
`taglib-web.wasm`, its artifact). The WASI backend loads from a filesystem
|
|
119
|
+
path or URL instead — use `wasmUrl` with it.
|
|
120
|
+
|
|
117
121
|
## Quick Start
|
|
118
122
|
|
|
119
123
|
> **Import paths:** Deno uses `@charlesw/taglib-wasm`, npm uses `taglib-wasm`.
|
|
@@ -206,8 +210,9 @@ console.log(
|
|
|
206
210
|
} files`,
|
|
207
211
|
);
|
|
208
212
|
|
|
209
|
-
// Process results
|
|
213
|
+
// Process results (narrow the ok/error union first)
|
|
210
214
|
for (const file of result.items) {
|
|
215
|
+
if (file.status !== "ok") continue;
|
|
211
216
|
console.log(
|
|
212
217
|
`${file.path}: ${file.tags.artist?.[0]} - ${file.tags.title?.[0]}`,
|
|
213
218
|
);
|
|
@@ -319,6 +324,37 @@ removes the chunk. iXML is passed through verbatim as a string
|
|
|
319
324
|
measurements, distinct from ReplayGain tags. `bwf.decodeBext` / `bwf.encodeBext`
|
|
320
325
|
are also exported for working with raw `bext` bytes directly.
|
|
321
326
|
|
|
327
|
+
### Raw ID3v2 Frames (Escape Hatch)
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
import { TagLib } from "taglib-wasm";
|
|
331
|
+
|
|
332
|
+
const taglib = await TagLib.initialize();
|
|
333
|
+
using file = await taglib.open("song.mp3");
|
|
334
|
+
|
|
335
|
+
// Escape hatch: read/write raw ID3v2 frame bytes by ID (MP3 only)
|
|
336
|
+
const frames = file.getId3v2Frames("TXXX"); // [{ id, data, flags? }]
|
|
337
|
+
const rgadBody = new Uint8Array([/* raw frame body bytes */]);
|
|
338
|
+
file.setId3v2Frames("RGAD", [rgadBody]); // replaces ALL RGAD frames
|
|
339
|
+
file.removeId3v2Frames("NCON"); // removes every NCON frame
|
|
340
|
+
file.save();
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
`data` is the frame body without the 10-byte header; the caller owns the body
|
|
344
|
+
encoding. Bytes round-trip verbatim for frames TagLib does not model. For
|
|
345
|
+
TagLib-modeled IDs (`TIT2`, `APIC`, …): typed getters see a raw write only
|
|
346
|
+
after save+reload; bytes may be normalized by later saves after that reload;
|
|
347
|
+
and raw reads reflect persisted state plus pending raw writes — not pending
|
|
348
|
+
typed edits (backend-dependent). A typed write to the same ID as an existing
|
|
349
|
+
raw write is silently ignored until that raw frame is removed or the file is
|
|
350
|
+
saved and reloaded — raw writes always win within a save. Frames with
|
|
351
|
+
compression/encryption flags are not supported for write (writes emit zero
|
|
352
|
+
flags). `flags` exists on the returned frames for forward compatibility, but
|
|
353
|
+
reads never populate it today — TagLib always blanks header flags when
|
|
354
|
+
re-rendering a frame. On both backends, a raw write to an ID3v1-mapped frame ID
|
|
355
|
+
(`TIT2`, `TPE1`, `TALB`, `COMM`, `TCON`, `TDRC`, `TRCK`) suspends the usual
|
|
356
|
+
ID3v1↔ID3v2 duplicate-sync on `save()` until that raw frame is removed.
|
|
357
|
+
|
|
322
358
|
### Container Format and Codec Detection
|
|
323
359
|
|
|
324
360
|
```typescript
|
package/dist/index.browser.js
CHANGED
|
@@ -314,6 +314,9 @@ var init_base = __esm({
|
|
|
314
314
|
});
|
|
315
315
|
|
|
316
316
|
// src/errors/classes.ts
|
|
317
|
+
function errorMessage(error) {
|
|
318
|
+
return error instanceof Error ? error.message : String(error);
|
|
319
|
+
}
|
|
317
320
|
function createErrorMessage(prefix, details) {
|
|
318
321
|
return `${prefix}: ${details}`;
|
|
319
322
|
}
|
|
@@ -564,6 +567,50 @@ var init_audio_file_bwf = __esm({
|
|
|
564
567
|
}
|
|
565
568
|
});
|
|
566
569
|
|
|
570
|
+
// src/taglib/id3v2-frames.ts
|
|
571
|
+
function assertMp3(format) {
|
|
572
|
+
if (format !== "MP3") {
|
|
573
|
+
throw new UnsupportedFormatError(format, ["MP3"], {
|
|
574
|
+
operation: "id3v2Frames"
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
function assertFrameId(id, operation) {
|
|
579
|
+
if (!FRAME_ID_PATTERN.test(id)) {
|
|
580
|
+
throw new MetadataError(
|
|
581
|
+
operation,
|
|
582
|
+
`Invalid ID3v2 frame ID: "${id}". Frame IDs must match [A-Z0-9]{4}`,
|
|
583
|
+
id
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
function assertFrameBodies(id, data) {
|
|
588
|
+
for (const body of data) {
|
|
589
|
+
if (body.length === 0) {
|
|
590
|
+
throw new MetadataError(
|
|
591
|
+
"write",
|
|
592
|
+
"Frame data must not be empty: zero-size ID3v2 frames are invalid",
|
|
593
|
+
id
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
function toPublicFrame(frame) {
|
|
599
|
+
return {
|
|
600
|
+
id: frame.id,
|
|
601
|
+
data: frame.data,
|
|
602
|
+
...frame.flags ? { flags: frame.flags } : {}
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
var FRAME_ID_PATTERN;
|
|
606
|
+
var init_id3v2_frames = __esm({
|
|
607
|
+
"src/taglib/id3v2-frames.ts"() {
|
|
608
|
+
"use strict";
|
|
609
|
+
init_classes();
|
|
610
|
+
FRAME_ID_PATTERN = /^[A-Z0-9]{4}$/;
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
|
|
567
614
|
// browser-stub:platform-io-browser-stub
|
|
568
615
|
function getPlatformIO() {
|
|
569
616
|
throw new Error("Filesystem operations are not available in the browser.");
|
|
@@ -594,6 +641,116 @@ var init_write = __esm({
|
|
|
594
641
|
}
|
|
595
642
|
});
|
|
596
643
|
|
|
644
|
+
// browser-stub:node-fs-browser-stub
|
|
645
|
+
function getNodeFsSync() {
|
|
646
|
+
return null;
|
|
647
|
+
}
|
|
648
|
+
var init_node_fs_browser_stub = __esm({
|
|
649
|
+
"browser-stub:node-fs-browser-stub"() {
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
// src/utils/rating.ts
|
|
654
|
+
function normalized(value) {
|
|
655
|
+
return value;
|
|
656
|
+
}
|
|
657
|
+
function popm(value) {
|
|
658
|
+
return value;
|
|
659
|
+
}
|
|
660
|
+
function toNormalized(value) {
|
|
661
|
+
return value / 255;
|
|
662
|
+
}
|
|
663
|
+
function fromNormalized(value) {
|
|
664
|
+
return Math.round(value * 255);
|
|
665
|
+
}
|
|
666
|
+
function toStars(value, maxStars = 5) {
|
|
667
|
+
return Math.round(value * maxStars);
|
|
668
|
+
}
|
|
669
|
+
function fromStars(stars, maxStars = 5) {
|
|
670
|
+
return stars / maxStars;
|
|
671
|
+
}
|
|
672
|
+
function toPopm(value) {
|
|
673
|
+
const stars = Math.round(value * 5);
|
|
674
|
+
return POPM_STAR_VALUES[stars] ?? 0;
|
|
675
|
+
}
|
|
676
|
+
function fromPopm(value) {
|
|
677
|
+
if (value === 0) return 0;
|
|
678
|
+
if (value <= 1) return 0.2;
|
|
679
|
+
if (value <= 64) return 0.4;
|
|
680
|
+
if (value <= 128) return 0.6;
|
|
681
|
+
if (value <= 196) return 0.8;
|
|
682
|
+
return 1;
|
|
683
|
+
}
|
|
684
|
+
function toPercent(value) {
|
|
685
|
+
return value * 100;
|
|
686
|
+
}
|
|
687
|
+
function fromPercent(percent) {
|
|
688
|
+
return percent / 100;
|
|
689
|
+
}
|
|
690
|
+
function clamp(rating) {
|
|
691
|
+
return Math.max(0, Math.min(1, rating));
|
|
692
|
+
}
|
|
693
|
+
function isValid(rating) {
|
|
694
|
+
return typeof rating === "number" && !Number.isNaN(rating) && rating >= 0 && rating <= 1;
|
|
695
|
+
}
|
|
696
|
+
var POPM_STAR_VALUES, RatingUtils;
|
|
697
|
+
var init_rating = __esm({
|
|
698
|
+
"src/utils/rating.ts"() {
|
|
699
|
+
"use strict";
|
|
700
|
+
POPM_STAR_VALUES = [0, 1, 64, 128, 196, 255];
|
|
701
|
+
RatingUtils = {
|
|
702
|
+
normalized,
|
|
703
|
+
popm,
|
|
704
|
+
toNormalized,
|
|
705
|
+
fromNormalized,
|
|
706
|
+
toStars,
|
|
707
|
+
fromStars,
|
|
708
|
+
toPopm,
|
|
709
|
+
fromPopm,
|
|
710
|
+
toPercent,
|
|
711
|
+
fromPercent,
|
|
712
|
+
clamp,
|
|
713
|
+
isValid,
|
|
714
|
+
POPM_STAR_VALUES
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
// src/runtime/detector.ts
|
|
720
|
+
function isDeno() {
|
|
721
|
+
return g.Deno !== void 0;
|
|
722
|
+
}
|
|
723
|
+
var g, EXNREF_PROBE;
|
|
724
|
+
var init_detector = __esm({
|
|
725
|
+
"src/runtime/detector.ts"() {
|
|
726
|
+
"use strict";
|
|
727
|
+
g = globalThis;
|
|
728
|
+
EXNREF_PROBE = new Uint8Array([
|
|
729
|
+
0,
|
|
730
|
+
97,
|
|
731
|
+
115,
|
|
732
|
+
109,
|
|
733
|
+
1,
|
|
734
|
+
0,
|
|
735
|
+
0,
|
|
736
|
+
0,
|
|
737
|
+
// Wasm header
|
|
738
|
+
6,
|
|
739
|
+
6,
|
|
740
|
+
// Global section, 6 bytes
|
|
741
|
+
1,
|
|
742
|
+
// 1 global
|
|
743
|
+
105,
|
|
744
|
+
0,
|
|
745
|
+
// exnref, const
|
|
746
|
+
208,
|
|
747
|
+
105,
|
|
748
|
+
11
|
|
749
|
+
// ref.null exnref, end
|
|
750
|
+
]);
|
|
751
|
+
}
|
|
752
|
+
});
|
|
753
|
+
|
|
597
754
|
// src/constants/additional-properties.ts
|
|
598
755
|
var ADDITIONAL_PROPERTIES;
|
|
599
756
|
var init_additional_properties = __esm({
|
|
@@ -1590,6 +1747,7 @@ function isValidBitrateMode(value) {
|
|
|
1590
1747
|
return value === "CBR" || value === "VBR" || value === "ABR";
|
|
1591
1748
|
}
|
|
1592
1749
|
function wrapEmbindHandle(raw) {
|
|
1750
|
+
const stagedId3v2Frames = {};
|
|
1593
1751
|
const overrides = {
|
|
1594
1752
|
getTagData() {
|
|
1595
1753
|
const tw = raw.getTag();
|
|
@@ -1649,6 +1807,17 @@ function wrapEmbindHandle(raw) {
|
|
|
1649
1807
|
else delete props["LYRICS"];
|
|
1650
1808
|
handle.setProperties(props);
|
|
1651
1809
|
},
|
|
1810
|
+
setId3v2Frames(id, data) {
|
|
1811
|
+
stagedId3v2Frames[id] = data.map((d) => new Uint8Array(d));
|
|
1812
|
+
raw.setId3v2Frames(id, data);
|
|
1813
|
+
},
|
|
1814
|
+
removeId3v2Frames(id) {
|
|
1815
|
+
stagedId3v2Frames[id] = [];
|
|
1816
|
+
raw.removeId3v2Frames(id);
|
|
1817
|
+
},
|
|
1818
|
+
getStagedId3v2Frames() {
|
|
1819
|
+
return Object.keys(stagedId3v2Frames).length > 0 ? { ...stagedId3v2Frames } : void 0;
|
|
1820
|
+
},
|
|
1652
1821
|
hasId3Tags() {
|
|
1653
1822
|
const v = raw.hasId3Tags();
|
|
1654
1823
|
if (!v || typeof v !== "object") return { v1: false, v2: false };
|
|
@@ -1756,6 +1925,16 @@ var init_extra_state_registry = __esm({
|
|
|
1756
1925
|
if (v !== void 0) target.setIxml(v);
|
|
1757
1926
|
else if (complete) target.setIxml(null);
|
|
1758
1927
|
}
|
|
1928
|
+
},
|
|
1929
|
+
{
|
|
1930
|
+
name: "id3v2Frames",
|
|
1931
|
+
copy(target, source) {
|
|
1932
|
+
const staged = source.getStagedId3v2Frames?.();
|
|
1933
|
+
if (!staged) return;
|
|
1934
|
+
for (const [id, bodies] of Object.entries(staged)) {
|
|
1935
|
+
target.setId3v2Frames(id, bodies);
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1759
1938
|
}
|
|
1760
1939
|
];
|
|
1761
1940
|
}
|
|
@@ -1815,25 +1994,27 @@ function inferEndTimeMs(sorted, index, trackEndMs) {
|
|
|
1815
1994
|
return next ? next.startTimeMs : trackEndMs;
|
|
1816
1995
|
}
|
|
1817
1996
|
function readFileSync(path) {
|
|
1818
|
-
if (
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
if (_nodeFs) return new Uint8Array(_nodeFs.readFileSync(path));
|
|
1827
|
-
return new Uint8Array(0);
|
|
1997
|
+
if (isDeno()) return Deno.readFileSync(path);
|
|
1998
|
+
const fs = getNodeFsSync();
|
|
1999
|
+
if (fs) return new Uint8Array(fs.readFileSync(path));
|
|
2000
|
+
throw new FileOperationError(
|
|
2001
|
+
"read",
|
|
2002
|
+
"node:fs is unavailable in this runtime: cannot read file data from disk",
|
|
2003
|
+
path
|
|
2004
|
+
);
|
|
1828
2005
|
}
|
|
1829
|
-
var
|
|
2006
|
+
var AudioFileImpl;
|
|
1830
2007
|
var init_audio_file_impl = __esm({
|
|
1831
2008
|
"src/taglib/audio-file-impl.ts"() {
|
|
1832
2009
|
"use strict";
|
|
1833
2010
|
init_types2();
|
|
1834
2011
|
init_audio_file_bwf();
|
|
2012
|
+
init_id3v2_frames();
|
|
1835
2013
|
init_errors2();
|
|
1836
2014
|
init_write();
|
|
2015
|
+
init_node_fs_browser_stub();
|
|
2016
|
+
init_rating();
|
|
2017
|
+
init_detector();
|
|
1837
2018
|
init_audio_file_base();
|
|
1838
2019
|
init_save_reconstruct();
|
|
1839
2020
|
AudioFileImpl = class extends BaseAudioFileImpl {
|
|
@@ -1856,6 +2037,7 @@ var init_audio_file_impl = __esm({
|
|
|
1856
2037
|
);
|
|
1857
2038
|
}
|
|
1858
2039
|
this.cachedAudioProperties = null;
|
|
2040
|
+
this.pathModeBuffer = null;
|
|
1859
2041
|
return this.handle.save();
|
|
1860
2042
|
}
|
|
1861
2043
|
getFileBuffer() {
|
|
@@ -1866,11 +2048,20 @@ var init_audio_file_impl = __esm({
|
|
|
1866
2048
|
try {
|
|
1867
2049
|
this.pathModeBuffer = readFileSync(this.sourcePath);
|
|
1868
2050
|
return this.pathModeBuffer;
|
|
1869
|
-
} catch {
|
|
1870
|
-
|
|
2051
|
+
} catch (error) {
|
|
2052
|
+
if (error instanceof FileOperationError) throw error;
|
|
2053
|
+
throw new FileOperationError(
|
|
2054
|
+
"read",
|
|
2055
|
+
`Cannot return file data: ${errorMessage(error)}`,
|
|
2056
|
+
this.sourcePath,
|
|
2057
|
+
{ cause: error }
|
|
2058
|
+
);
|
|
1871
2059
|
}
|
|
1872
2060
|
}
|
|
1873
|
-
|
|
2061
|
+
throw new FileOperationError(
|
|
2062
|
+
"read",
|
|
2063
|
+
"No file data available: in-memory buffer is empty and no source path is set"
|
|
2064
|
+
);
|
|
1874
2065
|
}
|
|
1875
2066
|
async saveToFile(path) {
|
|
1876
2067
|
const targetPath = path ?? this.sourcePath;
|
|
@@ -1911,6 +2102,7 @@ var init_audio_file_impl = __esm({
|
|
|
1911
2102
|
await writeFileData(targetPath, buffer);
|
|
1912
2103
|
}
|
|
1913
2104
|
}
|
|
2105
|
+
this.pathModeBuffer = null;
|
|
1914
2106
|
}
|
|
1915
2107
|
getPictures() {
|
|
1916
2108
|
const picturesArray = this.handle.getPictures();
|
|
@@ -2022,11 +2214,27 @@ var init_audio_file_impl = __esm({
|
|
|
2022
2214
|
}
|
|
2023
2215
|
getRating() {
|
|
2024
2216
|
const ratings = this.getRatings();
|
|
2025
|
-
return ratings.length > 0 ? ratings[0].rating : void 0;
|
|
2217
|
+
return ratings.length > 0 ? normalized(ratings[0].rating) : void 0;
|
|
2026
2218
|
}
|
|
2027
2219
|
setRating(rating, email) {
|
|
2028
2220
|
this.setRatings([{ rating, email, counter: 0 }]);
|
|
2029
2221
|
}
|
|
2222
|
+
getId3v2Frames(id) {
|
|
2223
|
+
assertMp3(this.getFormat());
|
|
2224
|
+
if (id !== void 0) assertFrameId(id, "read");
|
|
2225
|
+
return this.handle.getId3v2Frames(id ?? "").map(toPublicFrame);
|
|
2226
|
+
}
|
|
2227
|
+
setId3v2Frames(id, data) {
|
|
2228
|
+
assertMp3(this.getFormat());
|
|
2229
|
+
assertFrameId(id, "write");
|
|
2230
|
+
assertFrameBodies(id, data);
|
|
2231
|
+
this.handle.setId3v2Frames(id, data);
|
|
2232
|
+
}
|
|
2233
|
+
removeId3v2Frames(id) {
|
|
2234
|
+
assertMp3(this.getFormat());
|
|
2235
|
+
assertFrameId(id, "write");
|
|
2236
|
+
this.handle.removeId3v2Frames(id);
|
|
2237
|
+
}
|
|
2030
2238
|
hasId3Tags() {
|
|
2031
2239
|
return this.handle.hasId3Tags();
|
|
2032
2240
|
}
|
|
@@ -2211,7 +2419,7 @@ var VERSION;
|
|
|
2211
2419
|
var init_version = __esm({
|
|
2212
2420
|
"src/version.ts"() {
|
|
2213
2421
|
"use strict";
|
|
2214
|
-
VERSION = "1.
|
|
2422
|
+
VERSION = "1.5.1";
|
|
2215
2423
|
}
|
|
2216
2424
|
});
|
|
2217
2425
|
|
|
@@ -2270,8 +2478,8 @@ function toWasiPath(osPath) {
|
|
|
2270
2478
|
}
|
|
2271
2479
|
let p = osPath;
|
|
2272
2480
|
if (!p.startsWith("/") && !/^[A-Za-z]:/.test(p)) {
|
|
2273
|
-
const
|
|
2274
|
-
const cwd =
|
|
2481
|
+
const g2 = globalThis;
|
|
2482
|
+
const cwd = isDeno() ? Deno.cwd() : g2.process?.cwd?.();
|
|
2275
2483
|
if (cwd) {
|
|
2276
2484
|
p = cwd.replace(/[/\\]+$/, "") + "/" + p;
|
|
2277
2485
|
}
|
|
@@ -2294,6 +2502,7 @@ var init_taglib_class = __esm({
|
|
|
2294
2502
|
"use strict";
|
|
2295
2503
|
init_audio_formats();
|
|
2296
2504
|
init_errors2();
|
|
2505
|
+
init_detector();
|
|
2297
2506
|
init_audio_file_impl();
|
|
2298
2507
|
init_load_audio_data();
|
|
2299
2508
|
init_tag_mapping();
|
|
@@ -3156,68 +3365,7 @@ async function createPictureGallery(file, container, options = {}) {
|
|
|
3156
3365
|
|
|
3157
3366
|
// index.browser.ts
|
|
3158
3367
|
init_types2();
|
|
3159
|
-
|
|
3160
|
-
// src/utils/rating.ts
|
|
3161
|
-
function normalized(value) {
|
|
3162
|
-
return value;
|
|
3163
|
-
}
|
|
3164
|
-
function popm(value) {
|
|
3165
|
-
return value;
|
|
3166
|
-
}
|
|
3167
|
-
function toNormalized(value) {
|
|
3168
|
-
return value / 255;
|
|
3169
|
-
}
|
|
3170
|
-
function fromNormalized(value) {
|
|
3171
|
-
return Math.round(value * 255);
|
|
3172
|
-
}
|
|
3173
|
-
function toStars(value, maxStars = 5) {
|
|
3174
|
-
return Math.round(value * maxStars);
|
|
3175
|
-
}
|
|
3176
|
-
function fromStars(stars, maxStars = 5) {
|
|
3177
|
-
return stars / maxStars;
|
|
3178
|
-
}
|
|
3179
|
-
var POPM_STAR_VALUES = [0, 1, 64, 128, 196, 255];
|
|
3180
|
-
function toPopm(value) {
|
|
3181
|
-
const stars = Math.round(value * 5);
|
|
3182
|
-
return POPM_STAR_VALUES[stars] ?? 0;
|
|
3183
|
-
}
|
|
3184
|
-
function fromPopm(value) {
|
|
3185
|
-
if (value === 0) return 0;
|
|
3186
|
-
if (value <= 1) return 0.2;
|
|
3187
|
-
if (value <= 64) return 0.4;
|
|
3188
|
-
if (value <= 128) return 0.6;
|
|
3189
|
-
if (value <= 196) return 0.8;
|
|
3190
|
-
return 1;
|
|
3191
|
-
}
|
|
3192
|
-
function toPercent(value) {
|
|
3193
|
-
return value * 100;
|
|
3194
|
-
}
|
|
3195
|
-
function fromPercent(percent) {
|
|
3196
|
-
return percent / 100;
|
|
3197
|
-
}
|
|
3198
|
-
function clamp(rating) {
|
|
3199
|
-
return Math.max(0, Math.min(1, rating));
|
|
3200
|
-
}
|
|
3201
|
-
function isValid(rating) {
|
|
3202
|
-
return typeof rating === "number" && !Number.isNaN(rating) && rating >= 0 && rating <= 1;
|
|
3203
|
-
}
|
|
3204
|
-
var RatingUtils = {
|
|
3205
|
-
normalized,
|
|
3206
|
-
popm,
|
|
3207
|
-
toNormalized,
|
|
3208
|
-
fromNormalized,
|
|
3209
|
-
toStars,
|
|
3210
|
-
fromStars,
|
|
3211
|
-
toPopm,
|
|
3212
|
-
fromPopm,
|
|
3213
|
-
toPercent,
|
|
3214
|
-
fromPercent,
|
|
3215
|
-
clamp,
|
|
3216
|
-
isValid,
|
|
3217
|
-
POPM_STAR_VALUES
|
|
3218
|
-
};
|
|
3219
|
-
|
|
3220
|
-
// index.browser.ts
|
|
3368
|
+
init_rating();
|
|
3221
3369
|
init_module_loader_browser();
|
|
3222
3370
|
export {
|
|
3223
3371
|
AudioFileImpl,
|
package/dist/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export type { PropertyKey, PropertyValue } from "./src/constants.js";
|
|
|
51
51
|
export type { FormatPropertyKey, TagFormat, } from "./src/types/format-property-keys.js";
|
|
52
52
|
export type { TypedAudioProperties } from "./src/types/audio-formats.js";
|
|
53
53
|
export { COMPLEX_PROPERTIES, COMPLEX_PROPERTY_KEY, } from "./src/constants/complex-properties.js";
|
|
54
|
-
export type { ComplexPropertyKey, ComplexPropertyKeyMap, ComplexPropertyValueMap, Rating, UnsyncedLyrics, VariantMap, } from "./src/constants/complex-properties.js";
|
|
54
|
+
export type { ComplexPropertyKey, ComplexPropertyKeyMap, ComplexPropertyValueMap, Id3v2Frame, Rating, UnsyncedLyrics, VariantMap, } from "./src/constants/complex-properties.js";
|
|
55
55
|
export { RatingUtils } from "./src/utils/rating.js";
|
|
56
56
|
export type { NormalizedRating, PopmRating } from "./src/utils/rating.js";
|
|
57
57
|
export * as bwf from "./src/bwf/bext.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,YAAY,EACV,SAAS,EACT,cAAc,GACf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACtE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,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