taglib-wasm 1.0.0 → 1.0.2
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.browser.d.ts +29 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.browser.js +2495 -0
- package/dist/simple.browser.d.ts +8 -0
- package/dist/simple.browser.d.ts.map +1 -0
- package/dist/simple.browser.js +2029 -0
- package/dist/src/runtime/module-loader-browser.d.ts +16 -0
- package/dist/src/runtime/module-loader-browser.d.ts.map +1 -0
- package/dist/src/runtime/module-loader-browser.js +37 -0
- package/dist/src/taglib/taglib-class.js +2 -2
- package/package.json +20 -5
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Browser-only module loader for TagLib Wasm
|
|
3
|
+
*
|
|
4
|
+
* Emscripten-only loader with zero imports of WASI, Wasmer, node:fs, or Deno modules.
|
|
5
|
+
* Used by browser entry points to avoid bundler errors from server-only code paths.
|
|
6
|
+
*/
|
|
7
|
+
import type { LoadTagLibOptions } from "./loader-types.js";
|
|
8
|
+
import type { TagLibModule } from "../wasm.js";
|
|
9
|
+
/**
|
|
10
|
+
* Load the TagLib Wasm module using Emscripten only.
|
|
11
|
+
*
|
|
12
|
+
* Import paths use `./` because the browser bundle is output to `dist/`
|
|
13
|
+
* alongside `taglib-wrapper.js` and `taglib-web.wasm` (copied by postbuild).
|
|
14
|
+
*/
|
|
15
|
+
export declare function loadTagLibModule(options?: LoadTagLibOptions): Promise<TagLibModule>;
|
|
16
|
+
//# sourceMappingURL=module-loader-browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-loader-browser.d.ts","sourceRoot":"","sources":["../../../src/runtime/module-loader-browser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAwCvB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TagLibInitializationError } from "../errors/classes.js";
|
|
2
|
+
async function loadTagLibModule(options) {
|
|
3
|
+
let createTagLibModule;
|
|
4
|
+
try {
|
|
5
|
+
const module2 = await import("../../taglib-wrapper.js");
|
|
6
|
+
createTagLibModule = module2.default;
|
|
7
|
+
} catch {
|
|
8
|
+
try {
|
|
9
|
+
const module2 = await import("../../taglib-wrapper.js");
|
|
10
|
+
createTagLibModule = module2.default;
|
|
11
|
+
} catch {
|
|
12
|
+
throw new TagLibInitializationError(
|
|
13
|
+
"Could not load taglib-wrapper.js. Ensure it is co-located with the browser bundle."
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const moduleConfig = {};
|
|
18
|
+
if (options?.wasmBinary) {
|
|
19
|
+
moduleConfig.wasmBinary = options.wasmBinary;
|
|
20
|
+
}
|
|
21
|
+
if (options?.wasmUrl) {
|
|
22
|
+
moduleConfig.locateFile = (path) => {
|
|
23
|
+
if (path.endsWith(".wasm")) {
|
|
24
|
+
return options.wasmUrl;
|
|
25
|
+
}
|
|
26
|
+
return path;
|
|
27
|
+
};
|
|
28
|
+
} else if (!options?.wasmBinary) {
|
|
29
|
+
const wasmUrl = new URL("./taglib-web.wasm", import.meta.url);
|
|
30
|
+
moduleConfig.locateFile = (path) => path.endsWith(".wasm") ? wasmUrl.href : path;
|
|
31
|
+
}
|
|
32
|
+
const module = await createTagLibModule(moduleConfig);
|
|
33
|
+
return module;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
loadTagLibModule
|
|
37
|
+
};
|
|
@@ -17,7 +17,7 @@ class TagLib {
|
|
|
17
17
|
* @throws {TagLibInitializationError} If the Wasm module fails to load.
|
|
18
18
|
*/
|
|
19
19
|
static async initialize(options) {
|
|
20
|
-
const { loadTagLibModule } = await import("
|
|
20
|
+
const { loadTagLibModule } = await import("../runtime/module-loader.js");
|
|
21
21
|
const module = await loadTagLibModule(options);
|
|
22
22
|
return new TagLib(module);
|
|
23
23
|
}
|
|
@@ -124,7 +124,7 @@ class TagLib {
|
|
|
124
124
|
}
|
|
125
125
|
/** Returns the taglib-wasm version with embedded TagLib version. */
|
|
126
126
|
version() {
|
|
127
|
-
return "1.0.
|
|
127
|
+
return "1.0.2 (TagLib 2.1.1)";
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
async function createTagLib(module) {
|
package/package.json
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "taglib-wasm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "TagLib-Wasm is the universal tagging library for TypeScript/JavaScript platforms: Browsers, Node.js, Deno, Bun, Cloudflare Workers, and Electron apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"browser": "./dist/index.browser.js",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
11
|
+
"browser": {
|
|
12
|
+
"types": "./dist/index.browser.d.ts",
|
|
13
|
+
"default": "./dist/index.browser.js"
|
|
14
|
+
},
|
|
15
|
+
"default": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
12
19
|
},
|
|
13
20
|
"./simple": {
|
|
14
|
-
"
|
|
15
|
-
|
|
21
|
+
"browser": {
|
|
22
|
+
"types": "./dist/simple.browser.d.ts",
|
|
23
|
+
"default": "./dist/simple.browser.js"
|
|
24
|
+
},
|
|
25
|
+
"default": {
|
|
26
|
+
"types": "./dist/simple.d.ts",
|
|
27
|
+
"default": "./dist/simple.js"
|
|
28
|
+
}
|
|
16
29
|
},
|
|
17
30
|
"./folder": {
|
|
18
31
|
"types": "./dist/folder.d.ts",
|
|
@@ -49,7 +62,9 @@
|
|
|
49
62
|
"!dist/browser",
|
|
50
63
|
"!dist/deno-compile",
|
|
51
64
|
"index.ts",
|
|
65
|
+
"index.browser.ts",
|
|
52
66
|
"simple.ts",
|
|
67
|
+
"simple.browser.ts",
|
|
53
68
|
"folder.ts",
|
|
54
69
|
"web.ts",
|
|
55
70
|
"rating.ts",
|