taglib-wasm 1.0.7 → 1.1.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 (77) hide show
  1. package/dist/index.browser.js +318 -46
  2. package/dist/index.d.ts +1 -1
  3. package/dist/simple.browser.js +298 -25
  4. package/dist/src/constants/additional-properties.d.ts +242 -0
  5. package/dist/src/constants/additional-properties.d.ts.map +1 -0
  6. package/dist/src/constants/additional-properties.js +204 -0
  7. package/dist/src/constants/general-extended-properties.d.ts +7 -3
  8. package/dist/src/constants/general-extended-properties.d.ts.map +1 -1
  9. package/dist/src/constants/general-extended-properties.js +5 -3
  10. package/dist/src/constants/properties.d.ts +239 -3
  11. package/dist/src/constants/properties.d.ts.map +1 -1
  12. package/dist/src/constants/properties.js +3 -1
  13. package/dist/src/constants/tags.d.ts +20 -21
  14. package/dist/src/constants/tags.d.ts.map +1 -1
  15. package/dist/src/constants/tags.js +20 -21
  16. package/dist/src/deno-compile.js +1 -1
  17. package/dist/src/runtime/module-loader.d.ts.map +1 -1
  18. package/dist/src/runtime/module-loader.js +2 -3
  19. package/dist/src/runtime/unified-loader/module-loading.js +5 -19
  20. package/dist/src/runtime/unified-loader/module-selection.d.ts.map +1 -1
  21. package/dist/src/runtime/unified-loader/module-selection.js +0 -1
  22. package/dist/src/runtime/unified-loader/types.d.ts +1 -3
  23. package/dist/src/runtime/unified-loader/types.d.ts.map +1 -1
  24. package/dist/src/runtime/wasi-adapter/adapter.d.ts +1 -1
  25. package/dist/src/runtime/wasi-adapter/adapter.js +1 -1
  26. package/dist/src/runtime/wasi-adapter/file-handle.d.ts +3 -2
  27. package/dist/src/runtime/wasi-adapter/file-handle.d.ts.map +1 -1
  28. package/dist/src/runtime/wasi-adapter/file-handle.js +27 -11
  29. package/dist/src/runtime/wasi-adapter/wasm-io.d.ts +3 -1
  30. package/dist/src/runtime/wasi-adapter/wasm-io.d.ts.map +1 -1
  31. package/dist/src/runtime/wasi-adapter/wasm-io.js +66 -1
  32. package/dist/src/runtime/wasi-host-loader.d.ts +1 -1
  33. package/dist/src/runtime/wasi-host-loader.js +1 -1
  34. package/dist/src/runtime/wasmer-sdk-loader/types.d.ts +1 -24
  35. package/dist/src/runtime/wasmer-sdk-loader/types.d.ts.map +1 -1
  36. package/dist/src/runtime/wasmer-sdk-loader/types.js +1 -19
  37. package/dist/src/simple/tag-operations.d.ts.map +1 -1
  38. package/dist/src/simple/tag-operations.js +8 -4
  39. package/dist/src/simple/with-audio-file.d.ts +3 -2
  40. package/dist/src/simple/with-audio-file.d.ts.map +1 -1
  41. package/dist/src/simple/with-audio-file.js +11 -4
  42. package/dist/src/taglib/audio-file-impl.d.ts +1 -0
  43. package/dist/src/taglib/audio-file-impl.d.ts.map +1 -1
  44. package/dist/src/taglib/audio-file-impl.js +37 -6
  45. package/dist/src/taglib/taglib-class.d.ts.map +1 -1
  46. package/dist/src/taglib/taglib-class.js +34 -7
  47. package/dist/src/types/config.d.ts +1 -1
  48. package/dist/src/types/metadata-mappings.d.ts.map +1 -1
  49. package/dist/src/types/metadata-mappings.js +20 -1
  50. package/dist/src/types/tags.d.ts +24 -0
  51. package/dist/src/types/tags.d.ts.map +1 -1
  52. package/dist/src/version.d.ts +1 -1
  53. package/dist/src/version.js +1 -1
  54. package/dist/src/wasm.d.ts +3 -0
  55. package/dist/src/wasm.d.ts.map +1 -1
  56. package/dist/taglib-web.wasm +0 -0
  57. package/dist/taglib-wrapper.js +1 -1
  58. package/dist/taglib_wasi.wasm +0 -0
  59. package/package.json +2 -2
  60. package/dist/src/runtime/wasmer-sdk-loader/high-level-api.d.ts +0 -10
  61. package/dist/src/runtime/wasmer-sdk-loader/high-level-api.d.ts.map +0 -1
  62. package/dist/src/runtime/wasmer-sdk-loader/high-level-api.js +0 -83
  63. package/dist/src/runtime/wasmer-sdk-loader/index.d.ts +0 -6
  64. package/dist/src/runtime/wasmer-sdk-loader/index.d.ts.map +0 -1
  65. package/dist/src/runtime/wasmer-sdk-loader/index.js +0 -17
  66. package/dist/src/runtime/wasmer-sdk-loader/initialization.d.ts +0 -16
  67. package/dist/src/runtime/wasmer-sdk-loader/initialization.d.ts.map +0 -1
  68. package/dist/src/runtime/wasmer-sdk-loader/initialization.js +0 -55
  69. package/dist/src/runtime/wasmer-sdk-loader/loader.d.ts +0 -9
  70. package/dist/src/runtime/wasmer-sdk-loader/loader.d.ts.map +0 -1
  71. package/dist/src/runtime/wasmer-sdk-loader/loader.js +0 -47
  72. package/dist/src/runtime/wasmer-sdk-loader/module-creation.d.ts +0 -9
  73. package/dist/src/runtime/wasmer-sdk-loader/module-creation.d.ts.map +0 -1
  74. package/dist/src/runtime/wasmer-sdk-loader/module-creation.js +0 -71
  75. package/dist/src/runtime/wasmer-sdk-loader/wasi-stubs.d.ts +0 -16
  76. package/dist/src/runtime/wasmer-sdk-loader/wasi-stubs.d.ts.map +0 -1
  77. package/dist/src/runtime/wasmer-sdk-loader/wasi-stubs.js +0 -64
@@ -24,36 +24,36 @@ const Tags = {
24
24
  Publisher: "publisher",
25
25
  Mood: "mood",
26
26
  Media: "media",
27
- RadioStationOwner: "RADIOSTATIONOWNER",
28
- Producer: "PRODUCER",
29
- Subtitle: "SUBTITLE",
30
- Label: "LABEL",
27
+ RadioStationOwner: "radioStationOwner",
28
+ Producer: "producer",
29
+ Subtitle: "subtitle",
30
+ Label: "label",
31
31
  // Sorting Properties
32
32
  TitleSort: "titleSort",
33
33
  ArtistSort: "artistSort",
34
- AlbumArtistSort: "ALBUMARTISTSORT",
34
+ AlbumArtistSort: "albumArtistSort",
35
35
  AlbumSort: "albumSort",
36
- ComposerSort: "COMPOSERSORT",
36
+ ComposerSort: "composerSort",
37
37
  // Identifiers
38
38
  Isrc: "isrc",
39
- Asin: "ASIN",
39
+ Asin: "asin",
40
40
  CatalogNumber: "catalogNumber",
41
41
  Barcode: "barcode",
42
42
  // MusicBrainz Identifiers
43
43
  MusicBrainzArtistId: "musicbrainzArtistId",
44
- MusicBrainzReleaseArtistId: "MUSICBRAINZ_ALBUMARTISTID",
45
- MusicBrainzWorkId: "MUSICBRAINZ_WORKID",
44
+ MusicBrainzReleaseArtistId: "musicbrainzReleaseArtistId",
45
+ MusicBrainzWorkId: "musicbrainzWorkId",
46
46
  MusicBrainzReleaseId: "musicbrainzReleaseId",
47
47
  MusicBrainzRecordingId: "musicbrainzTrackId",
48
48
  MusicBrainzTrackId: "musicbrainzTrackId",
49
49
  MusicBrainzReleaseGroupId: "musicbrainzReleaseGroupId",
50
- MusicBrainzReleaseTrackId: "MUSICBRAINZ_RELEASETRACKID",
50
+ MusicBrainzReleaseTrackId: "musicbrainzReleaseTrackId",
51
51
  // AcoustID
52
52
  AcoustidFingerprint: "acoustidFingerprint",
53
53
  AcoustidId: "acoustidId",
54
54
  // Podcast Properties
55
- PodcastId: "PODCASTID",
56
- PodcastUrl: "PODCASTURL",
55
+ PodcastId: "podcastId",
56
+ PodcastUrl: "podcastUrl",
57
57
  // Grouping and Work
58
58
  Grouping: "grouping",
59
59
  Work: "work",
@@ -63,15 +63,14 @@ const Tags = {
63
63
  AlbumPeak: "replayGainAlbumPeak",
64
64
  TrackGain: "replayGainTrackGain",
65
65
  TrackPeak: "replayGainTrackPeak",
66
- // Special handling
67
- OriginalArtist: "ORIGINALARTIST",
68
- OriginalAlbum: "ORIGINALALBUM",
69
- OriginalDate: "ORIGINALDATE",
70
- Script: "SCRIPT",
71
- InvolvedPeopleList: "INVOLVEDPEOPLELIST",
72
- // Technical Properties
73
- EncoderSettings: "ENCODERSETTINGS",
74
- SourceMedia: "SOURCEMEDIA"
66
+ // Original release
67
+ OriginalArtist: "originalArtist",
68
+ OriginalAlbum: "originalAlbum",
69
+ OriginalDate: "originalDate",
70
+ // Miscellaneous
71
+ Script: "script",
72
+ InvolvedPeople: "involvedPeople",
73
+ Encoding: "encoding"
75
74
  };
76
75
  function isValidTagName(name) {
77
76
  return Object.values(Tags).includes(name);
@@ -32,7 +32,7 @@ async function prepareWasmForEmbedding(outputPath = "./taglib-web.wasm") {
32
32
  try {
33
33
  const possiblePaths = [
34
34
  new URL("../dist/taglib-web.wasm", import.meta.url),
35
- new URL("../build/taglib-web.wasm", import.meta.url),
35
+ new URL("../taglib-web.wasm", import.meta.url),
36
36
  new URL(
37
37
  "./node_modules/taglib-wasm/dist/taglib-web.wasm",
38
38
  import.meta.url
@@ -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,CAmDvB"}
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"}
@@ -34,8 +34,7 @@ async function loadTagLibModule(options) {
34
34
  wasmBinary: options?.wasmBinary,
35
35
  wasmUrl: options?.wasmUrl,
36
36
  forceWasmType: options?.forceWasmType,
37
- debug: false,
38
- useInlineWasm: false
37
+ debug: false
39
38
  });
40
39
  } catch (error) {
41
40
  console.warn(
@@ -71,7 +70,7 @@ async function loadBufferModeTagLibModule(options) {
71
70
  return path;
72
71
  };
73
72
  } else if (!options?.wasmBinary) {
74
- const wasmUrl = new URL("../../build/taglib-web.wasm", import.meta.url);
73
+ const wasmUrl = new URL("../../taglib-web.wasm", import.meta.url);
75
74
  moduleConfig.locateFile = (path) => path.endsWith(".wasm") ? wasmUrl.href : path;
76
75
  }
77
76
  const module = await createTagLibModule(moduleConfig);
@@ -17,11 +17,12 @@ async function loadModule(wasmType, runtime, options) {
17
17
  }
18
18
  }
19
19
  async function loadWasiModuleWithFallback(runtime, options) {
20
- const defaultWasmPath = resolveWasmPath("../../../build/taglib_wasi.wasm");
20
+ const defaultWasmPath = resolveWasmPath("../../../taglib_wasi.wasm");
21
21
  try {
22
22
  const { loadWasiHost } = await import("../wasi-host-loader.js");
23
23
  const wasiModule = await loadWasiHost({
24
- wasmPath: options.wasmUrl || defaultWasmPath
24
+ wasmPath: options.wasmUrl || defaultWasmPath,
25
+ preopens: { "/": "/" }
25
26
  });
26
27
  return { module: wasiModule, actualWasmType: "wasi" };
27
28
  } catch (hostError) {
@@ -35,22 +36,8 @@ async function loadWasiModuleWithFallback(runtime, options) {
35
36
  console.warn(`[UnifiedLoader] WASI host failed:`, hostError);
36
37
  }
37
38
  }
38
- try {
39
- const { initializeWasmer, loadWasmerWasi } = await import("../wasmer-sdk-loader/index.js");
40
- await initializeWasmer(options.useInlineWasm);
41
- const wasiModule = await loadWasmerWasi({
42
- wasmPath: options.wasmUrl || defaultWasmPath,
43
- useInlineWasm: options.useInlineWasm,
44
- debug: options.debug
45
- });
46
- return { module: wasiModule, actualWasmType: "wasi" };
47
- } catch (sdkError) {
48
- if (options.debug) {
49
- console.warn(`[UnifiedLoader] Wasmer SDK failed:`, sdkError);
50
- }
51
- }
52
39
  if (options.debug) {
53
- console.warn(`[UnifiedLoader] All WASI loaders failed, using Emscripten`);
40
+ console.warn(`[UnifiedLoader] WASI loader failed, using Emscripten`);
54
41
  }
55
42
  return {
56
43
  module: await loadEmscriptenModule(options),
@@ -83,8 +70,7 @@ async function loadEmscriptenModule(options) {
83
70
  return path.endsWith(".wasm") ? options.wasmUrl : path;
84
71
  };
85
72
  } else if (!options.wasmBinary) {
86
- const wasmUrl = new URL(
87
- "../../../build/taglib-web.wasm",
73
+ const wasmUrl = new URL("../../../taglib-web.wasm",
88
74
  import.meta.url
89
75
  );
90
76
  moduleConfig.locateFile = (path) => path.endsWith(".wasm") ? wasmUrl.href : path;
@@ -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,CAqB3D"}
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"}
@@ -26,7 +26,6 @@ function getRecommendedConfig() {
26
26
  if (runtime.supportsFilesystem) {
27
27
  return {
28
28
  forceWasmType: "wasi",
29
- useInlineWasm: false,
30
29
  disableOptimizations: false
31
30
  };
32
31
  }
@@ -1,5 +1,5 @@
1
1
  import type { RuntimeDetectionResult } from "../detector.js";
2
- import type { WasiModule } from "../wasmer-sdk-loader/index.js";
2
+ import type { WasiModule } from "../wasmer-sdk-loader/types.js";
3
3
  import type { TagLibModule } from "../../wasm.js";
4
4
  import { TagLibError } from "../../errors/base.js";
5
5
  export declare class UnifiedLoaderError extends TagLibError {
@@ -20,8 +20,6 @@ export interface UnifiedLoaderOptions {
20
20
  wasmUrl?: string;
21
21
  /** Enable debug output */
22
22
  debug?: boolean;
23
- /** Use inline WASM for bundling */
24
- useInlineWasm?: boolean;
25
23
  }
26
24
  export interface UnifiedTagLibModule extends TagLibModule {
27
25
  /** Runtime environment info */
@@ -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,KA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;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,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"}
@@ -5,7 +5,7 @@
5
5
  * providing Emscripten-compatible memory access and string operations.
6
6
  */
7
7
  import type { FileHandle, TagLibModule } from "../../wasm.js";
8
- import type { WasiModule } from "../wasmer-sdk-loader/index.js";
8
+ import type { WasiModule } from "../wasmer-sdk-loader/types.js";
9
9
  export declare class WasiToTagLibAdapter implements TagLibModule {
10
10
  private readonly wasi;
11
11
  private readonly heap;
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { WasmerExecutionError } from "../wasmer-sdk-loader/index.js";
4
+ import { WasmerExecutionError } from "../wasmer-sdk-loader/types.js";
5
5
  import { MemoryError } from "../../errors/classes.js";
6
6
  import { WasiFileHandle } from "./file-handle.js";
7
7
  class WasiToTagLibAdapter {
@@ -2,16 +2,17 @@
2
2
  * @fileoverview WASI-based FileHandle implementation
3
3
  */
4
4
  import type { AudioPropertiesWrapper, FileHandle, RawPicture, TagWrapper } from "../../wasm.js";
5
- import type { WasiModule } from "../wasmer-sdk-loader/index.js";
5
+ import type { WasiModule } from "../wasmer-sdk-loader/types.js";
6
6
  export declare class WasiFileHandle implements FileHandle {
7
7
  private readonly wasi;
8
8
  private fileData;
9
+ private filePath;
9
10
  private tagData;
10
11
  private destroyed;
11
12
  constructor(wasiModule: WasiModule);
12
13
  private checkNotDestroyed;
13
14
  loadFromBuffer(buffer: Uint8Array): boolean;
14
- loadFromPath(_path: string): boolean;
15
+ loadFromPath(path: string): boolean;
15
16
  isValid(): boolean;
16
17
  save(): boolean;
17
18
  getTag(): TagWrapper;
@@ -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,sBAAsB,EACtB,UAAU,EACV,UAAU,EACV,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AA2ChE,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAA2B;IAC3C,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,C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CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAShC,WAAW,IAAI,UAAU,EAAE;IAK3B,WAAW,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,IAAI;IAKzC,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI;IAOrC,cAAc,IAAI,IAAI;IAKtB,UAAU,IAAI;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE;IAOlE,UAAU,CACR,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,GAC9D,IAAI;IAaP,OAAO,IAAI,IAAI;CAKhB"}
@@ -1,10 +1,15 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { WasmerExecutionError } from "../wasmer-sdk-loader/index.js";
4
+ 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
- import { readTagsFromWasm, writeTagsToWasm } from "./wasm-io.js";
7
+ import {
8
+ readTagsFromWasm,
9
+ readTagsFromWasmPath,
10
+ writeTagsToWasm,
11
+ writeTagsToWasmPath
12
+ } from "./wasm-io.js";
8
13
  const AUDIO_KEYS = /* @__PURE__ */ new Set([
9
14
  "bitrate",
10
15
  "bitsPerSample",
@@ -42,6 +47,7 @@ class WasiFileHandle {
42
47
  constructor(wasiModule) {
43
48
  __publicField(this, "wasi");
44
49
  __publicField(this, "fileData", null);
50
+ __publicField(this, "filePath", null);
45
51
  __publicField(this, "tagData", null);
46
52
  __publicField(this, "destroyed", false);
47
53
  this.wasi = wasiModule;
@@ -60,21 +66,28 @@ class WasiFileHandle {
60
66
  this.tagData = decodeTagData(msgpackData);
61
67
  return true;
62
68
  }
63
- loadFromPath(_path) {
69
+ loadFromPath(path) {
64
70
  this.checkNotDestroyed();
65
- throw new WasmerExecutionError(
66
- "loadFromPath not implemented for WASI - use loadFromBuffer"
67
- );
71
+ this.filePath = path;
72
+ const msgpackData = readTagsFromWasmPath(this.wasi, path);
73
+ this.tagData = decodeTagData(msgpackData);
74
+ return true;
68
75
  }
69
76
  isValid() {
70
77
  this.checkNotDestroyed();
71
- return this.fileData !== null && this.fileData.length > 0;
78
+ return this.fileData !== null && this.fileData.length > 0 || this.filePath !== null && this.tagData !== null;
72
79
  }
73
80
  save() {
74
81
  this.checkNotDestroyed();
75
- if (!this.fileData || !this.tagData) {
76
- return false;
82
+ if (!this.tagData) return false;
83
+ if (this.filePath) {
84
+ return writeTagsToWasmPath(
85
+ this.wasi,
86
+ this.filePath,
87
+ this.tagData
88
+ );
77
89
  }
90
+ if (!this.fileData) return false;
78
91
  const result = writeTagsToWasm(this.wasi, this.fileData, this.tagData);
79
92
  if (result) {
80
93
  this.fileData = result;
@@ -147,13 +160,13 @@ class WasiFileHandle {
147
160
  }
148
161
  getFormat() {
149
162
  this.checkNotDestroyed();
150
- if (!this.fileData || this.fileData.length < 8) return "unknown";
151
163
  const container = this.tagData?.containerFormat;
152
164
  if (container) {
153
165
  const codec = this.tagData?.codec;
154
166
  if (container === "OGG" && codec === "Opus") return "OPUS";
155
167
  if (CONTAINER_TO_FORMAT[container]) return CONTAINER_TO_FORMAT[container];
156
168
  }
169
+ if (!this.fileData || this.fileData.length < 8) return "unknown";
157
170
  const magic = this.fileData.slice(0, 4);
158
171
  if (magic[0] === 255 && (magic[1] & 224) === 224) return "MP3";
159
172
  if (magic[0] === 73 && magic[1] === 68 && magic[2] === 51) {
@@ -241,7 +254,10 @@ class WasiFileHandle {
241
254
  }
242
255
  isMP4() {
243
256
  this.checkNotDestroyed();
244
- if (!this.fileData || this.fileData.length < 8) return false;
257
+ if (!this.fileData) {
258
+ return this.tagData?.containerFormat === "MP4";
259
+ }
260
+ if (this.fileData.length < 8) return false;
245
261
  const magic = this.fileData.slice(4, 8);
246
262
  return magic[0] === 102 && magic[1] === 116 && magic[2] === 121 && magic[3] === 112;
247
263
  }
@@ -4,8 +4,10 @@
4
4
  * Pure functions that handle the low-level Wasm memory allocation
5
5
  * and TagLib C API calls for reading and writing audio metadata.
6
6
  */
7
- import type { WasiModule } from "../wasmer-sdk-loader/index.js";
7
+ import type { WasiModule } from "../wasmer-sdk-loader/types.js";
8
8
  import type { ExtendedTag } from "../../types.js";
9
9
  export declare function readTagsFromWasm(wasi: WasiModule, buffer: Uint8Array): Uint8Array;
10
+ export declare function readTagsFromWasmPath(wasi: WasiModule, path: string): Uint8Array;
11
+ export declare function writeTagsToWasmPath(wasi: WasiModule, path: string, tagData: ExtendedTag): boolean;
10
12
  export declare function writeTagsToWasm(wasi: WasiModule, fileData: Uint8Array, tagData: ExtendedTag): Uint8Array | null;
11
13
  //# sourceMappingURL=wasm-io.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wasm-io.d.ts","sourceRoot":"","sources":["../../../../src/runtime/wasi-adapter/wasm-io.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAQhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAKlD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,UAAU,GACjB,UAAU,CAoCZ;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,WAAW,GACnB,UAAU,GAAG,IAAI,CA8BnB"}
1
+ {"version":3,"file":"wasm-io.d.ts","sourceRoot":"","sources":["../../../../src/runtime/wasi-adapter/wasm-io.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAQhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAKlD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,UAAU,GACjB,UAAU,CAoCZ;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,GACX,UAAU,CA8BZ;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,GACnB,OAAO,CA2BT;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,WAAW,GACnB,UAAU,GAAG,IAAI,CA8BnB"}
@@ -88,6 +88,69 @@ function readTagsFromWasm(wasi, buffer) {
88
88
  __callDispose(_stack, _error, _hasError);
89
89
  }
90
90
  }
91
+ function readTagsFromWasmPath(wasi, path) {
92
+ var _stack = [];
93
+ try {
94
+ const arena = __using(_stack, new WasmArena(wasi));
95
+ const pathAlloc = arena.allocString(path);
96
+ const outSizePtr = arena.allocUint32();
97
+ const resultPtr = wasi.tl_read_tags(pathAlloc.ptr, 0, 0, outSizePtr.ptr);
98
+ if (resultPtr === 0) {
99
+ const errorCode = wasi.tl_get_last_error_code();
100
+ if (errorCode === TL_ERROR_UNSUPPORTED_FORMAT || errorCode === TL_ERROR_PARSE_FAILED) {
101
+ throw new InvalidFormatError(
102
+ `File may be corrupted or in an unsupported format. Path: ${path}`
103
+ );
104
+ }
105
+ throw new WasmMemoryError(
106
+ `error code ${errorCode}. Path: ${path}`,
107
+ "read tags from path",
108
+ errorCode
109
+ );
110
+ }
111
+ const outSize = outSizePtr.readUint32();
112
+ const u8 = new Uint8Array(wasi.memory.buffer);
113
+ const result = new Uint8Array(u8.slice(resultPtr, resultPtr + outSize));
114
+ wasi.free(resultPtr);
115
+ return result;
116
+ } catch (_) {
117
+ var _error = _, _hasError = true;
118
+ } finally {
119
+ __callDispose(_stack, _error, _hasError);
120
+ }
121
+ }
122
+ function writeTagsToWasmPath(wasi, path, tagData) {
123
+ var _stack = [];
124
+ try {
125
+ const arena = __using(_stack, new WasmArena(wasi));
126
+ const pathAlloc = arena.allocString(path);
127
+ const tagBytes = encodeTagData(tagData);
128
+ const tagBuf = arena.allocBuffer(tagBytes);
129
+ const outSizePtr = arena.allocUint32();
130
+ const result = wasi.tl_write_tags(
131
+ pathAlloc.ptr,
132
+ 0,
133
+ 0,
134
+ tagBuf.ptr,
135
+ tagBuf.size,
136
+ 0,
137
+ outSizePtr.ptr
138
+ );
139
+ if (result !== 0) {
140
+ const errorCode = wasi.tl_get_last_error_code();
141
+ throw new WasmMemoryError(
142
+ `error code ${errorCode}. Path: ${path}`,
143
+ "write tags to path",
144
+ errorCode
145
+ );
146
+ }
147
+ return true;
148
+ } catch (_) {
149
+ var _error = _, _hasError = true;
150
+ } finally {
151
+ __callDispose(_stack, _error, _hasError);
152
+ }
153
+ }
91
154
  function writeTagsToWasm(wasi, fileData, tagData) {
92
155
  var _stack = [];
93
156
  try {
@@ -125,5 +188,7 @@ function writeTagsToWasm(wasi, fileData, tagData) {
125
188
  }
126
189
  export {
127
190
  readTagsFromWasm,
128
- writeTagsToWasm
191
+ readTagsFromWasmPath,
192
+ writeTagsToWasm,
193
+ writeTagsToWasmPath
129
194
  };
@@ -5,7 +5,7 @@
5
5
  * implementations, enabling efficient seek-based file I/O.
6
6
  */
7
7
  import type { FileSystemProvider } from "./wasi-fs-provider.js";
8
- import type { WasiModule } from "./wasmer-sdk-loader/index.js";
8
+ import type { WasiModule } from "./wasmer-sdk-loader/types.js";
9
9
  import { TagLibError } from "../errors/base.js";
10
10
  export interface WasiHostLoaderConfig {
11
11
  wasmPath?: string;
@@ -22,7 +22,7 @@ async function resolveFs(provided) {
22
22
  }
23
23
  async function loadWasiHost(config) {
24
24
  const defaultPath = (() => {
25
- const url = new URL("../../build/taglib_wasi.wasm", import.meta.url);
25
+ const url = new URL("../../taglib_wasi.wasm", import.meta.url);
26
26
  return url.protocol === "file:" ? fileUrlToPath(url) : url.href;
27
27
  })();
28
28
  const wasmPath = config.wasmPath ?? defaultPath;
@@ -1,13 +1,7 @@
1
1
  /**
2
- * @fileoverview Error types and interfaces for Wasmer SDK loader
2
+ * @fileoverview WASI module interface and error types
3
3
  */
4
4
  import { TagLibError } from "../../errors/base.js";
5
- export declare class WasmerInitError extends TagLibError {
6
- constructor(message: string, cause?: unknown);
7
- }
8
- export declare class WasmerLoadError extends TagLibError {
9
- constructor(message: string, cause?: unknown);
10
- }
11
5
  export declare class WasmerExecutionError extends TagLibError {
12
6
  constructor(message: string, cause?: unknown);
13
7
  }
@@ -26,21 +20,4 @@ export interface WasiModule {
26
20
  tl_clear_error(): void;
27
21
  memory: WebAssembly.Memory;
28
22
  }
29
- /**
30
- * Configuration for Wasmer SDK loader
31
- */
32
- export interface WasmerLoaderConfig {
33
- /** Path to WASI WASM binary */
34
- wasmPath?: string;
35
- /** Use inline WASM for bundling */
36
- useInlineWasm?: boolean;
37
- /** Initial file system mounts */
38
- mounts?: Record<string, unknown>;
39
- /** Environment variables */
40
- env?: Record<string, string>;
41
- /** Arguments to pass to WASI module */
42
- args?: string[];
43
- /** Enable debug output */
44
- debug?: boolean;
45
- }
46
23
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/runtime/wasmer-sdk-loader/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,eAAgB,SAAQ,WAAW;gBAClC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAM7C;AAED,qBAAa,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AAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/runtime/wasmer-sdk-loader/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,oBAAqB,SAAQ,WAAW;gBACvC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAM7C;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAEzB,UAAU,IAAI,MAAM,CAAC;IACrB,cAAc,IAAI,MAAM,CAAC;IAGzB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAGxB,YAAY,CACV,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,GACjB,MAAM,CAAC;IACV,aAAa,CACX,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,MAAM,CAAC;IAGV,iBAAiB,IAAI,MAAM,CAAC;IAC5B,sBAAsB,IAAI,MAAM,CAAC;IACjC,cAAc,IAAI,IAAI,CAAC;IAGvB,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;CAC5B"}
@@ -1,20 +1,4 @@
1
1
  import { TagLibError } from "../../errors/base.js";
2
- class WasmerInitError extends TagLibError {
3
- constructor(message, cause) {
4
- super("MODULE_LOAD", message, cause ? { cause } : void 0);
5
- this.name = "WasmerInitError";
6
- if (cause) this.cause = cause;
7
- Object.setPrototypeOf(this, WasmerInitError.prototype);
8
- }
9
- }
10
- class WasmerLoadError extends TagLibError {
11
- constructor(message, cause) {
12
- super("MODULE_LOAD", message, cause ? { cause } : void 0);
13
- this.name = "WasmerLoadError";
14
- if (cause) this.cause = cause;
15
- Object.setPrototypeOf(this, WasmerLoadError.prototype);
16
- }
17
- }
18
2
  class WasmerExecutionError extends TagLibError {
19
3
  constructor(message, cause) {
20
4
  super("WASM_MEMORY", message, cause ? { cause } : void 0);
@@ -24,7 +8,5 @@ class WasmerExecutionError extends TagLibError {
24
8
  }
25
9
  }
26
10
  export {
27
- WasmerExecutionError,
28
- WasmerInitError,
29
- WasmerLoadError
11
+ WasmerExecutionError
30
12
  };
@@ -1 +1 @@
1
- {"version":3,"file":"tag-operations.d.ts","sourceRoot":"","sources":["../../../src/simple/tag-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,WAAW,EACX,QAAQ,EACR,QAAQ,EACT,MAAM,aAAa,CAAC;AAUrB;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,WAAW,CAAC,CAKtB;AAED;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GACtB,OAAO,CAAC,UAAU,CAAC,CAIrB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GACtB,OAAO,CAAC,IAAI,CAAC,CAUf;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,eAAe,CAAC,CAY1B;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,OAAO,CAAC,CAYlB;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAW/B;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,UAAU,CAAC,CAKrB"}
1
+ {"version":3,"file":"tag-operations.d.ts","sourceRoot":"","sources":["../../../src/simple/tag-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,WAAW,EACX,QAAQ,EACR,QAAQ,EACT,MAAM,aAAa,CAAC;AAcrB;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,WAAW,CAAC,CAKtB;AAED;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GACtB,OAAO,CAAC,UAAU,CAAC,CAIrB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GACtB,OAAO,CAAC,IAAI,CAAC,CAWf;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,eAAe,CAAC,CAY1B;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,OAAO,CAAC,CAYlB;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAW/B;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,UAAU,CAAC,CAKrB"}
@@ -1,11 +1,14 @@
1
1
  import { FileOperationError, MetadataError } from "../errors.js";
2
- import { writeFileData } from "../utils/write.js";
3
2
  import {
4
3
  mapPropertiesToExtendedTag,
5
4
  mergeTagUpdates
6
5
  } from "../utils/tag-mapping.js";
7
6
  import { getTagLib } from "./config.js";
8
- import { withAudioFile, withAudioFileSave } from "./with-audio-file.js";
7
+ import {
8
+ withAudioFile,
9
+ withAudioFileSave,
10
+ withAudioFileSaveToFile
11
+ } from "./with-audio-file.js";
9
12
  async function readTags(file) {
10
13
  return withAudioFile(
11
14
  file,
@@ -24,8 +27,9 @@ async function applyTagsToFile(file, tags) {
24
27
  "applyTagsToFile requires a file path string to save changes"
25
28
  );
26
29
  }
27
- const modifiedBuffer = await applyTags(file, tags);
28
- await writeFileData(file, modifiedBuffer);
30
+ await withAudioFileSaveToFile(file, (audioFile) => {
31
+ mergeTagUpdates(audioFile, tags);
32
+ });
29
33
  }
30
34
  async function readProperties(file) {
31
35
  return withAudioFile(file, (audioFile) => {
@@ -1,5 +1,6 @@
1
1
  import type { AudioFile } from "../taglib/audio-file-interface.js";
2
- import type { AudioFileInput } from "../types.js";
3
- export declare function withAudioFile<T>(file: AudioFileInput, fn: (audioFile: AudioFile) => T): Promise<T>;
2
+ import type { AudioFileInput, OpenOptions } from "../types.js";
3
+ export declare function withAudioFile<T>(file: AudioFileInput, fn: (audioFile: AudioFile) => T | Promise<T>, options?: OpenOptions): Promise<T>;
4
4
  export declare function withAudioFileSave(file: AudioFileInput, fn: (audioFile: AudioFile) => void): Promise<Uint8Array>;
5
+ export declare function withAudioFileSaveToFile(file: string, fn: (audioFile: AudioFile) => void): Promise<void>;
5
6
  //# sourceMappingURL=with-audio-file.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"with-audio-file.d.ts","sourceRoot":"","sources":["../../../src/simple/with-audio-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,wBAAsB,aAAa,CAAC,CAAC,EACnC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,CAAC,GAC9B,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GACjC,OAAO,CAAC,UAAU,CAAC,CAWrB"}
1
+ {"version":3,"file":"with-audio-file.d.ts","sourceRoot":"","sources":["../../../src/simple/with-audio-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/D,wBAAsB,aAAa,CAAC,CAAC,EACnC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC5C,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GACjC,OAAO,CAAC,UAAU,CAAC,CAWrB;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GACjC,OAAO,CAAC,IAAI,CAAC,CAKf"}
@@ -1,15 +1,15 @@
1
1
  import { FileOperationError, InvalidFormatError } from "../errors.js";
2
2
  import { getTagLib } from "./config.js";
3
- async function withAudioFile(file, fn) {
3
+ async function withAudioFile(file, fn, options) {
4
4
  const taglib = await getTagLib();
5
- const audioFile = await taglib.open(file);
5
+ const audioFile = await taglib.open(file, options);
6
6
  try {
7
7
  if (!audioFile.isValid()) {
8
8
  throw new InvalidFormatError(
9
9
  "File may be corrupted or in an unsupported format"
10
10
  );
11
11
  }
12
- return fn(audioFile);
12
+ return await fn(audioFile);
13
13
  } finally {
14
14
  audioFile.dispose();
15
15
  }
@@ -24,9 +24,16 @@ async function withAudioFileSave(file, fn) {
24
24
  );
25
25
  }
26
26
  return audioFile.getFileBuffer();
27
+ }, { partial: false });
28
+ }
29
+ async function withAudioFileSaveToFile(file, fn) {
30
+ return withAudioFile(file, async (audioFile) => {
31
+ fn(audioFile);
32
+ await audioFile.saveToFile(file);
27
33
  });
28
34
  }
29
35
  export {
30
36
  withAudioFile,
31
- withAudioFileSave
37
+ withAudioFileSave,
38
+ withAudioFileSaveToFile
32
39
  };
@@ -10,6 +10,7 @@ import { BaseAudioFileImpl } from "./audio-file-base.js";
10
10
  * Use TagLib.open() to create instances.
11
11
  */
12
12
  export declare class AudioFileImpl extends BaseAudioFileImpl implements AudioFile {
13
+ private pathModeBuffer;
13
14
  constructor(module: TagLibModule, fileHandle: FileHandle, sourcePath?: string, originalSource?: string | Uint8Array | ArrayBuffer | File, isPartiallyLoaded?: boolean, partialLoadOptions?: OpenOptions);
14
15
  save(): boolean;
15
16
  getFileBuffer(): Uint8Array;
@@ -1 +1 @@
1
- {"version":3,"file":"audio-file-impl.d.ts","sourceRoot":"","sources":["../../../src/taglib/audio-file-impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAIjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,iBAAkB,YAAW,SAAS;gBAErE,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG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