taglib-wasm 1.0.0-beta.7 → 1.0.0-beta.8
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/src/runtime/wasi-adapter/wasm-io.d.ts.map +1 -1
- package/dist/src/runtime/wasi-adapter/wasm-io.js +10 -38
- package/dist/src/runtime/wasmer-sdk-loader/high-level-api.d.ts +1 -1
- package/dist/src/runtime/wasmer-sdk-loader/high-level-api.d.ts.map +1 -1
- package/dist/src/runtime/wasmer-sdk-loader/high-level-api.js +10 -21
- package/package.json +1 -1
|
@@ -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;AAOhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,UAAU,GACjB,UAAU,
|
|
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;AAOhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,UAAU,GACjB,UAAU,CA2BZ;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,WAAW,GACnB,UAAU,GAAG,IAAI,CAqBnB"}
|
|
@@ -54,36 +54,25 @@ function readTagsFromWasm(wasi, buffer) {
|
|
|
54
54
|
const arena = __using(_stack, new WasmArena(wasi));
|
|
55
55
|
const inputBuf = arena.allocBuffer(buffer);
|
|
56
56
|
const outSizePtr = arena.allocUint32();
|
|
57
|
-
const
|
|
57
|
+
const resultPtr = wasi.tl_read_tags(
|
|
58
58
|
0,
|
|
59
59
|
inputBuf.ptr,
|
|
60
60
|
inputBuf.size,
|
|
61
61
|
outSizePtr.ptr
|
|
62
62
|
);
|
|
63
|
-
if (
|
|
63
|
+
if (resultPtr === 0) {
|
|
64
64
|
const errorCode = wasi.tl_get_last_error_code();
|
|
65
65
|
throw new WasmMemoryError(
|
|
66
|
-
`error code ${errorCode}`,
|
|
67
|
-
"read tags
|
|
66
|
+
`error code ${errorCode}. Buffer size: ${buffer.length} bytes`,
|
|
67
|
+
"read tags",
|
|
68
68
|
errorCode
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
inputBuf.size,
|
|
77
|
-
outputBuf.ptr
|
|
78
|
-
);
|
|
79
|
-
if (readResult !== 0) {
|
|
80
|
-
throw new WasmMemoryError(
|
|
81
|
-
"failed to read data into buffer",
|
|
82
|
-
"read tags data",
|
|
83
|
-
readResult
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
return new Uint8Array(outputBuf.read().slice());
|
|
71
|
+
const outSize = outSizePtr.readUint32();
|
|
72
|
+
const u8 = new Uint8Array(wasi.memory.buffer);
|
|
73
|
+
const result = new Uint8Array(u8.slice(resultPtr, resultPtr + outSize));
|
|
74
|
+
wasi.free(resultPtr);
|
|
75
|
+
return result;
|
|
87
76
|
} catch (_) {
|
|
88
77
|
var _error = _, _hasError = true;
|
|
89
78
|
} finally {
|
|
@@ -98,7 +87,7 @@ function writeTagsToWasm(wasi, fileData, tagData) {
|
|
|
98
87
|
const inputBuf = arena.allocBuffer(fileData);
|
|
99
88
|
const tagBuf = arena.allocBuffer(tagBytes);
|
|
100
89
|
const outSizePtr = arena.allocUint32();
|
|
101
|
-
const
|
|
90
|
+
const result = wasi.tl_write_tags(
|
|
102
91
|
0,
|
|
103
92
|
inputBuf.ptr,
|
|
104
93
|
inputBuf.size,
|
|
@@ -107,23 +96,6 @@ function writeTagsToWasm(wasi, fileData, tagData) {
|
|
|
107
96
|
0,
|
|
108
97
|
outSizePtr.ptr
|
|
109
98
|
);
|
|
110
|
-
if (sizeResult !== 0) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
const outputSize = outSizePtr.readUint32();
|
|
114
|
-
const outputBuf = arena.alloc(outputSize);
|
|
115
|
-
const writeResult = wasi.tl_write_tags(
|
|
116
|
-
0,
|
|
117
|
-
inputBuf.ptr,
|
|
118
|
-
inputBuf.size,
|
|
119
|
-
tagBuf.ptr,
|
|
120
|
-
tagBuf.size,
|
|
121
|
-
outputBuf.ptr,
|
|
122
|
-
outSizePtr.ptr
|
|
123
|
-
);
|
|
124
|
-
if (writeResult === 0) {
|
|
125
|
-
return new Uint8Array(outputBuf.read().slice());
|
|
126
|
-
}
|
|
127
99
|
return null;
|
|
128
100
|
} catch (_) {
|
|
129
101
|
var _error = _, _hasError = true;
|
|
@@ -6,5 +6,5 @@ import type { WasiModule } from "./types.ts";
|
|
|
6
6
|
* High-level API for reading tags from audio files using WASI
|
|
7
7
|
* Uses RAII pattern with automatic memory cleanup
|
|
8
8
|
*/
|
|
9
|
-
export declare function readTagsWithWasi(audioBuffer: Uint8Array, wasiModule: WasiModule):
|
|
9
|
+
export declare function readTagsWithWasi(audioBuffer: Uint8Array, wasiModule: WasiModule): Uint8Array;
|
|
10
10
|
//# sourceMappingURL=high-level-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"high-level-api.d.ts","sourceRoot":"","sources":["../../../../src/runtime/wasmer-sdk-loader/high-level-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"high-level-api.d.ts","sourceRoot":"","sources":["../../../../src/runtime/wasmer-sdk-loader/high-level-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,UAAU,EACvB,UAAU,EAAE,UAAU,GACrB,UAAU,CA2BZ"}
|
|
@@ -47,42 +47,31 @@ import {
|
|
|
47
47
|
WasmArena,
|
|
48
48
|
WasmMemoryError
|
|
49
49
|
} from "../wasi-memory.js";
|
|
50
|
-
|
|
50
|
+
function readTagsWithWasi(audioBuffer, wasiModule) {
|
|
51
51
|
var _stack = [];
|
|
52
52
|
try {
|
|
53
53
|
const arena = __using(_stack, new WasmArena(wasiModule));
|
|
54
54
|
const inputBuf = arena.allocBuffer(audioBuffer);
|
|
55
55
|
const outSizePtr = arena.allocUint32();
|
|
56
|
-
const
|
|
56
|
+
const resultPtr = wasiModule.tl_read_tags(
|
|
57
57
|
0,
|
|
58
58
|
inputBuf.ptr,
|
|
59
59
|
inputBuf.size,
|
|
60
60
|
outSizePtr.ptr
|
|
61
61
|
);
|
|
62
|
-
if (
|
|
62
|
+
if (resultPtr === 0) {
|
|
63
63
|
const errorCode = wasiModule.tl_get_last_error_code();
|
|
64
64
|
throw new WasmMemoryError(
|
|
65
|
-
`error code ${errorCode}`,
|
|
66
|
-
"read tags
|
|
65
|
+
`error code ${errorCode}. Buffer size: ${audioBuffer.length} bytes`,
|
|
66
|
+
"read tags",
|
|
67
67
|
errorCode
|
|
68
68
|
);
|
|
69
69
|
}
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
inputBuf.size,
|
|
76
|
-
outputBuf.ptr
|
|
77
|
-
);
|
|
78
|
-
if (readResult !== 0) {
|
|
79
|
-
throw new WasmMemoryError(
|
|
80
|
-
"failed to read data into buffer",
|
|
81
|
-
"read tags data",
|
|
82
|
-
readResult
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
return new Uint8Array(outputBuf.read().slice());
|
|
70
|
+
const outSize = outSizePtr.readUint32();
|
|
71
|
+
const u8 = new Uint8Array(wasiModule.memory.buffer);
|
|
72
|
+
const result = new Uint8Array(u8.slice(resultPtr, resultPtr + outSize));
|
|
73
|
+
wasiModule.free(resultPtr);
|
|
74
|
+
return result;
|
|
86
75
|
} catch (_) {
|
|
87
76
|
var _error = _, _hasError = true;
|
|
88
77
|
} finally {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "taglib-wasm",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.8",
|
|
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",
|