taglib-wasm
Version:
TagLib-Wasm is the universal tagging library for TypeScript/JavaScript platforms: Browsers, Node.js, Deno, Bun, Cloudflare Workers, and Electron apps
62 lines • 2.5 kB
TypeScript
/**
* @fileoverview Helper utilities for using TagLib-Wasm in Deno compiled binaries
*
* This module provides simplified initialization for offline usage in compiled
* Deno binaries, with automatic detection and embedded WASM loading.
*
* @module taglib-wasm/deno-compile
*/
import { TagLib } from "./taglib.js";
export { isDenoCompiled } from "./runtime/deno-detect.js";
/**
* Where {@link prepareWasmForEmbedding} looks for the Emscripten binary, in
* order, resolved relative to this module.
*
* `build/` comes first deliberately: it holds the committed, authoritative
* artifact, while `dist/` is gitignored scratch that only the npm chain
* (`build:copy-wasm`/`postbuild`) refreshes. A stale `dist/` in a working
* checkout would otherwise silently shadow a freshly built binary. Published
* packages ship no `build/` (it is absent from package.json's `files`), so
* resolution there falls through to `dist/` exactly as before.
*/
export declare const WASM_EMBED_SEARCH_PATHS: readonly string[];
/**
* Initialize TagLib with automatic handling for Deno compiled binaries.
*
* In compiled binaries, this function attempts to load embedded WASM from a
* specified path relative to the binary. If the embedded WASM is not found
* or if running in development mode, it falls back to network fetch.
*
* @param embeddedWasmPath - Path to embedded WASM file (default: './taglib-web.wasm')
* @returns Promise resolving to initialized TagLib instance
*
* @example
* ```typescript
* // Basic usage with default path
* const taglib = await initializeForDenoCompile();
*
* // Custom embedded WASM path
* const taglib = await initializeForDenoCompile('./assets/taglib-web.wasm');
*
* // Compile command:
* // deno compile --allow-read --include taglib-web.wasm myapp.ts
* ```
*/
export declare function initializeForDenoCompile(embeddedWasmPath?: string): Promise<TagLib>;
/**
* Helper function to prepare a WASM file for embedding in a compiled binary.
* This function copies the WASM file from node_modules to a local path.
*
* @param outputPath - Where to save the WASM file (default: './taglib-web.wasm')
*
* @example
* ```typescript
* // In your build script:
* await prepareWasmForEmbedding('./assets/taglib-web.wasm');
*
* // Then compile with:
* // deno compile --allow-read --include assets/taglib-web.wasm myapp.ts
* ```
*/
export declare function prepareWasmForEmbedding(outputPath?: string): Promise<void>;
//# sourceMappingURL=deno-compile.d.ts.map