Repository navigation
Modernize for 2.0.0: streaming decoder, prebuilt binaries, ESM and typings - #1
Merged
Merged
Conversation
Replace both headers with unmodified upstream copies and record the pinned commit in lib/UPSTREAM.md. Drops the stray <iostream> include, and ignore build/ and prebuilds/ in git.
Tests for the current Decoder stream. Tests that document known bugs in the original chunk handling (dropped last sample frame, throwing on partial frames) are marked todo until the streaming rewrite lands.
The native Decoder class keeps one mp3dec_t per stream and carries partial frames between chunks, replacing the per-chunk mp3dec_load_buf call that broke on chunk boundaries, leaked its output buffer and dropped the last sample frame. It skips ID3v2 tags, ignores ID3v1 tags, trims encoder delay and padding using the Xing/LAME tag, and reports sample rate and channels. The JS Decoder emits a 'format' event (same shape as node-speaker options) before the first data. Also bump node-addon-api to 8 and stop requiring the dev-only 'debug' package at runtime. Tests now cover four fixtures at several chunk sizes, tags, truncated and corrupt input.
Gives contributors and CI the same dependency tree. It is not published to npm, so consumers are unaffected.
index.mjs wraps the CommonJS module so both require and import work, with named exports. An exports map in package.json selects the entry point and its typings (index.d.cts, index.d.mts). Decoder.decodeSync(buffer) decodes a whole MP3 in memory through the same native decoder as the stream and returns { format, pcm }. Tests cover both module systems and decodeSync, and npm run test:types type-checks the typings for CJS and ESM consumers.
The format now only describes the decoded PCM (sampleRate, channels, bitDepth). The output is always signed little-endian, so the flag added nothing for general consumers. node-speaker still accepts the object as is, since it defaults signed to true for 16-bit.
Document the current API (stream, decodeSync, format event and output format), behaviour notes and limitations. Replace the node-speaker example with generic ones: piping to a file and writing a WAV file from a buffer. Both examples were run against a fixture.
The addon is loaded with node-gyp-build, which uses the binary in prebuilds/ and otherwise compiles from source on install. The binary is N-API based, so one build per platform covers every supported Node version. Linux binaries link libstdc++ statically and are tagged with their libc, so Alpine falls back to compiling instead of failing to load a glibc binary. CI tests Node 22, 24 and 26 on Linux, macOS and Windows. The release workflow builds prebuilds for macOS (arm64, x64), Linux glibc (x64, arm64, built on Debian 11) and Windows x64, installs the packed tarball with install scripts disabled on each platform, and publishes with provenance when a v* tag is pushed. prepublishOnly refuses to publish unless every prebuild is present. scripts/smoke-install.js installs the tarball the way a user would. Also: require Node 22 or later, publish an explicit files list, replace the 'bindings' dependency, remove the unused 'debug' dependency and the dead prettier-eslint-cli, update the author email and describe installation in the README.
scripts/release.js bumps the version (major, minor or patch), commits, tags and pushes, which starts the release workflow that publishes to npm. It refuses to run unless on master with a clean, up to date tree and a free tag, runs the tests, and asks for confirmation. --dry-run shows what would happen.
Development setup, how the bundled minimp3 and the prebuilt binaries work, and how to cut a release with npm run release.
Flat config that keeps the standard style the code already follows. Adds npm run lint and lint:fix, a lint job in CI, and runs the linter before npm run release. The old ESLint 5 configuration and plugins are removed.
Describes the fixes, additions and breaking changes relative to the published 1.0.0, with figures from running that version: it fails to load in a clean install, loses audio when the input arrives in smaller chunks and returns extra encoder silence. The changelog is included in the package, and npm run release requires an entry for the version it is making.
checkout v7, setup-node v7, upload-artifact v7 and download-artifact v8, replacing the v4 versions that run on Node 20, which GitHub deprecated. None of the breaking changes since v4 affect how the workflows use them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings the bindings up to date with the latest minimp3 and Node.js, as
2.0.0. SeeCHANGELOG.mdfor the user-facing list of fixes and breaking changes.What changed
'format'event. The published1.0.0lost audio when input arrived in small chunks (262656 of 352800 bytes at 4096-byte chunks, 0 at 417) and did not load at all in a clean install (debugwas only a devDependency).ea99364(2026-07-27), unmodified copies (lib/UPSTREAM.md).Decoder.decodeSync(buffer), ES module entry point next to CommonJS, TypeScript typings for both.node-gyp-build+prebuildify, N-API): macOS arm64/x64, Linux glibc x64/arm64, Windows x64. Source build remains the fallback.node:testsuite with fixtures, ESLint 10 + neostandard, CI, a release workflow with npm trusted publishing (GitHub Actions on Node 24 versions),npm run release -- <major|minor|patch>, CONTRIBUTING.md, README rewrite.All commits are signed.
Verified
--ignore-scripts: macOS arm64 (Node 26) and Linux arm64 (Debian 11 and 12, no compilers) load the prebuilt binary. On Alpine (musl) it fails with a clear message without scripts, and builds from source with them.npm run releasewas tested end to end against a throwaway local remote (22 checks), never against this repository.After merging
The Release workflow only runs by hand or on a
v*tag, so it has not run yet. It builds the macOS x64, Linux x64 and Windows prebuilds, which have not been exercised, on themacos-15-intelandubuntu-24.04-armrunners.master. This is a dry run, the publish job only runs for tags.master:npm run release -- major. Pushing the tag publishes2.0.0to npm via the trusted publisher.