// Honest root entry for `@napi-rs/lzma` (the package `.` export). // // `index.js` is auto-generated by NAPI-RS and REWRITTEN on every `napi build`, so // it stays the raw binding: it exposes each namespace exactly as the loaded addon // does. On a native build that already includes `compressStream` / // `decompressStream`; on the wasm build those tokio-backed transforms are // compiled out, so the raw `xz`/`lzma`/`lzma2` namespaces would be MISSING them // even though the universal `index.d.ts` advertises them for every target. // // This hand-written wrapper (never touched by codegen, so the wiring survives a // rebuild) re-exports the raw classes unchanged and swaps in honest namespaces: // native transforms where present, otherwise a buffered class-API polyfill (see // `honestNamespaces` in `stream-polyfill.js`). Assignments are static so // `cjs-module-lexer` still detects the named exports for ESM `import { xz }`. 'use strict' const binding = require('./index.js') // The pure streaming logic is single-sourced in the browser-safe ESM module // `stream-polyfill.mjs`; Node consumes it via `require(esm)` (stable since Node // 22.12, guaranteed by the package `engines`). const { honestNamespaces } = require('./stream-polyfill.mjs') const { lzma, lzma2, xz } = honestNamespaces(binding) module.exports.Lzma2Compressor = binding.Lzma2Compressor module.exports.Lzma2Decompressor = binding.Lzma2Decompressor module.exports.LzmaCompressor = binding.LzmaCompressor module.exports.LzmaDecompressor = binding.LzmaDecompressor module.exports.XzCompressor = binding.XzCompressor module.exports.XzDecompressor = binding.XzDecompressor module.exports.lzma = lzma module.exports.lzma2 = lzma2 module.exports.xz = xz