UNPKG

taglib-wasm

Version:

TagLib-Wasm is the universal tagging library for TypeScript/JavaScript platforms: Browsers, Node.js, Deno, Bun, Cloudflare Workers, and Electron apps

27 lines 1.34 kB
/** * Synchronous node:fs acquisition that works in every module context * (ESM and CJS), including Electron main processes. See taglib-0b5 / GH #24. */ /** Structural subset of node:fs used by taglib-wasm's sync call sites. */ export type NodeFsLike = { statSync(path: string): unknown; readFileSync(path: string): Uint8Array; }; /** * Acquire node:fs synchronously without tripping bundlers. * * `process.getBuiltinModule("node:fs")` is the primary strategy: it is * synchronous, works in both ESM and CJS, and exists on every supported * runtime (added in Node 22.3.0, backported to 20.16.0; the package's * `engines` floor of node >= 22.6.0 gates installs, while Electron's * embedded Node has shipped it since Electron 32). The legacy * `new Function("return require(...)")` hack evaluates in the GLOBAL scope, * where `require` never exists in standard module files — it is kept only as * a fallback for contexts that expose `require` globally (Electron renderers * with nodeIntegration, node -e, the REPL) on runtimes predating * getBuiltinModule. Results are shape-checked so a polyfilled `process` * serving junk modules escalates to the next strategy instead of leaking a * non-fs object to callers. */ export declare function getNodeFsSync(): NodeFsLike | null; //# sourceMappingURL=node-fs.d.ts.map