taglib-wasm 1.0.0-beta.2 → 1.0.0-beta.4
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/README.md +4 -8
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/src/file-utils.js +7 -7
- package/dist/src/folder-api.d.ts.map +1 -1
- package/dist/src/folder-api.js +112 -113
- package/dist/src/msgpack/decoder.d.ts.map +1 -1
- package/dist/src/msgpack/decoder.js +24 -14
- package/dist/src/runtime/detector.d.ts +5 -4
- package/dist/src/runtime/detector.d.ts.map +1 -1
- package/dist/src/runtime/detector.js +15 -1
- package/dist/src/runtime/unified-loader.d.ts.map +1 -1
- package/dist/src/runtime/unified-loader.js +24 -17
- package/dist/src/runtime/wasi-fs-deno.d.ts +8 -0
- package/dist/src/runtime/wasi-fs-deno.d.ts.map +1 -0
- package/dist/src/runtime/wasi-fs-deno.js +26 -0
- package/dist/src/runtime/wasi-fs-node.d.ts +9 -0
- package/dist/src/runtime/wasi-fs-node.d.ts.map +1 -0
- package/dist/src/runtime/wasi-fs-node.js +60 -0
- package/dist/src/runtime/wasi-fs-provider.d.ts +25 -0
- package/dist/src/runtime/wasi-fs-provider.d.ts.map +1 -0
- package/dist/src/runtime/wasi-fs-provider.js +0 -0
- package/dist/src/runtime/wasi-host-loader.d.ts +2 -0
- package/dist/src/runtime/wasi-host-loader.d.ts.map +1 -1
- package/dist/src/runtime/wasi-host-loader.js +14 -3
- package/dist/src/runtime/wasi-host.d.ts +3 -1
- package/dist/src/runtime/wasi-host.d.ts.map +1 -1
- package/dist/src/runtime/wasi-host.js +21 -16
- package/dist/src/runtime/wasi-loader.d.ts +4 -0
- package/dist/src/runtime/wasi-loader.d.ts.map +1 -1
- package/dist/src/runtime/wasmer-sdk-loader.d.ts.map +1 -1
- package/dist/src/runtime/wasmer-sdk-loader.js +2 -1
- package/dist/src/simple.d.ts +12 -12
- package/dist/src/simple.d.ts.map +1 -1
- package/dist/src/simple.js +15 -11
- package/dist/src/taglib/audio-file-base.d.ts +0 -1
- package/dist/src/taglib/audio-file-base.d.ts.map +1 -1
- package/dist/src/taglib/audio-file-base.js +30 -10
- package/dist/src/taglib/audio-file-impl.d.ts.map +1 -1
- package/dist/src/taglib/audio-file-impl.js +0 -1
- package/dist/src/taglib/mutable-tag.d.ts +7 -7
- package/dist/src/taglib/mutable-tag.d.ts.map +1 -1
- package/dist/src/taglib/taglib-class.d.ts +2 -0
- package/dist/src/taglib/taglib-class.d.ts.map +1 -1
- package/dist/src/taglib/taglib-class.js +14 -0
- package/dist/src/workers/taglib-worker.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -225,17 +225,17 @@ console.log(`Found ${duplicates.size} groups of duplicates`);
|
|
|
225
225
|
### Working with Cover Art
|
|
226
226
|
|
|
227
227
|
```typescript
|
|
228
|
-
import {
|
|
228
|
+
import { applyCoverArt, readCoverArt } from "taglib-wasm/simple";
|
|
229
229
|
|
|
230
230
|
// Extract cover art
|
|
231
|
-
const coverData = await
|
|
231
|
+
const coverData = await readCoverArt("song.mp3");
|
|
232
232
|
if (coverData) {
|
|
233
233
|
await Deno.writeFile("cover.jpg", coverData);
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
// Set new cover art
|
|
237
237
|
const imageData = await Deno.readFile("new-cover.jpg");
|
|
238
|
-
const modifiedBuffer = await
|
|
238
|
+
const modifiedBuffer = await applyCoverArt("song.mp3", imageData, "image/jpeg");
|
|
239
239
|
// Save modifiedBuffer to file if needed
|
|
240
240
|
```
|
|
241
241
|
|
|
@@ -313,10 +313,6 @@ Supported formats:
|
|
|
313
313
|
- [Cloudflare Workers Setup](https://charleswiltgen.github.io/taglib-wasm/guide/workers-setup.html)
|
|
314
314
|
- [Error Handling](https://charleswiltgen.github.io/taglib-wasm/concepts/error-handling.html)
|
|
315
315
|
|
|
316
|
-
### Development
|
|
317
|
-
|
|
318
|
-
- [Testing Guide](https://charleswiltgen.github.io/taglib-wasm/development/testing.html)
|
|
319
|
-
- [Future Improvements](https://charleswiltgen.github.io/taglib-wasm/development/improvements.html)
|
|
320
316
|
- [Contributing](CONTRIBUTING.md)
|
|
321
317
|
|
|
322
318
|
## Supported Formats
|
|
@@ -357,7 +353,7 @@ file.setProperty(Tags.TrackGain, "-6.54 dB");
|
|
|
357
353
|
file.setProperty(Tags.TrackPeak, "0.987654");
|
|
358
354
|
```
|
|
359
355
|
|
|
360
|
-
[View all supported tag constants →](https://charleswiltgen.github.io/taglib-wasm/api/tag-
|
|
356
|
+
[View all supported tag constants →](https://charleswiltgen.github.io/taglib-wasm/api/tag-constants.html)
|
|
361
357
|
|
|
362
358
|
## Performance and Best Practices
|
|
363
359
|
|
package/dist/index.d.ts
CHANGED
|
@@ -62,14 +62,14 @@ export type { TagLibErrorCode } from "./src/errors.ts";
|
|
|
62
62
|
* @see {@link readProperties} - Read audio properties
|
|
63
63
|
* @see {@link readPictures} - Read cover art/pictures
|
|
64
64
|
* @see {@link applyPictures} - Apply pictures to audio files
|
|
65
|
-
* @see {@link
|
|
66
|
-
* @see {@link
|
|
65
|
+
* @see {@link readCoverArt} - Read primary cover art data
|
|
66
|
+
* @see {@link applyCoverArt} - Apply primary cover art
|
|
67
67
|
* @see {@link readTagsBatch} - Read tags from multiple files efficiently
|
|
68
68
|
* @see {@link readPropertiesBatch} - Read properties from multiple files efficiently
|
|
69
69
|
* @see {@link readMetadataBatch} - Read complete metadata from multiple files efficiently
|
|
70
70
|
* @see {@link setWorkerPoolMode} - Enable/disable worker pool for Simple API
|
|
71
71
|
*/
|
|
72
|
-
export { addPicture, applyPictures, applyTags, type BatchOptions, type BatchResult, clearPictures, clearTags, findPictureByType,
|
|
72
|
+
export { addPicture, applyCoverArt, applyPictures, applyTags, type BatchOptions, type BatchResult, clearPictures, clearTags, findPictureByType, isValidAudioFile, readCoverArt, readFormat, readMetadataBatch, readPictureMetadata, readPictures, readProperties, readPropertiesBatch, readTags, readTagsBatch, replacePictureByType, setBufferMode, setSidecarConfig, setWorkerPoolMode, updateTags, } from "./src/simple.ts";
|
|
73
73
|
/**
|
|
74
74
|
* Enhanced property constants and utilities with rich metadata.
|
|
75
75
|
* @see {@link PROPERTIES} - Comprehensive property definitions with metadata
|
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;;;;GAIG;AACH,OAAO,EAAE,aAAa,IAAI,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,cAAc,EACd,aAAa,EACb,wBAAwB,EACxB,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,sBAAsB,EACtB,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,UAAU,EACV,aAAa,EACb,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH;;;;GAIG;AACH,OAAO,EAAE,aAAa,IAAI,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrE,YAAY,EAAE,U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C;AAC9B,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,UAAU,GACX,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD;;GAEG;AAEH,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAyBvB"}
|
package/dist/index.js
CHANGED
|
@@ -24,16 +24,17 @@ import {
|
|
|
24
24
|
} from "./src/errors.js";
|
|
25
25
|
import {
|
|
26
26
|
addPicture,
|
|
27
|
+
applyCoverArt,
|
|
27
28
|
applyPictures,
|
|
28
29
|
applyTags,
|
|
29
30
|
clearPictures,
|
|
30
31
|
clearTags,
|
|
31
32
|
findPictureByType,
|
|
32
|
-
getCoverArt,
|
|
33
|
-
getFormat,
|
|
34
|
-
getPictureMetadata,
|
|
35
33
|
isValidAudioFile,
|
|
34
|
+
readCoverArt,
|
|
35
|
+
readFormat,
|
|
36
36
|
readMetadataBatch,
|
|
37
|
+
readPictureMetadata,
|
|
37
38
|
readPictures,
|
|
38
39
|
readProperties,
|
|
39
40
|
readPropertiesBatch,
|
|
@@ -41,7 +42,6 @@ import {
|
|
|
41
42
|
readTagsBatch,
|
|
42
43
|
replacePictureByType,
|
|
43
44
|
setBufferMode,
|
|
44
|
-
setCoverArt,
|
|
45
45
|
setSidecarConfig,
|
|
46
46
|
setWorkerPoolMode,
|
|
47
47
|
updateTags
|
|
@@ -190,6 +190,7 @@ export {
|
|
|
190
190
|
UnsupportedFormatError,
|
|
191
191
|
WorkerError,
|
|
192
192
|
addPicture,
|
|
193
|
+
applyCoverArt,
|
|
193
194
|
applyPictures,
|
|
194
195
|
applyTags,
|
|
195
196
|
canvasToPicture,
|
|
@@ -216,10 +217,7 @@ export {
|
|
|
216
217
|
getAllProperties,
|
|
217
218
|
getAllPropertyKeys,
|
|
218
219
|
getAllTagNames,
|
|
219
|
-
getCoverArt,
|
|
220
|
-
getFormat,
|
|
221
220
|
getGlobalWorkerPool,
|
|
222
|
-
getPictureMetadata,
|
|
223
221
|
getPropertiesByFormat,
|
|
224
222
|
getPropertyMetadata,
|
|
225
223
|
imageFileToPicture,
|
|
@@ -241,7 +239,10 @@ export {
|
|
|
241
239
|
loadPictureFromFile,
|
|
242
240
|
loadTagLibModule,
|
|
243
241
|
pictureToDataURL,
|
|
242
|
+
readCoverArt,
|
|
243
|
+
readFormat,
|
|
244
244
|
readMetadataBatch,
|
|
245
|
+
readPictureMetadata,
|
|
245
246
|
readPictures,
|
|
246
247
|
readProperties,
|
|
247
248
|
readPropertiesBatch,
|
|
@@ -251,7 +252,6 @@ export {
|
|
|
251
252
|
savePictureToFile,
|
|
252
253
|
scanFolder,
|
|
253
254
|
setBufferMode,
|
|
254
|
-
setCoverArt,
|
|
255
255
|
setCoverArtFromCanvas,
|
|
256
256
|
setSidecarConfig,
|
|
257
257
|
setWorkerPoolMode,
|
package/dist/src/file-utils.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { PICTURE_TYPE_VALUES } from "./types.js";
|
|
2
2
|
import {
|
|
3
|
+
applyCoverArt,
|
|
3
4
|
applyPictures,
|
|
4
|
-
|
|
5
|
+
readCoverArt,
|
|
5
6
|
readPictures,
|
|
6
|
-
replacePictureByType
|
|
7
|
-
setCoverArt
|
|
7
|
+
replacePictureByType
|
|
8
8
|
} from "./simple.js";
|
|
9
9
|
import { readFileData } from "./utils/file.js";
|
|
10
10
|
import { writeFileData } from "./utils/write.js";
|
|
11
11
|
async function exportCoverArt(audioPath, imagePath) {
|
|
12
|
-
const coverData = await
|
|
12
|
+
const coverData = await readCoverArt(audioPath);
|
|
13
13
|
if (!coverData) {
|
|
14
14
|
throw new Error(`No cover art found in: ${audioPath}`);
|
|
15
15
|
}
|
|
@@ -77,7 +77,7 @@ async function importCoverArt(audioPath, imagePath, options = {}) {
|
|
|
77
77
|
};
|
|
78
78
|
mimeType = mimeTypes[ext ?? ""] ?? "image/jpeg";
|
|
79
79
|
}
|
|
80
|
-
const modifiedBuffer = await
|
|
80
|
+
const modifiedBuffer = await applyCoverArt(audioPath, imageData, mimeType);
|
|
81
81
|
await writeFileData(audioPath, modifiedBuffer);
|
|
82
82
|
}
|
|
83
83
|
async function importPictureWithType(audioPath, imagePath, type, options = {}) {
|
|
@@ -138,7 +138,7 @@ async function copyCoverArt(sourcePath, targetPath, options = {}) {
|
|
|
138
138
|
const modifiedBuffer = await applyPictures(targetPath, pictures);
|
|
139
139
|
await writeFileData(targetPath, modifiedBuffer);
|
|
140
140
|
} else {
|
|
141
|
-
const coverData = await
|
|
141
|
+
const coverData = await readCoverArt(sourcePath);
|
|
142
142
|
if (!coverData) {
|
|
143
143
|
throw new Error(`No cover art found in: ${sourcePath}`);
|
|
144
144
|
}
|
|
@@ -146,7 +146,7 @@ async function copyCoverArt(sourcePath, targetPath, options = {}) {
|
|
|
146
146
|
const coverPicture = pictures.find(
|
|
147
147
|
(p) => p.type === PICTURE_TYPE_VALUES.FrontCover
|
|
148
148
|
) ?? pictures[0];
|
|
149
|
-
const modifiedBuffer = await
|
|
149
|
+
const modifiedBuffer = await applyCoverArt(
|
|
150
150
|
targetPath,
|
|
151
151
|
coverData,
|
|
152
152
|
coverPicture.mimeType
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder-api.d.ts","sourceRoot":"","sources":["../../src/folder-api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,GAAG,EAAc,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,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,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;IAC9C,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CA0CD;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAC,CA2B3C;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAkBf"}
|
package/dist/src/folder-api.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { TagLib } from "./taglib.js";
|
|
2
2
|
import { updateTags } from "./simple.js";
|
|
3
|
+
import { writeFileData } from "./utils/write.js";
|
|
3
4
|
import { getGlobalWorkerPool } from "./worker-pool.js";
|
|
5
|
+
const EMPTY_TAG = Object.freeze(
|
|
6
|
+
{
|
|
7
|
+
title: "",
|
|
8
|
+
artist: "",
|
|
9
|
+
album: "",
|
|
10
|
+
comment: "",
|
|
11
|
+
genre: "",
|
|
12
|
+
year: 0,
|
|
13
|
+
track: 0
|
|
14
|
+
}
|
|
15
|
+
);
|
|
4
16
|
function join(...paths) {
|
|
5
17
|
return paths.filter((p) => p).join("/").replace(/\/+/g, "/");
|
|
6
18
|
}
|
|
@@ -119,9 +131,9 @@ async function processFileWithWorker(filePath, pool, includeProperties, onProgre
|
|
|
119
131
|
]);
|
|
120
132
|
const hasCoverArt = pictures.length > 0;
|
|
121
133
|
const dynamics = extractDynamicsData(tags);
|
|
122
|
-
if (processed && totalFound) {
|
|
123
|
-
processed.count
|
|
124
|
-
onProgress?.(
|
|
134
|
+
if (processed !== void 0 && totalFound !== void 0) {
|
|
135
|
+
const current = ++processed.count;
|
|
136
|
+
onProgress?.(current, totalFound, filePath);
|
|
125
137
|
}
|
|
126
138
|
return {
|
|
127
139
|
path: filePath,
|
|
@@ -162,9 +174,9 @@ async function processFileWithTagLib(filePath, taglib, includeProperties, onProg
|
|
|
162
174
|
appleSoundCheck = audioFile.getMP4Item("----:com.apple.iTunes:iTunNORM");
|
|
163
175
|
}
|
|
164
176
|
if (appleSoundCheck) dynamics.appleSoundCheck = appleSoundCheck;
|
|
165
|
-
if (processed && totalFound) {
|
|
166
|
-
processed.count
|
|
167
|
-
onProgress?.(
|
|
177
|
+
if (processed !== void 0 && totalFound !== void 0) {
|
|
178
|
+
const current = ++processed.count;
|
|
179
|
+
onProgress?.(current, totalFound, filePath);
|
|
168
180
|
}
|
|
169
181
|
return {
|
|
170
182
|
path: filePath,
|
|
@@ -177,6 +189,83 @@ async function processFileWithTagLib(filePath, taglib, includeProperties, onProg
|
|
|
177
189
|
audioFile.dispose();
|
|
178
190
|
}
|
|
179
191
|
}
|
|
192
|
+
async function scanWithWorkerPool(pool, filePaths, opts) {
|
|
193
|
+
const { includeProperties, continueOnError, onProgress, totalFound } = opts;
|
|
194
|
+
const files = [];
|
|
195
|
+
const errors = [];
|
|
196
|
+
const progress = { count: 0 };
|
|
197
|
+
const batchSize = Math.min(50, filePaths.length);
|
|
198
|
+
for (let i = 0; i < filePaths.length; i += batchSize) {
|
|
199
|
+
const batch = filePaths.slice(
|
|
200
|
+
i,
|
|
201
|
+
Math.min(i + batchSize, filePaths.length)
|
|
202
|
+
);
|
|
203
|
+
const batchPromises = batch.map(async (filePath) => {
|
|
204
|
+
try {
|
|
205
|
+
return await processFileWithWorker(
|
|
206
|
+
filePath,
|
|
207
|
+
pool,
|
|
208
|
+
includeProperties,
|
|
209
|
+
onProgress,
|
|
210
|
+
progress,
|
|
211
|
+
totalFound
|
|
212
|
+
);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
215
|
+
if (continueOnError) {
|
|
216
|
+
errors.push({ path: filePath, error: err });
|
|
217
|
+
const current = ++progress.count;
|
|
218
|
+
onProgress?.(current, totalFound, filePath);
|
|
219
|
+
return { path: filePath, tags: EMPTY_TAG, error: err };
|
|
220
|
+
} else {
|
|
221
|
+
throw err;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
const batchResults = await Promise.all(batchPromises);
|
|
226
|
+
files.push(...batchResults.filter((r) => !r.error));
|
|
227
|
+
}
|
|
228
|
+
return { files, errors, processed: progress.count };
|
|
229
|
+
}
|
|
230
|
+
async function scanWithTagLib(taglib, filePaths, opts) {
|
|
231
|
+
const { includeProperties, continueOnError, onProgress, totalFound } = opts;
|
|
232
|
+
const files = [];
|
|
233
|
+
const errors = [];
|
|
234
|
+
const progress = { count: 0 };
|
|
235
|
+
const processor = async (filePath) => {
|
|
236
|
+
try {
|
|
237
|
+
return await processFileWithTagLib(
|
|
238
|
+
filePath,
|
|
239
|
+
taglib,
|
|
240
|
+
includeProperties,
|
|
241
|
+
onProgress,
|
|
242
|
+
progress,
|
|
243
|
+
totalFound
|
|
244
|
+
);
|
|
245
|
+
} catch (error) {
|
|
246
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
247
|
+
if (continueOnError) {
|
|
248
|
+
errors.push({ path: filePath, error: err });
|
|
249
|
+
const current = ++progress.count;
|
|
250
|
+
onProgress?.(current, totalFound, filePath);
|
|
251
|
+
return { path: filePath, tags: EMPTY_TAG, error: err };
|
|
252
|
+
} else {
|
|
253
|
+
throw err;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const concurrency = 4;
|
|
258
|
+
const batchSize = concurrency * 10;
|
|
259
|
+
for (let i = 0; i < filePaths.length; i += batchSize) {
|
|
260
|
+
const batch = filePaths.slice(
|
|
261
|
+
i,
|
|
262
|
+
Math.min(i + batchSize, filePaths.length)
|
|
263
|
+
);
|
|
264
|
+
const batchResults = await processBatch(batch, processor, concurrency);
|
|
265
|
+
files.push(...batchResults.filter((r) => !r.error));
|
|
266
|
+
}
|
|
267
|
+
return { files, errors, processed: progress.count };
|
|
268
|
+
}
|
|
180
269
|
async function scanFolder(folderPath, options = {}) {
|
|
181
270
|
const startTime = Date.now();
|
|
182
271
|
const {
|
|
@@ -188,8 +277,6 @@ async function scanFolder(folderPath, options = {}) {
|
|
|
188
277
|
onProgress,
|
|
189
278
|
forceBufferMode
|
|
190
279
|
} = options;
|
|
191
|
-
const files = [];
|
|
192
|
-
const errors = [];
|
|
193
280
|
const filePaths = [];
|
|
194
281
|
let fileCount = 0;
|
|
195
282
|
for await (const filePath of walkDirectory(folderPath, options)) {
|
|
@@ -198,112 +285,28 @@ async function scanFolder(folderPath, options = {}) {
|
|
|
198
285
|
if (fileCount >= maxFiles) break;
|
|
199
286
|
}
|
|
200
287
|
const totalFound = filePaths.length;
|
|
201
|
-
let processed = 0;
|
|
202
288
|
const shouldUseWorkerPool = useWorkerPool && (workerPool ?? typeof Worker !== "undefined");
|
|
203
289
|
let pool = null;
|
|
204
290
|
if (shouldUseWorkerPool) {
|
|
205
291
|
pool = workerPool ?? getGlobalWorkerPool();
|
|
206
292
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
try {
|
|
211
|
-
if (pool) {
|
|
212
|
-
const batchSize = Math.min(50, filePaths.length);
|
|
213
|
-
for (let i = 0; i < filePaths.length; i += batchSize) {
|
|
214
|
-
const batch = filePaths.slice(
|
|
215
|
-
i,
|
|
216
|
-
Math.min(i + batchSize, filePaths.length)
|
|
217
|
-
);
|
|
218
|
-
const batchPromises = batch.map(async (filePath) => {
|
|
219
|
-
try {
|
|
220
|
-
await Promise.all([
|
|
221
|
-
pool.readTags(filePath),
|
|
222
|
-
includeProperties ? pool.readProperties(filePath) : Promise.resolve(null),
|
|
223
|
-
pool.readPictures(filePath)
|
|
224
|
-
]);
|
|
225
|
-
return await processFileWithWorker(
|
|
226
|
-
filePath,
|
|
227
|
-
pool,
|
|
228
|
-
includeProperties,
|
|
229
|
-
onProgress,
|
|
230
|
-
{ count: processed },
|
|
231
|
-
totalFound
|
|
232
|
-
).then((result) => {
|
|
233
|
-
processed++;
|
|
234
|
-
return result;
|
|
235
|
-
});
|
|
236
|
-
} catch (error) {
|
|
237
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
238
|
-
if (continueOnError) {
|
|
239
|
-
errors.push({ path: filePath, error: err });
|
|
240
|
-
processed++;
|
|
241
|
-
onProgress?.(processed, totalFound, filePath);
|
|
242
|
-
return { path: filePath, tags: {}, error: err };
|
|
243
|
-
} else {
|
|
244
|
-
throw err;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
const batchResults = await Promise.all(batchPromises);
|
|
249
|
-
files.push(...batchResults.filter((r) => !r.error));
|
|
250
|
-
}
|
|
251
|
-
} else {
|
|
252
|
-
const processor = async (filePath) => {
|
|
253
|
-
try {
|
|
254
|
-
const audioFile = await taglib.open(filePath);
|
|
255
|
-
try {
|
|
256
|
-
audioFile.tag();
|
|
257
|
-
if (includeProperties) {
|
|
258
|
-
audioFile.audioProperties();
|
|
259
|
-
}
|
|
260
|
-
audioFile.getPictures();
|
|
261
|
-
return await processFileWithTagLib(
|
|
262
|
-
filePath,
|
|
263
|
-
taglib,
|
|
264
|
-
includeProperties,
|
|
265
|
-
onProgress,
|
|
266
|
-
{ count: processed },
|
|
267
|
-
totalFound
|
|
268
|
-
).then((result) => {
|
|
269
|
-
processed++;
|
|
270
|
-
return result;
|
|
271
|
-
});
|
|
272
|
-
} finally {
|
|
273
|
-
audioFile.dispose();
|
|
274
|
-
}
|
|
275
|
-
} catch (error) {
|
|
276
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
277
|
-
if (continueOnError) {
|
|
278
|
-
errors.push({ path: filePath, error: err });
|
|
279
|
-
processed++;
|
|
280
|
-
onProgress?.(processed, totalFound, filePath);
|
|
281
|
-
return { path: filePath, tags: {}, error: err };
|
|
282
|
-
} else {
|
|
283
|
-
throw err;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
const concurrency = 4;
|
|
288
|
-
const batchSize = concurrency * 10;
|
|
289
|
-
for (let i = 0; i < filePaths.length; i += batchSize) {
|
|
290
|
-
const batch = filePaths.slice(
|
|
291
|
-
i,
|
|
292
|
-
Math.min(i + batchSize, filePaths.length)
|
|
293
|
-
);
|
|
294
|
-
const batchResults = await processBatch(batch, processor, concurrency);
|
|
295
|
-
files.push(...batchResults.filter((r) => !r.error));
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
} finally {
|
|
299
|
-
if (pool && !workerPool) {
|
|
300
|
-
}
|
|
293
|
+
let initOptions;
|
|
294
|
+
if (forceBufferMode) {
|
|
295
|
+
initOptions = { forceBufferMode: true };
|
|
301
296
|
}
|
|
297
|
+
const taglib = shouldUseWorkerPool ? null : await TagLib.initialize(initOptions);
|
|
298
|
+
const processOpts = {
|
|
299
|
+
includeProperties,
|
|
300
|
+
continueOnError,
|
|
301
|
+
onProgress,
|
|
302
|
+
totalFound
|
|
303
|
+
};
|
|
304
|
+
const result = pool ? await scanWithWorkerPool(pool, filePaths, processOpts) : await scanWithTagLib(taglib, filePaths, processOpts);
|
|
302
305
|
return {
|
|
303
|
-
files,
|
|
304
|
-
errors,
|
|
306
|
+
files: result.files,
|
|
307
|
+
errors: result.errors,
|
|
305
308
|
totalFound,
|
|
306
|
-
totalProcessed: processed,
|
|
309
|
+
totalProcessed: result.processed,
|
|
307
310
|
duration: Date.now() - startTime
|
|
308
311
|
};
|
|
309
312
|
}
|
|
@@ -333,7 +336,7 @@ async function updateFolderTags(updates, options = {}) {
|
|
|
333
336
|
async (path) => {
|
|
334
337
|
const update = batch.find((u) => u.path === path);
|
|
335
338
|
await processor(update);
|
|
336
|
-
return { path, tags:
|
|
339
|
+
return { path, tags: EMPTY_TAG };
|
|
337
340
|
},
|
|
338
341
|
concurrency
|
|
339
342
|
);
|
|
@@ -377,12 +380,8 @@ async function exportFolderMetadata(folderPath, outputPath, options) {
|
|
|
377
380
|
files: result.files,
|
|
378
381
|
errors: result.errors
|
|
379
382
|
};
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
} else if (typeof globalThis.process !== "undefined") {
|
|
383
|
-
const fs = await import("fs/promises");
|
|
384
|
-
await fs.writeFile(outputPath, JSON.stringify(data, null, 2));
|
|
385
|
-
}
|
|
383
|
+
const jsonBytes = new TextEncoder().encode(JSON.stringify(data, null, 2));
|
|
384
|
+
await writeFileData(outputPath, jsonBytes);
|
|
386
385
|
}
|
|
387
386
|
export {
|
|
388
387
|
exportFolderMetadata,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decoder.d.ts","sourceRoot":"","sources":["../../../src/msgpack/decoder.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,OAAO,EACP,WAAW,EACZ,MAAM,aAAa,CAAC;AAkBrB;;GAEG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,UAAU,GAAG,WAAW,CAOpE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,UAAU,GACxB,eAAe,CAOjB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,UAAU,GAAG,WAAW,CAOxE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,UAAU,GAAG,OAAO,CAchE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,UAAU,GAAG,OAAO,EAAE,CAevE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAC3C,aAAa,EAAE,UAAU,EACzB,OAAO,GAAE,OAAO,CAAC,cAAc,CAAM,GACpC,CAAC,CAQH;
|
|
1
|
+
{"version":3,"file":"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H,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,UAAU,GACxB,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAqBpE"}
|
|
@@ -76,25 +76,35 @@ function decodeMessagePack(msgpackBuffer, options = {}) {
|
|
|
76
76
|
throw new Error(`Failed to decode MessagePack data: ${error}`);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
function isAudioProperties(obj) {
|
|
80
|
+
return "bitrate" in obj && "sampleRate" in obj && "length" in obj;
|
|
81
|
+
}
|
|
82
|
+
function isPicture(obj) {
|
|
83
|
+
return "mimeType" in obj && "data" in obj;
|
|
84
|
+
}
|
|
85
|
+
function coercePictureData(obj) {
|
|
86
|
+
if (obj.data && !(obj.data instanceof Uint8Array)) {
|
|
87
|
+
obj.data = new Uint8Array(obj.data);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function isTagLike(obj) {
|
|
91
|
+
return "title" in obj || "artist" in obj || "album" in obj;
|
|
92
|
+
}
|
|
93
|
+
function isPropertyMap(obj) {
|
|
94
|
+
return Object.values(obj).every((value) => Array.isArray(value));
|
|
95
|
+
}
|
|
79
96
|
function decodeMessagePackAuto(msgpackBuffer) {
|
|
80
97
|
try {
|
|
81
98
|
const decoded = decode(msgpackBuffer, MSGPACK_DECODE_OPTIONS);
|
|
82
99
|
if (decoded && typeof decoded === "object") {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
decoded.data = new Uint8Array(decoded.data);
|
|
89
|
-
}
|
|
90
|
-
return decoded;
|
|
91
|
-
}
|
|
92
|
-
if ("title" in decoded || "artist" in decoded || "album" in decoded) {
|
|
93
|
-
return decoded;
|
|
94
|
-
}
|
|
95
|
-
if (Object.values(decoded).every((value) => Array.isArray(value))) {
|
|
96
|
-
return decoded;
|
|
100
|
+
const obj = decoded;
|
|
101
|
+
if (isAudioProperties(obj)) return obj;
|
|
102
|
+
if (isPicture(obj)) {
|
|
103
|
+
coercePictureData(obj);
|
|
104
|
+
return obj;
|
|
97
105
|
}
|
|
106
|
+
if (isTagLike(obj)) return obj;
|
|
107
|
+
if (isPropertyMap(obj)) return obj;
|
|
98
108
|
}
|
|
99
109
|
return decoded;
|
|
100
110
|
} catch (error) {
|
|
@@ -7,14 +7,15 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Priority order:
|
|
9
9
|
* 1. Deno + WASI (optimal filesystem performance)
|
|
10
|
-
* 2.
|
|
11
|
-
* 3.
|
|
12
|
-
* 4.
|
|
10
|
+
* 2. Bun + WASI (via node:fs, check before Node)
|
|
11
|
+
* 3. Node.js + WASI (when available)
|
|
12
|
+
* 4. Browser + Emscripten (required for web)
|
|
13
|
+
* 5. Node.js + Emscripten (fallback compatibility)
|
|
13
14
|
*/
|
|
14
15
|
/**
|
|
15
16
|
* Supported runtime environments with their optimal WASM target
|
|
16
17
|
*/
|
|
17
|
-
export type RuntimeEnvironment = "deno-wasi" | "node-wasi" | "browser" | "node-emscripten" | "worker" | "cloudflare";
|
|
18
|
+
export type RuntimeEnvironment = "deno-wasi" | "node-wasi" | "bun-wasi" | "browser" | "node-emscripten" | "worker" | "cloudflare";
|
|
18
19
|
/**
|
|
19
20
|
* WASM binary types that can be loaded
|
|
20
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../../src/runtime/detector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../../src/runtime/detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,WAAW,GACX,WAAW,GACX,UAAU,GACV,SAAS,GACT,iBAAiB,GACjB,QAAQ,GACR,YAAY,CAAC;AAEjB;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,YAAY,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,mCAAmC;IACnC,WAAW,EAAE,kBAAkB,CAAC;IAChC,oDAAoD;IACpD,QAAQ,EAAE,cAAc,CAAC;IACzB,kDAAkD;IAClD,kBAAkB,EAAE,OAAO,CAAC;IAC5B,qDAAqD;IACrD,iBAAiB,EAAE,OAAO,CAAC;IAC3B,sDAAsD;IACtD,eAAe,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAC5B;AA2ED;;GAEG;AACH,wBAAgB,aAAa,IAAI,sBAAsB,CAsFtD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAmBzE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAWjE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAGlE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,sBAAsB,CAG5D"}
|
|
@@ -20,6 +20,9 @@ function isCloudflareWorker() {
|
|
|
20
20
|
const globalAny = globalThis;
|
|
21
21
|
return typeof caches !== "undefined" && typeof Request !== "undefined" && typeof addEventListener === "function" && typeof Deno === "undefined" && typeof globalAny.process === "undefined";
|
|
22
22
|
}
|
|
23
|
+
function isBun() {
|
|
24
|
+
return typeof globalThis.Bun !== "undefined";
|
|
25
|
+
}
|
|
23
26
|
function isNode() {
|
|
24
27
|
const globalAny = globalThis;
|
|
25
28
|
return typeof globalAny.process !== "undefined" && globalAny.process.versions?.node !== void 0;
|
|
@@ -37,6 +40,15 @@ function detectRuntime() {
|
|
|
37
40
|
performanceTier: 1
|
|
38
41
|
};
|
|
39
42
|
}
|
|
43
|
+
if (isBun()) {
|
|
44
|
+
return {
|
|
45
|
+
environment: "bun-wasi",
|
|
46
|
+
wasmType: "wasi",
|
|
47
|
+
supportsFilesystem: true,
|
|
48
|
+
supportsStreaming: true,
|
|
49
|
+
performanceTier: 1
|
|
50
|
+
};
|
|
51
|
+
}
|
|
40
52
|
if (isNode() && hasWASISupport()) {
|
|
41
53
|
return {
|
|
42
54
|
environment: "node-wasi",
|
|
@@ -98,6 +110,8 @@ function getEnvironmentDescription(env) {
|
|
|
98
110
|
return "Deno with WASI (optimal filesystem performance)";
|
|
99
111
|
case "node-wasi":
|
|
100
112
|
return "Node.js with WASI (high performance)";
|
|
113
|
+
case "bun-wasi":
|
|
114
|
+
return "Bun with WASI (via node:fs)";
|
|
101
115
|
case "browser":
|
|
102
116
|
return "Browser with Emscripten (web compatibility)";
|
|
103
117
|
case "worker":
|
|
@@ -113,7 +127,7 @@ function getEnvironmentDescription(env) {
|
|
|
113
127
|
function canLoadWasmType(wasmType) {
|
|
114
128
|
const result = detectRuntime();
|
|
115
129
|
if (wasmType === "wasi") {
|
|
116
|
-
return result.environment === "deno-wasi" || result.environment === "node-wasi";
|
|
130
|
+
return result.environment === "deno-wasi" || result.environment === "node-wasi" || result.environment === "bun-wasi";
|
|
117
131
|
}
|
|
118
132
|
return true;
|
|
119
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unified-loader.d.ts","sourceRoot":"","sources":["../../../src/runtime/unified-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"unified-loader.d.ts","sourceRoot":"","sources":["../../../src/runtime/unified-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,Q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