taglib-wasm 1.0.8 → 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.
- package/dist/index.browser.js +61 -8
- package/dist/simple.browser.js +61 -8
- package/dist/src/deno-compile.js +1 -1
- package/dist/src/runtime/module-loader.d.ts.map +1 -1
- package/dist/src/runtime/module-loader.js +2 -3
- package/dist/src/runtime/unified-loader/module-loading.js +5 -19
- package/dist/src/runtime/unified-loader/module-selection.d.ts.map +1 -1
- package/dist/src/runtime/unified-loader/module-selection.js +0 -1
- package/dist/src/runtime/unified-loader/types.d.ts +1 -3
- package/dist/src/runtime/unified-loader/types.d.ts.map +1 -1
- package/dist/src/runtime/wasi-adapter/adapter.d.ts +1 -1
- package/dist/src/runtime/wasi-adapter/adapter.js +1 -1
- package/dist/src/runtime/wasi-adapter/file-handle.d.ts +3 -2
- package/dist/src/runtime/wasi-adapter/file-handle.d.ts.map +1 -1
- package/dist/src/runtime/wasi-adapter/file-handle.js +27 -11
- package/dist/src/runtime/wasi-adapter/wasm-io.d.ts +3 -1
- package/dist/src/runtime/wasi-adapter/wasm-io.d.ts.map +1 -1
- package/dist/src/runtime/wasi-adapter/wasm-io.js +66 -1
- package/dist/src/runtime/wasi-host-loader.d.ts +1 -1
- package/dist/src/runtime/wasi-host-loader.js +1 -1
- package/dist/src/runtime/wasmer-sdk-loader/types.d.ts +1 -24
- package/dist/src/runtime/wasmer-sdk-loader/types.d.ts.map +1 -1
- package/dist/src/runtime/wasmer-sdk-loader/types.js +1 -19
- package/dist/src/taglib/audio-file-impl.d.ts +1 -0
- package/dist/src/taglib/audio-file-impl.d.ts.map +1 -1
- package/dist/src/taglib/audio-file-impl.js +37 -6
- package/dist/src/taglib/taglib-class.d.ts.map +1 -1
- package/dist/src/taglib/taglib-class.js +26 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/wasm.d.ts +3 -0
- package/dist/src/wasm.d.ts.map +1 -1
- package/dist/taglib_wasi.wasm +0 -0
- package/package.json +2 -2
- package/dist/src/runtime/wasmer-sdk-loader/high-level-api.d.ts +0 -10
- package/dist/src/runtime/wasmer-sdk-loader/high-level-api.d.ts.map +0 -1
- package/dist/src/runtime/wasmer-sdk-loader/high-level-api.js +0 -83
- package/dist/src/runtime/wasmer-sdk-loader/index.d.ts +0 -6
- package/dist/src/runtime/wasmer-sdk-loader/index.d.ts.map +0 -1
- package/dist/src/runtime/wasmer-sdk-loader/index.js +0 -17
- package/dist/src/runtime/wasmer-sdk-loader/initialization.d.ts +0 -16
- package/dist/src/runtime/wasmer-sdk-loader/initialization.d.ts.map +0 -1
- package/dist/src/runtime/wasmer-sdk-loader/initialization.js +0 -55
- package/dist/src/runtime/wasmer-sdk-loader/loader.d.ts +0 -9
- package/dist/src/runtime/wasmer-sdk-loader/loader.d.ts.map +0 -1
- package/dist/src/runtime/wasmer-sdk-loader/loader.js +0 -47
- package/dist/src/runtime/wasmer-sdk-loader/module-creation.d.ts +0 -9
- package/dist/src/runtime/wasmer-sdk-loader/module-creation.d.ts.map +0 -1
- package/dist/src/runtime/wasmer-sdk-loader/module-creation.js +0 -71
- package/dist/src/runtime/wasmer-sdk-loader/wasi-stubs.d.ts +0 -16
- package/dist/src/runtime/wasmer-sdk-loader/wasi-stubs.d.ts.map +0 -1
- package/dist/src/runtime/wasmer-sdk-loader/wasi-stubs.js +0 -64
package/dist/index.browser.js
CHANGED
|
@@ -1376,7 +1376,19 @@ var init_audio_file_base = __esm({
|
|
|
1376
1376
|
});
|
|
1377
1377
|
|
|
1378
1378
|
// src/taglib/audio-file-impl.ts
|
|
1379
|
-
|
|
1379
|
+
function readFileSync(path) {
|
|
1380
|
+
if (typeof Deno !== "undefined") return Deno.readFileSync(path);
|
|
1381
|
+
if (_nodeFs === void 0) {
|
|
1382
|
+
try {
|
|
1383
|
+
_nodeFs = new Function("return require('node:fs')")();
|
|
1384
|
+
} catch {
|
|
1385
|
+
_nodeFs = null;
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
if (_nodeFs) return new Uint8Array(_nodeFs.readFileSync(path));
|
|
1389
|
+
return new Uint8Array(0);
|
|
1390
|
+
}
|
|
1391
|
+
var _nodeFs, AudioFileImpl;
|
|
1380
1392
|
var init_audio_file_impl = __esm({
|
|
1381
1393
|
"src/taglib/audio-file-impl.ts"() {
|
|
1382
1394
|
"use strict";
|
|
@@ -1395,6 +1407,7 @@ var init_audio_file_impl = __esm({
|
|
|
1395
1407
|
isPartiallyLoaded,
|
|
1396
1408
|
partialLoadOptions
|
|
1397
1409
|
);
|
|
1410
|
+
__publicField(this, "pathModeBuffer", null);
|
|
1398
1411
|
}
|
|
1399
1412
|
save() {
|
|
1400
1413
|
if (this.isPartiallyLoaded && this.originalSource) {
|
|
@@ -1408,7 +1421,17 @@ var init_audio_file_impl = __esm({
|
|
|
1408
1421
|
}
|
|
1409
1422
|
getFileBuffer() {
|
|
1410
1423
|
const buffer = this.handle.getBuffer();
|
|
1411
|
-
|
|
1424
|
+
if (buffer.length > 0) return buffer;
|
|
1425
|
+
if (this.pathModeBuffer) return this.pathModeBuffer;
|
|
1426
|
+
if (this.sourcePath) {
|
|
1427
|
+
try {
|
|
1428
|
+
this.pathModeBuffer = readFileSync(this.sourcePath);
|
|
1429
|
+
return this.pathModeBuffer;
|
|
1430
|
+
} catch {
|
|
1431
|
+
return new Uint8Array(0);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
return new Uint8Array(0);
|
|
1412
1435
|
}
|
|
1413
1436
|
async saveToFile(path) {
|
|
1414
1437
|
const targetPath = path ?? this.sourcePath;
|
|
@@ -1419,14 +1442,15 @@ var init_audio_file_impl = __esm({
|
|
|
1419
1442
|
);
|
|
1420
1443
|
}
|
|
1421
1444
|
if (this.isPartiallyLoaded && this.originalSource) {
|
|
1422
|
-
const fullData = await readFileData(this.originalSource);
|
|
1423
1445
|
const fullFileHandle = this.module.createFileHandle();
|
|
1424
1446
|
try {
|
|
1425
|
-
const success =
|
|
1447
|
+
const success = await (async () => {
|
|
1448
|
+
const data = await readFileData(this.originalSource);
|
|
1449
|
+
return fullFileHandle.loadFromBuffer(data);
|
|
1450
|
+
})();
|
|
1426
1451
|
if (!success) {
|
|
1427
1452
|
throw new InvalidFormatError(
|
|
1428
|
-
"Failed to load full audio file for saving"
|
|
1429
|
-
fullData.byteLength
|
|
1453
|
+
"Failed to load full audio file for saving"
|
|
1430
1454
|
);
|
|
1431
1455
|
}
|
|
1432
1456
|
const partialTag = this.handle.getTag();
|
|
@@ -1462,7 +1486,10 @@ var init_audio_file_impl = __esm({
|
|
|
1462
1486
|
"Failed to save changes to in-memory buffer"
|
|
1463
1487
|
);
|
|
1464
1488
|
}
|
|
1465
|
-
|
|
1489
|
+
const buffer = this.handle.getBuffer();
|
|
1490
|
+
if (buffer.length > 0) {
|
|
1491
|
+
await writeFileData(targetPath, buffer);
|
|
1492
|
+
}
|
|
1466
1493
|
}
|
|
1467
1494
|
}
|
|
1468
1495
|
getPictures() {
|
|
@@ -1666,7 +1693,7 @@ var VERSION;
|
|
|
1666
1693
|
var init_version = __esm({
|
|
1667
1694
|
"src/version.ts"() {
|
|
1668
1695
|
"use strict";
|
|
1669
|
-
VERSION = "1.0
|
|
1696
|
+
VERSION = "1.1.0";
|
|
1670
1697
|
}
|
|
1671
1698
|
});
|
|
1672
1699
|
|
|
@@ -1761,6 +1788,32 @@ var init_taglib_class = __esm({
|
|
|
1761
1788
|
}
|
|
1762
1789
|
const actualInput = isNamedAudioInput(input) ? input.data : input;
|
|
1763
1790
|
const sourcePath = typeof actualInput === "string" ? actualInput : void 0;
|
|
1791
|
+
if (typeof actualInput === "string" && this.module.isWasi) {
|
|
1792
|
+
const fileHandle2 = this.module.createFileHandle();
|
|
1793
|
+
try {
|
|
1794
|
+
const fh = fileHandle2;
|
|
1795
|
+
if (fh.loadFromPath) {
|
|
1796
|
+
const success = fh.loadFromPath(actualInput);
|
|
1797
|
+
if (!success) {
|
|
1798
|
+
throw new InvalidFormatError(
|
|
1799
|
+
`Failed to load audio file. Path: ${actualInput}`
|
|
1800
|
+
);
|
|
1801
|
+
}
|
|
1802
|
+
return new AudioFileImpl(
|
|
1803
|
+
this.module,
|
|
1804
|
+
fileHandle2,
|
|
1805
|
+
sourcePath,
|
|
1806
|
+
actualInput,
|
|
1807
|
+
false
|
|
1808
|
+
);
|
|
1809
|
+
}
|
|
1810
|
+
} catch (error) {
|
|
1811
|
+
if (typeof fileHandle2.destroy === "function") {
|
|
1812
|
+
fileHandle2.destroy();
|
|
1813
|
+
}
|
|
1814
|
+
throw error;
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1764
1817
|
const opts = {
|
|
1765
1818
|
partial: true,
|
|
1766
1819
|
maxHeaderSize: 1024 * 1024,
|
package/dist/simple.browser.js
CHANGED
|
@@ -1364,7 +1364,19 @@ var init_audio_file_base = __esm({
|
|
|
1364
1364
|
});
|
|
1365
1365
|
|
|
1366
1366
|
// src/taglib/audio-file-impl.ts
|
|
1367
|
-
|
|
1367
|
+
function readFileSync(path) {
|
|
1368
|
+
if (typeof Deno !== "undefined") return Deno.readFileSync(path);
|
|
1369
|
+
if (_nodeFs === void 0) {
|
|
1370
|
+
try {
|
|
1371
|
+
_nodeFs = new Function("return require('node:fs')")();
|
|
1372
|
+
} catch {
|
|
1373
|
+
_nodeFs = null;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
if (_nodeFs) return new Uint8Array(_nodeFs.readFileSync(path));
|
|
1377
|
+
return new Uint8Array(0);
|
|
1378
|
+
}
|
|
1379
|
+
var _nodeFs, AudioFileImpl;
|
|
1368
1380
|
var init_audio_file_impl = __esm({
|
|
1369
1381
|
"src/taglib/audio-file-impl.ts"() {
|
|
1370
1382
|
"use strict";
|
|
@@ -1383,6 +1395,7 @@ var init_audio_file_impl = __esm({
|
|
|
1383
1395
|
isPartiallyLoaded,
|
|
1384
1396
|
partialLoadOptions
|
|
1385
1397
|
);
|
|
1398
|
+
__publicField(this, "pathModeBuffer", null);
|
|
1386
1399
|
}
|
|
1387
1400
|
save() {
|
|
1388
1401
|
if (this.isPartiallyLoaded && this.originalSource) {
|
|
@@ -1396,7 +1409,17 @@ var init_audio_file_impl = __esm({
|
|
|
1396
1409
|
}
|
|
1397
1410
|
getFileBuffer() {
|
|
1398
1411
|
const buffer = this.handle.getBuffer();
|
|
1399
|
-
|
|
1412
|
+
if (buffer.length > 0) return buffer;
|
|
1413
|
+
if (this.pathModeBuffer) return this.pathModeBuffer;
|
|
1414
|
+
if (this.sourcePath) {
|
|
1415
|
+
try {
|
|
1416
|
+
this.pathModeBuffer = readFileSync(this.sourcePath);
|
|
1417
|
+
return this.pathModeBuffer;
|
|
1418
|
+
} catch {
|
|
1419
|
+
return new Uint8Array(0);
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
return new Uint8Array(0);
|
|
1400
1423
|
}
|
|
1401
1424
|
async saveToFile(path) {
|
|
1402
1425
|
const targetPath = path ?? this.sourcePath;
|
|
@@ -1407,14 +1430,15 @@ var init_audio_file_impl = __esm({
|
|
|
1407
1430
|
);
|
|
1408
1431
|
}
|
|
1409
1432
|
if (this.isPartiallyLoaded && this.originalSource) {
|
|
1410
|
-
const fullData = await readFileData(this.originalSource);
|
|
1411
1433
|
const fullFileHandle = this.module.createFileHandle();
|
|
1412
1434
|
try {
|
|
1413
|
-
const success =
|
|
1435
|
+
const success = await (async () => {
|
|
1436
|
+
const data = await readFileData(this.originalSource);
|
|
1437
|
+
return fullFileHandle.loadFromBuffer(data);
|
|
1438
|
+
})();
|
|
1414
1439
|
if (!success) {
|
|
1415
1440
|
throw new InvalidFormatError(
|
|
1416
|
-
"Failed to load full audio file for saving"
|
|
1417
|
-
fullData.byteLength
|
|
1441
|
+
"Failed to load full audio file for saving"
|
|
1418
1442
|
);
|
|
1419
1443
|
}
|
|
1420
1444
|
const partialTag = this.handle.getTag();
|
|
@@ -1450,7 +1474,10 @@ var init_audio_file_impl = __esm({
|
|
|
1450
1474
|
"Failed to save changes to in-memory buffer"
|
|
1451
1475
|
);
|
|
1452
1476
|
}
|
|
1453
|
-
|
|
1477
|
+
const buffer = this.handle.getBuffer();
|
|
1478
|
+
if (buffer.length > 0) {
|
|
1479
|
+
await writeFileData(targetPath, buffer);
|
|
1480
|
+
}
|
|
1454
1481
|
}
|
|
1455
1482
|
}
|
|
1456
1483
|
getPictures() {
|
|
@@ -1654,7 +1681,7 @@ var VERSION;
|
|
|
1654
1681
|
var init_version = __esm({
|
|
1655
1682
|
"src/version.ts"() {
|
|
1656
1683
|
"use strict";
|
|
1657
|
-
VERSION = "1.0
|
|
1684
|
+
VERSION = "1.1.0";
|
|
1658
1685
|
}
|
|
1659
1686
|
});
|
|
1660
1687
|
|
|
@@ -1748,6 +1775,32 @@ var init_taglib_class = __esm({
|
|
|
1748
1775
|
}
|
|
1749
1776
|
const actualInput = isNamedAudioInput(input) ? input.data : input;
|
|
1750
1777
|
const sourcePath = typeof actualInput === "string" ? actualInput : void 0;
|
|
1778
|
+
if (typeof actualInput === "string" && this.module.isWasi) {
|
|
1779
|
+
const fileHandle2 = this.module.createFileHandle();
|
|
1780
|
+
try {
|
|
1781
|
+
const fh = fileHandle2;
|
|
1782
|
+
if (fh.loadFromPath) {
|
|
1783
|
+
const success = fh.loadFromPath(actualInput);
|
|
1784
|
+
if (!success) {
|
|
1785
|
+
throw new InvalidFormatError(
|
|
1786
|
+
`Failed to load audio file. Path: ${actualInput}`
|
|
1787
|
+
);
|
|
1788
|
+
}
|
|
1789
|
+
return new AudioFileImpl(
|
|
1790
|
+
this.module,
|
|
1791
|
+
fileHandle2,
|
|
1792
|
+
sourcePath,
|
|
1793
|
+
actualInput,
|
|
1794
|
+
false
|
|
1795
|
+
);
|
|
1796
|
+
}
|
|
1797
|
+
} catch (error) {
|
|
1798
|
+
if (typeof fileHandle2.destroy === "function") {
|
|
1799
|
+
fileHandle2.destroy();
|
|
1800
|
+
}
|
|
1801
|
+
throw error;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1751
1804
|
const opts = {
|
|
1752
1805
|
partial: true,
|
|
1753
1806
|
maxHeaderSize: 1024 * 1024,
|
package/dist/src/deno-compile.js
CHANGED
|
@@ -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("../
|
|
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,
|
|
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("../../
|
|
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("../../../
|
|
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]
|
|
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,
|
|
1
|
+
{"version":3,"file":"module-selection.d.ts","sourceRoot":"","sources":["../../../../src/runtime/unified-loader/module-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,wBAAgB,cAAc,CAC5B,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,oBAAoB,GAC5B,MAAM,GAAG,YAAY,CAcvB;AAED,wBAAgB,eAAe,IAAI,OAAO,CAGzC;AAED,wBAAgB,oBAAoB,IAAI,oBAAoB,CAoB3D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RuntimeDetectionResult } from "../detector.js";
|
|
2
|
-
import type { WasiModule } from "../wasmer-sdk-loader/
|
|
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,KAAK,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/runtime/unified-loader/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,kBAAmB,SAAQ,WAAW;gBACrC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAM7C;AAED,qBAAa,eAAgB,SAAQ,WAAW;aAG5B,QAAQ,EAAE,MAAM,GAAG,YAAY;gBAD/C,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM,GAAG,YAAY,EAC/C,KAAK,CAAC,EAAE,OAAO;CAOlB;AAED,MAAM,WAAW,oBAAoB;IACnC,+BAA+B;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IACtC,0CAA0C;IAC1C,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,sCAAsC;IACtC,UAAU,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IACtC,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,+BAA+B;IAC/B,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/
|
|
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/
|
|
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/
|
|
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(
|
|
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;
|
|
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;AAgDhE,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,SAAS,CAAS;gBAEd,UAAU,EAAE,UAAU;IAIlC,OAAO,CAAC,iBAAiB;IAQzB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO;IAW3C,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAWnC,OAAO,IAAI,OAAO;IAMlB,IAAI,IAAI,OAAO;IAqBf,MAAM,IAAI,UAAU;IASpB,OAAO,CAAC,gBAAgB;IAsCxB,kBAAkB,IAAI,sBAAsB,GAAG,IAAI;IAqBnD,SAAS,IAAI,MAAM;IA2DnB,OAAO,CAAC,cAAc;IAiBtB,SAAS,IAAI,UAAU;IAKvB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAuBzC,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAgBpD,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAOhC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAc7C,KAAK,IAAI,OAAO;IAehB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAK/B,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5C,aAAa,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/
|
|
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 {
|
|
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(
|
|
69
|
+
loadFromPath(path) {
|
|
64
70
|
this.checkNotDestroyed();
|
|
65
|
-
|
|
66
|
-
|
|
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.
|
|
76
|
-
|
|
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
|
|
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/
|
|
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
|
-
|
|
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/
|
|
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("../../
|
|
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
|
|
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
|