taglib-wasm 0.3.21 → 0.3.23
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/dist/index.d.ts +22 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -2
- package/dist/src/deno-compile-loader.d.ts +27 -0
- package/dist/src/deno-compile-loader.d.ts.map +1 -0
- package/dist/src/deno-compile-loader.js +40 -0
- package/dist/src/deno-compile-support.d.ts +51 -0
- package/dist/src/deno-compile-support.d.ts.map +1 -0
- package/dist/src/deno-compile-support.js +50 -0
- package/dist/src/deno-compile.d.ts +55 -0
- package/dist/src/deno-compile.d.ts.map +1 -0
- package/dist/src/deno-compile.js +52 -0
- package/dist/src/taglib.d.ts +14 -3
- package/dist/src/taglib.d.ts.map +1 -1
- package/dist/src/taglib.js +12 -4
- package/dist/src/types.d.ts +3 -3
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/write.d.ts.map +1 -1
- package/dist/src/wasm-workers.d.ts +2 -2
- package/dist/src/wasm-workers.d.ts.map +1 -1
- package/dist/src/wasm-workers.js +2 -2
- package/dist/src/workers.d.ts +4 -4
- package/dist/src/workers.d.ts.map +1 -1
- package/package.json +3 -3
- package/README.md +0 -311
package/dist/index.d.ts
CHANGED
|
@@ -94,9 +94,8 @@ export { canvasToPicture, createPictureDownloadURL, createPictureGallery, dataUR
|
|
|
94
94
|
* @see {@link Tag} - Basic metadata structure
|
|
95
95
|
* @see {@link ExtendedTag} - Extended metadata with advanced fields
|
|
96
96
|
* @see {@link AudioProperties} - Audio technical properties
|
|
97
|
-
* @see {@link TagLibConfig} - Configuration options
|
|
98
97
|
*/
|
|
99
|
-
export type { AudioFormat, AudioProperties, ExtendedTag, FieldMapping, FileType, Picture, PropertyMap, Tag,
|
|
98
|
+
export type { AudioFormat, AudioProperties, ExtendedTag, FieldMapping, FileType, Picture, PropertyMap, Tag, TagName, } from "./src/types.ts";
|
|
100
99
|
/**
|
|
101
100
|
* Enum exports
|
|
102
101
|
*/
|
|
@@ -108,11 +107,27 @@ export { PictureType } from "./src/types.ts";
|
|
|
108
107
|
*/
|
|
109
108
|
export type { TagLibModule, WasmModule } from "./src/wasm.ts";
|
|
110
109
|
import type { TagLibModule } from "./src/wasm.ts";
|
|
110
|
+
/**
|
|
111
|
+
* Configuration options for loading the TagLib WASM module
|
|
112
|
+
*/
|
|
113
|
+
export interface LoadTagLibOptions {
|
|
114
|
+
/**
|
|
115
|
+
* Optional pre-loaded WASM binary data.
|
|
116
|
+
* If provided, this will be used instead of fetching from network.
|
|
117
|
+
*/
|
|
118
|
+
wasmBinary?: ArrayBuffer | Uint8Array;
|
|
119
|
+
/**
|
|
120
|
+
* Optional custom URL or path for the WASM file.
|
|
121
|
+
* This is passed to the locateFile function.
|
|
122
|
+
*/
|
|
123
|
+
wasmUrl?: string;
|
|
124
|
+
}
|
|
111
125
|
/**
|
|
112
126
|
* Load the TagLib Wasm module.
|
|
113
127
|
* This function initializes the WebAssembly module and returns
|
|
114
128
|
* the loaded module for use with the Core API.
|
|
115
129
|
*
|
|
130
|
+
* @param config - Optional configuration for module initialization
|
|
116
131
|
* @returns Promise resolving to the initialized TagLib module
|
|
117
132
|
*
|
|
118
133
|
* @example
|
|
@@ -122,10 +137,14 @@ import type { TagLibModule } from "./src/wasm.ts";
|
|
|
122
137
|
* // Manual module loading for advanced configuration
|
|
123
138
|
* const module = await loadTagLibModule();
|
|
124
139
|
* const taglib = await createTagLib(module);
|
|
140
|
+
*
|
|
141
|
+
* // With custom WASM binary
|
|
142
|
+
* const wasmData = await fetch("taglib.wasm").then(r => r.arrayBuffer());
|
|
143
|
+
* const module = await loadTagLibModule({ wasmBinary: wasmData });
|
|
125
144
|
* ```
|
|
126
145
|
*
|
|
127
146
|
* @note Most users should use `TagLib.initialize()` instead,
|
|
128
147
|
* which handles module loading automatically.
|
|
129
148
|
*/
|
|
130
|
-
export declare function loadTagLibModule(): Promise<TagLibModule>;
|
|
149
|
+
export declare function loadTagLibModule(options?: LoadTagLibOptions): Promise<TagLibModule>;
|
|
131
150
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH;;;;;GAKG;AACH,OAAO,EACL,aAAa,IAAI,SAAS,EAC1B,YAAY,EACZ,MAAM,GACP,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;GAUG;AACH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,aAAa,EACb,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;GAWG;AACH,OAAO,EACL,UAAU,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,oBAAoB,EACpB,WAAW,EACX,UAAU,GACX,MAAM,iBAAiB,CAAC;AAEzB;;;;;;GAMG;AACH,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,IAAI,GACL,MAAM,oBAAoB,CAAC;AAC5B;;;;;GAKG;AACH,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAE7B;;;;;GAKG;AACH,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH;;;;;GAKG;AACH,OAAO,EACL,aAAa,IAAI,SAAS,EAC1B,YAAY,EACZ,MAAM,GACP,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;GAUG;AACH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,aAAa,EACb,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;GAWG;AACH,OAAO,EACL,UAAU,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,oBAAoB,EACpB,WAAW,EACX,UAAU,GACX,MAAM,iBAAiB,CAAC;AAEzB;;;;;;GAMG;AACH,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,IAAI,GACL,MAAM,oBAAoB,CAAC;AAC5B;;;;;GAKG;AACH,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAE7B;;;;;GAKG;AACH,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;GAQG;AACH,YAAY,EACV,WAAW,EACX,eAAe,EACf,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,WAAW,EACX,GAAG,EACH,OAAO,GACR,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AACH,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IAEtC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CA0BzF"}
|
package/dist/index.js
CHANGED
|
@@ -68,9 +68,21 @@ import {
|
|
|
68
68
|
setCoverArtFromCanvas
|
|
69
69
|
} from "./src/web-utils.js";
|
|
70
70
|
import { PictureType } from "./src/types.js";
|
|
71
|
-
async function loadTagLibModule() {
|
|
71
|
+
async function loadTagLibModule(options) {
|
|
72
72
|
const { default: createTagLibModule } = await import("./taglib-wrapper.js");
|
|
73
|
-
const
|
|
73
|
+
const moduleConfig = {};
|
|
74
|
+
if (options?.wasmBinary) {
|
|
75
|
+
moduleConfig.wasmBinary = options.wasmBinary;
|
|
76
|
+
}
|
|
77
|
+
if (options?.wasmUrl) {
|
|
78
|
+
moduleConfig.locateFile = (path) => {
|
|
79
|
+
if (path.endsWith(".wasm")) {
|
|
80
|
+
return options.wasmUrl;
|
|
81
|
+
}
|
|
82
|
+
return path;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const module = await createTagLibModule(moduleConfig);
|
|
74
86
|
return module;
|
|
75
87
|
}
|
|
76
88
|
export {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Static module loader for Deno compile compatibility
|
|
3
|
+
*
|
|
4
|
+
* This module provides a version of taglib-wasm that uses static imports
|
|
5
|
+
* to ensure all dependencies are bundled during Deno compilation.
|
|
6
|
+
*/
|
|
7
|
+
import type { TagLibModule, LoadTagLibOptions } from "../index.ts";
|
|
8
|
+
/**
|
|
9
|
+
* Loads and initializes the TagLib WebAssembly module using static imports.
|
|
10
|
+
* This version ensures all dependencies are bundled during Deno compilation.
|
|
11
|
+
*
|
|
12
|
+
* @param options - Optional configuration for module loading
|
|
13
|
+
* @returns Promise resolving to initialized TagLib module
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Basic usage in Deno compiled binary
|
|
18
|
+
* const module = await loadTagLibModuleStatic();
|
|
19
|
+
*
|
|
20
|
+
* // With embedded WASM binary
|
|
21
|
+
* const wasmBinary = await Deno.readFile('./taglib.wasm');
|
|
22
|
+
* const module = await loadTagLibModuleStatic({ wasmBinary });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function loadTagLibModuleStatic(options?: LoadTagLibOptions): Promise<TagLibModule>;
|
|
26
|
+
export default loadTagLibModuleStatic;
|
|
27
|
+
//# sourceMappingURL=deno-compile-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deno-compile-loader.d.ts","sourceRoot":"","sources":["../../src/deno-compile-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKnE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CA8C/F;AAGD,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import createTagLibModule from "../build/taglib-wrapper.js";
|
|
2
|
+
let cachedModule = null;
|
|
3
|
+
async function loadTagLibModuleStatic(options) {
|
|
4
|
+
if (cachedModule && !options) {
|
|
5
|
+
return cachedModule;
|
|
6
|
+
}
|
|
7
|
+
const moduleConfig = {};
|
|
8
|
+
if (options?.wasmBinary) {
|
|
9
|
+
moduleConfig.wasmBinary = options.wasmBinary;
|
|
10
|
+
}
|
|
11
|
+
if (options?.wasmUrl) {
|
|
12
|
+
moduleConfig.locateFile = (path) => {
|
|
13
|
+
if (path.endsWith(".wasm")) {
|
|
14
|
+
return options.wasmUrl;
|
|
15
|
+
}
|
|
16
|
+
return path;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const module = await createTagLibModule(moduleConfig);
|
|
21
|
+
if (!module || !module.HEAPU8) {
|
|
22
|
+
throw new Error("Module not initialized: missing HEAPU8");
|
|
23
|
+
}
|
|
24
|
+
if (!module._malloc || !module.allocate) {
|
|
25
|
+
throw new Error("Module not initialized: missing memory allocation functions");
|
|
26
|
+
}
|
|
27
|
+
if (!options) {
|
|
28
|
+
cachedModule = module;
|
|
29
|
+
}
|
|
30
|
+
return module;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
33
|
+
throw new Error(`Failed to load TagLib module: ${message}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var deno_compile_loader_default = loadTagLibModuleStatic;
|
|
37
|
+
export {
|
|
38
|
+
deno_compile_loader_default as default,
|
|
39
|
+
loadTagLibModuleStatic
|
|
40
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Deno compile support for taglib-wasm
|
|
3
|
+
*
|
|
4
|
+
* This module provides utilities to make taglib-wasm work seamlessly
|
|
5
|
+
* with Deno compile by handling WASM loading appropriately.
|
|
6
|
+
*/
|
|
7
|
+
import type { LoadTagLibOptions } from "../index.ts";
|
|
8
|
+
/**
|
|
9
|
+
* Detects if running in a Deno compiled binary
|
|
10
|
+
*/
|
|
11
|
+
export declare function isDenoCompiled(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Enhanced WASM loading options for Deno compile
|
|
14
|
+
*/
|
|
15
|
+
export interface DenoCompileOptions extends LoadTagLibOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Path to WASM file for runtime loading (not compiled binaries)
|
|
18
|
+
*/
|
|
19
|
+
wasmPath?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Fallback URL if local WASM is not found
|
|
22
|
+
*/
|
|
23
|
+
fallbackUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Smart WASM loader that handles both development and compiled environments
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* // In your application
|
|
31
|
+
* import { TagLib } from "taglib-wasm";
|
|
32
|
+
* import { loadWasmForDeno } from "taglib-wasm/deno-compile-support";
|
|
33
|
+
*
|
|
34
|
+
* const wasmBinary = await loadWasmForDeno();
|
|
35
|
+
* const taglib = await TagLib.initialize({ wasmBinary });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function loadWasmForDeno(options?: DenoCompileOptions): Promise<Uint8Array | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Simplified initialization for Deno applications
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* import { initializeForDeno } from "taglib-wasm/deno-compile-support";
|
|
45
|
+
*
|
|
46
|
+
* // Works in development, production, and compiled binaries
|
|
47
|
+
* const taglib = await initializeForDeno();
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function initializeForDeno(options?: DenoCompileOptions): Promise<import("./mod.ts").TagLib>;
|
|
51
|
+
//# sourceMappingURL=deno-compile-support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deno-compile-support.d.ts","sourceRoot":"","sources":["../../src/deno-compile-support.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAIxC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAwCvG;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,sCAcvE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function isDenoCompiled() {
|
|
2
|
+
return typeof Deno !== "undefined" && Deno.mainModule?.startsWith("file:///") && Deno.execPath()?.includes("deno") === false;
|
|
3
|
+
}
|
|
4
|
+
async function loadWasmForDeno(options = {}) {
|
|
5
|
+
const strategies = [
|
|
6
|
+
// 1. User-provided binary
|
|
7
|
+
async () => options.wasmBinary,
|
|
8
|
+
// 2. Local file (development)
|
|
9
|
+
async () => {
|
|
10
|
+
if (typeof Deno !== "undefined" && !isDenoCompiled()) {
|
|
11
|
+
try {
|
|
12
|
+
const path = options.wasmPath || "./build/taglib.wasm";
|
|
13
|
+
return await Deno.readFile(path);
|
|
14
|
+
} catch {
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
// 3. Fetch from URL
|
|
19
|
+
async () => {
|
|
20
|
+
const url = options.wasmUrl || options.fallbackUrl || "https://cdn.jsdelivr.net/npm/taglib-wasm@latest/dist/taglib.wasm";
|
|
21
|
+
try {
|
|
22
|
+
const response = await fetch(url);
|
|
23
|
+
if (response.ok) {
|
|
24
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
25
|
+
}
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
];
|
|
30
|
+
for (const strategy of strategies) {
|
|
31
|
+
const result = await strategy();
|
|
32
|
+
if (result) return result;
|
|
33
|
+
}
|
|
34
|
+
return void 0;
|
|
35
|
+
}
|
|
36
|
+
async function initializeForDeno(options = {}) {
|
|
37
|
+
const { TagLib } = await import("../src/taglib.js");
|
|
38
|
+
const wasmBinary = await loadWasmForDeno(options);
|
|
39
|
+
if (!wasmBinary) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
"Failed to load WASM module. For compiled binaries, either bundle the WASM or ensure network access."
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return TagLib.initialize({ wasmBinary });
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
initializeForDeno,
|
|
48
|
+
isDenoCompiled,
|
|
49
|
+
loadWasmForDeno
|
|
50
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Helper utilities for using taglib-wasm in Deno compiled binaries
|
|
3
|
+
*
|
|
4
|
+
* This module provides simplified initialization for offline usage in compiled
|
|
5
|
+
* Deno binaries, with automatic detection and embedded WASM loading.
|
|
6
|
+
*
|
|
7
|
+
* @module taglib-wasm/deno-compile
|
|
8
|
+
*/
|
|
9
|
+
import { TagLib } from "./taglib.ts";
|
|
10
|
+
/**
|
|
11
|
+
* Detects if the code is running in a compiled Deno binary.
|
|
12
|
+
*
|
|
13
|
+
* @returns true if running in a Deno compiled binary, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
export declare function isDenoCompiled(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Initialize TagLib with automatic handling for Deno compiled binaries.
|
|
18
|
+
*
|
|
19
|
+
* In compiled binaries, this function attempts to load embedded WASM from a
|
|
20
|
+
* specified path relative to the binary. If the embedded WASM is not found
|
|
21
|
+
* or if running in development mode, it falls back to network fetch.
|
|
22
|
+
*
|
|
23
|
+
* @param embeddedWasmPath - Path to embedded WASM file (default: './taglib.wasm')
|
|
24
|
+
* @returns Promise resolving to initialized TagLib instance
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Basic usage with default path
|
|
29
|
+
* const taglib = await initializeForDenoCompile();
|
|
30
|
+
*
|
|
31
|
+
* // Custom embedded WASM path
|
|
32
|
+
* const taglib = await initializeForDenoCompile('./assets/taglib.wasm');
|
|
33
|
+
*
|
|
34
|
+
* // Compile command:
|
|
35
|
+
* // deno compile --allow-read --include taglib.wasm myapp.ts
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function initializeForDenoCompile(embeddedWasmPath?: string): Promise<TagLib>;
|
|
39
|
+
/**
|
|
40
|
+
* Helper function to prepare a WASM file for embedding in a compiled binary.
|
|
41
|
+
* This function copies the WASM file from node_modules to a local path.
|
|
42
|
+
*
|
|
43
|
+
* @param outputPath - Where to save the WASM file (default: './taglib.wasm')
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* // In your build script:
|
|
48
|
+
* await prepareWasmForEmbedding('./assets/taglib.wasm');
|
|
49
|
+
*
|
|
50
|
+
* // Then compile with:
|
|
51
|
+
* // deno compile --allow-read --include assets/taglib.wasm myapp.ts
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function prepareWasmForEmbedding(outputPath?: string): Promise<void>;
|
|
55
|
+
//# sourceMappingURL=deno-compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deno-compile.d.ts","sourceRoot":"","sources":["../../src/deno-compile.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAQxC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,wBAAwB,CAC5C,gBAAgB,SAAkB,GACjC,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,uBAAuB,CAAC,UAAU,SAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCzF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { TagLib } from "./taglib.js";
|
|
2
|
+
function isDenoCompiled() {
|
|
3
|
+
return typeof Deno !== "undefined" && // @ts-ignore: Deno global is only available in Deno runtime
|
|
4
|
+
typeof Deno.mainModule === "string" && // @ts-ignore: Deno global is only available in Deno runtime
|
|
5
|
+
Deno.mainModule.includes("deno-compile://");
|
|
6
|
+
}
|
|
7
|
+
async function initializeForDenoCompile(embeddedWasmPath = "./taglib.wasm") {
|
|
8
|
+
if (isDenoCompiled()) {
|
|
9
|
+
try {
|
|
10
|
+
const wasmUrl = new URL(embeddedWasmPath, import.meta.url);
|
|
11
|
+
const wasmBinary = await Deno.readFile(wasmUrl);
|
|
12
|
+
return await TagLib.initialize({ wasmBinary });
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.warn(`Could not load embedded WASM from ${embeddedWasmPath}:`, error);
|
|
15
|
+
console.warn("Falling back to network fetch (requires --allow-net)");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return await TagLib.initialize();
|
|
19
|
+
}
|
|
20
|
+
async function prepareWasmForEmbedding(outputPath = "./taglib.wasm") {
|
|
21
|
+
try {
|
|
22
|
+
const possiblePaths = [
|
|
23
|
+
new URL("../dist/taglib.wasm", import.meta.url),
|
|
24
|
+
new URL("../build/taglib.wasm", import.meta.url),
|
|
25
|
+
new URL("./node_modules/taglib-wasm/dist/taglib.wasm", import.meta.url)
|
|
26
|
+
];
|
|
27
|
+
let wasmData = null;
|
|
28
|
+
let sourcePath = null;
|
|
29
|
+
for (const path of possiblePaths) {
|
|
30
|
+
try {
|
|
31
|
+
wasmData = await Deno.readFile(path);
|
|
32
|
+
sourcePath = path.pathname;
|
|
33
|
+
break;
|
|
34
|
+
} catch {
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (!wasmData || !sourcePath) {
|
|
38
|
+
throw new Error("Could not find taglib.wasm in expected locations");
|
|
39
|
+
}
|
|
40
|
+
await Deno.writeFile(outputPath, wasmData);
|
|
41
|
+
console.log(`WASM file copied from ${sourcePath} to ${outputPath}`);
|
|
42
|
+
console.log(`Include this file when compiling: deno compile --include ${outputPath} ...`);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
45
|
+
throw new Error(`Failed to prepare WASM for embedding: ${message}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
initializeForDenoCompile,
|
|
50
|
+
isDenoCompiled,
|
|
51
|
+
prepareWasmForEmbedding
|
|
52
|
+
};
|
package/dist/src/taglib.d.ts
CHANGED
|
@@ -398,18 +398,29 @@ export declare class TagLib {
|
|
|
398
398
|
private module;
|
|
399
399
|
constructor(module: WasmModule);
|
|
400
400
|
/**
|
|
401
|
-
* Initialize TagLib with
|
|
401
|
+
* Initialize TagLib with optional configuration.
|
|
402
402
|
* This is the recommended way to create a TagLib instance.
|
|
403
403
|
*
|
|
404
|
+
* @param options - Optional configuration for loading the WASM module
|
|
404
405
|
* @returns Promise resolving to initialized TagLib instance
|
|
405
406
|
*
|
|
406
407
|
* @example
|
|
407
408
|
* ```typescript
|
|
409
|
+
* // Basic usage
|
|
408
410
|
* const taglib = await TagLib.initialize();
|
|
409
|
-
*
|
|
411
|
+
*
|
|
412
|
+
* // With pre-loaded WASM binary (for offline usage)
|
|
413
|
+
* const wasmBinary = await fetch("taglib.wasm").then(r => r.arrayBuffer());
|
|
414
|
+
* const taglib = await TagLib.initialize({ wasmBinary });
|
|
415
|
+
*
|
|
416
|
+
* // With custom WASM URL
|
|
417
|
+
* const taglib = await TagLib.initialize({ wasmUrl: "/assets/taglib.wasm" });
|
|
410
418
|
* ```
|
|
411
419
|
*/
|
|
412
|
-
static initialize(
|
|
420
|
+
static initialize(options?: {
|
|
421
|
+
wasmBinary?: ArrayBuffer | Uint8Array;
|
|
422
|
+
wasmUrl?: string;
|
|
423
|
+
}): Promise<TagLib>;
|
|
413
424
|
/**
|
|
414
425
|
* Open an audio file from various sources.
|
|
415
426
|
* Automatically detects the file format based on content.
|
package/dist/src/taglib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taglib.d.ts","sourceRoot":"","sources":["../../src/taglib.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EACV,eAAe,EACf,QAAQ,EACR,OAAO,EACP,WAAW,EACX,GAAG,IAAI,QAAQ,EAChB,MAAM,YAAY,CAAC;AAUpB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,GAAI,SAAQ,QAAQ;IACnC,0BAA0B;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,0BAA0B;IAC1B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,yBAAyB;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,sBAAsB;IACtB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,oBAAoB;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,2BAA2B;IAC3B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;;;;;;;;;;;;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gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,aAAa,EACb,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,aAAa,CAAC"}
|
package/dist/src/taglib.js
CHANGED
|
@@ -310,20 +310,28 @@ class TagLib {
|
|
|
310
310
|
this.module = module;
|
|
311
311
|
}
|
|
312
312
|
/**
|
|
313
|
-
* Initialize TagLib with
|
|
313
|
+
* Initialize TagLib with optional configuration.
|
|
314
314
|
* This is the recommended way to create a TagLib instance.
|
|
315
315
|
*
|
|
316
|
+
* @param options - Optional configuration for loading the WASM module
|
|
316
317
|
* @returns Promise resolving to initialized TagLib instance
|
|
317
318
|
*
|
|
318
319
|
* @example
|
|
319
320
|
* ```typescript
|
|
321
|
+
* // Basic usage
|
|
320
322
|
* const taglib = await TagLib.initialize();
|
|
321
|
-
*
|
|
323
|
+
*
|
|
324
|
+
* // With pre-loaded WASM binary (for offline usage)
|
|
325
|
+
* const wasmBinary = await fetch("taglib.wasm").then(r => r.arrayBuffer());
|
|
326
|
+
* const taglib = await TagLib.initialize({ wasmBinary });
|
|
327
|
+
*
|
|
328
|
+
* // With custom WASM URL
|
|
329
|
+
* const taglib = await TagLib.initialize({ wasmUrl: "/assets/taglib.wasm" });
|
|
322
330
|
* ```
|
|
323
331
|
*/
|
|
324
|
-
static async initialize() {
|
|
332
|
+
static async initialize(options) {
|
|
325
333
|
const { loadTagLibModule } = await import("../index.js");
|
|
326
|
-
const module = await loadTagLibModule();
|
|
334
|
+
const module = await loadTagLibModule(options);
|
|
327
335
|
return new TagLib(module);
|
|
328
336
|
}
|
|
329
337
|
/**
|
package/dist/src/types.d.ts
CHANGED
|
@@ -301,12 +301,12 @@ export declare const BITRATE_CONTROL_MODE_VALUES: Record<BitrateControlMode, num
|
|
|
301
301
|
*/
|
|
302
302
|
export declare const BITRATE_CONTROL_MODE_NAMES: Record<number, BitrateControlMode>;
|
|
303
303
|
/**
|
|
304
|
-
* Configuration options for TagLib initialization.
|
|
304
|
+
* Configuration options for TagLib Workers initialization.
|
|
305
305
|
* Allows customization of memory limits and debug settings.
|
|
306
306
|
*
|
|
307
307
|
* @example
|
|
308
308
|
* ```typescript
|
|
309
|
-
* const config:
|
|
309
|
+
* const config: TagLibWorkersConfig = {
|
|
310
310
|
* memory: {
|
|
311
311
|
* initial: 16 * 1024 * 1024, // 16MB
|
|
312
312
|
* maximum: 64 * 1024 * 1024 // 64MB
|
|
@@ -317,7 +317,7 @@ export declare const BITRATE_CONTROL_MODE_NAMES: Record<number, BitrateControlMo
|
|
|
317
317
|
* const taglib = await TagLibWorkers.initialize(wasmBinary, config);
|
|
318
318
|
* ```
|
|
319
319
|
*/
|
|
320
|
-
export interface
|
|
320
|
+
export interface TagLibWorkersConfig {
|
|
321
321
|
/** Memory allocation settings */
|
|
322
322
|
memory?: {
|
|
323
323
|
/** Initial memory size in bytes */
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,QAAQ,GAChB,KAAK,GACL,KAAK,GACL,MAAM,GACN,KAAK,GACL,MAAM,GACN,KAAK,GACL,MAAM,GACN,SAAS,CAAC;AAEd;;;;GAIG;AACH,MAAM,MAAM,WAAW,GACnB,KAAK,GACL,KAAK,GACL,KAAK,GACL,MAAM,GACN,KAAK,GACL,MAAM,GACN,KAAK,GACL,MAAM,GACN,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,KAAK,GACL,IAAI,CAA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B,KAAK;IACvB,YAAY,KAAK;IACjB,YAAY,KAAK;IACjB,QAAQ,KAAK;IACb,aAAa,KAAK;CACnB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAC1B,UAAU,GACV,iBAAiB,GACjB,qBAAqB,GACrB,UAAU,CAAC;AAEf;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAK1E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAKzE,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,mBAAmB;IAClC,iCAAiC;IACjC,MAAM,CAAC,EAAE;QACP,mCAAmC;QACnC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,mCAAmC;QACnC,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,0BAA0B;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/utils/write.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/utils/write.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,IAAI,CAAC,CA6Cf"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview WebAssembly module interface for Cloudflare Workers
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { TagLibModule, TagLibWorkersConfig } from "./types.ts";
|
|
5
5
|
export type { TagLibModule };
|
|
6
6
|
/**
|
|
7
7
|
* Load and initialize the TagLib WebAssembly module for Cloudflare Workers
|
|
@@ -17,7 +17,7 @@ export type { TagLibModule };
|
|
|
17
17
|
* const taglib = await loadTagLibModuleForWorkers(wasmBinary);
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
export declare function loadTagLibModuleForWorkers(wasmBinary: Uint8Array, config?:
|
|
20
|
+
export declare function loadTagLibModuleForWorkers(wasmBinary: Uint8Array, config?: TagLibWorkersConfig): Promise<TagLibModule>;
|
|
21
21
|
/**
|
|
22
22
|
* Convert a C string pointer to JavaScript string (Workers-compatible)
|
|
23
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm-workers.d.ts","sourceRoot":"","sources":["../../src/wasm-workers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"wasm-workers.d.ts","sourceRoot":"","sources":["../../src/wasm-workers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAIpE,YAAY,EAAE,YAAY,EAAE,CAAC;AAc7B;;;;;;;;;;;;;GAaG;AACH,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,UAAU,EACtB,MAAM,GAAE,mBAAwB,GAC/B,OAAO,CAAC,YAAY,CAAC,CAkEvB;AA4BD;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQrE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAYrE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAS7C"}
|
package/dist/src/wasm-workers.js
CHANGED
|
@@ -13,8 +13,8 @@ async function loadTagLibModuleForWorkers(wasmBinary, config = {}) {
|
|
|
13
13
|
const moduleConfig = {
|
|
14
14
|
wasmBinary,
|
|
15
15
|
wasmMemory: new WebAssembly.Memory({
|
|
16
|
-
initial: mergedConfig.memory
|
|
17
|
-
maximum: mergedConfig.memory
|
|
16
|
+
initial: (mergedConfig.memory?.initial || 8 * 1024 * 1024) / (64 * 1024),
|
|
17
|
+
maximum: (mergedConfig.memory?.maximum || 64 * 1024 * 1024) / (64 * 1024)
|
|
18
18
|
}),
|
|
19
19
|
print: mergedConfig.debug ? console.log : () => {
|
|
20
20
|
},
|
package/dist/src/workers.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module taglib-wasm/workers
|
|
9
9
|
*/
|
|
10
|
-
import type { AudioFormat, AudioProperties, ExtendedTag, Tag,
|
|
10
|
+
import type { AudioFormat, AudioProperties, ExtendedTag, Tag, TagLibWorkersConfig } from "./types.ts";
|
|
11
11
|
import { type TagLibModule } from "./wasm-workers.ts";
|
|
12
12
|
/**
|
|
13
13
|
* Represents an audio file with metadata and properties (Workers-compatible).
|
|
@@ -158,7 +158,7 @@ export declare class TagLibWorkers {
|
|
|
158
158
|
* const metadata = file.tag();
|
|
159
159
|
* ```
|
|
160
160
|
*/
|
|
161
|
-
static initialize(wasmBinary: Uint8Array, config?:
|
|
161
|
+
static initialize(wasmBinary: Uint8Array, config?: TagLibWorkersConfig): Promise<TagLibWorkers>;
|
|
162
162
|
/**
|
|
163
163
|
* Open an audio file from a buffer.
|
|
164
164
|
*
|
|
@@ -205,7 +205,7 @@ export declare class TagLibWorkers {
|
|
|
205
205
|
* };
|
|
206
206
|
* ```
|
|
207
207
|
*/
|
|
208
|
-
export declare function processAudioMetadata(wasmBinary: Uint8Array, audioData: Uint8Array, config?:
|
|
208
|
+
export declare function processAudioMetadata(wasmBinary: Uint8Array, audioData: Uint8Array, config?: TagLibWorkersConfig): Promise<{
|
|
209
209
|
tag: Tag;
|
|
210
210
|
properties: AudioProperties | null;
|
|
211
211
|
format: AudioFormat;
|
|
@@ -215,5 +215,5 @@ export declare function processAudioMetadata(wasmBinary: Uint8Array, audioData:
|
|
|
215
215
|
* These types define the structure of metadata, audio properties,
|
|
216
216
|
* and configuration options.
|
|
217
217
|
*/
|
|
218
|
-
export type { AudioFormat, AudioProperties, ExtendedTag, Tag,
|
|
218
|
+
export type { AudioFormat, AudioProperties, ExtendedTag, Tag, TagLibWorkersConfig, };
|
|
219
219
|
//# sourceMappingURL=workers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../src/workers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,WAAW,EACX,GAAG,EACH,
|
|
1
|
+
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../src/workers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,WAAW,EACX,GAAG,EACH,mBAAmB,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;AAG3B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAS;gBAEb,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IAOhD;;;OAGG;IACH,OAAO,IAAI,OAAO;IAIlB;;;OAGG;IACH,MAAM,IAAI,WAAW;IAOrB;;;OAGG;IACH,GAAG,IAAI,GAAG;IAsBV;;;OAGG;IACH,eAAe,IAAI,eAAe,GAAG,IAAI;IAyBzC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAO7B;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAO/B;;;OAGG;IACH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ED;;;;GAIG;AACH,YAAY,EACV,WAAW,EACX,eAAe,EACf,WAAW,EACX,GAAG,EACH,mBAAmB,GACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "taglib-wasm",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.23",
|
|
4
4
|
"description": "TagLib for TypeScript platforms: Deno, Node.js, Bun, Electron, browsers, and Cloudflare Workers",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build:wasm": "./build/build-wasm.sh",
|
|
28
|
-
"build:ts": "tsc &&
|
|
29
|
-
"postbuild": "
|
|
28
|
+
"build:ts": "tsc && deno run --allow-read --allow-write --allow-run --allow-env --unstable-detect-cjs scripts/build-js.js",
|
|
29
|
+
"postbuild": "deno run --allow-read --allow-write --allow-run --allow-env scripts/postbuild.js",
|
|
30
30
|
"build": "npm run build:wasm && npm run build:ts && npm run postbuild",
|
|
31
31
|
"test": "deno test --allow-read --allow-write tests/",
|
|
32
32
|
"test:all": "deno test --allow-read --allow-write tests/index.test.ts",
|
package/README.md
DELETED
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
# TagLib-Wasm
|
|
2
|
-
|
|
3
|
-
[](https://github.com/CharlesWiltgen/taglib-wasm/actions/workflows/test.yml)
|
|
4
|
-
[](https://www.npmjs.com/package/taglib-wasm)
|
|
5
|
-
[](https://www.npmjs.com/package/taglib-wasm)
|
|
6
|
-
[](https://github.com/CharlesWiltgen/taglib-wasm/blob/main/LICENSE)
|
|
7
|
-
<br>[](https://www.typescriptlang.org/)
|
|
8
|
-
[](https://emscripten.org/)
|
|
9
|
-
[](https://webassembly.org/)
|
|
10
|
-
[](https://taglib.org/)
|
|
11
|
-
<br>[](https://deno.land/)
|
|
12
|
-
[](https://nodejs.org/)
|
|
13
|
-
[](https://bun.sh/)
|
|
14
|
-
[](https://workers.cloudflare.com/)
|
|
15
|
-
[](https://www.electronjs.org/)
|
|
16
|
-
[](https://html.spec.whatwg.org/multipage/)
|
|
17
|
-
|
|
18
|
-
TagLib-Wasm is the **universal tagging library for TypeScript/JavaScript**
|
|
19
|
-
(TS|JS) platforms: **Deno**, **Node.js**, **Bun**, **Cloudflare Workers**,
|
|
20
|
-
**Electron**, and **browsers**.
|
|
21
|
-
|
|
22
|
-
This project exists because the TS|JS ecosystem had no battle-tested audio
|
|
23
|
-
tagging library that supports reading and writing music metadata to all popular
|
|
24
|
-
audio formats. It aspires to be a universal solution for all TS|JS-capable
|
|
25
|
-
platforms — Deno, Node.js, Bun, Electron, Cloudflare Workers, and browsers.
|
|
26
|
-
|
|
27
|
-
TagLib-Wasm stands on the shoulders of giants, including
|
|
28
|
-
[TagLib](https://taglib.org/) itself, [Emscripten](https://emscripten.org/), and
|
|
29
|
-
[Wasm](https://webassembly.org/) ([WebAssembly](https://webassembly.org/)).
|
|
30
|
-
TagLib itself is legendary, and a core dependency of many music apps.
|
|
31
|
-
|
|
32
|
-
## 🎯 Features
|
|
33
|
-
|
|
34
|
-
- **✅ Full audio format support** – Supports all audio formats supported by
|
|
35
|
-
TagLib
|
|
36
|
-
- **✅ TypeScript first** – Complete type definitions and modern API
|
|
37
|
-
- **✅ Wide TS/JS runtime support** – Deno, Node.js, Bun, Electron, Cloudflare
|
|
38
|
-
Workers, and browsers
|
|
39
|
-
- **✅ Format abstraction** – Handles container format details automagically
|
|
40
|
-
when possible
|
|
41
|
-
- **✅ Zero dependencies** – Self-contained Wasm bundle
|
|
42
|
-
- **✅ Production ready** – Growing test suite helps ensure safety and
|
|
43
|
-
reliability
|
|
44
|
-
- **✅ Two API styles** – Use the “Simple” API (3 functions), or the full “Core”
|
|
45
|
-
API for more advanced applications
|
|
46
|
-
|
|
47
|
-
## 📦 Installation
|
|
48
|
-
|
|
49
|
-
### Deno
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
import { TagLib } from "npm:taglib-wasm";
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Node.js
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
npm install taglib-wasm
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
> **Note:** Requires Node.js v22.6.0 or higher. If you want to use the
|
|
62
|
-
> TypeScript version with Node.js, see the
|
|
63
|
-
> [installation guide](https://charleswiltgen.github.io/taglib-wasm/guide/installation.html).
|
|
64
|
-
|
|
65
|
-
### Bun
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
bun add taglib-wasm
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Electron
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
npm install taglib-wasm
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Works in both main and renderer processes:
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
// Main process
|
|
81
|
-
import { TagLib } from "taglib-wasm";
|
|
82
|
-
|
|
83
|
-
// Renderer process (with nodeIntegration: true)
|
|
84
|
-
const { TagLib } = require("taglib-wasm");
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## 🚀 Quick Start
|
|
88
|
-
|
|
89
|
-
### Simple API
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
import { applyTags, readTags, updateTags } from "taglib-wasm/simple";
|
|
93
|
-
|
|
94
|
-
// Read tags - just one function call!
|
|
95
|
-
const tags = await readTags("song.mp3");
|
|
96
|
-
console.log(tags.title, tags.artist, tags.album);
|
|
97
|
-
|
|
98
|
-
// Apply tags and get modified buffer (in-memory)
|
|
99
|
-
const modifiedBuffer = await applyTags("song.mp3", {
|
|
100
|
-
title: "New Title",
|
|
101
|
-
artist: "New Artist",
|
|
102
|
-
album: "New Album",
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
// Or update tags on disk (requires file path)
|
|
106
|
-
await updateTags("song.mp3", {
|
|
107
|
-
title: "New Title",
|
|
108
|
-
artist: "New Artist",
|
|
109
|
-
});
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Core API
|
|
113
|
-
|
|
114
|
-
The full Core API might be a better choice for apps and utilities focused on
|
|
115
|
-
advanced metadata management.
|
|
116
|
-
|
|
117
|
-
```typescript
|
|
118
|
-
import { TagLib } from "taglib-wasm";
|
|
119
|
-
|
|
120
|
-
// Initialize taglib-wasm
|
|
121
|
-
const taglib = await TagLib.initialize();
|
|
122
|
-
|
|
123
|
-
// Load audio file
|
|
124
|
-
const file = await taglib.open("song.mp3");
|
|
125
|
-
|
|
126
|
-
// Read and update metadata
|
|
127
|
-
const tag = file.tag();
|
|
128
|
-
tag.setTitle("New Title");
|
|
129
|
-
tag.setArtist("New Artist");
|
|
130
|
-
|
|
131
|
-
// Save changes
|
|
132
|
-
file.save();
|
|
133
|
-
|
|
134
|
-
// Clean up
|
|
135
|
-
file.dispose();
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Working with Cover Art
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
import { getCoverArt, setCoverArt } from "taglib-wasm/simple";
|
|
142
|
-
|
|
143
|
-
// Extract cover art
|
|
144
|
-
const coverData = await getCoverArt("song.mp3");
|
|
145
|
-
if (coverData) {
|
|
146
|
-
await Deno.writeFile("cover.jpg", coverData);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Set new cover art
|
|
150
|
-
const imageData = await Deno.readFile("new-cover.jpg");
|
|
151
|
-
const modifiedBuffer = await setCoverArt("song.mp3", imageData, "image/jpeg");
|
|
152
|
-
// Save modifiedBuffer to file if needed
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### Codec Detection and Audio Properties
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
import { readProperties } from "taglib-wasm/simple";
|
|
159
|
-
|
|
160
|
-
// Get detailed audio properties including codec info
|
|
161
|
-
const props = await readProperties("song.m4a");
|
|
162
|
-
|
|
163
|
-
console.log(props.codec); // "AAC" or "ALAC"
|
|
164
|
-
console.log(props.isLossless); // false for AAC, true for ALAC
|
|
165
|
-
console.log(props.bitsPerSample); // 16 for most formats
|
|
166
|
-
console.log(props.bitrate); // 256 (kbps)
|
|
167
|
-
console.log(props.sampleRate); // 44100 (Hz)
|
|
168
|
-
console.log(props.length); // 180 (duration in seconds)
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
Supported codec detection:
|
|
172
|
-
- **MP3** – Returns "MP3" (lossy)
|
|
173
|
-
- **M4A/MP4** – Distinguishes between "AAC" (lossy) and "ALAC" (lossless)
|
|
174
|
-
- **FLAC** – Returns "FLAC" (lossless)
|
|
175
|
-
- **OGG** – Returns "Vorbis" (lossy) or "Opus" (lossy)
|
|
176
|
-
- **WAV** – Returns "PCM" (uncompressed)
|
|
177
|
-
|
|
178
|
-
## 📚 Documentation
|
|
179
|
-
|
|
180
|
-
**[📖 View Full Documentation](https://charleswiltgen.github.io/taglib-wasm/)**
|
|
181
|
-
|
|
182
|
-
### Getting Started
|
|
183
|
-
|
|
184
|
-
- [Installation Guide](https://charleswiltgen.github.io/taglib-wasm/guide/installation.html)
|
|
185
|
-
- [Quick Start Tutorial](https://charleswiltgen.github.io/taglib-wasm/guide/quick-start.html)
|
|
186
|
-
- [All Examples](https://charleswiltgen.github.io/taglib-wasm/guide/examples.html)
|
|
187
|
-
|
|
188
|
-
### Guides
|
|
189
|
-
|
|
190
|
-
- [API Reference](https://charleswiltgen.github.io/taglib-wasm/API.html)
|
|
191
|
-
- [Platform Examples](https://charleswiltgen.github.io/taglib-wasm/guide/platform-examples.html)
|
|
192
|
-
- [Working with Cover Art](https://charleswiltgen.github.io/taglib-wasm/guide/cover-art.html)
|
|
193
|
-
- [Cloudflare Workers Setup](https://charleswiltgen.github.io/taglib-wasm/guide/workers-setup.html)
|
|
194
|
-
- [Error Handling](https://charleswiltgen.github.io/taglib-wasm/Error-Handling.html)
|
|
195
|
-
|
|
196
|
-
### Development
|
|
197
|
-
|
|
198
|
-
- [Testing Guide](https://charleswiltgen.github.io/taglib-wasm/development/testing.html)
|
|
199
|
-
- [Future Improvements](https://charleswiltgen.github.io/taglib-wasm/development/improvements.html)
|
|
200
|
-
- [Contributing](https://charleswiltgen.github.io/taglib-wasm/CONTRIBUTING.html)
|
|
201
|
-
|
|
202
|
-
## 📋 Supported Formats
|
|
203
|
-
|
|
204
|
-
`taglib-wasm` is designed to support all formats supported by TagLib:
|
|
205
|
-
|
|
206
|
-
- ✅ **.mp3** – ID3v2 and ID3v1 tags
|
|
207
|
-
- ✅ **.m4a/.mp4** – MPEG-4/AAC metadata for AAC and Apple Lossless audio
|
|
208
|
-
- ✅ **.flac** – Vorbis comments and audio properties
|
|
209
|
-
- ✅ **.ogg** – Ogg Vorbis format with full metadata support
|
|
210
|
-
- ✅ **.wav** – INFO chunk metadata
|
|
211
|
-
- ✅ **Additional formats** – Opus, APE, MPC, WavPack, TrueAudio, AIFF, WMA, and
|
|
212
|
-
more
|
|
213
|
-
|
|
214
|
-
## 🎯 Key Features
|
|
215
|
-
|
|
216
|
-
### Extended Metadata Support
|
|
217
|
-
|
|
218
|
-
Beyond basic tags, taglib-wasm supports extended metadata:
|
|
219
|
-
|
|
220
|
-
```typescript
|
|
221
|
-
import { Tags } from "taglib-wasm";
|
|
222
|
-
|
|
223
|
-
// AcoustID fingerprints
|
|
224
|
-
file.setProperty(
|
|
225
|
-
Tags.AcoustidFingerprint,
|
|
226
|
-
"AQADtMmybfGO8NCNEESLnzHyXNOHeHnG...",
|
|
227
|
-
);
|
|
228
|
-
|
|
229
|
-
// MusicBrainz IDs
|
|
230
|
-
file.setProperty(
|
|
231
|
-
Tags.MusicBrainzTrackId,
|
|
232
|
-
"f4d1b6b8-8c1e-4d9a-9f2a-1234567890ab",
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
// ReplayGain volume normalization
|
|
236
|
-
file.setProperty(Tags.TrackGain, "-6.54 dB");
|
|
237
|
-
file.setProperty(Tags.TrackPeak, "0.987654");
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
[View all supported tag constants →](https://charleswiltgen.github.io/taglib-wasm/Tag-Name-Constants.html)
|
|
241
|
-
|
|
242
|
-
## 🏗️ Development
|
|
243
|
-
|
|
244
|
-
### Build from Source
|
|
245
|
-
|
|
246
|
-
```bash
|
|
247
|
-
# Prerequisites: Emscripten SDK
|
|
248
|
-
# Install via: https://emscripten.org/docs/getting_started/downloads.html
|
|
249
|
-
|
|
250
|
-
# Clone and build
|
|
251
|
-
git clone https://github.com/CharlesWiltgen/taglib-wasm.git
|
|
252
|
-
cd taglib-wasm
|
|
253
|
-
|
|
254
|
-
# Build Wasm module
|
|
255
|
-
npm run build:wasm
|
|
256
|
-
|
|
257
|
-
# Run tests
|
|
258
|
-
npm test
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
[View full development guide →](CONTRIBUTING.md)
|
|
262
|
-
|
|
263
|
-
## 🌐 Runtime Compatibility
|
|
264
|
-
|
|
265
|
-
`taglib-wasm` works across all major JavaScript runtimes:
|
|
266
|
-
|
|
267
|
-
| Runtime | Status | Installation | Notes |
|
|
268
|
-
| ---------------------- | ------- | ------------------------- | ------------------------- |
|
|
269
|
-
| **Deno** | ✅ Full | `npm:taglib-wasm` | Native TypeScript |
|
|
270
|
-
| **Node.js** | ✅ Full | `npm install taglib-wasm` | TypeScript via tsx |
|
|
271
|
-
| **Bun** | ✅ Full | `bun add taglib-wasm` | Native TypeScript |
|
|
272
|
-
| **Browser** | ✅ Full | Via bundler | Full API support |
|
|
273
|
-
| **Cloudflare Workers** | ✅ Full | `taglib-wasm/workers` | Memory-optimized build |
|
|
274
|
-
| **Electron** | ✅ Full | `npm install taglib-wasm` | Main & renderer processes |
|
|
275
|
-
|
|
276
|
-
## 🚧 Known Limitations
|
|
277
|
-
|
|
278
|
-
- **Memory Usage** – Entire file must be loaded into memory (may be an issue for
|
|
279
|
-
very large files)
|
|
280
|
-
- **Concurrent Access** – Not thread-safe (JavaScript single-threaded nature
|
|
281
|
-
mitigates this)
|
|
282
|
-
- **Cloudflare Workers** – Limited to 128MB memory per request; files larger
|
|
283
|
-
than ~100MB may fail
|
|
284
|
-
|
|
285
|
-
## 🤝 Contributing
|
|
286
|
-
|
|
287
|
-
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md)
|
|
288
|
-
for details on our code of conduct and the process for submitting pull requests.
|
|
289
|
-
|
|
290
|
-
## 📄 License
|
|
291
|
-
|
|
292
|
-
This project uses dual licensing:
|
|
293
|
-
|
|
294
|
-
- **TypeScript/JavaScript code** – MIT License (see [LICENSE](LICENSE))
|
|
295
|
-
- **WebAssembly binary (taglib.wasm)** – LGPL-2.1-or-later (inherited from
|
|
296
|
-
TagLib)
|
|
297
|
-
|
|
298
|
-
The TagLib library is dual-licensed under LGPL/MPL. When compiled to
|
|
299
|
-
WebAssembly, the resulting binary must comply with LGPL requirements. This
|
|
300
|
-
means:
|
|
301
|
-
|
|
302
|
-
- You can use taglib-wasm in commercial projects
|
|
303
|
-
- If you modify the TagLib C++ code, you must share those changes
|
|
304
|
-
- You must provide a way for users to relink with a modified TagLib
|
|
305
|
-
|
|
306
|
-
For details, see [lib/taglib/COPYING.LGPL](lib/taglib/COPYING.LGPL)
|
|
307
|
-
|
|
308
|
-
## 🙏 Acknowledgments
|
|
309
|
-
|
|
310
|
-
- [TagLib](https://taglib.org/) – Excellent audio metadata library
|
|
311
|
-
- [Emscripten](https://emscripten.org/) – WebAssembly compilation toolchain
|