taglib-wasm
Version:
TagLib for TypeScript platforms: Deno, Node.js, Bun, Electron, browsers, and Cloudflare Workers
200 lines (199 loc) • 4.11 kB
JavaScript
// index.ts
import {
AudioFileImpl,
createTagLib,
TagLib
} from "./src/taglib.js";
import {
EnvironmentError,
FileOperationError,
InvalidFormatError,
isEnvironmentError,
isFileOperationError,
isInvalidFormatError,
isMemoryError,
isMetadataError,
isTagLibError,
isUnsupportedFormatError,
MemoryError,
MetadataError,
SUPPORTED_FORMATS,
TagLibError,
TagLibInitializationError,
UnsupportedFormatError
} from "./src/errors.js";
import {
addPicture,
applyPictures,
applyTags,
clearPictures,
clearTags,
findPictureByType,
getCoverArt,
getFormat,
getPictureMetadata,
isValidAudioFile,
readMetadataBatch,
readPictures,
readProperties,
readPropertiesBatch,
readTags,
readTagsBatch,
replacePictureByType,
setCoverArt,
setWorkerPoolMode,
updateTags
} from "./src/simple.js";
import {
FormatMappings,
getAllProperties,
getAllPropertyKeys,
getAllTagNames,
getPropertiesByFormat,
getPropertyMetadata,
isValidProperty,
isValidTagName,
PROPERTIES,
Tags
} from "./src/constants.js";
import {
copyCoverArt,
exportAllPictures,
exportCoverArt,
exportPictureByType,
findCoverArtFiles,
importCoverArt,
importPictureWithType,
loadPictureFromFile,
savePictureToFile
} from "./src/file-utils.js";
import {
exportFolderMetadata,
findDuplicates,
scanFolder,
updateFolderTags
} from "./src/folder-api.js";
import {
canvasToPicture,
createPictureDownloadURL,
createPictureGallery,
dataURLToPicture,
displayPicture,
imageFileToPicture,
pictureToDataURL,
setCoverArtFromCanvas
} from "./src/web-utils.js";
import { PICTURE_TYPE_NAMES, PICTURE_TYPE_VALUES } from "./src/types.js";
import {
getGlobalWorkerPool,
TagLibWorkerPool,
terminateGlobalWorkerPool
} from "./src/worker-pool.js";
async function loadTagLibModule(options) {
let createTagLibModule;
try {
const module2 = await import("./taglib-wrapper.js");
createTagLibModule = module2.default;
} catch {
try {
const module2 = await import("./dist/taglib-wrapper.js");
createTagLibModule = module2.default;
} catch {
throw new Error(
"Could not load taglib-wrapper.js from either ./build or ./dist"
);
}
}
const moduleConfig = {};
if (options?.wasmBinary) {
moduleConfig.wasmBinary = options.wasmBinary;
}
if (options?.wasmUrl) {
moduleConfig.locateFile = (path) => {
if (path.endsWith(".wasm")) {
return options.wasmUrl;
}
return path;
};
}
const module = await createTagLibModule(moduleConfig);
return module;
}
export {
AudioFileImpl as AudioFile,
EnvironmentError,
FileOperationError,
FormatMappings,
InvalidFormatError,
MemoryError,
MetadataError,
PICTURE_TYPE_NAMES,
PICTURE_TYPE_VALUES,
PROPERTIES,
SUPPORTED_FORMATS,
TagLib,
TagLibError,
TagLibInitializationError,
TagLibWorkerPool,
Tags,
UnsupportedFormatError,
addPicture,
applyPictures,
applyTags,
canvasToPicture,
clearPictures,
clearTags,
copyCoverArt,
createPictureDownloadURL,
createPictureGallery,
createTagLib,
dataURLToPicture,
displayPicture,
exportAllPictures,
exportCoverArt,
exportFolderMetadata,
exportPictureByType,
findCoverArtFiles,
findDuplicates,
findPictureByType,
getAllProperties,
getAllPropertyKeys,
getAllTagNames,
getCoverArt,
getFormat,
getGlobalWorkerPool,
getPictureMetadata,
getPropertiesByFormat,
getPropertyMetadata,
imageFileToPicture,
importCoverArt,
importPictureWithType,
isEnvironmentError,
isFileOperationError,
isInvalidFormatError,
isMemoryError,
isMetadataError,
isTagLibError,
isUnsupportedFormatError,
isValidAudioFile,
isValidProperty,
isValidTagName,
loadPictureFromFile,
loadTagLibModule,
pictureToDataURL,
readMetadataBatch,
readPictures,
readProperties,
readPropertiesBatch,
readTags,
readTagsBatch,
replacePictureByType,
savePictureToFile,
scanFolder,
setCoverArt,
setCoverArtFromCanvas,
setWorkerPoolMode,
terminateGlobalWorkerPool,
updateFolderTags,
updateTags
};