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.
Files changed (65) hide show
  1. package/README.md +37 -1
  2. package/dist/index.browser.js +228 -80
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/simple.browser.js +171 -18
  6. package/dist/src/constants/complex-properties.d.ts +19 -0
  7. package/dist/src/constants/complex-properties.d.ts.map +1 -1
  8. package/dist/src/msgpack/encoder.d.ts.map +1 -1
  9. package/dist/src/msgpack/encoder.js +1 -0
  10. package/dist/src/runtime/detector.d.ts +2 -0
  11. package/dist/src/runtime/detector.d.ts.map +1 -1
  12. package/dist/src/runtime/detector.js +1 -0
  13. package/dist/src/runtime/loader-types.d.ts +5 -2
  14. package/dist/src/runtime/loader-types.d.ts.map +1 -1
  15. package/dist/src/runtime/module-loader.d.ts +3 -2
  16. package/dist/src/runtime/module-loader.d.ts.map +1 -1
  17. package/dist/src/runtime/module-loader.js +12 -0
  18. package/dist/src/runtime/unified-loader/loader.d.ts.map +1 -1
  19. package/dist/src/runtime/unified-loader/loader.js +7 -0
  20. package/dist/src/runtime/unified-loader/module-loading.d.ts +2 -0
  21. package/dist/src/runtime/unified-loader/module-loading.d.ts.map +1 -1
  22. package/dist/src/runtime/unified-loader/module-loading.js +19 -8
  23. package/dist/src/runtime/unified-loader/module-selection.d.ts.map +1 -1
  24. package/dist/src/runtime/unified-loader/module-selection.js +3 -0
  25. package/dist/src/runtime/unified-loader/types.d.ts +4 -1
  26. package/dist/src/runtime/unified-loader/types.d.ts.map +1 -1
  27. package/dist/src/runtime/wasi-adapter/file-handle.d.ts +5 -1
  28. package/dist/src/runtime/wasi-adapter/file-handle.d.ts.map +1 -1
  29. package/dist/src/runtime/wasi-adapter/file-handle.js +34 -0
  30. package/dist/src/runtime/wasi-adapter/wasm-io.d.ts +2 -0
  31. package/dist/src/runtime/wasi-adapter/wasm-io.d.ts.map +1 -1
  32. package/dist/src/runtime/wasi-adapter/wasm-io.js +56 -1
  33. package/dist/src/runtime/wasi-host-loader.d.ts.map +1 -1
  34. package/dist/src/runtime/wasi-host-loader.js +3 -1
  35. package/dist/src/runtime/wasmer-sdk-loader/types.d.ts +1 -0
  36. package/dist/src/runtime/wasmer-sdk-loader/types.d.ts.map +1 -1
  37. package/dist/src/taglib/audio-file-impl.d.ts +8 -2
  38. package/dist/src/taglib/audio-file-impl.d.ts.map +1 -1
  39. package/dist/src/taglib/audio-file-impl.js +55 -17
  40. package/dist/src/taglib/audio-file-interface.d.ts +24 -4
  41. package/dist/src/taglib/audio-file-interface.d.ts.map +1 -1
  42. package/dist/src/taglib/embind-adapter.d.ts.map +1 -1
  43. package/dist/src/taglib/embind-adapter.js +12 -0
  44. package/dist/src/taglib/extra-state-registry.d.ts.map +1 -1
  45. package/dist/src/taglib/extra-state-registry.js +10 -0
  46. package/dist/src/taglib/id3v2-frames.d.ts +12 -0
  47. package/dist/src/taglib/id3v2-frames.d.ts.map +1 -0
  48. package/dist/src/taglib/id3v2-frames.js +42 -0
  49. package/dist/src/taglib/taglib-class.d.ts.map +1 -1
  50. package/dist/src/taglib/taglib-class.js +2 -1
  51. package/dist/src/types/metadata-mappings.d.ts +1 -1
  52. package/dist/src/types/metadata-mappings.d.ts.map +1 -1
  53. package/dist/src/types/tags.d.ts +2 -0
  54. package/dist/src/types/tags.d.ts.map +1 -1
  55. package/dist/src/utils/node-fs.d.ts +27 -0
  56. package/dist/src/utils/node-fs.d.ts.map +1 -0
  57. package/dist/src/utils/node-fs.js +21 -0
  58. package/dist/src/version.d.ts +1 -1
  59. package/dist/src/version.js +1 -1
  60. package/dist/src/wasm.d.ts +20 -0
  61. package/dist/src/wasm.d.ts.map +1 -1
  62. package/dist/taglib-wasi.wasm +0 -0
  63. package/dist/taglib-web.wasm +0 -0
  64. package/dist/taglib-wrapper.js +1 -1
  65. package/package.json +1 -1
@@ -302,6 +302,9 @@ var init_base = __esm({
302
302
  });
303
303
 
304
304
  // src/errors/classes.ts
305
+ function errorMessage(error) {
306
+ return error instanceof Error ? error.message : String(error);
307
+ }
305
308
  function createErrorMessage(prefix, details) {
306
309
  return `${prefix}: ${details}`;
307
310
  }
@@ -552,6 +555,50 @@ var init_audio_file_bwf = __esm({
552
555
  }
553
556
  });
554
557
 
558
+ // src/taglib/id3v2-frames.ts
559
+ function assertMp3(format) {
560
+ if (format !== "MP3") {
561
+ throw new UnsupportedFormatError(format, ["MP3"], {
562
+ operation: "id3v2Frames"
563
+ });
564
+ }
565
+ }
566
+ function assertFrameId(id, operation) {
567
+ if (!FRAME_ID_PATTERN.test(id)) {
568
+ throw new MetadataError(
569
+ operation,
570
+ `Invalid ID3v2 frame ID: "${id}". Frame IDs must match [A-Z0-9]{4}`,
571
+ id
572
+ );
573
+ }
574
+ }
575
+ function assertFrameBodies(id, data) {
576
+ for (const body of data) {
577
+ if (body.length === 0) {
578
+ throw new MetadataError(
579
+ "write",
580
+ "Frame data must not be empty: zero-size ID3v2 frames are invalid",
581
+ id
582
+ );
583
+ }
584
+ }
585
+ }
586
+ function toPublicFrame(frame) {
587
+ return {
588
+ id: frame.id,
589
+ data: frame.data,
590
+ ...frame.flags ? { flags: frame.flags } : {}
591
+ };
592
+ }
593
+ var FRAME_ID_PATTERN;
594
+ var init_id3v2_frames = __esm({
595
+ "src/taglib/id3v2-frames.ts"() {
596
+ "use strict";
597
+ init_classes();
598
+ FRAME_ID_PATTERN = /^[A-Z0-9]{4}$/;
599
+ }
600
+ });
601
+
555
602
  // browser-stub:platform-io-browser-stub
556
603
  function getPlatformIO() {
557
604
  throw new Error("Filesystem operations are not available in the browser.");
@@ -582,6 +629,60 @@ var init_write = __esm({
582
629
  }
583
630
  });
584
631
 
632
+ // browser-stub:node-fs-browser-stub
633
+ function getNodeFsSync() {
634
+ return null;
635
+ }
636
+ var init_node_fs_browser_stub = __esm({
637
+ "browser-stub:node-fs-browser-stub"() {
638
+ }
639
+ });
640
+
641
+ // src/utils/rating.ts
642
+ function normalized(value) {
643
+ return value;
644
+ }
645
+ var init_rating = __esm({
646
+ "src/utils/rating.ts"() {
647
+ "use strict";
648
+ }
649
+ });
650
+
651
+ // src/runtime/detector.ts
652
+ function isDeno() {
653
+ return g.Deno !== void 0;
654
+ }
655
+ var g, EXNREF_PROBE;
656
+ var init_detector = __esm({
657
+ "src/runtime/detector.ts"() {
658
+ "use strict";
659
+ g = globalThis;
660
+ EXNREF_PROBE = new Uint8Array([
661
+ 0,
662
+ 97,
663
+ 115,
664
+ 109,
665
+ 1,
666
+ 0,
667
+ 0,
668
+ 0,
669
+ // Wasm header
670
+ 6,
671
+ 6,
672
+ // Global section, 6 bytes
673
+ 1,
674
+ // 1 global
675
+ 105,
676
+ 0,
677
+ // exnref, const
678
+ 208,
679
+ 105,
680
+ 11
681
+ // ref.null exnref, end
682
+ ]);
683
+ }
684
+ });
685
+
585
686
  // src/constants/additional-properties.ts
586
687
  var ADDITIONAL_PROPERTIES;
587
688
  var init_additional_properties = __esm({
@@ -1578,6 +1679,7 @@ function isValidBitrateMode(value) {
1578
1679
  return value === "CBR" || value === "VBR" || value === "ABR";
1579
1680
  }
1580
1681
  function wrapEmbindHandle(raw) {
1682
+ const stagedId3v2Frames = {};
1581
1683
  const overrides = {
1582
1684
  getTagData() {
1583
1685
  const tw = raw.getTag();
@@ -1637,6 +1739,17 @@ function wrapEmbindHandle(raw) {
1637
1739
  else delete props["LYRICS"];
1638
1740
  handle.setProperties(props);
1639
1741
  },
1742
+ setId3v2Frames(id, data) {
1743
+ stagedId3v2Frames[id] = data.map((d) => new Uint8Array(d));
1744
+ raw.setId3v2Frames(id, data);
1745
+ },
1746
+ removeId3v2Frames(id) {
1747
+ stagedId3v2Frames[id] = [];
1748
+ raw.removeId3v2Frames(id);
1749
+ },
1750
+ getStagedId3v2Frames() {
1751
+ return Object.keys(stagedId3v2Frames).length > 0 ? { ...stagedId3v2Frames } : void 0;
1752
+ },
1640
1753
  hasId3Tags() {
1641
1754
  const v = raw.hasId3Tags();
1642
1755
  if (!v || typeof v !== "object") return { v1: false, v2: false };
@@ -1744,6 +1857,16 @@ var init_extra_state_registry = __esm({
1744
1857
  if (v !== void 0) target.setIxml(v);
1745
1858
  else if (complete) target.setIxml(null);
1746
1859
  }
1860
+ },
1861
+ {
1862
+ name: "id3v2Frames",
1863
+ copy(target, source) {
1864
+ const staged = source.getStagedId3v2Frames?.();
1865
+ if (!staged) return;
1866
+ for (const [id, bodies] of Object.entries(staged)) {
1867
+ target.setId3v2Frames(id, bodies);
1868
+ }
1869
+ }
1747
1870
  }
1748
1871
  ];
1749
1872
  }
@@ -1803,25 +1926,27 @@ function inferEndTimeMs(sorted, index, trackEndMs) {
1803
1926
  return next ? next.startTimeMs : trackEndMs;
1804
1927
  }
1805
1928
  function readFileSync(path) {
1806
- if (typeof Deno !== "undefined") return Deno.readFileSync(path);
1807
- if (_nodeFs === void 0) {
1808
- try {
1809
- _nodeFs = new Function("return require('node:fs')")();
1810
- } catch {
1811
- _nodeFs = null;
1812
- }
1813
- }
1814
- if (_nodeFs) return new Uint8Array(_nodeFs.readFileSync(path));
1815
- return new Uint8Array(0);
1929
+ if (isDeno()) return Deno.readFileSync(path);
1930
+ const fs = getNodeFsSync();
1931
+ if (fs) return new Uint8Array(fs.readFileSync(path));
1932
+ throw new FileOperationError(
1933
+ "read",
1934
+ "node:fs is unavailable in this runtime: cannot read file data from disk",
1935
+ path
1936
+ );
1816
1937
  }
1817
- var _nodeFs, AudioFileImpl;
1938
+ var AudioFileImpl;
1818
1939
  var init_audio_file_impl = __esm({
1819
1940
  "src/taglib/audio-file-impl.ts"() {
1820
1941
  "use strict";
1821
1942
  init_types2();
1822
1943
  init_audio_file_bwf();
1944
+ init_id3v2_frames();
1823
1945
  init_errors2();
1824
1946
  init_write();
1947
+ init_node_fs_browser_stub();
1948
+ init_rating();
1949
+ init_detector();
1825
1950
  init_audio_file_base();
1826
1951
  init_save_reconstruct();
1827
1952
  AudioFileImpl = class extends BaseAudioFileImpl {
@@ -1844,6 +1969,7 @@ var init_audio_file_impl = __esm({
1844
1969
  );
1845
1970
  }
1846
1971
  this.cachedAudioProperties = null;
1972
+ this.pathModeBuffer = null;
1847
1973
  return this.handle.save();
1848
1974
  }
1849
1975
  getFileBuffer() {
@@ -1854,11 +1980,20 @@ var init_audio_file_impl = __esm({
1854
1980
  try {
1855
1981
  this.pathModeBuffer = readFileSync(this.sourcePath);
1856
1982
  return this.pathModeBuffer;
1857
- } catch {
1858
- return new Uint8Array(0);
1983
+ } catch (error) {
1984
+ if (error instanceof FileOperationError) throw error;
1985
+ throw new FileOperationError(
1986
+ "read",
1987
+ `Cannot return file data: ${errorMessage(error)}`,
1988
+ this.sourcePath,
1989
+ { cause: error }
1990
+ );
1859
1991
  }
1860
1992
  }
1861
- return new Uint8Array(0);
1993
+ throw new FileOperationError(
1994
+ "read",
1995
+ "No file data available: in-memory buffer is empty and no source path is set"
1996
+ );
1862
1997
  }
1863
1998
  async saveToFile(path) {
1864
1999
  const targetPath = path ?? this.sourcePath;
@@ -1899,6 +2034,7 @@ var init_audio_file_impl = __esm({
1899
2034
  await writeFileData(targetPath, buffer);
1900
2035
  }
1901
2036
  }
2037
+ this.pathModeBuffer = null;
1902
2038
  }
1903
2039
  getPictures() {
1904
2040
  const picturesArray = this.handle.getPictures();
@@ -2010,11 +2146,27 @@ var init_audio_file_impl = __esm({
2010
2146
  }
2011
2147
  getRating() {
2012
2148
  const ratings = this.getRatings();
2013
- return ratings.length > 0 ? ratings[0].rating : void 0;
2149
+ return ratings.length > 0 ? normalized(ratings[0].rating) : void 0;
2014
2150
  }
2015
2151
  setRating(rating, email) {
2016
2152
  this.setRatings([{ rating, email, counter: 0 }]);
2017
2153
  }
2154
+ getId3v2Frames(id) {
2155
+ assertMp3(this.getFormat());
2156
+ if (id !== void 0) assertFrameId(id, "read");
2157
+ return this.handle.getId3v2Frames(id ?? "").map(toPublicFrame);
2158
+ }
2159
+ setId3v2Frames(id, data) {
2160
+ assertMp3(this.getFormat());
2161
+ assertFrameId(id, "write");
2162
+ assertFrameBodies(id, data);
2163
+ this.handle.setId3v2Frames(id, data);
2164
+ }
2165
+ removeId3v2Frames(id) {
2166
+ assertMp3(this.getFormat());
2167
+ assertFrameId(id, "write");
2168
+ this.handle.removeId3v2Frames(id);
2169
+ }
2018
2170
  hasId3Tags() {
2019
2171
  return this.handle.hasId3Tags();
2020
2172
  }
@@ -2199,7 +2351,7 @@ var VERSION;
2199
2351
  var init_version = __esm({
2200
2352
  "src/version.ts"() {
2201
2353
  "use strict";
2202
- VERSION = "1.4.3";
2354
+ VERSION = "1.5.1";
2203
2355
  }
2204
2356
  });
2205
2357
 
@@ -2257,8 +2409,8 @@ function toWasiPath(osPath) {
2257
2409
  }
2258
2410
  let p = osPath;
2259
2411
  if (!p.startsWith("/") && !/^[A-Za-z]:/.test(p)) {
2260
- const g = globalThis;
2261
- const cwd = typeof Deno !== "undefined" ? Deno.cwd() : g.process?.cwd?.();
2412
+ const g2 = globalThis;
2413
+ const cwd = isDeno() ? Deno.cwd() : g2.process?.cwd?.();
2262
2414
  if (cwd) {
2263
2415
  p = cwd.replace(/[/\\]+$/, "") + "/" + p;
2264
2416
  }
@@ -2281,6 +2433,7 @@ var init_taglib_class = __esm({
2281
2433
  "use strict";
2282
2434
  init_audio_formats();
2283
2435
  init_errors2();
2436
+ init_detector();
2284
2437
  init_audio_file_impl();
2285
2438
  init_load_audio_data();
2286
2439
  init_tag_mapping();
@@ -36,6 +36,25 @@ export interface Rating {
36
36
  /** Play counter (if supported by format) */
37
37
  counter?: number;
38
38
  }
39
+ /**
40
+ * A raw ID3v2 frame (escape hatch for vendor and unsupported frames).
41
+ *
42
+ * `data` is the frame BODY only (no 10-byte header); the caller owns the
43
+ * body encoding. Reads of TagLib-modeled IDs (TIT2, APIC, ...) return
44
+ * TagLib's canonical rendering; see the raw-frames docs for caveats.
45
+ */
46
+ export interface Id3v2Frame {
47
+ /** 4-character frame ID matching [A-Z0-9]{4}, e.g. "TXXX", "RGAD" */
48
+ id: string;
49
+ /** Frame body bytes (without the 10-byte frame header) */
50
+ data: Uint8Array;
51
+ /**
52
+ * Frame header flags. Reserved for forward compatibility: currently never
53
+ * populated — TagLib blanks frame header flags when rendering, so they
54
+ * cannot be observed or preserved. Read-only.
55
+ */
56
+ flags?: number;
57
+ }
39
58
  /**
40
59
  * Unsynchronized lyrics text.
41
60
  * For lyrics without timing information.
@@ -1 +1 @@
1
- {"version":3,"file":"complex-properties.d.ts","sourceRoot":"","sources":["../../../src/constants/complex-properties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,WAAW,MAAM;IACrB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,uBAAuB;IACtC,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,MAAM,EAAE,cAAc,CAAC;IACvB,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,uBAAuB,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CrB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,CAAC,IAAI,kBAAkB,GAAG,CAAC;CACtC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,EAAE,qBAKzB,CAAC"}
1
+ {"version":3,"file":"complex-properties.d.ts","sourceRoot":"","sources":["../../../src/constants/complex-properties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,WAAW,MAAM;IACrB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,0DAA0D;IAC1D,IAAI,EAAE,UAAU,CAAC;IACjB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,C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*/ new Set([
5
5
  "pictures",
6
6
  "ratings",
7
+ "id3v2Frames",
7
8
  "lyrics",
8
9
  "chapters",
9
10
  "_mp4ChapterStyle",
@@ -13,6 +13,8 @@ export interface RuntimeDetectionResult {
13
13
  * Pass undefined for non-Node environments (always returns undefined).
14
14
  */
15
15
  export declare function checkNodeVersion(nodeVersion: string | undefined): string | undefined;
16
+ /** Shared Deno-runtime check — do not hand-roll `typeof Deno` tests (taglib-rfr). */
17
+ export declare function isDeno(): boolean;
16
18
  export declare function detectRuntime(): RuntimeDetectionResult;
17
19
  /**
18
20
  * Detect whether the runtime supports the Wasm `exnref` type.
@@ -1 +1 @@
1
- {"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../../src/runtime/detector.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAC1B,WAAW,GACX,WAAW,GACX,UAAU,GACV,SAAS,GACT,iBAAiB,GACjB,QAAQ,GACR,YAAY,CAAC;AAEjB,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,YAAY,CAAC;AAEnD,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,kBAAkB,CAAC;IAChC,QAAQ,EAAE,cAAc,CAAC;IACzB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,eAAe,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAC5B;AAOD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,GAAG,SAAS,CAepB;AA2CD,wBAAgB,aAAa,IAAI,sBAAsB,CA8EtD;AAWD;;;GAGG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAMxC;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAmBzE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAQjE;AAED,gBAAgB;AAChB,wBAAgB,a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export {
183
183
  checkNodeVersion,
184
184
  detectRuntime,
185
185
  getEnvironmentDescription,
186
+ isDeno,
186
187
  supportsExnref
187
188
  };
@@ -8,8 +8,11 @@
8
8
  */
9
9
  export interface LoadTagLibOptions {
10
10
  /**
11
- * Optional pre-loaded WASM binary data.
12
- * If provided, this will be used instead of fetching from network.
11
+ * Optional pre-loaded Wasm binary data (Emscripten backend only).
12
+ * If provided, it is used instead of fetching from network, and auto mode
13
+ * selects the Emscripten backend deterministically. Combining with
14
+ * `forceWasmType: "wasi"` throws — the WASI backend loads from a
15
+ * filesystem path or URL; use `wasmUrl` for that backend.
13
16
  */
14
17
  wasmBinary?: ArrayBuffer | Uint8Array;
15
18
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"loader-types.d.ts","sourceRoot":"","sources":["../../../src/runtime/loader-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IAEtC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAEtC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC"}
1
+ {"version":3,"file":"loader-types.d.ts","sourceRoot":"","sources":["../../../src/runtime/loader-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IAEtC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAEtC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC"}
@@ -32,8 +32,9 @@ import type { TagLibModule } from "../wasm.js";
32
32
  * // Force WASI mode (Deno/Node.js only)
33
33
  * const module = await loadTagLibModule({ forceWasmType: "wasi" });
34
34
  *
35
- * // With custom WASM binary
36
- * const wasmData = await fetch("taglib.wasm").then(r => r.arrayBuffer());
35
+ * // With custom WASM binary (selects the Emscripten backend; the bytes
36
+ * // must be its artifact, taglib-web.wasm)
37
+ * const wasmData = await fetch("taglib-web.wasm").then(r => r.arrayBuffer());
37
38
  * const module = await loadTagLibModule({ wasmBinary: wasmData });
38
39
  * ```
39
40
  *
@@ -1 +1 @@
1
- {"version":3,"file":"module-loader.d.ts","sourceRoot":"","sources":["../../../src/runtime/module-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAkDvB"}
1
+ {"version":3,"file":"module-loader.d.ts","sourceRoot":"","sources":["../../../src/runtime/module-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAqEvB"}
@@ -12,6 +12,12 @@ async function loadTagLibModule(options) {
12
12
  if (versionError) {
13
13
  throw new EnvironmentError("Node.js", versionError, "WASI support");
14
14
  }
15
+ if (options?.forceWasmType === "wasi" && options?.wasmBinary) {
16
+ throw new TagLibInitializationError(
17
+ "wasmBinary is not supported by the WASI backend: it loads from a filesystem path or URL. Use wasmUrl, or omit forceWasmType to use the Emscripten backend",
18
+ { forceWasmType: "wasi" }
19
+ );
20
+ }
15
21
  if (!options?.wasmBinary && !options?.wasmUrl && !options?.forceWasmType && isDenoCompiled()) {
16
22
  const wasmBinary = await tryLoadEmbeddedWasm();
17
23
  if (!wasmBinary) {
@@ -37,6 +43,12 @@ async function loadTagLibModule(options) {
37
43
  debug: false
38
44
  });
39
45
  } catch (error) {
46
+ if (options?.forceWasmType === "wasi") {
47
+ throw new TagLibInitializationError(
48
+ `WASI backend failed to load: ${errorMessage(error)}. forceWasmType is "wasi", so the Emscripten fallback was not attempted`,
49
+ { cause: error, forceWasmType: "wasi" }
50
+ );
51
+ }
40
52
  console.warn(
41
53
  `[TagLib] Unified loader failed, falling back to buffer mode: ${errorMessage(error)}`
42
54
  );
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/runtime/unified-loader/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAI5E,wBAAsB,uBAAuB,CAC3C,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAmC9B"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/runtime/unified-loader/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAK5E,wBAAsB,uBAAuB,CAC3C,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CA4C9B"}
@@ -1,7 +1,14 @@
1
1
  import { detectRuntime } from "../detector.js";
2
+ import { ModuleLoadError } from "./types.js";
2
3
  import { selectWasmType } from "./module-selection.js";
3
4
  import { loadModule } from "./module-loading.js";
4
5
  async function loadUnifiedTagLibModule(options = {}) {
6
+ if (options.forceWasmType === "wasi" && options.wasmBinary) {
7
+ throw new ModuleLoadError(
8
+ "wasmBinary is not supported by the WASI backend: it loads from a filesystem path or URL. Use wasmUrl, or omit forceWasmType to select the Emscripten backend",
9
+ "wasi"
10
+ );
11
+ }
5
12
  const startTime = performance.now();
6
13
  const runtime = detectRuntime();
7
14
  if (options.debug) {
@@ -1,4 +1,6 @@
1
1
  import type { RuntimeDetectionResult } from "../detector.js";
2
2
  import type { LoadModuleResult, UnifiedLoaderOptions } from "./types.js";
3
+ /** @internal Exported for unit tests (tests/node-fs-acquisition.test.ts). */
4
+ export declare function getPreopens(): Record<string, string>;
3
5
  export declare function loadModule(wasmType: "wasi" | "emscripten", runtime: RuntimeDetectionResult, options: UnifiedLoaderOptions): Promise<LoadModuleResult>;
4
6
  //# sourceMappingURL=module-loading.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"module-loading.d.ts","sourceRoot":"","sources":["../../../../src/runtime/unified-loader/module-loading.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAG7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA0CzE,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,GAAG,YAAY,EAC/B,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAS3B"}
1
+ {"version":3,"file":"module-loading.d.ts","sourceRoot":"","sources":["../../../../src/runtime/unified-loader/module-loading.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAG7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAiBzE,6EAA6E;AAC7E,wBAAgB,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwBpD;AAOD,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,GAAG,YAAY,EAC/B,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAS3B"}
@@ -1,22 +1,25 @@
1
- import { supportsExnref } from "../detector.js";
1
+ import { isDeno, supportsExnref } from "../detector.js";
2
2
  import { ModuleLoadError } from "./types.js";
3
3
  import { errorMessage } from "../../errors/classes.js";
4
4
  import { fileUrlToPath } from "../../utils/path.js";
5
+ import { getNodeFsSync } from "../../utils/node-fs.js";
5
6
  function isWindows() {
6
- return typeof Deno !== "undefined" ? Deno.build.os === "windows" : globalThis.process ? globalThis.process.platform === "win32" : false;
7
+ return isDeno() ? Deno.build.os === "windows" : globalThis.process ? globalThis.process.platform === "win32" : false;
7
8
  }
8
9
  function getPreopens() {
9
10
  if (!isWindows()) return { "/": "/" };
11
+ const statSync = isDeno() ? Deno.statSync : getNodeFsSync()?.statSync;
12
+ if (!statSync) {
13
+ console.warn(
14
+ "[taglib-wasm] Windows drive detection unavailable: node:fs could not be loaded. Only C:\\ is registered as a WASI preopen."
15
+ );
16
+ return { "/C": "C:\\" };
17
+ }
10
18
  const preopens = {};
11
19
  for (const letter of "CDEFGHIJKLMNOPQRSTUVWXYZAB") {
12
20
  const root = `${letter}:\\`;
13
21
  try {
14
- if (typeof Deno !== "undefined") {
15
- Deno.statSync(root);
16
- } else {
17
- const fs = new Function("return require('node:fs')")();
18
- fs.statSync(root);
19
- }
22
+ statSync(root);
20
23
  preopens[`/${letter}`] = root;
21
24
  } catch {
22
25
  }
@@ -47,6 +50,13 @@ async function loadWasiModuleWithFallback(runtime, options) {
47
50
  });
48
51
  return { module: wasiModule, actualWasmType: "wasi" };
49
52
  } catch (hostError) {
53
+ if (options.forceWasmType === "wasi") {
54
+ throw new ModuleLoadError(
55
+ `WASI backend failed to load: ${errorMessage(hostError)}. forceWasmType is "wasi", so the Emscripten fallback was not attempted`,
56
+ "wasi",
57
+ hostError
58
+ );
59
+ }
50
60
  if (runtime.environment === "node-wasi" && !supportsExnref()) {
51
61
  const g = globalThis;
52
62
  const nodeVersion = g.process?.versions?.node ?? "";
@@ -107,5 +117,6 @@ async function loadEmscriptenModule(options) {
107
117
  }
108
118
  }
109
119
  export {
120
+ getPreopens,
110
121
  loadModule
111
122
  };
@@ -1 +1 @@
1
- {"version":3,"file":"module-selection.d.ts","sourceRoot":"","sources":["../../../../src/runtime/unified-loader/module-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,wBAAgB,cAAc,CAC5B,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,oBAAoB,GAC5B,MAAM,GAAG,YAAY,CAcvB;AAED,wBAAgB,eAAe,IAAI,OAAO,CAGzC;AAED,wBAAgB,oBAAoB,IAAI,oBAAoB,CAoB3D"}
1
+ {"version":3,"file":"module-selection.d.ts","sourceRoot":"","sources":["../../../../src/runtime/unified-loader/module-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,wBAAgB,cAAc,CAC5B,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,oBAAoB,GAC5B,MAAM,GAAG,YAAY,CAqBvB;AAED,wBAAgB,eAAe,IAAI,OAAO,CAGzC;AAED,wBAAgB,oBAAoB,IAAI,oBAAoB,CAoB3D"}
@@ -3,6 +3,9 @@ function selectWasmType(runtime, options) {
3
3
  if (options.forceWasmType) {
4
4
  return options.forceWasmType;
5
5
  }
6
+ if (options.wasmBinary) {
7
+ return "emscripten";
8
+ }
6
9
  if (options.disableOptimizations) {
7
10
  return "emscripten";
8
11
  }
@@ -14,7 +14,10 @@ export interface UnifiedLoaderOptions {
14
14
  forceWasmType?: "wasi" | "emscripten";
15
15
  /** Disable optimizations for debugging */
16
16
  disableOptimizations?: boolean;
17
- /** Custom WASM binary path or data */
17
+ /**
18
+ * Pre-loaded Wasm binary (Emscripten backend only; auto mode selects
19
+ * Emscripten when set, and forcing "wasi" with it throws — use wasmUrl).
20
+ */
18
21
  wasmBinary?: ArrayBuffer | Uint8Array;
19
22
  /** Custom WASM URL */
20
23
  wasmUrl?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/runtime/unified-loader/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,kBAAmB,SAAQ,WAAW;gBACrC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAM7C;AAED,qBAAa,eAAgB,SAAQ,WAAW;aAG5B,QAAQ,EAAE,MAAM,GAAG,YAAY;gBAD/C,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM,GAAG,YAAY,EAC/C,KAAK,CAAC,EAAE,OAAO;CAOlB;AAED,MAAM,WAAW,oBAAoB;IACnC,+BAA+B;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IACtC,0CAA0C;IAC1C,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,sCAAsC;IACtC,UAAU,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IACtC,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,+BAA+B;IAC/B,O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AW,GAAG,UAAU,CAAC;IACtC,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,+BAA+B;IAC/B,OAAO,EAAE,sBAAsB,CAAC;IAChC,wCAAwC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,8CAA8C;IAC9C,YAAY,EAAE,OAAO,CAAC;IACtB,8BAA8B;IAC9B,qBAAqB,CAAC,EAAE,MAAM,kBAAkB,CAAC;CAClD;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,YAAY,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,YAAY,GAAG,UAAU,CAAC;IAClC,cAAc,EAAE,MAAM,GAAG,YAAY,CAAC;CACvC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @fileoverview WASI-based FileHandle implementation
3
3
  */
4
- import type { FileHandle, RawChapter, RawLyrics, RawPicture } from "../../wasm.js";
4
+ import type { FileHandle, RawChapter, RawId3v2Frame, RawLyrics, RawPicture } from "../../wasm.js";
5
5
  import type { BasicTagData } from "../../types/tags.js";
6
6
  import type { AudioProperties } from "../../types.js";
7
7
  import type { WasiModule } from "../wasmer-sdk-loader/types.js";
@@ -61,6 +61,10 @@ export declare class WasiFileHandle implements FileHandle {
61
61
  }[]): void;
62
62
  getLyrics(): RawLyrics[];
63
63
  setLyrics(lyrics: RawLyrics[]): void;
64
+ getId3v2Frames(id: string): RawId3v2Frame[];
65
+ setId3v2Frames(id: string, data: Uint8Array[]): void;
66
+ removeId3v2Frames(id: string): void;
67
+ getStagedId3v2Frames(): Record<string, Uint8Array[]> | undefined;
64
68
  destroy(): void;
65
69
  }
66
70
  //# sourceMappingURL=file-handle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-handle.d.ts","sourceRoot":"","sources":["../../../../src/runtime/wasi-adapter/file-handle.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAkFhE,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,SAAS,CAAS;gBAEd,UAAU,EAAE,UAAU;IAIlC,OAAO,CAAC,iBAAiB;IAQzB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO;IAW3C,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAWnC,OAAO,IAAI,OAAO;IAMlB,IAAI,IAAI,OAAO;IAqBf,UAAU,IAAI,YAAY;IAc1B,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAc7C,kBAAkB,IAAI,eAAe,GAAG,IAAI;IA+B5C,SAAS,IAAI,MAAM;IA2DnB,OAAO,CAAC,cAAc;IAiBtB,SAAS,IAAI,UAAU;IAKvB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IA2BzC,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IA6BpD,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAOh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AE,MAAM,CAAA;KAAE,EAAE,GAC9D,IAAI;IAaP,SAAS,IAAI,SAAS,EAAE;IAoBxB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI;IAKpC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,EAAE;IAsB3C,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI;IAUpD,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAInC,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,GAAG,SAAS;IAMhE,OAAO,IAAI,IAAI;CAKhB"}
@@ -5,6 +5,7 @@ import { WasmerExecutionError } from "../wasmer-sdk-loader/types.js";
5
5
  import { decodeTagData } from "../../msgpack/decoder.js";
6
6
  import { fromTagLibKey, toTagLibKey } from "../../constants/properties.js";
7
7
  import {
8
+ readId3v2FramesFromWasm,
8
9
  readTagsFromWasm,
9
10
  readTagsFromWasmPath,
10
11
  writeTagsToWasm,
@@ -398,6 +399,39 @@ class WasiFileHandle {
398
399
  this.checkNotDestroyed();
399
400
  this.tagData = { ...this.tagData, lyrics };
400
401
  }
402
+ getId3v2Frames(id) {
403
+ this.checkNotDestroyed();
404
+ const filter = id === "" ? void 0 : id;
405
+ const source = this.filePath ?? this.fileData;
406
+ let frames = [];
407
+ if (source) {
408
+ frames = readId3v2FramesFromWasm(this.wasi, source, filter);
409
+ }
410
+ const staged = this.getStagedId3v2Frames();
411
+ if (!staged) return frames;
412
+ const stagedIds = new Set(Object.keys(staged));
413
+ frames = frames.filter((f) => !stagedIds.has(f.id));
414
+ for (const [sid, bodies] of Object.entries(staged)) {
415
+ if (filter && sid !== filter) continue;
416
+ for (const data of bodies) frames.push({ id: sid, data: data.slice() });
417
+ }
418
+ return frames;
419
+ }
420
+ setId3v2Frames(id, data) {
421
+ this.checkNotDestroyed();
422
+ const staged = { ...this.getStagedId3v2Frames() ?? {} };
423
+ staged[id] = data.map((d) => new Uint8Array(d));
424
+ this.tagData = {
425
+ ...this.tagData,
426
+ id3v2Frames: staged
427
+ };
428
+ }
429
+ removeId3v2Frames(id) {
430
+ this.setId3v2Frames(id, []);
431
+ }
432
+ getStagedId3v2Frames() {
433
+ return this.tagData?.id3v2Frames;
434
+ }
401
435
  destroy() {
402
436
  this.fileData = null;
403
437
  this.tagData = null;